Live data from Hacker News

"Hello World" in Dart, compiled to JavaScript

gist.github.com

141–150 of 162 posts

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

#141

Earlier quoted context omitted.

"Dart is not a standard, it's not controlled or directed by any open body" You say that like it is a bad thing. I don't think it is. Standardizing technologies is great once they are mature and are already accepted as the obvious de-facto standard, but trying to push real change through standards bodies results in exactly the sort of morass that JavaScript has been stuck in and which makes Dart a refreshing attempt a…

> exactly the sort of morass that JavaScript has been > stuck in You mean the one where some large corporations are doing what they can to keep it from improving? Seriously, Google has been sabotaging all sorts of JavaScript improvements by flat-out refusing to implement them. So in fact the "other players" _are_ directing their effort to something they perceive as better than Dart: Harmony. As for the rest, what wil…

JavaScript was stuck in the mud before Chrome or V8 even existed. Before Google, Microsoft and Yahoo got the blame.

Regardless of who the actors are that are most currently gumming up the works, all of this just proves the point that standard bodies are not an effective tool for actually creating useful technology.

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

#142

This is called "a runtime". A bunch of things that have to be loaded on the target machine for use by a compiled program. Just about every compiler works this way, whether the output is machine code or JavaScript. It is possible to not emit or load the parts of the runtime which will not be used by a given program, but that's difficult and in many cases even impossible. I am not a web programmer, and I don't use JS a…

> This is called "a runtime". > I am not a web programmer

You see, it's not a spherical runtime in vacuum. In practical terms it's more like a whole lot of stuff to download, parse and execute each time your browser hits a new page.

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

#143

This is called "a runtime". A bunch of things that have to be loaded on the target machine for use by a compiled program. Just about every compiler works this way, whether the output is machine code or JavaScript. It is possible to not emit or load the parts of the runtime which will not be used by a given program, but that's difficult and in many cases even impossible. I am not a web programmer, and I don't use JS a…

> maybe they will figure out a way to exclude parts of it which are not needed

This is called "tree-shaking", is fairly standard, and is on the to-do list. I believe it does some now, but I think more is coming.

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

#144

This is called "a runtime". A bunch of things that have to be loaded on the target machine for use by a compiled program. Just about every compiler works this way, whether the output is machine code or JavaScript. It is possible to not emit or load the parts of the runtime which will not be used by a given program, but that's difficult and in many cases even impossible. I am not a web programmer, and I don't use JS a…

> This is called "a runtime". > I am not a web programmer You see, it's not a spherical runtime in vacuum. In practical terms it's more like a whole lot of stuff to download, parse and execute each time your browser hits a new page.

shrug

I bet most of the people including JQuery on their pages only use a fraction of its functionality even though it all must be parsed. So what?

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

#145

Earlier quoted context omitted.

> exactly the sort of morass that JavaScript has been > stuck in You mean the one where some large corporations are doing what they can to keep it from improving? Seriously, Google has been sabotaging all sorts of JavaScript improvements by flat-out refusing to implement them. So in fact the "other players" _are_ directing their effort to something they perceive as better than Dart: Harmony. As for the rest, what wil…

JavaScript was stuck in the mud before Chrome or V8 even existed. Before Google, Microsoft and Yahoo got the blame. Regardless of who the actors are that are most currently gumming up the works, all of this just proves the point that standard bodies are not an effective tool for actually creating useful technology.

There was all sort of innovation in JavaScript going on at the time; still is.

As you note, getting the innovation into a standard is the hard part, when some of the parties to the standards process don't actually want the language to improve...

But Google claiming this is a problem for JavaScript while it is one of those exact parties is just hypocritical.

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

#146

This is called "a runtime". A bunch of things that have to be loaded on the target machine for use by a compiled program. Just about every compiler works this way, whether the output is machine code or JavaScript. It is possible to not emit or load the parts of the runtime which will not be used by a given program, but that's difficult and in many cases even impossible. I am not a web programmer, and I don't use JS a…

In general it's true that you can't avoid the runtime, but in this case I think people's expectations are colored by CoffeeScript, which offers (for many) a more productive environment than vanilla JavaScript, with no runtime at all. Since Dart is a CoffeeScript competitor in the "languages that compile to JS" space, this is a legitimate disadvantage. Dart may well have so many advantages over CS that this becomes a…

[deleted]

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

#147
post #130

Earlier quoted context omitted.

I agree that it's perfectly legitimate to discuss the runtime needed for Dart, and point out that it's a disadvantage that it is needed at all, or to criticize the runtime, or whatever. What shocks me is that people who are supposed to be techies are pointing their fingers at the runtime and making monkey noises, because they apparently have never seen a language runtime or heard of the concept. Dart did not compile…

The reason we are making monkey noises and pointing fingers is because we expected a better JavaScript, not a Java that compiles to JavaScript. We already have that. It's called GWT and this is just GWT 2.0 with a pretty name.

There's already a GWT 2.0; this is more like GWT 9.0. And as someone who has done a lot of work in GWT (and JS, and CS), I can see a lot of potential in Dart. GWT is superior to javascript/coffeescript for a certain set of problems (mostly fat-client-type webapps); a major upgrade to the language and tooling would be welcome.

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

#148
post #49

same code in coffeescript (@ preceding testMain makes it a static method and it looks like print in Dart converts to console.log) class HelloCoffeeTest @testMain: -> console.log "Hello, Coffee!" HelloCoffeeTest.testMain() resulting js var HelloCoffeeTest; HelloCoffeeTest = (function() { function HelloCoffeeTest() {} HelloCoffeeTest.testMain = function() { return console.log("Hello, Coffee!"); }; return HelloCoffeeTes…

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.

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

I think you are correct here. But there is still something very worrying about what Dart compiles into. It isn't just the amount of code, which is what most people are discussing. It's the content too.

The content of the code makes it look like much of that code will be run all the time. In other words, it isn't just some library functions that are called rarely, it is stuff that will end up being called from your inner loops. I might be wrong here, but that's what the code suggests to me.

In that respect, the Dart compiler looks different from both CoffeeScript and Emscripten. CoffeeScript by design compiles into straightforward JS, and Emscripten manages to compile into mostly-straightforward JS as well, which is why it has decent performance. But what Dart compiles into looks like it would not run very fast on most JS engines. It might run fast on Chrome, if they tune its inlining and other capabilities for Dart-like code, but I doubt that would hold anywhere else.

Again, though, I have not profiled the generated code, I just took a look at it, so I might be wrong.

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

#149
post #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 r…

On 32-bit Linux GCC, C hello world comes out to only 7 KB. Without optimization.

Just as a datapoint (I did this test before seeing the comment), in 32-bit cygwin a hello world written in C compiled to 12KB. In C++, it compiled to 497KB.

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

#150
post #72
post #65

Earlier quoted context omitted.

"...given that they should be grasping for any chance to leave the warty and dated pile of compromises that is Javascript behind..." I would not characterize the JavaScript community as desperate graspers, but even so, I don't see the virtue in grasping for the chance to replace a dated pile of compromises with a contemporary pile of compromises. All the hate is totally overblown - this project is young and will like…

Not desperate graspers? Try and count the number of libraries and frameworks that have come out in the last 5 years for JavaScript. Think of how many "to JS" solutions there are. Seriously, google that. Like 20? 25? How much "to C" solutions do you see getting on the front page of Hacker News these days? It's staggering how much 'grasping' has been happening compared to other ecosystems. It's ironic that people would…

> Think of how many "to JS" solutions there are. Seriously, google that. Like 20? 25?

What do you expect? The most important platform to write software for only accepts a single language. It doesn't matter how good the language is, people will be writing things that get converted to that language.

> How much "to C" solutions do you see getting on the front page of Hacker News these days?

Well, there's ShedSkin, and HipHop. But that's not the point. Anything that can run C can run [arbitrary other language]. Because, often enough, that arbitrary other language was written in C. Surely, by your terms, everyone who programs in Python is a desperate grasper hoping to escape C?

Post reply on HN