It transpiles your code to a small lump of useful code. It also includes a runtime library which takes up a chunk of space. That ends up being a large fraction of the overall result when the application in question is "hello, world!", but in a real-world app, it's a relatively small piece of the pie.
I'll also note that the Gist is from 2012. Dart is twice as old today as it was when that Gist was published.
Here's what the output looks like today [1]. We have two compilers right now:
dart2js is designed to produce output that runs as fast as possible and is as small as possible. You can think of it as "-O3". Optimize all the things at the expense of readability. The dart2js output on the simple example is 170 lines, or 5K of JS (before gzip). Still kind of big, but like I said, most of that is runtime library that amortizes better in large programs.
dev_compiler, or "ddc" is for producing human-readable, debuggable output. It's like "gcc -g". No optimizations or minifications, fast compile times, maximum readability. Its output for this is 29 lines. This does not include the runtime library, since it compiles that to separate (also readable) files. The output uses ES6 and looks like:
dart_library.library('simple', null, /* Imports */[
"dart_runtime/dart",
'dart/core'
], /* Lazy imports */[
], function(exports, dart, core) {
'use strict';
let dartx = dart.dartx;
class Simple extends core.Object {
Simple(name) {
this.name = name;
}
greet(who) {
return `Greetings ${who}, I'm ${this.name}!`;
}
}
dart.setSignature(Simple, {
constructors: () => ({Simple: [Simple, [core.String]]}),
methods: () => ({greet: [dart.dynamic, [dart.dynamic]]})
});
function main() {
let s = new Simple('Flyn');
core.print(s.greet('Program'));
}
dart.fn(main);
// Exports:
exports.Simple = Simple;
exports.main = main;
});
//# sourceMappingURL=simple.js.map
Pretty readable, I think, especially given how young ddc is. The team is still hard at work on it.[1]: https://gist.github.com/munificent/bde42b3d02c563fb4a9c