ECMAScript 2015 Approved
ecma-international.org
ecma-international.org
Here's an example of what it looks like: http://pastebin.com/raw.php?i=yEB4mrty
As someone who usually works with C, Scala, and Java -- I'm currently working on a small app built on ec6/7 babel, npm, jspm, system.js, aurelia, gulp, etc. It's been a great experience so far.
http://photos3.meetupstatic.com/photos/event/4/b/c/2/600_436...
I think that at least some like the callback hell, because they think it makes them look clever.
Sounds more like something from a certain python web framework to me. ie:
http://docs.pylonsproject.org/en/latest/_downloads/pyramid-a...
Part of the problem with the Javascript ecosystem is that you have to use so many different tools/libraries to create a "simple" app.
Saying you "have to use" any of those things (except for the compiler/runtime) is an overstatement at best. As in other languages, if something solves a problem for you, use it. If not, well, you don't have to use it, unless you're stuck on a team who uses things because This Is How We Do Things Now(TM), which is not a JS specific affliction.
I think one could reasonably argue that two package managers is not only overkill it's a problem (in fact, I sometimes do argue that browser-specific package management shouldn't be part of projects I'm on), and that most languages don't have to deal with competing module implementations because they came baked in (fair).
I think one could also possibly argue that the explosion of JS libs/tools seems to be near-cambrian in its proportions and it's hard to keep up with, but from where I sit this looks like a consequence of (a) the expanding reach of the browser as a platform (b) second-order magnifying effects of popularity (c) where npm is involved a tilt towards smaller libraries and lots of dependencies and (d) the fact that making a library is a way to make a name for yourself (incentivizing lots of libraries).
Using Gradle or Maven to handle builds for Java require you to learn another syntax and vocabulary, i.e. Groovy or XML. In the case of Gradle/Groovy, if you set up the stack first, you'd need to learn another programming language before you even write your "simple app" in your target language Java, which is tedious at best. Perhaps Ruby, C#, and those other languages you've used use the target language for the build which makes more sense.
If you want to do compilation there are various solutions available to you as well!
For an idiomatic node app, you'd clone the repo, then type `npm install` to get the dependencies, `npm test` to make sure the tests pass, and then `npm start` to run it.
Not a lot of people writing apps in Java, C, Ruby, or Python without using libraries, build tools, test runners, Makefile, frameworks, package managers, etc.
To use ES7 in production today, you need babel. And nothing is stopping you from writing a simple app in ES7, running it through babel, and shipping it. You could think of it as an updated compiler or switching to PyPy.
You probably do want a build step to lint, minify, and concatenate your code, and (if targeting the browser) to turn modules into something the browser can deal with. Which basically means webpack (or gulp+browserify), but much like a traditional Makefile (which is basically all it is), you write the webpack config once and then you're done.
And finally you probably want a framework, and probably a package manager to install it. Not a lot of people writing webapps in any language without frameworks. And downloading tarballs off sourceforge is very 1990s. So, a package manager. Does it matter if it's called gem, or npm? I don't think so.
All OP has done is listed some parts of his development environment that might just be implied with another language and framework. If someone talks about "a small app built on rails", by implication they're using a massive pile of bits. Just because you don't say "a small app built on ruby, gems, rails, rake, etc." doesn't mean they don't exist. (Hell, don't rails apps include coffeescript by default these days?)
If there's a problem, it's that "the browser as a runtime target doesn't lend itself to creating simple apps" (hence why you need all those libraries, frameworks, and elaborate build tools). But that's not really the fault of JS...and it's not like deskop apps or Android apps are any better. The last time I wrote a "simple" app (with no libraries or tooling) was in an intro to programming course in the 90s; I don't think that was a realistic example of how people wrote real applications even then.
For the last couple of projects I've worked on, I've had to choose:
- The scaffold
- The build tool
- The actually-good language variant that compiles to JS that a browser can run
- The tool that makes the build tool work with the scaffold
- The tool that makes the build tool work with the language variant
And by the time I make any progress, one of those has made a compatibility-breaking update, or even been abandoned and replaced by something better.
Great that things keep getting better, but at some point I want to get off the ride.
If you don't like the complexity all that tooling and boilerplate adds to your project, why not just write your application in vanilla CSS, HTML and JavaScript? It still works fine.
Most of the time I'd much rather work with imperfect but standard tools than waste time learning the "hot new stuff" and constantly fix what flighty other developers break or abandon. Framework churn is a symptom of invented problems that don't need solving.
Frameworks rarely give you much for all the baggage that comes with it. I say this as an angular user specifically, but I haven't used any others that don't have this problem.
It might, MIGHT, be that these standard setups suck, but if they do, adding a complicated toolchain without a reason doesn't seem like a very pragmatic approach to why the suck or how to fix them.
My point was simple, if it didn't suck, there wouldn't be all these workarounds, shims, essential libraries that every website uses, half bastardised coffee/live/closure/whatever scripts, gulps, glubs, and 1500 different templating languages.
activate(params) {
let fabric_response = yield this.http.get(`${ this.url_base }/fabrics`)
return fabric_response.content.map( fabric => {
let cluster_response = yield this.http.get(`${ this.url_base }/fabrics/${ fabric.name }/clusters`)
if(fabric.clusters_exist) {
this.fabrics.push({"name": fabric.name, "clusters": cluster_response.content});
}
});
}
EDIT: note that I am very sleepy and probably did a poor job of this =)Yours is a nice example of using yield to turn asynchronous code synchronous.
Oh, the irony...
I mean, no inheritance? No method_missing? How do you write humane, readable DSLs with just functions and prototypes?
I've explored all kinds of tricks since then: OO libraries, promises, fibers, CoffeeScript classes and all its other sugar.
What's interesting is I've swung fully back in the other direction. I find myself increasingly drawn to very simple, very JavaScripty JavaScript. Functions. Variables. Constructors. Prototypes. Closures. Arrays. Objects. I think almost all of the new JavaScript features are more trouble than they're worth.
Take promises for example. Here's some junky callbacky JavaScript:
libraryStuff(function() {
moreLibraryStuff(function() {
thirdLibraryStuff(function() {
console.log("done!")
})
})
})
Gross. Nesting. With promises you can do this lovely bit of magic: libraryStuff()
.then(moreLibraryStuff)
.then(thirdLibraryStuff)
.then(function() {
console.log("done!")
})
Which certainly fixed the nesting problem. But you made your stack almost incomprehensible, and you made your execution thread harder to trace. And now the runtime is popping back and forth between your code and the promise library every step. But the scariest thing of all is you created a bunch of these promise objects that you could, like, return, and some totally unrelated code could interact with it and totally fudge up the control here. You took something that had really well bounded semantics and turned it into something that is wide open to be messed with in bizarre ways.That's what power is. That's why people love promises, you have power to do all manner of outlandish control flow. Except I really don't want to have to debug your bizarre circus of promises.
Don't get me wrong, I am certainly capable of debugging your circus of promises. I just really would prefer not to.
And anyway there's a way easier solution. Because JavaScript uses function scope, you can just do this:
libraryStuff(yourResponse)
function yourResponse() {
moreLibraryStuff(yourNextResponse)
}
function yourNextResponse() {
thirdLibraryStuff(finish)
}
function finish() {
console.log("done!")
}
It's easily traceable. You get a real call stack no matter where you crash in that flow. And yeah, I doubled the number of symbols here, but that just means I was forced to actually label my application code. Which might not be such a bad idea anyway. In my production code all of these functions are going to be several lines anyway, and it's quite nice to be reminded that I should give them a good label.Of course if this was CoffeeScript, your stacktrace wouldn't have function names because CoffeeScript threw away that feature in exchange for being able to type "->" instead of "function".
I've noticed this pattern over and over: someone gets frustrated because JavaScript doesn't give you insane tools to quickly spin up bafflingly complex flow structures. They find this frustrating, because they're used to baffling flow structures from all of the crappy code they've been forced to get comfortable with, so they write some insane library that lets you do crazy stuff in JavaScript.
The same thing happened to me in Ruby. I was so entranced by the power and magic of DSLs that I was constantly looking for excuses to return chainable objects from functions and all of this stuff. I would build things like that in production code, and feel proud of myself that I made this super powerful thing with a complicated implementation and a simple, prose-like interface.
But almost every time, after living with the interface for a while, I would realize that I could've solved the problem with just functions, literals, and arrays, and structs if I had actually taken the time to figure out the right abstractions.
Less and less do I think I need some fancy new kind of function. More and more I think I need to be more thoughtful about what the function actually does.
A fallback solution like JQuery isn't possible for new keywords. Try-catch keywords were previously introduced too, but are rarely used because their implementation is known to be slow. Beside that JS5 code with fallback functions still works fine in very old browsers like IE5.
It handles all the transpilation work for you (at runtime for development, or during a manual build/bundling for production) using either Babel, Traceur or Typescript, and allows you to seamlessly use ES6 everywhere in your code and even load third party code on Github and NPM as ES6 modules.
https://github.com/jspm/jspm-cli
https://github.com/systemjs/systemjs
EDIT: Some more info copied from another post:
SystemJS (jspm's module loader) has the following main advantages compared to competing module loaders:
- Able to load any type of module as any other type of module (global, CommonJS, AMD, ES6)
- Can handle transpilation and module loading at runtime without requiring a manual build step
However, jspm itself is primarily a package manager. Its main advantages over existing package management solutions include:
- Tight integration with the SystemJS module loader for ES6 usage
- Maintains a flat dependency hierarchy with deduplication
- Ability to override package.json configuration for any dependency
- Allows loading of packages from just about any source (local git repos, Github, NPM) as any module format
[0] ES6 COMPAT TABLE: https://kangax.github.io/compat-table/es6/
Overall happy with many of the improvements (e.g. standard syntax for modules and classes).
/s
There is also this, slightly more in-depth: git.io/es6features
Another problem is that I often upvote articles by scrolling on my phone. In addition to providing false signal, this has the unfortunate side effect of polluting my "saved stories".
I wish there was a mechanic to change votes after submission (even if the ability to change your vote was only momentary).
Do pg, et al. accept PRs?
Now I have to wait for browsers to get off their little snowflake asses and update. Oh wait then there is all those paranoids who use WinXP with IE8. Damn it, I'll be dead by the time this stuff is available universally.
https://www.netmarketshare.com/browser-market-share.aspx?qpr...
...suggests that IE 8, 9 and 10 combined have about ~28% market share. Of course, I don't know what they're measuring --- somewhere like github is going to see a very different balance of browsers than, say, Amazon --- but that's a hell of a lot, roughly equal to the IE 11 market share. I'd say that's way too much to dismiss out of hand.
Edit: I've since found this: https://en.wikipedia.org/wiki/Usage_share_of_web_browsers#Su...
That suggestions that netmarketshare are consistently measuring IE high --- other people show IE at about half that, and Chrome at about double what netmarketshare do. Which, of course, makes it even more important to find out who your audience are before giving up support for old browsers.
That's because those tables arae
StatCounter (and the W3Counter/Wikimedia things in the tables you cite) are measuring website visits.
NetApplications/netmarketshare is measuring unique users.
So what that data shows is likely several things going on at once:
1) Chrome (and Firefox, for that matter, if you look at te the tables)) users load more webpages than IE users.
2) Chrome does some webpage prerendering stuff that can get counted as "visits" if you're not very careful; not sure how well StatCounter accounts for this.
3) Likely some differences in the actual base data, though I expect this is really minor compared to item #1.
Of course I couldn't agree more with your general claim that web-wide statistics are a poor replacement for specific statistics for a particular site. But even there the question of "visits" vs "unique users" might be an important one.
That's because those tables are comparing apples and oranges. StatCounter (and the W3Counter/Wikimedia things in the tables you cite) are measuring website visits. NetApplications/netmarketshare is measuring unique users.
For example: "This browser requires WebGL" -> IE11 and up.