Might be one of the saddest things I've read linked out of Hacker News. As developers we're doomed to a future of using a awful language because it happened to be at the right place at the right time and was good enough. Now we're stuck with it. Reminds me of DOS.
Developers who say that JavaScript is bad are ones who haven't seriously used it recently. Personally, I've come to prefer (by a long shot) JavaScript's prototype-based OO over traditional class-based OO.
JavaScript is a great language with a dark past and it suffers from its legacy.
I've programmed in C/C++, C#, Java, AVR assembly, PHP, ActionScript and Python among others and I would not hesitate to say that JavaScript is my favourite.
Why are there so many NPM modules?
- Because people who know JavaScript love it. I'm yet to see the same kind of passion in any other programming community.
Yes, it has some gotchas, but so does every other language.
When used correctly, function closures are awesome! REALLY awesome. I pity the poor, poor fools who misuse them and end up with callback hell.
People mention 'callback hell' a lot, but no one talks about callback heaven.
I used to complain about JS a lot, and from an OO standpoint it is annoying, but after I started getting more into functional programming, I started to like JS more and more.
Although a shorter function syntax with default-return on everything would make it a lot nicer (and more similar to LISP).
You could always use transpile to js language like CoffeeScript or ClojureScript for a nicer syntax. Combines it with build system like Gulp or Grunt really makes the experiences pretty painless.
EcmaScript 6 and 7 are actually adding beautiful language features. JavaScript is changing in a big way, a lot of new JavaScript will not even resemble the stuff you're probably referring to.
If you are saying this, you certainly didn't read the article (properly).
You can not "eradicate old legacy libraries" on whim - this stuff is out there. It is used by software out there. Software that would break if things like that would be removed. You can't just rip out and change parts of it at whim. You have to work around problems - at least until they wane in popularity and slowly die out. Evolution, rather then revolution - as stated in the article. That is exactly what TC39 is doing when they are improving on the standard and JavaScript itself.
Case in point: Array.prototype.values was a proposed feature - returning an iterator for the values in an array[1]. The feature was introduced and had to be backed out at least twice[2] because widely used web frameworks (in this case, Sencha) used the attribute "values" on arrays and webapps broke as the method was added to the Array prototype. And this wasn't the first case.
So, that's the thing, right, despite all the downvotes above.
We get to strongly push for new language features, or we get to strongly push for backwards compatibility.
If we elect to do both blindly and without forethought, as the JS community seems to be doing (having learned from the C++, evidently), we are going to run into these things over and over again.
And frankly, a lot of the legacy code and terrible hacks on the Web deserve to be broken, noticed, and remove/updated. Hacking prototypes (as Sencha did here) is something they shouldn't have done in the first place.
The origins of this code come a bit before jQuery.. when libraries commonly extended existing structure prototypes... Some of those became the basis for the additional methods (map/reduce/filter etc) on Array, and others. JavaScript is very flexible which is a blessing and a curse.
I've been a fan of JS since pretty early on... the DOM differences between IE and NN were really horrible to deal with in the v4 browser days, and until jQuery didn't start to get much better really, where today you really don't need jQuery. It's an evolution here... If you're willing to use transpilers you can go anywhere you like... from BabelJS to ClosureScript, TypeScript, CoffeeScript or others... you can get the style you like.
npm + browserify (or webpack) have made developing modern web applications a dream compared to the past.
It has awful parts that should be avoided. Once you learn to avoid them you can have a great time. This isn't that different from most other languages. I think javascript has just been more heavily complained about. There is also an automatic look-down-your-nose tendency that most of us started with, including myself. Once I decided to learn more than the bare minimum I became very happy with it.
It"s the very strange mix of very bad ideas and very good ideas that's baffling. Some other languages are homogeneously bad (php) but provides less suprises than js, because of their regularity. js is bipolar/schizophreniac.
JS is special because it has to be backwards-compatible.
It basically contains its entire history, from a PHP-like hack job that started it to the very elegant ES6/7. It's probably one of the few languages that expose their whole fossil record.
Yes. We tend to forget javascript was the first mainstream language (no, CommonLisp is not mainstream) proposing lambdas & closures, for instance. In the 1990's, that was quite amazing. And, on the other hand, they couldn't implement the 'this' keyword correctly, among other trivial mistakes.
>> It has awful parts that should be avoided. Once you learn to avoid them you can have a great time. <<
Oh, I imagine my copy of Crockford's "The Good Parts" is more well thumbed than most, and I do my utmost best to keep it all clean, but having a great time I am not.
> This isn't that different from most other languages.
Based on what people tend to complain about, some languages have more should-be-avoided parts than others. I guess no language is perfect... but that is so obvious that it doesn't need to be mentioned. Yeah, no language is perfect. But it's still interesting to see which ones are the least "perfect".
I don't get this tendency to want to muddy the waters with appeals to "nothing is perfect". Nothing is perfect, but some things sure seem to suck 5 times or more than other things.
(For that matter - it actually does seem like there are languages where you at least don't have to actively avoid parts of the language. Maybe they're not the best or currently the ones which are recommended, but it's not like people say that you should avoid them because they might trip you up in a weird way.)
But what features does JS have that no other language has, other than the ubiquity of the browser as a platform? JS has been mostly frozen ever since it was created in the mid 90s and you also don't have much to work with when it comes to the standard library.
"...happened to be at the right place at the right time and was good enough."
Sounds like almost every successful startup, too.
Starting out as just "good enough" is fine. Improvements will happen over time. It is short-sighted to look at where we are today and believe it to be the end of the story.
As developers, we're blessed to be a part of a future where we can take a sometimes clunky language like JavaScript and improve it to incorporate elements of our favorite languages.
Because if there is one thing we've learnt about programming languages, it is: throw enough features at a language and it gets transformed from bad to good.
Everyone gets the wrong idea from the Betamax vs VHS thing. The correct lesson to learn is to actually solve the problems people have. VHS could record an entire football game on one tape. Betamax couldn't, because they prioritized video quality over recording length. They bet wrong; consumers prioritized recording length over video quality, because a mediocre picture of 100% of the thing they wanted to watch beat a better picture of 60% of the thing they wanted to watch.
And yet everyone turns Beta vs VHS into a sob story about how the best doesn't always win, instead of figuring out the real lesson: know what your customers want and give it to them.
I thought the reason Betamax didn't succeed was that Sony required deals to release things on their format, and it turned out a lot of people wanted videocassettes for porn?
I'll make no strong apology for JavaScript besides saying that compared to other "popular" languages I have had the opportunity to use professionally -- a list that includes perl, php, and vbscript -- JavaScript annoys me considerably less than many.