News for hackers. Stuff that matters.
Re:Angular 2: Built on TypeScript by electrotype on Thursday March 05, 2015 @12:01PM (#9151992)
Why not Dart?
Re:Angular 2: Built on TypeScript by ahoge on Thursday March 05, 2015 @12:52PM (#9152459)
Because Dart isn't a viable option for writing libraries or frameworks which are meant to be used from JavaScript.

You can interact with JS libraries, but exposing some API to JS-land is a completely different matter.

There are some vague plans to improve this, but there hasn't been much interest, because if you use Dart anyways, you do of course want to use it as the "host" language. It has the tooling and all that jazz. Of course you'd want to use it for as much as you can.

Re:Angular 2: Built on TypeScript by aikah on Thursday March 05, 2015 @12:37PM (#9152326)
There is angular Dart, I'm sure there will be angular Dart 2. The problem of Dart , well have you ever seen some Dart code ? it's miles away from javascript. Have you ever seen some Dart2Js code ? It's heavy , megabyte heavy. Who's going to work with a framework that weight that much ,developped in a third party language ? Good luck with that.
Re:Angular 2: Built on TypeScript by sethladd on Thursday March 05, 2015 @07:11PM (#9154807)
It's only megabyte heavy if you use all of Dart's reflection capabilities. If you don't use dart:mirrors, Dart is competitive in size when compiled to JavaScript, especially when you consider that a modern web app today contains a bunch of support libraries like jQuery (which itself is ~30kb). With Dart, you don't need jQuery because Dart's dart:html and dart:core libraries are pretty good out of the box. Of course, do your own measurements as each app is different.
Re:Angular 2: Built on TypeScript by robmcm on Thursday March 05, 2015 @12:12PM (#9152095)
Do you really think writing a framework for a language in a different language is a good idea?
Re:Angular 2: Built on TypeScript by SureshG on Sunday March 08, 2015 @05:05PM (#9167257)
Re:Angular 2: Built on TypeScript by ceronman on Thursday March 05, 2015 @02:21PM (#9153179)
Re:Angular 2: Built on TypeScript by aberatiu on Thursday March 05, 2015 @12:03PM (#9152014)
Yeah. Seriously, why not dart. Any clue, anybody?
Re:Angular 2: Built on TypeScript by tinza123 on Thursday March 05, 2015 @12:12PM (#9152106)
I guess as TypeScript is less likely to break existing JavaScript code base, as all JavaScript code are already valid TypeScript code.
Re:Angular 2: Built on TypeScript by ratbeard on Thursday March 05, 2015 @12:07PM (#9152053)
Dart requires loading a dart runtime js file on to the page, as far as I know. And I think they would claim Typescript is javascript + some extra stuff on top, whereas dart is a whole new language to learn.
Re:Angular 2: Built on TypeScript by dubcanada on Thursday March 05, 2015 @12:28PM (#9152247)
No Dart compiles to JS. Obviously there is some overhead with transpiling languages, but it's actually pretty small. They have done a good job with it.
Re:Angular 2: Built on TypeScript by xrstf on Thursday March 05, 2015 @01:10PM (#9152619)
Dart can be run in both modes. Chrome (dunno if enabled by default and/or in stable) contains a Dart VM, so you "only" need to transpile into JS for non-Chrome.

The main problem I had with Dart was [a year ago] that using existing JS libraries like jQuery wasn't as seemless as I would liked. So that would be a reason against Dart, if Angular wants to make that aspect easier.

Haven't looked at TypeScript's interop with JS. I got frightened by the name Microsoft and the fact that they only had a huge language spec PDF and not a single tutorial or something easier to digest.

Re:Angular 2: Built on TypeScript by danellis on Thursday March 05, 2015 @01:29PM (#9152780)
> Dart can be run in both modes.

In production, it's only ever transpiled to JavaScript.

> Chrome (dunno if enabled by default and/or in stable) contains a Dart VM, so you "only" need to transpile into JS for non-Chrome.

Not the real Chrome. A version of Chromium that you can use to make the development cycle smoother. When you deploy, you still transpile to JavaScript for all browsers.

Re:Angular 2: Built on TypeScript by jdmichal on Thursday March 05, 2015 @01:32PM (#9152799)
> Haven't looked at TypeScript's interop with JS.

All JavaScript is valid TypeScript. This was one of the founding tenants for TypeScript. So interop is "just use the JS".

You can optionally also provide a binding file that tells TypeScript about the JS code so that it can perform compile-time checking on calls. There is a repository of these bindings for common libraries called DefinitivelyTyped [0].

> ... They only had a huge language spec PDF and not a single tutorial or something easier to digest.

Not sure when you originally looked, but there is now a tutorial [1], handbook [2], and samples [3] in addition to the language spec [4].

[0] https://github.com/borisyankov/DefinitelyTyped

[1] http://www.typescriptlang.org/Tutorial

[2] http://www.typescriptlang.org/Handbook

[3] http://www.typescriptlang.org/Samples

[4] http://www.typescriptlang.org/Content/TypeScript%20Language%...

Re:Angular 2: Built on TypeScript by ratbeard on Thursday March 05, 2015 @12:38PM (#9152331)
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/#inter... in dart would require a non-trivial amount of wrapping code to be generated.

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

Re:Angular 2: Built on TypeScript by ahoge on Thursday March 05, 2015 @12:59PM (#9152536)
> 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

Re:Angular 2: Built on TypeScript by ratbeard on Thursday March 05, 2015 @01:25PM (#9152737)
I 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

Re:Angular 2: Built on TypeScript by ahoge on Thursday March 05, 2015 @01:55PM (#9153001)
If 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.

Re:Angular 2: Built on TypeScript by ratbeard on Thursday March 05, 2015 @02:17PM (#9153144)
Ah, 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.

Re:Angular 2: Built on TypeScript by DDcsidsIOIDp on Thursday March 05, 2015 @07:11PM (#9154804)
> "No Dart compiles to JS."

The question is not here, the relevant question is

"Does JS compiles in Dart ?"

Because, JS Compiles fine in TypeScript, which means Typescript benefits from all JS ecosystem and vice versa.

Re:Angular 2: Built on TypeScript by logicalmind on Thursday March 05, 2015 @12:28PM (#9152253)
Because Microsoft wants to add tooling in Visual Studio to use this and they obviously would want to use Typescript for that.
Re:Angular 2: Built on TypeScript by adrianlmm on Thursday March 05, 2015 @12:21PM (#9152196)
Why Dart?