4 ms·
These are totally fine most of the time. Typescript in particular looks like a good choice for game development. Sometimes the language is less of a good choic
by yoklov 11y ago
These are totally fine most of the time. Typescript in particular looks like a good choice for game development.
Sometimes the language is less of a good choice. E.g. i did a small toy project in coffeescript about two years ago, and found to my horror, that if your function ended in a loop, it would return an array. Always. This isn't possible to accidentally do in the host language, so I'd say it is a bad fit (for game development, where you care about such things).
- odbol_ 11y agowtf coffeescript. What is the point of that?
- goldbrick 11y agoIt's what ruby does and coffeescript is basically an exercise in making js more like ruby.
- matthewmacleod 11y agoThis is a deliberate design decision in CoffeeScript – "everything is an expression" (see http://coffeescript.org/#expressions http://coffeescript.org/#expressions). This is probably as a result of CoffeeScript's Ruby-esque syntax and semantics. It does mean you can write some very clear and succinct code at times, but the tradeoff is that it can have unforeseen performance implications.
- tdy721 11y agoCoffeescript returns the last line always, all you needed to do was add a 'return null' (or just 'return') as the last line in the function. You have to be explicit in Vanilla JS to return things or it just return null. Coffeescript explicitly returns the last line every time.
- tdy721 11y agoI believe that point is that JS always returns something for every object. Many users of JS just don't realize it. (I know I didn't till I started drinking the coffee flavored kool-aid)
- gsnedders 11y agoJavaScript functions always return something, yes—but unless you have a return statement, that something is `undefined`.