4 ms·
I feel my curly-brace intertia softening a bit lately, so Im considering converting Orbium to CoffeScript. The game has "classes", like this: https://github.c
by bni 16y ago
I feel my curly-brace intertia softening a bit lately, so Im considering converting Orbium to CoffeScript.
The game has "classes", like this:
https://github.com/bni/orbium/blob/gh-pages/js/tile.js https://github.com/bni/orbium/blob/gh-pages/js/tile.js
https://github.com/bni/orbium/blob/gh-pages/js/inspector.js https://github.com/bni/orbium/blob/gh-pages/js/inspector.js
So I think it will translate well.
Anyone with CoffeScript experience that can share what its like to convert over a codebase from JS -> CoffeScript?
- jashkenas 16y agoHah, mostly: delete, delete, delete. http://www.screenr.com/xd0 http://www.screenr.com/xd0 Fair warning, the syntax in that screencast is a bit out of date. For your codebase, instead of having to "call super" manually: orbium.Inspector = function(count, xnr, ynr, vari, col) { this.setBase = function() { orbium.Tile.prototype.setBase.call(this, "modtile"); }; } It'll look more like: class orbium.Inspector extends orbium.Tile constructor: (count, xnr, ynr, vari, col) -> ... setBase: -> super "modtile"
- bni 16y agoThanks, probably some search and replace will do most of the boring stuff. Since it follows the classical pattern already the structure of the code will be mostly the same, but with a lot less dense syntax :-) Im concerned about adding a compile step, since I like the "just reload" workflow a lot that you get with JS. text/coffeescript script tags could help out with this. But from the the CoffeScript site: "it's not recommended for serious use". Why not?
- jashkenas 16y agoCheck out the --watch flag, which will give you the same "just reload" workflow you have with JS. Using `text/coffeescript` script tags works, but isn't recommended because you're effectively programming through an eval(), and debugging becomes more difficult.