21 ms·
ES6 is beautiful
- news_to_me 11y agoWhat's the plan for browser support of ES6? I like to imagine a world where I don't have to transpile my code with Babel first.
- dc2 11y agoMost modern browsers are gunning hard for full support. Here is the best breakdown: https://kangax.github.io/compat-table/es6/ https://kangax.github.io/compat-table/es6/ That said, it will be a long time before you can write vanilla ES6 without transpilation and publish it, for the same reason that many sites still sadly support IE<=8.
- glhaynes 11y agomany sites still sadly support IE<=8 I'm curious: how much have "evergreen" browsers changed this? Do developers typically target Chrome from a few months ago? Two years ago? Just "today"? Maybe a better way to put it: if you only cared about Chrome, how long would you wait after a new feature was introduced to start using it?
- quarterto 11y agoWell, IE8 is the most recent version that's supported on Windows XP, which is still used in a distressingly large amount of corporate environments. There's also still a load of corporate IT on Vista and 7 that won't upgrade past IE8 because reasons. IE9 and above is effectively evergreen, and Edge explicitly is, but we're gonna have a load of people stuck on IE8 for a while to come.
- mordocai 11y agoI don't know about IE9 being "effectively evergreen" but I can say that the only browser specific bugs we've had to deal with recently have been IE9 so I wouldn't consider it on the same level as IE10 and IE11. IE9 is the oldest browser we support, and soon we won't support it either.
- Nadya 11y agoChrome/Firefox/Safari auto-update unless a user disables autoupdates which is atypical. As such, most devs will only target the most up-to-date version and maybe a single version back (which if something breaks in a single version back, you're already using bleeding edge stuff and probably don't care...) Few devs care for older support unless they're working on enterprise, are masochists, or really really really care about supporting 0.00000001% [0] of their users because they care that much (and more power to them!!) Most devs can point to Microsoft and say "Look, even the guys who created it are no longer supporting it." as an excuse to not support it themselves. I frequently do this when asked to support Safari 5... on Windows. Apple doesn't support it - neither do I. If you work with say.. Healthcare clients you often need to support back to IE7 or even IE6 because that is what they use internally.... [0] I mean to say "practically zero, but not zero percent".
- ilkkao 11y agoBasically when IE11 and old Android browsers can be ignored. Even Windows 10 ships with with IE11. I guess it will take several years before IE11 market share is <2-3%. Still, it will be a glorious day.
- jnbiche 11y agoSadly, looking at that table, it's clear that Safari is the one dragging their feet. Full support for ES6 in the latest Chrome, FF, and Edge, but very poor support in the latest Safari. Apple recognizes that the Web poses a threat to their business model (although I think it's not as big as they fear, after all, how much of their profits come from the app store). This is why I am skeptical they will support WebAssembly in the end. After all, it will be possible to compile ES6 to WebAssembly just as much as any other language. I'm open to other suggestions for why Safari has become essentially the IE6 of our time, but pure business strategy is the only one I can come up with (which is fair, since Apple is a business after all).
- eknkc 11y agoThey are getting a little bit better, transparent about new features lately. https://webkit.org/status/ https://webkit.org/status/ WebAssembly is listed as in development.
- cedricr 11y agoWebKit Nightly gets a 98% on that table.
- evanriley 11y agoI guess were in luck then. Apple recently released the Safari Technology Preview version of Safari.[0]. And if you open the ES6 support page in the post you replied to it shows support for 98% of the features. Supposedly the STP version is getting updated every 2 weeks, so lets hope that that also transitions to the non-developer version of Safari. [0] https://developer.apple.com/safari/technology-preview/ https://developer.apple.com/safari/technology-preview/
- coldtea 11y ago>Sadly, looking at that table, it's clear that Safari is the one dragging their feet. Full support for ES6 in the latest Chrome, FF, and Edge, but very poor support in the latest Safari. Actually Safari (well, Webkit), in beta, is the closest to full ES6 support of all current browsers -- down to 98% or so. It's just that Safari has a release only once or twice a year. But when it has, suddenly everybody on OS X/iOS using Safari would get all that stuff at once. (And recently they started a public beta builds program that might see them releasing new versions much sooner). >Apple recognizes that the Web poses a threat to their business model And with that information above, can we put this age old conspiracy theory to rest? Apple had long had the best mobile browser when Android still had the horrible "Android Browser". They regularly added all kinds of features that benefit apps (e.g. the canvas, css animations, several API to access native mobile features, etc.), and they continuously improve it (see this 98% ES6 support). For a company that "fears web apps" Apple not only promoted them to developers (before and after they created their native app frameworks and app store), not only has extensive documentation and how to's for best mobile experiences on their dev pages, but also has seen that Safari webkit based apps have traditionally been a better experience than Chrome based web apps on Android. Even today, it's faster, and more memory/cpu/battery efficient on mobile than Chrome is on Android. https://blog.runspired.com/2016/03/25/the-chrome-distortion-chrome-alters-our-expectations-in-highly-negative-ways/ https://blog.runspired.com/2016/03/25/the-chrome-distortion-... Safari was only held back because it's not a huge priority for Apple -- not because of some fear that web apps will eat their app store lunch. After all, web apps are difficult to monetize (no credit cards at hand), people expect most of them to be free, have a subpar experience for anything more demanding compared to bare metal languages, and don't integrate that well with native APIs anywhere (iOS, Android, Desktop, etc), as they have to run in a more restricted sandbox than native apps do (and of course somebody has to continuously porting all the native APIs, and at a great common denominator at that, since they also need to be portable).
- triangleman 11y agoCan we call it EMCAScript2015? It will help people get into the habit of referring to annual releases. ES6 was actually never called that right? The last ES was ES5.
- capote 11y agoLiterally every time I see ES6 I think "Elder Scrolls 6." Without fail. I wonder when that's coming out...
- lucideer 11y agoI agree, es2015 would definitely be preferable, and I do my best to remind myself to refer to it as that, but people do tend to be partial to what's terse and most easily pronounceable
- seivan 11y agoWhat about safety? Optionals? Interfaces? TypeScript has a lot of value here.
- softawre 11y agoAgreed. But it's not an either-or. Interfaces are a TypeScript thing, not an ES6 thing. TypeScript is (or tries to be) ES6/ES2015 plus interfaces/types. If you want types use TypeScript.
- rubiquity 11y agoCoffeeScript errr... ES6 is beautiful
- HorizonXP 11y agoI've been coding for over 20 years, and HTML was one of the first "languages" that I picked up, because it was cool to create websites in the infancy of the Internet. When it came to writing more complex stuff, I gravitated towards IE, ActiveX, and VBScript. I hated JavaScript. I was also 10 years old, so my criteria for picking a language was a bit less nuanced. Obviously, JavaScript became the programming language of the web, and I had to learn it. I hated the inane syntax, and the fact that I was always forced to use jQuery for dealing with browser differences. I tolerated JavaScript, but still hated it. With React, Babel, and ES6, that's all changed. I've been writing a lot of ES6 code over the last year, and it's been an absolute joy to use. Everything the author writes about is what I've learned to love. Perhaps I've become more mature. But I'd like to think JavaScript has too.
- azernik 11y agoThis seems to be selling existing JS developers on switching to ES6 features - all the comparisons are with ES5. No one is under any illusions about switching from Python to Node if you have the choice.
- wdmeldon 11y agoA lot of the criticism seems to be from people who will never like JS. I've always loved JS (for whatever reason) so ES6 is a godsend.
- azernik 11y agoI hate JS with a fiery passion. Which is why I also think ES6 is a godsend.
- natrius 11y agoI switched from Python. They are very similar languages, but one works on the web. Django might pull me back in if I need a CRUD app, but otherwise, it's easier to build a one-language team.
- 11y ago
- aridiculous 11y agoI like and use ES6, but I am not a fan of the trend to use as little syntax as possible to be 'beautiful' or 'clean'. Am I the only one who is bothered by this ultra reduction? To me, it ends up as either parentheses soup or unreadable clever code.
- russellbeattie 11y agoYep, I had just submitted a comment making basically the same observation. There's always the clarity vs. conciseness argument in every language evolution process, and compromises made due to compatibility issues, but ECMAScript veered too far towards line noise this round for sure.
- mrharrison 11y agoI agree. I think a language's determined beauty is by its readability, and the less complexity/clever code the more readable it becomes.
- duderific 11y agoI agree, when I look at the code in his examples, I have to work a lot harder to figure out what's going on. Maybe I'll get used to it, but as I mature in my programming style I strive to write code that others will not have to work hard to understand. OTOH We've been using some ES6/Babel at work, and I'm really digging the Promise/resolve/reject paradigm.
- carsongross 11y agoNo, it isn't. It's a kitchen sink of unrelated and often ugly, difficult to parse and unnecessary features. Yes, there is some good in there, but overall it's a shit show. Why can't we just be honest about it? "Welp, this is what we've got. We shouldn't be surprised, since this is what happens when we design by committee. Now let's make the best of it."
- serpix 11y agoI recently witnessed the absurdity of arrow functions NOT returning implicitly if you put the function body in {}. It's a shit show.
- rimunroe 11y agoThat actually is one of my favorite things about arrow functions next to the no-changing-this aspect. I find CoffeeScript's optional return statement really awkward to read for anything that isn't a one-liner. I don't want to have side-effectful functions return values, and dropping bare statements in in order to accomplish that seems extra noisy.
- btdiehr 11y agoIf you want to return an object literal just do this, `(text) => ({ label: text })` In my opinion the arrow function has great syntax. Rest assured, no matter what the syntax was chosen to be, there would be an extremely vocal group of people who hate it (such as yourself).
- rhinoceraptor 11y agoThat's part of the spec, they're really meant for doing functional style, one liner type of things, like [1, 2, 3, 4].map(x => x + 1) You should probably avoid using them for other applications, particularly if you're using a library that uses prototypes because it won't work.
- douche 11y agoIf that's what they are for, why call them "arrow functions", and not lambdas like everybody else does?
- russellbeattie 11y agoThe ambiguity that EMCAScript 2015 added really makes mentally parsing code a lot harder, and not what I would describe 'beautiful'. I've learned to accept it, but => functions are especially hard to see - it makes function definitions into Perl-like line noise, which I really don't think was worth the 4 characters savings. e.g. function(a){ and (a) => { . *functions as well is just badly designed. JavaScript would be well served to emulate Python's model of less options/more clarity, not pandering to uber-geeks who want to use as few keystrokes as possible for whatever reason.
- jack_jennings 11y agoThe implicit return in the last variation of arrow functions presented is a terrible implementation mistake and not a win for clarity nor consistency.
- jahewson 11y agoI couldn't disagree more about arrow functions: x => this.y + x Is almost pure signal, compared with the noise of: (function(x) { return this.y + x; }).bind(this) I know which piece of code I'd rather maintain.
- btdiehr 11y agoArrow functions are immensly useful, and the lack of some of this syntax for a language which naturally lends itself to a functional approach was so jarring that coffee-script grew to immense popularity because of it. Like any sufficiently popular language, literally any choice will be met with a vocal group of people who dislike every single aspect of it. ES6 was a long time coming, and has made Javascript much more legible to read as well as making it easier to write.
- asztal 11y agoThe main thing I am looking forward to becoming accepted is the async/await proposal. It makes my code look a lot easier to follow, easier to write, and less error-prone.
- carsongross 11y agoHeh, my comment goes +3 -1 +2 in less than a minute. Always amusing to refresh a few times after saying something that isn't Technolitically Correct.
- supernintendo 11y agoGet over yourself. Some people agree and some people disagree. Replying to your own comment like this is just cringeworthy.
- sehr 11y agoIt's also against the HN guidelines.
- theoh 11y agoTechnically the guidelines only mention complaining about being downvoted. Crowing over upvotes appears to be permitted. Personally I think the ability to anonymously downvote a comment is socially problematic, and it creates a climate in which long-term users (who can downvote) can appear to be more intolerant of dissenting voices than they probably are.
- coldtea 11y ago>Technically the guidelines only mention complaining about being downvoted. Crowing over upvotes appears to be permitted. https://mind-exchange.com/wp-content/uploads/2015/05/thank-you-technically-correct-man.png https://mind-exchange.com/wp-content/uploads/2015/05/thank-y...
- fapjacks 11y agoSort of related, but possibly interesting... I've created a Chrome extension that completely removes all of the voting functionality and point tallies from my interface (except for being able to upvote threads on the main or new posts page). Including removing the lighter-grey of downvoted posts. I noticed long ago that I was allowing myself to be behavior-shaped through comment voting, and saw how it had impacted my own conversation and even thought processes. Had to do away with that as much as I could.
- willlma 11y agoI thought variable unpacking was called destructuring assignment.
- reycharles 11y agoAnd transpilers are called compilers.
- pacomerh 11y agoheader is bigger than the article. Nothing wrong with that, but was expecting more insight.
- btdiehr 11y agoWhat is truly lacking of content is your pointless comment. HN has an annoyingly large amount of posters who feel the need to always comment on some minor design/structure related piece of a webpage which derails conversations and adds nothing but an extra small piece of cynicism ontop of the mountain of cynicism that already exists in nearly all anonymous tech-centric communities.
- pacomerh 11y agoI don't think you got my point. I'm not complaining about design for no reason. I'm complaining about the fact that this post's content is not HN front-page worthy. If those are the reasons why the author thinks ES6 is beautiful, I think he hasn't explored enough yet.
- williamcotton 11y agoThe top comment is literally someone trying to shit on something someone else says is beautiful. Why the fuck? What? WHAAAT? face palm
- carsongross 11y agoI should have been more generous in my comment. I emailed an apology to the author.
- X0nic 11y agoI agree this is great stuff for JS, but it is nothing new if you have been using a modern dynamic language like ruby.
- douche 11y agoOr Python, or .NET 4+, or Haskell, or many other languages, static, dynamic, or otherwise.
- Grue3 11y agoNo, it's just lipstick on a pig. The pig is still there, and no amount of syntax sugar will fix it.