4 ms·
Ask HN: CoffeeScript or ClojureScript for writing a game in JS?
As a side project I'm planning to write a simple game in javascript, and why not learn something new?
- electrichead 12y agoFrom my experience, coffeescript won't teach you anything new and won't give you any performance improvents. In fact, it will make you scratch your head a lot and will make you do a mental js-coffee conversion each time. You might end up liking it, but I think that clojurescript is the better bet here for performance gains as well as better coding in general, since its focus on functional programming is more concrete and inherent in it. Functional programming in coffeescript is exactly the same as in js ie. GIGO
- endemic 12y agoIf you use CoffeeScript, you might have to watch out for unexpected variables being created by the transpiler. For example, if you write a method that ends with a `while` loop, CoffeeScript will actually return an array with the evaluated results of the loop. Normally not a big deal, but when doing games in JS you need to watch out for excess memory use, since your framerate will tank if the GC runs too long/frequently.
- mattdw 12y agoIf your game is at all taxing in terms of performance, you may find that neither give you enough visibility into, or control over, allocations and garbage collection. I suspect particularly that ClojureScript (which would otherwise be my choice), with its use of persistent/immutable types and collections, might burden the GC quite heavily for a game. CoffeeScript, IMO, offers so little over JS that it's not really worth the trouble.
- meowface 12y agoCoffeeScript isn't really supposed to offer new features, just syntactic sugar. And in my opinion it excels at that. IcedCoffeeScript, on the other hand, does introduce a few new interesting features: http://maxtaco.github.io/coffee-script/ http://maxtaco.github.io/coffee-script/ It's still technically sugar, but it changes the way you think about and write code.
- zura 12y agoWhy not Dart? or at least TypeScript?
- jozi9 12y agoI don't like their syntax, and it's a hobby project so to say. I like the pythonic syntax of coffescript, and I have lisp/FP learning on my bucket list, so I think I'll go the clojurescript way!