4 ms·
same code in coffeescript (@ preceding testMain makes it a static method and it looks like print in Dart converts to console.log) class HelloCoffeeTest
by cubicle67 15y ago
same code in coffeescript (@ preceding testMain makes it a static method and it looks like print in Dart converts to console.log)
class HelloCoffeeTest
@testMain: ->
console.log "Hello, Coffee!"
HelloCoffeeTest.testMain()
resulting js
var HelloCoffeeTest;
HelloCoffeeTest = (function() {
function HelloCoffeeTest() {}
HelloCoffeeTest.testMain = function() {
return console.log("Hello, Coffee!");
};
return HelloCoffeeTest;
})();
HelloCoffeeTest.testMain();
- swannodette 15y agoDoes CoffeeScript have all these data structures, http://www.dartlang.org/docs/api/index.html http://www.dartlang.org/docs/api/index.html?
- DanielRibeiro 15y agoYou can always import JS.Class: http://jsclass.jcoglan.com/ http://jsclass.jcoglan.com/
- swannodette 15y agoWhich is > 300K before minification.
- cubicle67 15y agoThat's a long list, so probably not. Does Dart have an existential operator?[0] zip = lottery.drawWinner?().address?.zipcode Hey look, I know they're not really comparable. They're solving different problems, are at different stages in maturity and have a different philosophy on how to do things. I also think that Hello World is probably the worst way to compare any two languages, but it's a fun exercise anyway [0] example code from http://jashkenas.github.com/coffee-script http://jashkenas.github.com/coffee-script
- rayiner 15y agoCoffeeScript is meant to be synaptic sugar on top of JS. Dart is a language with different semantics that happens to compile to JS. As such it includes a lot of runtime code. More appropriate examples would be Emscripten, Parenscript, or ClojureScript.
- ootachi 15y agoThere is a legitimate point here though. If I'm a developer working on a new project, and I'm dissatisfied with JavaScript, I have a couple of options. I could try Dart, which will cost me a significant amount of performance in all browsers that aren't Chrome, or I could go with CoffeeScript, which will have good performance in all browsers (including Chrome, since Chrome will be forced by the other browser manufacturers to keep its engine up-to-date). For me that'd be an easy choice, unless one of three things happens: (1) Dart's performance is so much better than that of JavaScript that it's worth sacrificing performance in every other browser to get hugely better performance in Chrome. That seems unlikely to me, but maybe it's possible. (2) Chrome ends up with 90%+ market share, so it doesn't matter that I'm bad in all the other browsers. But I can't see this happening as long as e.g. iOS is around and relevant. (3) I have the resources to write both a Dart version for Chrome and a CoffeeScript version for older browsers. At this point, Google has strictly made my life harder than it would have been otherwise. I do want to give Dart a fair shake, but I'm having a hard time seeing how it could realistically succeed.
- swannodette 15y agoAnything happening in a client browser will involve a significant amount of IO - querying / modifying DOM and remote requests. I don't think that choosing Dart over CoffeeScript is going to make much of a difference for most applications. See Objective-J / Cappuccino which chose to eat the very real overhead messaging in order to gain expressiveness. How many JS apps are as responsive / elegant as 280 North Slides?
- ootachi 15y agoI'm referring mainly to the page load time increase, which is important, especially on mobile. (Given what I've seen of the generated code, I suspect runtime performance will be affected too, but I haven't tested, so I can't say for sure.) This is why people create microframeworks—the page load time improvement with e.g. zepto over jQuery is not insignificant.