67 comments

[ 3.3 ms ] story [ 146 ms ] thread
The thing for me is, I'd much rather use clojurescript if I'm going to use a language that doesn't compile ~1:1 to javascript.
Great article to make people mad. I liked the metaphors. :D
Good luck convincing Apple to implement the Dart VM in Safari.

One complaint I have heard about Dart is that the dart2js library outputs unoptimized JS. This is unfortunately an issue if we will not see the Dart VM implemented natively by the browser vendors.

Got a reference on that? They claim otherwise.

http://news.dartlang.org/2013/03/why-dart2js-produces-faster...

I don't want to quote the exact person here since it was told to me in a discussion at a meetup a couple of months ago and may have been told in confidence, but it comes from a fairly prominent & known Google developer.

For the record, I'm not against Dart - I wouldn't mind a new language being the norm that draws the good parts from JavaScript and other languages. New languages face an uphill battle though, from an adoption standpoint.

This sounds wrong, the Dart team are a team of highly talented perf-focused hackers who spend a lot of effort optimizing both Dart2JS and DartVM with advanced compiler tricks to get the most out of each platform.

See advanced profiler and introspection tools to profile Dart Apps: https://www.youtube.com/watch?v=Ww8ISWzZGRE

From Kasper Lund showing advanced compiler tricks Dart2JS uses to generate highly optimized JS: https://www.youtube.com/watch?v=FqsU3TbUw_s

From V8 and Dart founders about why Dart is faster and easier to optimize: https://www.youtube.com/watch?v=huawCRlo9H4

Performance for each platform can be tracked at: https://www.dartlang.org/performance/

If you look at https://www.dartlang.org/performance/ it looks like performance of js vs. dart2js is basically a wash. One benchmark is much faster in js, one much is much faster in dart2js, two are slightly faster in js, one is slightly faster in dart2js. The DeltaBlue benchmark highlighted in the article you linked to is now faster in js than dart2js. But one wonders what those plots would look like with another js engine, since dart2js is presumably optimized to emit code that v8 can optimize.
(comment deleted)
A lot of the mines are here for good.

I'd love to hear that someone is proposing that JS raise exceptions when you use mathematical operators on non-numeric data.

I really hope the Dart team succeeds. Their language has some problems, but nobody else working on the JavaScript Problem has both the motivation and the actual ability to challenge JavaScript's invincible monopoly on the web.

The metaphor is incomplete, how do you reconcile the ubiquitous nature of JavaScript and the browser makers and ES6 and standards? It's just not that good. Sorry.
> They build this nice big platform above the minefield, so you can't even step on it unless you really want to.

Except that Dart isn't type safe. And e.g. if statements treat most values as false. Plenty of mines still there.

What land mines? Only `true` is true in Dart, everything else is false.
Isn't this in sharp contrast to most other programming languages out there?
Java only allows booleans in conditionals, and it remains the most popular programming language.
I'd say so too. Many languages say that everything NOT false or null is true.
Numbers between DartVM run code and JS compiled code have different behavior[0].

[0] https://code.google.com/p/dart/issues/detail?id=1533

Everyone likes to bring up this same issue each time which is rarely an issue in practice. Yes, numeric overflows have different behavior because of Dart's variable integers vs JS where all numbers are floats behind the scenes.

There is a VM and command-line `throw_on_javascript_int_overflow` flag that can be used to throw an error if there is any such overflow in your app.

Ideally when BigNums lands in JS this will no longer be an issue.

It's breathtaking when someone asks for examples, then discards the answer they get as too common.
Things that rarely happen in practice aren't mine-fields. The only common thing in this issue is that it's brought up in every Dart thread, the actual issue of integer overflows is itself rare and usually an indication of a bug in your program.
Exactly. And in the UK, they drive on the left. If either of these facts were the normal/usual/default, we wouldn't need to point them out.
Is "string s = 5" still legal in Dart, or did they fix that? Last I heard, that worked by design.
I'm sorry but Dart just doesn't have that many convincing features. Having type checking is a good thing and I like it, but there also needs to be things that allow me to write more concise and clear code (and allowing certain patterns to be easily expressed)

The patterns that Dart facilitate are just as easy to describe in JS.

What are convincing features? I'm not sure you've look at Dart, but there is a lot more then type checking.
There's almost nothing in Dart that isn't in Java.
Java... or JavaScript? I know this is pedantic but if you are talking about the intricacies of Dart vs JavaScript then making that mistake brings up a lot of questions.
except Dart compiles to effective JS (see Dart perf) + mixins + await async (soon) + less verbose + good unified package system + ...

yea sure - almost nothing.

> but there also needs to be things that allow me to write more concise and clear code

So what are some examples of those things that would helper you write more concise code?

Dart's operator overloading alone makes it easier to write clear and concise code than in JS, e.g. for map and list types.

    // dart
    var listA = listB + listC;

    // js
    var listA = listB.concat(listC);
That's just the tip of the iceburg. Overriding the [] accessor for custom list types opens up whole worlds of possibilities.
Guys, JavaScript just isn't that bad.
No, it is even worse, PHP league bad. JavaScript was never intended for building complex applications. The same goes for HTML and CSS; the intention was to layout documents, not to build user interfaces.

I fully acknowledge that this stack is the best we have when it comes to web applications. I fully acknowledge that it might take ages or even forever to get a better alternative than sweeping the ugliness under the rug and compiling from more sane platforms. But being the best solution available does not make it a good solution.

We once build a small cabin in the mountains in the '90. Now we are running a hotel with a thousand rooms in and on top of that cabin.

PHP is fine, if written properly and consciously. It's like blaming your chainsaw for maiming your limbs with improper use.
It's actually like blaming a chainsaw that has ten blades that spin around in unpredictable dimensions all the time and you can't turn it off. PHP isn't exactly an elegant butterfly of a language, that will make it hard for you to shoot yourself in the foot.
Where is the difference to JavaScript? If you are careful enough, you can build nice stuff with JavaScript, too. That's the whole point of good language design - it must make it easy to express your intention and hard to make mistakes.
We once build a small cabin in the mountains in the '90. Now we are running a hotel with a thousand rooms in and on top of that cabin.

And what exactly is wrong with that? Looks to me like the hotel is doing just fine.

"Blub was never mean to do foo" is a statement that could be made with just about any language you can name.

I also think that while it's true that HTML and CSS were not originally intended for building user interfaces, the vast ecosystem that surrounds JS is designed to do just that (among many other things). It's not JS anymore; it's thousands of well-written libraries, some of which transform the way you write in the language itself (and I'm not talking about things like Coffeescript, but things like Underscore).

TLDR: author in the shower ,makes no point at all,there is no TLDR.

I'm no fan of Dart,but competition is good. Choice is good. If you dont like Dart dont use it.

pretty sure the author shares your view. Author spent 99% of the article bashing vanilla javascript, and the last paragraph praising dart.
No, the obvious point was there is some difficult technology X that people have learned to deal with and have actually grown to like, and there is a new technology Y that is somewhat better but perhaps it doesn't offer enough to convince the fans if X to use it. We could be talking about Java vs C++ 20 years ago.

Some people are wired to want the new thing while others will say "the old thing is good enough for me." Now it's just a matter of waiting to see if the new thing has enough new features to supplant the old thing. It took Java quite a few versions to gain traction. Remember how it was known for being "slow" for years?

Really, coding in JavaScript is hardly worse than most other languages.
So that means that either JS just isn't that bad, or most other languages just aren't that good.
> Really, coding in JavaScript is hardly worse than most other languages.

See, that's the really sad thing about JavaScript: it's a Blub.

In addition to JavaScript, I've written C, Python, Ruby, Perl, Go, C++, Java, Common Lisp, Scheme, HyperTalk, Visual Basic, Lua and shell (I'm probably forgetting something). I've played with Erlang and Haskell. Every one of those is better than JavaScript. Most are much better than JavaScript.

What are my issues?

Well, there's the whole hasOwnProperty hack when iterating over an object used as a hash table. Then there's the default variable scoping. Then there's == vs. ===. The default fallthrough in switch. The lack of integers. The goofiness of details of the object mode (I'm not objecting to prototypal inheritance; I'm objecting to the myriad subtly different ways to do prototypal inheritance). The lack of a metaprogramming facility. The lack of a standard package or module facility and its consequent explosion into a myriad subtly-different systems.

And there's the callback hell of the browser runtime, but that's not necessarily JavaScript's fault.

When I write JavaScript, I feel like I'm back in the bad old days of C, where a single error will be undetectable by the compiler and result in simply a core dump, leaving my to single-step through my code looking for what went awry.

If it weren't The Language of the Web™ it'd be about as popular as Befunge.

Ha! The comments prove the article's point!

If you think JavaScript isn't too that bad, you need to think about whether you're truly a programmer at heart.

If you think Javascript is really that bad, you need to reconsider whether you're truly a programmer at all.
So, the post you're replying to was sort of a worthless no-true-scotsman statement, but more of the same doesn't make it better!
(comment deleted)
I think a lot of people using JS don't know any other languages. That is ok. But many have convinced themselves (and each other as a community) that this is RockStarTech(tm) and as good as it gets, as the article suggests.

If anyone/anything comes along and claims otherwise they will probably lash out against that. It would mean invalidating all the emotional investment (and real code and time investment) they put into it in the past.

Ha! The comments prove the article's point!

If you think JavaScript isn't too that bad, you need to think about whether you're truly a programmer at heart.

Here's another analogy: ActiveX was to Microsoft as Dart is to Google. Dart is another brick in Google's walled garden.
I don't think you understand how Dart works.

You can compile Dart to JS, which you can then run vanilla on any browser.

There was no way to do anything remotely similar with ActiveX.

Calling "Dart" part of a walled garden doesn't make sense.

Just wait for the "runs best on Chrome" campaign. Deja vu all over again.
compiles to JS so works on all modern browsers - wondering why bias like yours isn't downvoted
Yes exactly the same! except ActiveX isn't a language, cross-platform or transpiles to JS but more a platform-specific proprietary binary blob vs Dart which couldn't be any more open than it is already:

  - 100% open source that includes open patent grants
  - Has a language specification
  - Has multiple compliant open source implementations (Dart VM + Dart2JS)
  - Develops in the open
  - Accepts external contributions
  - Features are prioritized and driven by user feedback
  - Encourages re-use and adoption
Great little article! I thought not on v8/dart when i read it, but on many other projects, the Stockholm Syndrome is everywhere.

If something new come up, you find many articles about "the new stuff" and how "fun" it is, how "easy" it is and how much it make your developer life "better".

Nothing against motivition & enthusiasm, but your metapher fits like a glove eye, in most cases it is the Stockholm Syndrome.

The most "new" things just solve things only "different".

That's a really weak and biased analogy… but going with it:

An entire thriving city has been built around the playground-over-minefield, and a fancy 6th set attractions is being built as we speak. It's right next to your door.

The nifty clean Dart-playground is still alone in a middle of a desert, waiting for a city to be built around it (and it's accessible via a tunnel dug from the middle of the minefield, if you like to get there quicker).

The irrational advocating of a technology in the past is proportional to the level of Stockholm Syndrome.

In other words, often, those who do not understand but blindly repeat claims and advocate X to others (think of religious fanatics), will have a harder time overcoming cognitive dissonance and seeing that maybe there is something else better than X out there.

The truth is JavaScript is not bad. In fact, it's terribly good. It's one of those languages that people love to hate because they feel they sound very knowledgeable if they do so. And they haven't bothered learning the language as well.
.bind(this)

-- a guy who built his career on JavaScript

Genuinely curious as somewhat of a novice, can any one give an example of how javascript is insecure in a way that is difficult to fix?
Two of the worst things about JS that come to mind in terms of security:

Every number is in 64-bit floating point. So if you want to do any number-theory-based crypto (Elliptic Curve) or you have do deal with numbers bigger than (2^48) you either have to study IEEE 754 very carefully (and likely push to production a series of mistakes), or take the hit of using an integer math library that has worked out how to do proper integer math with the 48-bit mantissa of a 64-bit float.

Of course there are those who don't realize this at all, and try to do integer math in JS, or in the case of a beginning programmer (many students start with JS these days), they don't realize that 0.1 + 0.2 == 0.30000000000000004.

Every variable is global by default. The best way to hide data in JS is within a function closure. However, one forgotten var keyword, and your whole encapsulation model is trashed.

Stockholm syndrome comments up in here.
I read some good things on HN, I mean - really good things -

And then this, it's not even the level of what you can hear at the coffee machine.

OP please don't metaphor in the shower. You're wasting the planet's water.

Java was in the browser first and it lost, we had flash etc. get over it - and enough already of the "you're not a good programmer if you like JavaScript" comments.
Yet another "booohooo JS language design sucks and I don't like it" post.

What year is this?

To extend the analogy, imagine there are lots of tour guides to the mine field, they make lots of money using it. Imagine their opinion of something that makes their knowledge of all the mine positions they have spent years learning obsolete...
Are we now modding /r/showerthoughts upto HN front page ?
(comment deleted)