Live data from Hacker News

"Hello World" in Dart, compiled to JavaScript

gist.github.com

21–30 of 162 posts

Re: "Hello World" in Dart, compiled to JavaScript

#21

I'll repeat what I said in the GitHub thread: There's this interesting tool called Google Closure Compiler. It does dead code elimination. https://gist.github.com/1277285 Notice that this source is now 2000 lines of pretty printed JS. Given that anything interesting these days uses jQuery or Underscore.js clientside, and similar things serverside, this amount of JS for even Hello World is standard fare. EDIT: To be c…

Oh yeah, 2300 lines of gibberish JS and FSM only knows how many global variables and functions is a real improvement.

the original example should "compile" to nothing more than the following:

(function () { window.HelloDartTest = { testMain: function testMain() { console.log("Hello, Darter!"); } };

HelloDartTest.testMain(); })();

Re: "Hello World" in Dart, compiled to JavaScript

#22
Funny. But to be fair, a Hello World in C compiles to a 27k binary. Yeah yeah, optimize this, leave out that and you can get it smaller. Still doesn't change the fact that Hello World is not the target use-case for either C or Dart. Dart is intended for very large applications (compared to JS), so the additional weight for includes isn't that big of a deal.

It also doesn't change the fact that Dart sucks. For other reasons though.

Re: "Hello World" in Dart, compiled to JavaScript

#23
post #6
post #4

I wonder if the only speed benefits that the Dart VM gives would be able to be beaten out by a smart compiler. I know this is early for the cross-compilation code (it doesn't trim out anything it doesn't need here), but I hope this isn't what is ultimately used in that comparison.

[deleted]

v8 is not crazy fast. It is a fast dynamic language VM -- beats php, ruby, python and other javascript VMs. In absolute terms, it executes code slowly compared to, for instance, the Java, Scala, C, C++, C# and others.

Re: "Hello World" in Dart, compiled to JavaScript

#24

I'll repeat what I said in the GitHub thread: There's this interesting tool called Google Closure Compiler. It does dead code elimination. https://gist.github.com/1277285 Notice that this source is now 2000 lines of pretty printed JS. Given that anything interesting these days uses jQuery or Underscore.js clientside, and similar things serverside, this amount of JS for even Hello World is standard fare. EDIT: To be c…

Oh yeah, 2300 lines of gibberish JS and FSM only knows how many global variables and functions is a real improvement. the original example should "compile" to nothing more than the following: (function () { window.HelloDartTest = { testMain: function testMain() { console.log("Hello, Darter!"); } }; HelloDartTest.testMain(); })();

This is false. It is like claiming that it "should" really compile to just console.log("Hello,Darter!"); They're functionally equivalent so why not right?

Dart was designed for big apps. Google is not aiming at optimizing all the Hello World pages. Every single framework in existence has terrible size characteristics for Hello, World. Loading all of Foundation and UIKit for showing Hello World on the screen in iOS? It SHOULD just magically know to compile to the few commands that show the one text string right? No, that would be a waste of time optimization.

Now, if we start writing big apps in this thing and they are also bloated compared to their JavaScript equivalents then I will agree 100% that there is a problem. But there are just no worthwhile conclusions from the HelloWorld app regarding size. The only worthwhile conclusions are from the high level perspective, aka "how easy is it to write a hello world app".

Re: "Hello World" in Dart, compiled to JavaScript

#25
As me1000 (Randy Luecke) says Dart is not meant for hello world. If you run this through closure-compiler it's reduced to 2000 lines which is nothing next to Underscore, jQuery, Dojo, etc.

We all know the benefits of offloading code to a well known and well tested library or framework, especially if you're writing an app that is thousands of lines anyway. How is this contentious at the end of 2011 unless you're just hating Dart for the sake of it?

I haven't looked into the language yet and unless you haven't either let's all refrain from judgements based on this silly metric alone. Circle jerks and knee-jerk reactions are for Reddit, not HN.

Don't get me started on the whining about math performance. Reminds me of dinosaurs whining about how assembly is better than C is better than Java is better than.... There is more to software development than math. Crazy, new fangled, inefficient languages eat the lunch of older languages every single time. You have to be insane to pull out that gem. If math is your bottleneck then don't use Dart, if you know that math is your bottleneck then you shouldn't have to be told this! Sorry for the rant but half of the complaints I've read about Dart are utterly ridiculous, and speculative to boot.

Re: "Hello World" in Dart, compiled to JavaScript

#26
post #25

As me1000 (Randy Luecke) says Dart is not meant for hello world. If you run this through closure-compiler it's reduced to 2000 lines which is nothing next to Underscore, jQuery, Dojo, etc. We all know the benefits of offloading code to a well known and well tested library or framework, especially if you're writing an app that is thousands of lines anyway. How is this contentious at the end of 2011 unless you're just…

..and here's the jsperf for the --optimize'd hello world vs. vanilla JS - http://jsperf.com/dart-hello-world-test-with-optimize/2. 17k vs. 4M for me

Re: "Hello World" in Dart, compiled to JavaScript

#27
post #6
post #4

I wonder if the only speed benefits that the Dart VM gives would be able to be beaten out by a smart compiler. I know this is early for the cross-compilation code (it doesn't trim out anything it doesn't need here), but I hope this isn't what is ultimately used in that comparison.

[deleted]

V8 does not use static type inference, as you seem to suggest. It uses dynamic type specialization based on observed types. Only recent builds of SpiderMonkey (not those that are shipping in current Firefoxes) do static type inference.

Re: "Hello World" in Dart, compiled to JavaScript

#28
post #25

As me1000 (Randy Luecke) says Dart is not meant for hello world. If you run this through closure-compiler it's reduced to 2000 lines which is nothing next to Underscore, jQuery, Dojo, etc. We all know the benefits of offloading code to a well known and well tested library or framework, especially if you're writing an app that is thousands of lines anyway. How is this contentious at the end of 2011 unless you're just…

..and here's the jsperf for the --optimize'd hello world vs. vanilla JS - http://jsperf.com/dart-hello-world-test-with-optimize/2 . 17k vs. 4M for me

Got any useful benchmarks? Nobody is wondering which language to write their next "hello world" app in.

Just for the record I'm not saying Dart is amazing and everyone should use it, all I'm saying is that we should evaluate it objectively. If raw speed is your bottleneck then why are you wasting time evaluating Dart? Nobody is forcing anyone to use it, you can ignore it and move on with your day.

Post reply on HN