
ES6 is beautiful - edward
http://ewanvalentine.io/es6-is-beautiful/
======
carsongross
No, 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."

~~~
stevebmark
I'm guessing you don't write Javascript full time? After using ES6 in depth
for a few months now, I can vouch that all of these syntax details are well
thought out, practical, and improve the readability and writability of the
language. I've used most of the ES6 features, if not all, repeatedly in
production code. None of them seen "unnecessary" and teams I've worked on echo
this experience.

Who cares though, Hacker News embraces trolls who engage in syntax wars.

~~~
CuriouslyC
Overall Javascript even with ES6 still seems like a fairly immature language.
It is a definite step in the right direction though. Specifically:

I think the lambda syntax is nice and concise, although the disconnect between
an implicit return with a bare statement versus required explicit return with
braces is kind of silly. They should have made it just implicitly return the
evaluated value of the last statement in the lambda all the time.

The de-structuring syntax is less clear and consistent than, for example,
Python's. The fact that both array-like things and object-like things are de-
structured using '...' means that you have to consider the context when you
see it, and you could probably construct cases where it isn't clear exactly
what is going on.

Template literals are obnoxious because they bind when declared. This means
you can't pass a template literal around to be evaluated later. You could wrap
it in quotes and use eval, but then you lose multi-line support. Pretty fail.

The fact that module support is finally part of the language is a good thing.
Not having a built-in module system is probably the biggest embarrassment in
the language. Now we just need a dependency manager built into the browser so
people can require jQuery >= 2.0 for instance, and we won't have to worry
about CDNs and what not.

~~~
pcwalton
The template literal "fail" (which is really just static scoping) is necessary
to make JS JITting anywhere near reasonable. You may not care about JS runtime
performance, but lots of people do.

~~~
CuriouslyC
Or they could have just made template literals be multi-line strings, and
added an eval method, taking an optional context object which could override
local names. That would have been a lot more useful...

------
HorizonXP
I'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
This 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
A 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
I hate JS with a fiery passion. Which is why I also think ES6 is a godsend.

------
aridiculous
I 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.

~~~
mrharrison
I agree. I think a language's determined beauty is by its readability, and the
less complexity/clever code the more readable it becomes.

------
russellbeattie
The 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
The implicit return in the last variation of arrow functions presented is a
terrible implementation mistake and not a win for clarity nor consistency.

~~~
jahewson
It's an expression... clear and consistent. You're confusing it with a
statement.

------
triangleman
Can 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.

~~~
lucideer
I 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

------
news_to_me
What'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
Most 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.

~~~
jnbiche
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.

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).

~~~
coldtea
> _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-...](https://blog.runspired.com/2016/03/25/the-chrome-distortion-
chrome-alters-our-expectations-in-highly-negative-ways/)

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).

~~~
jnbiche
Fair enough. However, my paid work for the past several years has been as a
frontend developer, and consistently, the browser that has held us back from
adopting newer features has been Safari. I'm very happy to hear they have
better/very good ES6 support coming up, I'm very glad to be wrong there.

And hey, for whatever reason, Apple has earned my eternal gratitude (and my
consumer dollar) over the past few months by being one of the only entities in
this country capable and willing to stand up to government bullying and
surveillance. Web standard are great for me in my job, and I believe they're
important for the future of online communication. But standing up to
government overreach is of critical importance to all of us. I'm an Android
user myself, but wife uses iPhone so I'm already getting ready to buy her a
new iPhone 7 when they come out.

------
asztal
The 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.

------
X0nic
I agree this is great stuff for JS, but it is nothing new if you have been
using a modern dynamic language like ruby.

~~~
douche
Or Python, or .NET 4+, or Haskell, or many other languages, static, dynamic,
or otherwise.

------
Grue3
No, it's just lipstick on a pig. The pig is still there, and no amount of
syntax sugar will fix it.

------
rubiquity
CoffeeScript errr... ES6 is beautiful

------
willlma
I thought variable unpacking was called destructuring assignment.

~~~
reycharles
And transpilers are called compilers.

------
pacomerh
header is bigger than the article. Nothing wrong with that, but was expecting
more insight.

~~~
btdiehr
What 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
I 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
The top comment is literally someone trying to shit on something someone else
says is beautiful.

Why the fuck? What? WHAAAT?

 _face palm_

~~~
carsongross
I should have been more generous in my comment. I emailed an apology to the
author.

------
seivan
What about safety? Optionals? Interfaces? TypeScript has a lot of value here.

~~~
softawre
Agreed. 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.

------
carsongross
Heh, 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
Get over yourself. Some people agree and some people disagree. Replying to
your own comment like this is just cringeworthy.

~~~
dang
> _Get over yourself._

Please don't be uncivil in comments here.

~~~
carsongross
In fairness, my original comment was pretty uncivilized.

If I could edit it now, I would rephrase it to something more along the lines
of "This blog post shows some pretty nice code you can write in ES6, but
overall the new features in ES6 are deeply flawed etc. etc."

