Is ES5 outdated? Should we use ES6 or TypeScript for building new Node APIs?

I really want to use TypeScript, but I am forced to use ES5, because half of the team has no JavaScript experience, and the other half only have experience with ES5.

Write your answer…

3 answers

Basically, ES6 is just ES5 with a bunch of new features. ES5 is not outdated as many browsers still do not fully support ES6 specs (Node.JS LTS doesn't either). But I guess, yeah, you should start embracing ES6, now, in order to write new Node.JS APIs.

Do not worry about your team. Most of the new features are very easy to understand. I recommend taking half a day to take a look at the new features and another half to train it with your team. You can take that opportunity to show the ones without any experience a thing or two. ES6 is just JavaScript. They will have to learn it sooner or later, so why not make use of all the advantages of ES6 now?

Here is a list with new features and a comparison to ES5. You do not have to enforce everything at once. Just read through all new features and then use the things you can remember. Once you feel safe using them, take a look at other ES6 features which you can start using.

Reply to this…

Share your programming knowledge and learn from the best developers on Hashnode

Get started

JavaScript is the simpliest and most powerful language. It is easy to learn and start from.

ES6 should be used since it is a current JavaScript already for a year and actually we will have ES7 very soon. Absolutely everything I write today works in all modern browsers, we won't need babel soon, however, I still recommmend to use rollup.js to bundle everything into single file. The only one thing in ES6 I would avoid is classes and new keyword. That will make everything even simplier.

By using TS over JS you will loose simplicity and flexibility and, probably, will have a Gorilla/banana problem with a lot of interfaces and classes.

Reply to this…

The other answers already speak about ES6 and I agree with them there. I will restrict my answer to TypeScript.

Firstly, TypeScript is a superset of Javascript. It will absolutely not force you to use classes. Valid Javascript is valid TypeScript. And even in TypeScript there's an 'any' type which basically allows you to escape static typing where you need to. It's true that classes are hardly ever really needed but the existence of classes allows you to use them easily where they would actually be a good fit instead of the ugliness we had to go through in ES5 just to simulate classes. Don't simply run away from a language because it has a tool you could misuse. Learn the correct way to use your tools and use the best tool for the job.

Secondly, the concept of interfaces and classes work way differently in TypeScript than in say Java or C#. The type system is made with contemporary Javascript usage in mind. It's called structural duck typing. You don't have to change the way you write Javascript code. TypeScript simply provides you with extra safety and huge gains in productivity.

You should definitely be using ES6 for any new code where possible. It's really easy to pick up. That's the way forward and everyone is using it. There's really no downside to using it, except that there's an extra build step to convert it to ES5 but you should really already have a build step for your project.

As for TypeScript, definitely give it a try after moving to ES6. Chances are you'll like it if you give it a shot :)

Reply to this…