title: Why is javascript files generated by dart is so huge?
body: <p>I have the following dart code:</p>
  
  <pre><code>$ cat helloworld.dart
  main() =&gt; print('Hello world!');
  $ 
  </code></pre>
  
  <p>The javascript code generated by the dart compiler for the above code is as follows:</p>
  
  <pre><code>$ cat helloworld.dart.app.js 
  function native_ListFactory__new(typeToken, length) {
    return RTT.setTypeInfo(
        new Array(length),
        Array.$lookupRTT(RTT.getTypeInfo(typeToken).typeArgs));
  }
  function native_ListImplementation__indexOperator(index) {
    return this[index];
  }
  function native_ListImplementation__indexAssignOperator(index, value) {
    this[index] = value;
  }
  function native_ListImplementation_get$length() {
    return this.length;
  }
  function native_ListImplementation__setLength(length) {
    this.length = length;
  }
  function native_ListImplementation__add(element) {
    this.push(element);
  }
  function native_BoolImplementation_EQ(other) {
    return typeof other == 'boolean' &amp;&amp; this == other;
  }
  function native_BoolImplementation_toString() {
    return this.toString();
  }
  
  &lt;snapped&gt;
  
  var static$uninitialized = {};
  var static$initializing = {};
  function $inherits(child, parent) {
    if (child.prototype.__proto__) {
      child.prototype.__proto__ = parent.prototype;
    } else {
      function tmp() {};
      tmp.prototype = parent.prototype;
      child.prototype = new tmp();
      child.prototype.constructor = child;
    }
  }
  isolate$inits.push(function(){
    isolate$current.Duration$DartMILLISECONDS_PER_MINUTE$field = static$uninitialized;
    isolate$current.Duration$DartMILLISECONDS_PER_HOUR$field = static$uninitialized;
    isolate$current.Duration$DartMILLISECONDS_PER_DAY$field = static$uninitialized;
    isolate$current.Duration$DartSECONDS_PER_HOUR$field = static$uninitialized;
    isolate$current.Duration$DartSECONDS_PER_DAY$field = static$uninitialized;
    isolate$current.Duration$DartMINUTES_PER_DAY$field = static$uninitialized;
  }
  );
  RunEntry(unnamedd9297f$main$member, this.arguments ? (this.arguments.slice ? [].concat(this.arguments.slice()) : this.arguments) : []);
  $
  </code></pre>
  
  <p>And the size of <code>helloworld.dart.app.js</code> is 102k!</p>
  
  <p>When ran in optimize mode, it generated the following javascript - <code>helloworld.dart.js</code> which is of size 20k</p>
  
  <pre><code>$ cat helloworld.dart.js 
  var e;function f(a,b){if(b&gt;=0&amp;&amp;b&lt;a.length)return b;h(i(b))};var j={},k={};function aa(a,b,c){if(b)a.g=function(){return b.call(c)}}function ba(a,b,c,d){function g(b,g,t,m){return a.call(c,d,b,g,t,m)}aa(g,b,c);return g}function l(a,b){if(a.prototype.__proto__)a.prototype.__proto__=b.prototype;else{var c=function(){};c.prototype=b.prototype;a.prototype=new c;a.prototype.constructor=a}}function ca(a,b){return typeof a=="number"&amp;&amp;typeof b=="number"?a+b:a.na(b)}function da(a){a/=4;return a&lt;0?Math.ceil(a):Math.floor(a)}
  function o(a,b){if(a===void 0)return b===void 0;else if(typeof a==typeof b&amp;&amp;typeof a!="object")return a===b;return a.G(b)}function h(a){a&amp;&amp;typeof a=="object"&amp;&amp;Error.captureStackTrace&amp;&amp;Error.captureStackTrace(a);throw a;}function p(){var a=new q;a.f=s("ya",ea);a.va="";a.qa="";a.N=[];h(a)}var u={d:0};
  
  &lt;snapped&gt;
  
  y.push(function(){x.fb=j;x.eb=j;x.gb=j});y.push(function(){x.Ta=j;x.Sa=j;x.Ra=j;x.Wa=j;x.Va=j;x.Ua=j});(function(a,b){if(!A){var c=new ya;oa=c;sa(c,function(){a(b)});Ea();x=c}})(function(){return qb()(1,u,"Hello world!")},this.arguments?this.arguments.slice?[].concat(this.arguments.slice()):this.arguments:[]);
  $
  </code></pre>
  
  <p>Why is the javascript code which was generated by a dart compiler so huge?</p>
  
  <p>What problem are they trying to solve by generating such huge javascript files?</p>
  
  <p>Side Note: The javascript files were so huge, SO threw the following error:</p>
  
  <blockquote>
    <p>Oops! Your question couldn't be submitted because: body is limited to 30000 characters; you entered 140984</p>
  </blockquote>