4 ms·
Why not Dart?
by electrotype 12y ago
Why not Dart?
- aberatiu 12y agoYeah. Seriously, why not dart. Any clue, anybody?
- ratbeard 12y agoDart 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.
- dubcanada 12y agoNo 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.
- ratbeard 12y agoYes 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.
- xrstf 12y agoDart 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.
- danellis 12y ago> 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.
- jdmichal 12y ago> 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 https://github.com/borisyankov/DefinitelyTyped [1] http://www.typescriptlang.org/Tutorial http://www.typescriptlang.org/Tutorial [2] http://www.typescriptlang.org/Handbook http://www.typescriptlang.org/Handbook [3] http://www.typescriptlang.org/Samples http://www.typescriptlang.org/Samples [4] http://www.typescriptlang.org/Content/TypeScript%20Language%20Specification.pdf http://www.typescriptlang.org/Content/TypeScript%20Language%...
- DDcsidsIOIDp 12y ago> "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.
- tinza123 12y agoI guess as TypeScript is less likely to break existing JavaScript code base, as all JavaScript code are already valid TypeScript code.
- logicalmind 12y agoBecause Microsoft wants to add tooling in Visual Studio to use this and they obviously would want to use Typescript for that.
- robmcm 12y agoDo you really think writing a framework for a language in a different language is a good idea?
- adrianlmm 12y agoWhy Dart?
- aikah 12y agoThere 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.
- sethladd 12y agoIt'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.
- ahoge 12y agoBecause 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.
- ceronman 12y agoThere is a Dart version: https://pub.dartlang.org/packages/angular2 https://pub.dartlang.org/packages/angular2
- SureshG 12y agoAngular.ts.js.at.dart.wtf - http://work.j832.com/2015/03/angulartsjsatdartwtf.html http://work.j832.com/2015/03/angulartsjsatdartwtf.html . Also see the comment from Brad Green - https://plus.google.com/+KasperLund/posts/JtWmoEs5EjC https://plus.google.com/+KasperLund/posts/JtWmoEs5EjC