4 ms·
I am a Ruby dev so I definitely don't pretend to know, however it does seem wild that something like Babel is even needed. It seems to me that it's like trying
by briandear 10y ago
I am a Ruby dev so I definitely don't pretend to know, however it does seem wild that something like Babel is even needed.
It seems to me that it's like trying to mix Ruby 1.8.7 and 2x in the same project and needing a tool to translate it into 1.9.3. Why not just write in 1.9.3 if that's the required target?
I clearly don't know what I'm talking about but what's wrong with actually just writing the JavaScript that Babel spits out? Why is something like Babel even tolerated? What I mean is that I would never try to mix five different Ruby versions and expect that to be a good practice. Someone educate me -- I'm not entirely sold on what's happening or why it's considered good.
- gotofritz 10y agoNobody's really mixing versions, it transpiles ES6 and above to ES5. You don't have to use Babel, you only use it if you want to use the latest version of JS, ES6. You can happily just use ES5, and many people do. Why use ES6? Firstly, it's a much better version, it solves a lot of problems (chief of all, it has a module system which ES5 doesn't have, not built in at least). Second, JS technology moves incredibly fast. ES6 will likely be supported 100% before the end of next year in all major browsers. So by then you can drop babel and just have raw code. Same with node. It was supposed to be fully implemented end of this year or thereabout, but it seems that implementing the module system is problematic. Sadly, it's the most important thing, without which you can't drop babel.
- douche 10y agoIt will be years and years before transpiling for backwards compatibility is no longer necessary. I breathe a sigh of relief when I learn that our customers are using something as modern as IE 11.
- gotofritz 10y agoWell, yeah, by then we'll have to go back to serve different JS files for different browsers. Luckily old IEs support conditional comments so it shouldn't be an issue.
- acemarke 10y agoBecause browser bugs, platform features, and language features have always been a mish-mash and a set of moving targets. See the ES6 language compatibility tables for a visualization ( http://kangax.github.io/compat-table/es6/ http://kangax.github.io/compat-table/es6/ ). So, the choices are either only use features once you _know_ that a large enough percentage of your target audience supports it, or transpile newer syntax into older, more widely compatible syntax.
- connorelsea 10y agoIf you are required to support legacy browsers (which is just the nature of the beast for certain projects), Babel makes it relatively simple to use a new version of JS that may not be supported by those older browsers. Newer versions of JS come with helpful features that reduce bloat and aid developer experience