5 ms·
Edit2: When do you switch off your transpiler and serve native ES6? In 2020? Original: What do you do in 2017? What if you already code in ES6 and transpile i
by frik 11y ago
Edit2: When do you switch off your transpiler and serve native ES6? In 2020?
Original:
What do you do in 2017? What if you already code in ES6 and transpile it to JS5 at the moment. Do you simply switch from serving JS5 to JS6?
Older browsers (todays current browser) don't support "class", "let" and other new syntax constructs. The just fail with JS errors. Can one browse the web with IE11 and iOS 8 Safari in 2017? (e.g. "lifetime support" of the device)
Polyfills can be used for pre-JS5 browsers. But can you polyfill "let" and "class" syntax keyword? One can today still browse the web with IE6 and Phoenix 0.l (early Firefox), despite a few glitches and layout bugs. Many sites use polyfills like JQuery and still use JS3 functionality made popular by Crockford "JavaScript the Good Parts". JS5 added a few things that JQuery made popular.
The syntax changes between previous JS versions were smaller in comparison to ES4 and ES6 (ES4/E4X failed and was abandoned).
Edit1: I added "What if you already code in ES6 and transpile it to JS5 at the moment." as the second sentence to make it clearer. As several down voters misunderstood my serious question.
- magicalist 11y agoThe web is a lot more broken if you browse in IE6 than you appear to think. Some major sites work OK only because they had a financial interest (single digits of IE6 marketshare) until the last few years to maintain IE6 compatibility. This will degrade rapidly, but go off the very-well beaten path today and you'll find the web basically unusable. Backwards compatibility on the web has long been backwards compatibility of source. Sites written in the IE6 era and not touched since should continue to work in browsers of today (which is why things like vendor-prefixed features proved to be a poor idea and are mostly no longer created). You'll get some rendering oddities, but this is still very much true.
- frik 11y agoIE11 (Win8) and various devices that won't receive an update like many Android 4 and older iOS devices will be around for a few years! Sure, you can use a transpiler and serve JS5 the next ten years (2025). What do you plant to do? It seems most simply haven't thought about the problems lying ahead. Many were against the ES4/E4X changes that e.g. Firefox supported for some time, as they would have broken backwards compatibility. ES6 breaks backwards compatibility with the new syntax keywords and there is no fallback afaik. If there is a fallback, well then everything would be fine. Wouldn't it be better if such vendors would ship an security & ES6 syntax support update to their old browser software?
- magicalist 11y agoNo, people have been against breaking compatibility with old source, like changing how certain statements are parsed and executed that would have made old code now in error. This is why strict mode is opt-in and larger ES4-like changes are dead in the water without careful design. On the other side of things, though, new features that break in old browsers are added all the time. Try and run Date.now or Function.bind in old browsers and they'll immediately throw an error. It's only through polyfilling (and in some cases transpiling) that sites work in even IE8 today, and it will be the same situation in the future if a site wants to still work on an old Android or iOS device. But yes, staying up to date as a user does depend on a newish browser being available for the platform you're running, and it would be great if old devices could continue to get updates. Really old iOS is out of luck, but Firefox supports back to Android 2.3, so users stuck there can download that browser to continue browsing the web.
- TazeTSchnitzel 11y ago> Polyfills can be used for pre-JS5 browsers. But can you polyfill "let" and "class" syntax keyword? No, but you can compile ES6 code using it to ES5 code.
- frik 11y agoIs the only solution to transpile ES6 to ES5 until 2025 or whenever IE11, Safari 7 and all current Smart TVs and Cars and what not have their end-of-life and simply vanish? Let's remember the problems with Internet Explorer 6 and its long actual lifetime. At the moment IE8 (WinXP), IE11 (Win8) as well as various other browsers will never receive an update on their platforms.
- AlexeyBrin 11y agoI'm pretty sure that at some point someone will create a library to test for ES6 compatibility when the JS code loads, I envision something like: if ES6 { use "mycode_js6.js"; } else { use "mycode_js6_to_js5.js"; } or something similar.
- TazeTSchnitzel 11y ago> Is the only solution to transpile ES6 to ES5 until 2025 or whenever IE11, Safari 7 and all current Smart TVs and Cars and what not have their end-of-life and simply vanish? Well, it depends who your target audience is. If users with old browsers don't matter, you don't need to transpile.
- sesquipedalian 11y agoI believe something like http://sweetjs.org http://sweetjs.org can polyfill "let" and "class" syntax.
- M2Ys4U 11y agoYou can transpile from ES2015/16 (ES6/7) to ES5 code today. Babel[0] (formerly 6to5) is one such tool that will do just that. [0] https://babeljs.io/ https://babeljs.io/
- frik 11y agoMy question was: When do you switch off your transpiler and serve native ES6? In 2020? Today we can use native JS5 and use polyfill for JS1-3 browser. In future (e.g. 2017) one will have to rely on a transpiler or stay with JS5 for many years - right?
- erokar 11y ago> When do you switch off your transpiler and serve native ES6? In 2020? Never, probably. Why would you? When most browsers support ES6 you would want to write in ES7, or 8, or TypeScript, or CoffeeScript, or — most likely — in some new exciting language that will transpile to JS.
- Touche 11y ago> Never, probably. Why would you? For me at least, running a build script in order to develop is worse than simply refreshing the page.