Let's say I'm writing a NodeJS project with a language that compiles to JavaScript, like TypeScript for example. With TypeScript (or other things that use Babel) I have the option to compile my code to any version of JavaScript, be it ES3
, ES5
, ES6
, ES2017
, etc.
Obviously, if I was writing something client-side, I'd stick to an earlier version like ES5
to maintain compatibility for users. However, since I'm writing something server-side specifically for the latest version of NodeJS, I could use any of these options. What I want to know is, which version should I use to help provide the best performance?
NodeJS's interpreter, V8, provides different optimizations depending on how the source code is written, so I would imagine that selecting one or the other may result in different benefits. On the one hand, you would think that selecting an older version of JS would be better since its been around longer and has had more time to be optimized. On the other hand, compiling to later versions of JS results in significantly cleaner code and relies upon newer, available features, which may also help.
Any thoughts / feedback would be appreciated!