DEV Community

Discussion on: Why TypeScript is the better JavaScript

Collapse
 
bennycode profile image
Benny Code

Hello and thank you for sharing your perspectives on the matter. The primary argument for adopting TypeScript over .NET is that it serves as a superset of JavaScript. This eliminates the need to learn an entirely new language and ecosystem, allowing for a gradual upgrade of knowledge and development practices. Another advantage is the ability to utilize the same code for both frontend and backend applications.

Furthermore, code completion with JavaScript is notably limited. Due to the absence of types, IDEs face difficulties in accurately determining the properties of classes used from third-party libraries. In many cases, code completion in plain JavaScript relies on analyzing JSDoc comments, which can potentially be out of sync with the actual implementation.

The same applies to the other benefits I mentioned. While modern JavaScript includes classes, it lacks support for abstract classes. Therefore, all of the advantages of TypeScript that I mentioned are either completely absent in JavaScript or available in a very limited capacity.

Collapse
 
lucsan profile image
lucsan

TLDR: My apologies, but what benefits?

Learning TypeScript requires the effort of learning a new language, part of the beauty of javaScript is you can begin to code with no real coding knowledge.

You get code completion from the typescript ide plugin (vscode) you don't need to 'do' typescript for that, also Soto voice copilot.

You don't need classes in JavaScript, you can emulate them, if you must, and enjoy supporting the pile of compiler plugin's needed, or maybe try a functional approach which is the paradigm from which JavaScript is created.

Thread Thread
 
bennycode profile image
Benny Code

Hi @lucsan, there's no need to go through the trouble of learning an entirely new language when you can transition gradually from JavaScript to TypeScript. As mentioned, TypeScript is a superset of JavaScript, allowing you to write regular JavaScript code and leverage advanced programming patterns as needed. I recorded a video that shows that: youtube.com/watch?v=AZhZlEbBaB4

Regarding functional approaches, TypeScript offers support for readonly types, which can be valuable when applying functional programming principles. These readonly types help safeguard your code against unintended side effects, promoting more predictable and maintainable code. In light of that, if you're considering to try a functional approach, TypeScript would be a preferable choice.

Collapse
 
lucsan profile image
lucsan

PS: Benny,

On a personal note, it is not my intention to start a TypeScript flame war. I can see you're thoroughly enjoying TypeScript, and why not it is masterfully crafted and if you have taken the time and effort to master it, then a joy to use, I'm sure.

As I see it TypeScript's primary benefit is in its type safe handling of objects.

Lets just say, I am a javaScript purist.

Good luck with your TypeScript TV channel I liked your linux on win piece, and next time I dip into TypeScript I will be sure to check out your other articles.

Thread Thread
 
bennycode profile image
Benny Code

I appreciate your positive response. Just to clarify, I value engaging in constructive discussions. I dedicated a significant amount of time, actually several years, to become proficient in TypeScript. That's why I've made the decision to create a video tutorial series to share my experience and help others save time in their learning journey.

I understand and respect your stance as a JavaScript purist. There is actually an ECMAScript Proposal to introduce Type Annotations in JavaScript. This development might potentially change the landscape, and it's possible that I might become a JavaScript purist myself in the future. 😀

However, at this moment, I personally find TypeScript to be the better programming language and appreciate its advantages.