Live data from Hacker News

"Hello World" in Dart, compiled to JavaScript

gist.github.com

91–100 of 162 posts

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

#91
post #18
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.

As I understand it, dart isn't trying to be a faster javascript. Its trying to be a better GWT. Many googlers I've spoken to firmly believe that you need a strongly typed, OO language with good tooling to be able to develop any large application. They believe web apps are no exception. Google has worked hard adding types to javascript with the closure compiler. But, there are limits to what you can achieve using java…

> Many googlers I've spoken to firmly believe that you need a strongly typed

Dart might be many things, none of them come remotely close to _strongly typed_.

Also, I never understood why Google ever started GWT, the idea itself is like a bad Apr 1st joke that got out of hand. I guess that the legions of Java programmers google has been hiring have started to take over sigh

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

#92
post #43
post #7

Wow. Reminds me of GWT...

you say that like GWT is somehow bad! I think GWT is a great piece of tech. To be honest, google has way too much NiH syndrome, even internally...

I still have trouble understanding how anyone can take something like GWT seriously.

Whole books could be written about everything that is wrong with GWT, but here is one post that barely scratches the surface: http://ryandoherty.net/2007/04/29/why-google-web-toolkit-rot...

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

#93
post #68

Earlier quoted context omitted.

> I don't understand why Dart is supposed to be good It's like Go: "It's from google, so awesome by default".

Go is awesome by default because of Ken Thompson, not because of Google.

And Dart is awesome by default because of Gilad Bracha :P

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

#94
This reminds me of the very early days of C++ were people would use the size of a compiled "Hello World" to argue their point. C++ targets a completely different domain from JS where the size of the runtime etc. is somewhat important and it makes sense to think about this.

I always thought that JS had this culture of "it works and is fast enough for most users" attached to it, so I'm curious what is so different here? Every JS application nowadays comes with tons of framework code already. Does it make a big difference if you carry around a (non-minified) 17000 lines runtime?

Of course, if you argue about elegance, none of this matters.

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

#95
post #55
post #49

Earlier quoted context omitted.

CoffeeScript is meant to be synaptic sugar on top of JS. Dart is a language with different semantics that happens to compile to JS. As such it includes a lot of runtime code. More appropriate examples would be Emscripten, Parenscript, or ClojureScript.

There is a legitimate point here though. If I'm a developer working on a new project, and I'm dissatisfied with JavaScript, I have a couple of options. I could try Dart, which will cost me a significant amount of performance in all browsers that aren't Chrome, or I could go with CoffeeScript, which will have good performance in all browsers (including Chrome, since Chrome will be forced by the other browser manufactu…

> I could try Dart, which will cost me a significant amount of performance in all browsers that aren't Chrome

But will it, though? Sure, "Hello, World" transpiles to 17,000 lines of code, but I'd want to see some actual benchmarks of actual code to see what kind of performance hit that implies, before deciding against Dart on that basis.

And then there's the whole python argument about developer time being more valuable, and most applications these days not being performance constrained, etc, that could possibly apply here, as well.

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

#96
post #82

Earlier quoted context omitted.

> synaptic sugar Is this a typo, tongue-in-cheek, or a technical term I don't know? I've only heard of "syntactic sugar" myself.

Dopamine is synaptic sugar.

Dopamine isn't a sugar - it contains Nitrogen.

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

#97

Oooooooo. So it's Javascript except with a highly constraining layer of blub on top of it. I'll go back to learning coffeescript then...

I'd say the gist demonstrates that it's not Javascript. What you see is the entire runtime, compiled to naive js.

If anything, Coffeescript is "just" js with syntactic sugar. Not that there is anything wrong with that.

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

#98
post #64

So the joke is that a prototype of a whole separate language has to include its runtime in its cross-compiled output? Did people... think this wouldn't be the case? Do they think that Javascript is not thousands of lines of C/C++ lurking in your browser? Good joke guys, but I don't think you realize which way the punchline is pointing... It sort of amazes me that people are being so hard on Dart, given that they shou…

Amen. The "me too" culture that's going on w/r/t Dart is really disappointing. Google: "Hey everyone, let's make the browser better by switching to something that smells less like garbage than javascript." Community: "You forgot a semi-colon!" Shameful.

> Community: "You forgot a semi-colon!"

The user is king. If Google doesn't give a shit about dart's users - ie programmers - then why should we care?

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

#99
post #81

Earlier quoted context omitted.

I'm sorry, but 2,300 lines of code is in no way acceptable as a "dead code"-eliminated Hello World program. Not by a longshot.

$ cat hello.c int main() { printf("Hello, world!\n"); } $ gcc hello.c $ ls -l a.out -rwxr-xr-x 1 brian staff 8.5K Oct 11 02:23 a.out* And that's compiled code! And it also links to libc! But then again, any JS program requires tons of compiled C/C++ code to run.

See here for an effort to create the smallest possible hello world x86 ELF binary: http://timelessname.com/elfbin/

His original C app was about 6k, and 3k when stripped of debug symbols. Not content, he switched to assembly, which got him down to ... nah, I won't spoil the rest. ;)

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

#100
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…

> If you run this through closure-compiler it's reduced to 2000 lines > which is nothing next to Underscore, jQuery, Dojo, etc.

jQuery is 9000 lines, uncompressed with all the comments.

I call that about the same order of magnitude as the things you mention, hardly "next to nothing".

Additionally, just about every line in jQuery is actually useful for something, even the optimized code seems to mostly consist of a whole load of getters and setters and definitions of what addition and multiplication does.

> 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.

Lines of code stops being a "silly metric" when the numbers get really big, as they do here.

> 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.

Surely you didn't mean "There is more to software development than performance." :-)

Easy to pick off "math". But is this stuff not supposed to run in a browser? I'll reconsider when I see a simple application running smoothly on a cheap 3 year old desktop PC.

No, a Hello World program that compiles to 170kloc is what is ridiculous. That you can optimize it to 2kloc is nice, but it's still just a Hello World program.

And a more serious program, how big would that be?

Post reply on HN