I'm a Python developer and this strictly typed langauges this something I left after I finished my Diploma (C, C++, Java)
I later got into React and all those web dev stuffs that the kids are into. At that time javascript was all you really needed. Then the wave of Typescript hit and everyone jumped on.
I get all the "advantages" of it, but in the past few months I looked into it and decided to rebuild my portfolio with it - the portfolio is still not done.
Most of my time was spent making Typescript happy and not building.
So, you Typescript pundits, why must I use it?
Latest comments (60)
A big advantage of TS is the way it helps you check logic errors you won't catch using only Js. A lot of times, I don't even bother writing tests for these, cause well, TS done most of the checking for me indirectly. Working in a team, TS helps to prevent a lot of programming error types also. Even if these are the only two merits, it's totally worth it for me.
IMHO TS itself does nothing else then clears a bit of context of our code.
If you don't know js but came from any other strongly typed language, it helps you to understand what's going on with typeflow - assuming the project is properly typed - and gives you some insights of the surroundings, like it's typed for node or browser env.
But to really make code that is efficient and consumable, discoverable you still have to understand javascript, since it is just a superset of it.
I moved to TS about 3 years ago. I never looked back.
The ability to work in a pseudo typesafe environment is an absolute game changer and will make your code more robust and easier to iterate on.
It will also force you to do more "engineering" vs simple dev. Needless to mention that I would write many tests which have now become obsolete.
for frontend, i don't think it requires that much of types except when you are passing different data throughout the components and for the back end it becomes incredibly useful when you are able to look up what you need to pass and in which format
nice jucie auto complition
My argument for typescript has 2 parts:
My own personal reasons for using typescript involve being able to be self-accountable and make sure all the contracts I write with the code are properly handled. It can give you some freedom when writing internal code, so you don't need to necessarily write tons of runtime checks on the data since you know the compiler will check for a lot of that. The only areas where data checking is really important in typescript is when you have an external data source (or input) that could come in during runtime that can possibly not meet the structure contract. As you adapt to the nuances of the flavored language, it gets easier and faster to build.
The biggest evidence of your struggle not being with the language is that the code you write does not obey the rules you write, so its more of an issue of how you are writing the code, not with typescript itself. Think of it like training wheels. Eventually with enough coding in typescript, writing a specific way will become second nature and you can take those practices with you into JavaScript.
Contacts? Web3?
I'm not foreign to typed languages, Typescript has just given me more grief than the other ones.
I wanted to understand the increasing adoption of it
For many, the fact that javascript isn't typed keeps people from working on web projects, and typescript was a way to bridge that gap. Being that it was developed by Microsoft, perhaps it was developed to bridge the gap between C# and web so they could reuse developers from backend on frontend to a degree, for familiarity.
The cost of learning and applying typescript is quite high. It will slow you down at first.
The main early benefit is type safety and intellisense. But it often feels like it's a lot of work for little gain.
But in my experience, you reach a point where you suddenly find yourself moving much faster, having way more confidence, and then you'll join another codebase in javascript and you'll realise how much you lose when you don't use static typing.
I am a die hard TypeScript fan. But not because of TypeScript; I am a die hard fan of it because of types.
At first, it will definitely slow you down. The equation is simple: if you start writing Rust now, you'd be way less productive than you are with Python, for instance. That's not exclusive to TypeScript. But once things click in you head, you won't look back.
In the long term, I think types give you more critical thinking on how you code. That means less bugs, greater developer experience, hence better productivity. In the end of the day, TypeScript is something you'll only find value once you really feel it flow.
But in general, I think TypeScript's benefits (or really, static types benefits) can be summarized to:
That said, I'd say TypeScript is far from being required for small projects. Your portfolio, for instance - you definitely don't need it and barely will feel its benefits, regardless of how proficient you are. But if you are willing to scale your portfolio's features, then I'd say it's a great call.
This I understand, I had specifc questions in reagrds to Typescript is all
Well I don't know.
On one hand I love static typing. In Rust or Kotlin, it takes you by the hand and helps you figure where you are and what you are doing. Very useful.
There is also the case of typing annotations in Python which are super useful for the same reason. I write them all the time and it's no bother at all.
But then when I try TypeScript I feel like I'm fighting against the world. The whole JS world is not built around typing and especially inputs from the API. Taking in all this external data (which let's face it is the largest chance of getting a typing problem) is always super tricky.
On the other hand I'm using Vue and PyCharm, which handles Vue super well so all the auto-complete basically just works without me having to take care of annotating anything.
Not sure what to make of that. JSDoc is indeed probably a better way to go. Getting 99% compliance (JSDoc) is easy but 100% compliance (TS) can be a fucking pain in the ass.