2 ms·
Yes Dart compiles to javascript, but it has pretty different semantics from javascript and needs to insert extra javacript to get your transpiled javascript to
by ratbeard 12y ago
Yes Dart compiles to javascript, but it has pretty different semantics from javascript and needs to insert extra javacript to get your transpiled javascript to run. For example, noSuchMethod isn't available in all js engines so using https://www.dartlang.org/articles/emulating-functions/#interactions-with-mirrors-and-nosuchmethod https://www.dartlang.org/articles/emulating-functions/#inter... in dart would require a non-trivial amount of wrapping code to be generated.
http://stackoverflow.com/questions/8815437/why-is-javascript-files-generated-by-dart-is-so-huge http://stackoverflow.com/questions/8815437/why-is-javascript...
> And the size of helloworld.dart.app.js is 102k
> When ran in optimize mode, it generated the following javascript - helloworld.dart.js which is of size 20k
- ahoge 12y ago> And the size of helloworld.dart.app.js is 102k No, it's not. dart2js --minify hello.dart -o hello.dart.js Results in a 5 KB JS file. This game is 35 KB (procedural graphics included): http://mbtic.com/games/fuzetsu http://mbtic.com/games/fuzetsu
- ratbeard 12y agoI imagine they've improved the runtime size since that stack overflow post was posted a few years ago. However I've never used dart and just tried it out using a basic html sample from the tutorial page and I see: 264 Mar 5 12:21 a.dart 237K Mar 5 12:21 a.js 101K Mar 5 12:22 a.min.js It was also slow to compile, 6 secs. Anything I'm missing? https://gist.github.com/ratbeard/70902d6347ad448de0a4 https://gist.github.com/ratbeard/70902d6347ad448de0a4
- ahoge 12y agoIf you add gzip compression, it's still smaller than doing the same thing with jQuery. "dart:html" provides an idiomatic DOM API where all list-like things are actually Lists, events are streams, Futures instead of callbacks, and so forth. It's pretty nice to use, but it's also one of the bulkier libraries. Also note that you could now add a thousand lines of code and the file size wouldn't increase much. You already paid that one-time cost. You can further improve the size by using a better minifier on top of --minify.
- ratbeard 12y agoAh, that makes sense re:same size as if you added jquery, and the API abstractions do sound better. Though as a counterpoint (and relevant to angular 2 :) I read they're going to just use the raw dom api's instead of a jquery/jquery-lite abstraction layer as the dom api's don't need the smoothing over in modern browsers like they used to.