7 ms·
I've read about Dart, but I haven't used it much in practice. What does it do better than similar languages that compile to JS (CoffeeScript, Typescript, etc)?
by d4mi3n 12y ago
I've read about Dart, but I haven't used it much in practice. What does it do better than similar languages that compile to JS (CoffeeScript, Typescript, etc)?
Specifically, why would one consider moving to Dart from any of the above languages?
- chrischen 12y agoDart compiles to javascript, but it's just a feature to ease migration. It also has its own VM.
- spankalee 12y agodart2js is not just a feature to ease migration. It's the primary means of deploying Dart code, and will be so for a long time, even if/when the Dart VM gets into Chrome.
- pyre 12y ago> It's the primary means of deploying Dart code I'm assuming that you mean on the browser, or are you targeting dart => dart2js => nodejs as the primary means of server-side deployment?
- spankalee 12y agoOh yes, you're right, on the browser. On the server there's absolutely no need for Node.js.
- rdtsc 12y agoFew reasons: There is a native VM for it that is fast and it has the highest chance of getting implemented in a browser (let's say higher than Typescript). There is good tooling behind it (IDE, package system). Google supports it. Whether we like it or not that makes a huge difference. Native VM has good IO characteristics and can be used on the server side as well. (So can start using that on the server side without having to wait for browsers to embed it). Does away with Javascript warts better than CoffeeScript.
- idibidiart 12y agoThe imperfections in Javascript is what makes it beautiful. http://www.utne.com/mind-and-body/wabi-sabi.aspx http://www.utne.com/mind-and-body/wabi-sabi.aspx
- spankalee 12y agoWhen those imperfections cost you time, money, users and your own sanity you begin to look for a better option.
- idibidiart 12y agoImperfections in an art form like Glitch are the substance, not the dirt. Same way, imperfections in JS make it so much fun to work with, for the sufficiently insane. Taking a puritanical approach to programming and weeding out the imperfections leads to a very boring language. I understand the business argument, but creativity requires a certain amount of chaos, no? Or it depends on your theory of creativity I guess. Fair enough.
- Flow 12y agoI bet you loved Visual Basic 6 :-)
- idibidiart 12y agoComparing to VB is like .. Well, I won't even bother
- mattgreenrocks 12y agoJS is not an artistic statement, it's a programming language foisted on us by corporate politics and Industry. Also, mental chaos begets creativity. Chaos emerging from tools only serves to impede the expression of those using the tool. I'm not sure how you can argue how a tool that works against the user in a non-performance art is a good thing.
- coldtea 12y ago
- lukasm 12y agoThe great thing about Dart is that it breaks backward compatibility with js. The bad thing about Dart is that it breaks backward compatibility with js :)
- discreteevent 12y agoNot sure what you mean by breaking backward compatibility. It generates js. Does e.g. Clojurescript break backward compatibility with js?
- pyre 12y agoI think that the parent was referring to the fact that it is it's own language with its own VM/runtime. The idea is to create a new language with JavaScript as a compile target. Things like CoffeeScript, TypeScript, etc are much more conservative approaches to dealing with the issues JavaScript has.
- lukasm 12y agoTypescript is a superset of Javascript. Similar to C and C++. Almost every C code can be compiled as C++. Dart is Java in this analogy.
- spankalee 12y agoHi, I'm on the Dart team, I'll try to answer the best I can. CoffeeScript doesn't really change the semantics of JavaScript at all, it mostly is just a new syntax. I don't fine the syntax to be the worst thing about JavaScript, so CoffeeScript has never seems that compelling to me. TypeScript does a little more by offering types and classes, but it's still a superset of JavaScript and can't fix major issues because of backwards compatibility. I like TypeScript, but I prefer to go a lot farther. Dart fixes a lot of fundamental issues with JavaScript, largely related to having a well-defined structure that humans and tools can reason about. This makes it easier for the VM to optimize too. Here's a grab bag of things that Dart has over JavaScript: * Dart has libraries, and library scope, no global scope. All code must be imported to be used. * It has true classes with inheritance, interfaces and mixins. Objects are closed, so you can't accidentally add a new property because of a typo, and you get static warnings about undefined property names. * Dart has optional type annotations and a static type checker. We catch a lot of bugs when porting JavaScript code to Dart and adding types. * There are no top-level statements, only variable, function and class declarations. A program always starts at main(). * True lexical block scoping. No function scoping. * Final variables and library private names. * There are generics and they are reified. * 'this' is lexically bound, removing a whole swath of confusing patterns and bugs. * There is no implicit type coercion or boolean conversion. Being more explicit in boolean contexts reduces bugs. * There are real collections like Maps, Lists, and Sets. They are interfaces and can be implemented by users. * Dart has operator overloading * There is an actor-like unit of concurrency call Isolates * Metadata annotations (@something) can be processed by build-time and runtime tools. * noSuchMethod() let's you catch undefined method calls. All combined, I find Dart to be much easier to code in and much, much easier to read and navigate. Jump into a new Dart codebase and the types give you a lot of information. Even in code that's not typed, because it's statically analyzable you can jump to definitions and get documentation for fields and functions. At Google we see productivity is _much_ higher on Dart projects. Hope that helps a little!
- rdtsc 12y agoHey great work, congratulations! I like the performance of Dart VM for server side. I remember it was so-so initially and then it got a huge performance boost. You could see a sharp jump on https://www.dartlang.org/performance/io/ https://www.dartlang.org/performance/io/ (now it almost disappeared to the left side due to the timeline moving)
- ahoge 12y ago> What does [Dart] do better than similar languages that compile to JS (CoffeeScript, Typescript, etc)? CoffeeScript doesn't really help with scaling. It's basically just a slightly more compact JavaScript dialect. Personally, I don't see the point. TypeScript is closer. It offers type annotations and more structure. Being a strict superset of JavaScript also means that it can't fix any of JavaScript's issues. However, it also means that it can seamlessly interact with JavaScript. Dart is a clean break. Straightforward, nice semantics, and none of the weird stuff. There are official code conventions, a package manager, a doc generator, and a built-in way to do inheritance. Compared to JS, this skips a lot of research and pointless discussions. Naturally, it also avoids the associated compatibility issues and annoyances. The VM is also a big advantage, because you don't have to compile your code hundreds of times a day during development. As a result, the compiler can perform rather heavy optimizations, because compile speed isn't the top priority anymore. Having that VM also allows you to write command line tools and web servers. It can be also embedded in other applications. Anyhow, if you know something like C#, you already know most of Dart's syntax. Just give it a try. You can be productive on your very first day. It's really that straightforward.