DEV Community

Discussion on: Why I'm Learning Typescript

Collapse
 
eshimischi profile image
eshimischi

Wasn’t talking about trends..

Thread Thread
 
joelbonetr profile image
JoelBonetR 🥇 • Edited

Neither do I, it's just the current state of the market since long time ago.

Trends are spikes in between that and they may cope the market till certain point (see React for example, with more users than Angular, Vue and Svelte together) or set a tendency growing steadily (like TS) or keep living in the community hype for some time without reaching a worth mentioning piece of the market (see Tailwind).

All of them are in a certain situation for good reasons.

Thread Thread
 
eshimischi profile image
eshimischi • Edited

Again, i wasn’t talking about it, calm down. Anna stated that “it is recommended to use..” not the case, you can use JS/TS whatever suits you the best. Period

Thread Thread
 
ashleyjsheridan profile image
Ashley Sheridan

I think the point is still valid. It is recommended to use Typescript where possible over Javascript. It does catch some issues at development time, provides way better feedback on variables and instances in your IDE (and it's 2022, who isn't using an IDE by now?), and it makes you think about the way you write your code.

Of course, as with anything there are ways round all of that if you really want to ignore best practices. You can use any for pretty much all your type declarations, you can force wrong types in at runtime (which won't be caught by the transpiler), and you can just disable warnings given by your IDE.

Typescript aims to enhance Javascript, and bring some more modern concepts to the language, such as you'd find on C#, for example. You don't have to use Typescript, but it's recommended that you do because it will make your life easier.

Thread Thread
 
joelbonetr profile image
JoelBonetR 🥇 • Edited

Agree, still the amount of things you can learn at once is limited.
In my experience with newcomers they tend to focus into solving warnings and errors on types (which need to be defined) and less into actually learning the language (JS) API, hence the delivery is poor and individuals last longer to be able to get to an efficiency point.

Learning JS first (if you do it properly, of course) allows people to focus on what's most important first (learning the language, the huge API and the quirks of the language) because with that you can do things, protect yourself from runtime errors by experience, and then move forward to TS to get all those extra benefits.

I can recommend to jump into TS directly if you already have experience with another language that's strong-typed such Java or C# to make things easier though.

Thread Thread
 
ashleyjsheridan profile image
Ashley Sheridan

I have noticed the opposite. Newcomers tend to focus more on Javascript, as Typescript is seen as more difficult and harder to learn. I've noticed this with plenty of other languages too. PHP has quite a similar aspect in that there are the traditional older approach to writing code with it, versus the newer approach with stricter typing and cleaner architectural thinking (this is going back over the past decade and more of PHP). There is some level of pushback from developers who've only learned the older way, who don't see any value in more modern approaches. Personally, having worked with a lot of other languages with strict types, like C++ and C#, I come down on the side of preferring stricter typing in "loose" languages, because it's one step towards writing cleaner code.

For Typescript, one thing that it does introduce with the transpiler is the option to ignore some quirks of Javascript. This is made even easier when you are using something like NPM to bundle any required polyfills according to your build targets. After all, why re-invent the wheel. We're not developing in the days where IE6 was running ramshod over the specifications, the browsers are much more closely aligned in terms of support for features. Sure, some browsers might not support certain things, like Chrome doesn't support MathML, and some browsers implement many things that aren't officially part of the spec (unfortanetely have to highlight Chrome there again), but by and large, we're in a better position that we were 12+ years ago.

Jumping to TS from a position of knowing another strongly typed language does make sense. Microsoft did take a lot of what they learned creating C# in their creation of Typescript.