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."
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."
Who cares though, Hacker News embraces trolls who engage in syntax wars.
The future of Javascript is bright, and the new features added are vast improvements onto a language that stagnated far too long. Many of the criticisms towards the new features are not well thought out. Luckily the TC39 committee is full of extremely intelligent developers who have a good understanding of the nuances in adding new features.
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.
Other, one thing I often observe in ES6 examples is replacing quite complex constructs that could have been expressed much simpler using older JS standards. E.g., "Array.prototype.push.apply(arr1, arr2)", where "arr1.concat(arr2)" would have done fine. Not too sure, what this means for real-life applications, but there's definitely a trend in expressing things in artfully complex ways.
On the other hand, I also work on Gosu (http://gosu-lang.github.io/) which is has its own kitchen sink issues, so I believe I'm not being a troll, or at least not simply being a troll, when talking about language design.
import Foo from 'bar';
or import { Foo } from 'bar';i think syntactically the destructuring syntax for imports is cool and clever, but in practice i find it annoying to use
In the case that they don't, I generally just try "import * as Foo" to find out exactly what the library exports. Not saying this is ideal, but it really isn't too bad either, in my opinion, considering the flexibility and conciseness this approach offers for the general case.
Given an extra few days to learn the semantics of import vs. losing access to the millions of npm packages out there, I'd rather spend the extra few days.
English.
We're talking about languages here. The most popular languages tend to be the ones that are the most adaptable. Successful languages aren't afraid to borrow and tend to have multiple overlapping grammars. They are not designed. They evolve over time. They are far from perfect.
The things you hate about these languages are exactly why they are so successful. Instead of being endlessly upset at the dominant programming language for not being 100% perfect, just embrace and celebrate its haphazard nature.
`({ id, option = true, name = 'unnamed' }) => // ...`
replaces
``` function(userObject) {
const id = userObject.id;
const option = userObject.option || true;
const name = userObject.name || 'unnamed';
// ...
}
```I think this comparison speaks for itself. In pre-es6 code bases you TONS of code that looks like the second.
It could be an argument to criticize changes proposed for a nimble performance-oriented language like Lua where "parseability" means hackability as a feature for developers working on the language & core tooling itself. But it seems to me that the bulk of the users of a popular / high-level language like JS is people trying to get things done, not tools developers hacking on JS itself.
"Difficult to parse" semantic constructs may be a hurdle for the 1% doing the parsing, but they mean more syntax goodness to help the the other 99% programmers do things pleasantly and succinctly.
I've heard Python is difficult to parse, too, but behind this difficulty there's syntax sugar helping your average developer. Much like Python list comprehensions, context managers and decorators, these ES6 features make the task harder for tool builders, but they help me as a developer.
You probably got it wrong. When he says "difficult to parse", he means for the programmers using JS -- not for people working on JS parsers.
Besides compiler construction, "parse" is also commonly used to mean "read/understand" some new code.
In this case, I'd still contradict OP, arguing the same as stevebmark did in a sibling comment: "[...] these syntax details are well thought out, practical, and improve the readability and writability of the language [...]. None of them seen "unnecessary" and teams I've worked on echo this experience."
Lots of people are being honest, this article included. Don't disguise your different opinion as "the truth". Not everything can or should have a consensus.
https://reagent-project.github.io/
Back when investigating React for a personal project, I fiddled around with Reagent as a short introduction to Clojurescript, I was not familiar with the language at all, and yet Reagent was immediately more understandable to me than React.
When an alien framework in an alien language are easier to grok than one in a familiar language, one can't call that language "beautiful" with a straight face.
ES6 is "less shitty", (maybe,) but the language itself is still a garbled mess. I can't wait for the day it goes the way of the dinosaur (or survives merely as a transpiler target).
I'm not usually one for bikeshedding. But in the case of JS, where the syntax actively hurts one's ability to understand and organize code, maybe it's warranted. Ever inherit a JS project of even moderate size? More often than not, it's a nightmare moreso than most other languages.
(Also please don't tell me I don't understand the lisp-syntax due to 'familiarity', I've heard that a thousand times and it's not the case, I just don't agree with the syntax trade-off).
A fairer comparison to Reagent would be something like Redux, which is far more elegant and understandable than low-level React code. I personally still prefer working with ClojureScript frameworks like Om/Reagent when given the choice since they have a much more robust solution for handling async tasks, but Redux doesn't fall very far behind in most other aspects.
`(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).
[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.
[1, 2, 3, 4].map(function (x) { return x + 1; })