

Anders Hejlsberg and Lars Bak: TypeScript, JavaScript, and Dart - michaelwww
http://channel9.msdn.com/Shows/Going+Deep/Anders-Hejlsberg-and-Lars-Bak-TypeScript-JavaScript-and-Dart
Lars Bak: <i>To contrast these two languages, TypeScript is a safe bet... where Dart is trying to change some of the fundamental issues with JavaScript. I feel, from a computer science background, I still have problems that you can design applications with libraries where you can monkey patch the libraries when you get up running. I find that very, very disturbing when you are trying to write big applications. [with TypeScript] you end up in the same mess.</i><p>Anders Hejlsberg: Everything you say and more I will agree with. The question is not whether JavaScript is broken. The question is whether it is broken enough to merit being replaced by something else.
======
michaelwww
Lars Bak: _To contrast these two languages, TypeScript is a safe bet... where
Dart is trying to change some of the fundamental issues with JavaScript. I
feel, from a computer science background, I still have problems that you can
design applications with libraries where you can monkey patch the libraries
when you get up running. I find that very, very disturbing when you are trying
to write big applications. [with TypeScript] you end up in the same mess._

Anders Hejlsberg: _Everything you say and more I will agree with. The question
is not whether JavaScript is broken. The question is whether it is broken
enough to merit being replaced by something else._

------
yonran
TypeScript is what Google Closure Compiler should have been; Closure’s static
typing is similar but is much more tedious (you need to type 16 characters
just to declare an int!
[https://developers.google.com/closure/compiler/docs/js-
for-c...](https://developers.google.com/closure/compiler/docs/js-for-
compiler)). I’m disappointed that nobody from Google Closure has stepped up to
unify TypeScript and Closure’s syntax and to provide better tooling.

------
seanalltogether
Can anyone explain what the difference between TypeScript and ECMAScript 4
are? I know ECMAScript 4 was abandoned for some reason, but from the few
examples I've seen of Typescript it looks very similar. Did the js community
just need a few more years to come around to the ideas?

~~~
phase_9
ECMAScript 4 was implemented in ActionScript 3[1]; a very nice language to
work with IMHO. The members of the ECMAScript steering group launched into a
public fracas on their respective blogs[2] which eventually ended in the draft
being canned, despite the fact both ActionScript and Silverlight were already
based on the standard... shame.

[1] <http://en.wikipedia.org/wiki/ActionScript#ActionScript_3.0>

[2]
[http://blogs.msdn.com/b/ie/archive/2007/10/30/ecmascript-3-a...](http://blogs.msdn.com/b/ie/archive/2007/10/30/ecmascript-3-and-
beyond.aspx#5788577)

~~~
camus

        >    The second system syndrome is that evil effect that often happens when redesign a small, working system so that it becomes a huge leviathan built by piling new features over new features.
    
        >    Today I was reading the overview of ECMASCript 4 from ecmascript.org, and I got this very bad feeling that maybe the fourth version of ES, is suffering of an extremely strong case of this problem.
    

I dont know who is that guy , but what a load of cr*p ... it's people like him
that got us stuck with what is javascript today. People often complain that
Flash prevented Javascript from being widely adopted , the truth is that
Macromedia/Adobe tried to push a better Javascript that would have helped the
language then and today.

Imagine we had ES4 and HTML5 today. Nobody would be complaining about how much
javascript sucks , and there would be no need for typescript, coffeescript
,etc ...

~~~
riffraff
actually, it's my words[0] :)

I wrote it many years ago, but if you think it's wrong I'd be happy to
understand why.

I have never been against Flash nor ActionScript(which I don't know enough to
criticize) but my understanding was that ES4 was vastly more complex than even
AS ever was, rather than being an incremental change as ES6 is.

And please note I wrote

""" ECMAScript 4 seems cool, I want to use a lot of those things (yay for
multi method dispatch!), but maybe it is changing the language a little bit
too much . """

And I wish I could influence what the dev world does, but I believe it is
unlikely.

[0] [http://www.riffraff.info/2007/10/25/ecmascript-4-the-
fourth-...](http://www.riffraff.info/2007/10/25/ecmascript-4-the-fourth-
system-syndrome)

------
pnt
I feel like Dart's emphasis on a fast but chrome-only vm has hindered it's
adoption. I understand their goal, unlike most compile-to-js languages, was a
language more amenable to fast implementation. However, I think the initial
community reaction would have been more positive if Dart was positioned first
as a language that compiled to js, with the added benefit that it runs
significantly faster on Chrome.

~~~
dragonwriter
> I feel like Dart's emphasis on a fast but chrome-only vm has hindered it's
> adoption.

Dart's VM isn't Chrome-only, its open source, and available both standalone
and bundled into Chromium.

> However, I think the initial community reaction would have been more
> positive if Dart was positioned first as a language that compiled to js,
> with the added benefit that it runs significantly faster on Chrome.

Reaction might have been more positive in the short run if it was sold as a
on-top-of-JS language rather than part of a long-term plan to build something
to replace (or complement) JS as a language for which browsers would have a a
built-in, language-specific VM. However, I think that even if initial reaction
might have been better with such a response, Google clearly did the right
thing by being up front about their vision.

~~~
pnt
> Dart's VM isn't Chrome-only

I meant that dart is chrome-only in practice. I don't know of any other
browser vendor that bundles the dart vm, including the few browsers based on
chromium like rockmelt or 360.

> However, I think that even if initial reaction might have been better with
> such a response, Google clearly did the right thing by being up front about
> their vision.

I can appreciate Google's directness regarding Dart's intention. However, from
a web developer's perspective, Dart's multiple backends is very unappealing. I
hesitate to adopt even a language like clojurescript or coffeescript because
of debugging barriers and potential bugs in the language's crevices (though
these problems are diminishing with things like source map support).

~~~
ttrreeww
Dart is Google's Silverlight.

~~~
michaelwww
ActionScript/Flash and .NET/SilverLight require a plugin, with Dart the
"plugin" is optional.

~~~
ttrreeww
It's called the Dart Runtime which is not included in non Google browsers.

~~~
dragonwriter
Except: 1\. The Dart VM isn't included in Google's generally-released
browsers, either (it's included in Dartium, the special version of Chromium
bundled with the Dart SDK). 2\. The Dart VM isn't a plug-in. 3\. As Dart
compiles to JS, you don't need the Dart VM to run code developed with Dart,
you just need a browser that supports JS.

------
edtechdev
Dart is great and I like how they are focusing on making it fast and creating
a special VM for it (dartium, although it compiles to javascript, too). It's
tempting to target a compiler to generate dart code, too, instead of
javascript. But there is one deal breaker for me - dart can't compile locally
in the browser (even a dartium one). It requires a server or else compiling
off-line (same issue with Closure Compiler, too). You can't code a dart app on
a chromebook, for example (unless you use remote desktop or install ubuntu on
it). The future to me is doing all development work in the browser, and only
connecting to the server for the server components or version control, like
with c9.io and other browser-based IDEs. Even Eclipse has a browser-based
version now - Orion.

It's not a huge deal - there are over a hundred alternative languages that
compile to javascript out there now, many of which do support compiling in the
browser: [https://github.com/jashkenas/coffee-script/wiki/List-of-
lang...](https://github.com/jashkenas/coffee-script/wiki/List-of-languages-
that-compile-to-JS)

~~~
munificent
> dart can't compile locally in the browser

dart2js is written in Dart. There's some small amount of work needed to self-
host it and run the result in a browser, mainly swapping out the file IO API
with something that works on the web. I think multiple people on the team have
slapped together working examples of this, so it's not a lot of work.

It isn't a high priority for the dart2js team right now, though, and they are
very careful to avoid taking on responsibility for features or use cases that
don't have solid tests. I think before too long, we will have a reliably self-
hosted Dart->JS compiler that runs in a browser, we're just focused on other
stuff for the moment.

------
sultezdukes
It's a pretty smart move that Microsoft did with TypeScript, making it a
proper superset of JavaScript. Google seems to be stuck in the past, bringing
out its own VM that is a complete non-starter, and making another class-based,
Java-like language. I guess Google is going down the road that Microsoft did
years ago with flinging feces on the wall and see what sticks.

I have nothing against Dart. I played with it a year and a half ago when the
Eclipse beta came out. It's nice tooling, but brings absolutely nothing
interesting to the table.

~~~
weareconvo
Yesterday, I rewrote one of my JS modules into Dart, and it ended up being
about 10 lines of code with only two modules imported. Then I compiled it to
JS, and it was over 120k. I tried for about an hour to get that down to a
reasonable size with Closure Compiler/Uglify, but the names were too wonky.

I'm sure that, given enough time, they'll solve these problems, but as for
right now... it isn't ready for primetime. Not by a longshot.

~~~
michaelwww
You don't say if you used the 'dart2js --minify' setting, but Closure Compiler
should do well. The --minify flag leaves alot more room for additional
minification. You say you used two modules. The result really depends on the
modules. For example, the Dart/JS interop module adds about 140K un-minified.
Tree shaking is always on, so the 140K is after stripping unused code. I
initially jumped into Dart because I was interested in doing packaged apps
that run locally, so the size over the wire didn't concern me as much. I
recently converted an ActionScript app to Dart and the post-minify Dart was
around the same size as the compiled .swf file (for comparison, same
functionality)

Seth Ladd has a couple of posts about Tree Shaking and Minification if you're
interested [http://blog.sethladd.com/2013/01/minification-is-not-
enough-...](http://blog.sethladd.com/2013/01/minification-is-not-enough-you-
need.html) [http://blog.sethladd.com/2013/03/i-shrunk-my-dart-to-js-
code...](http://blog.sethladd.com/2013/03/i-shrunk-my-dart-to-js-code-
by-11x-and.html)

~~~
weareconvo
> You don't say if you used the 'dart2js --minify' setting

I did. I'm no stranger to Closure Compiler, and even after fiddling around
with ADVANCED_OPTIMIZATIONS for an hour, those ridiculous $variables
persisted. What was even weirder was, just as a test, I imported a module I
wasn't even using at all, and for some reason, Closure Compiler still refused
to remove its code...

~~~
michaelwww
Just for grins, I compiled the Dart app I'm working on now with --minify. It
went from 530K to 240K. Then I cleared the --minify flag and used the Closure
Compiler but it failed with errors. Not sure what is going on yet, but I don't
think this is necessary or advisable -- I've never read of anyone using the
Closure Compiler with Dart. Here is a sample few lines from --minify. It's
fairly minimal.

function I(){} init() var $=I.p var $$={}

~~~
weareconvo
Okay, but um, why did minify not get rid of the module i wasn't even using?

~~~
michaelwww
Just to be clear, here is what I did.

    
    
      Dart source -> dart2js -> JavaScript (530K) 
      Dart source -> dart2js -> JavaScript (530K) -> Closure Compiler -> *error*  
      Dart source -> dart2js --minify -> JavaScript (240K)
    

If I import a module and don't use it, such as 'dart:utf', the resulting
JavaScript output size does not go up. If I call a function in dart:utf the
JavaScript size goes up. If I stop calling the function, the size goes down.
If I create a function but don't call it, the size stays the same. If I call
it, the size goes up. Everything seems to be working. They just release a new
version a few days ago and I'm on the latest.

------
camus
Haxe anyone ? full HTML5 api support , dead-code elimination, loads of
libraries and frameworks , easy integration with third party libraries ,multi-
target (C++,Flash,JS,...) and open source...

~~~
coolsunglasses
Stop trying to make Haxe happen, it's not going to happen.

~~~
bsaul
I've been wondering whether I should start using this language for a project,
and almost every time there's a good reason not too, but I'm still thinking
one day there won't and i will. I'm curious to know what makes you think it
will never happen, though.

~~~
coolsunglasses
It tries to be too many things to too many people, can't do a good enough job
on any of it. Not really worth the investment.

~~~
camus
haxe has flaws , but haxe is not backed by windows nor google. The team is 3/4
developers and they did a great work. Haxe will grow in the future. All it
needs is a better "PR" and a bit of hype. A lot of successfull projects have
been made with haxe.

------
andyl
To me this interview underlines the accomplishment of CoffeeScript.

No committees. No marketing team. No developer evangelists. No PR team. No
corporate interests. No budget.

Just code.

~~~
rayiner
Also nobody with the sense of history to design proper lexical scoping of
variables.

~~~
baudehlo
To achieve that CS would have had to put everything with a new variable inside
a new function scope, having a major impact on performance and readability of
the generated code.

~~~
gruseom
Parenscript gets lexical scoping by renaming variables (but only where
necessary). It works fine. The original variable name is used as a prefix, so
the generated code remains readable.

------
ttrreeww
Transcript?

~~~
michaelwww
Doesn't appear to be one. The quotes I lifted start at 11:23

