4 ms·
Your comparison is unfair, because CoffeeScript and Go try to do vastly different things. Go is a fairly low level systems language, while CoffeeScript is as hi
by phoboslab 15y ago
Your comparison is unfair, because CoffeeScript and Go try to do vastly different things. Go is a fairly low level systems language, while CoffeeScript is as high level as it gets.
That said, what Go achieves with its syntax is remarkable, imho.
Consider this: How do you add another function (e.g. "close()") to your file class in CoffeeScript? By extending the existing class into a "MyFile" class? But then you have to make sure all your "File" instances are actually instances of "MyFile", so you can call your newly defined function on them.
In Go you just define the new function.
- Ezku 15y agoNot to detract from your point of vastly different things, but you picked a bad example. You add a method to the prototype: File::close = -> Et voilà, all Files are closeable.
- phoboslab 15y agoNice, I didn't know that CoffeeScript has a shorthand for .prototype. So, to revise my point: with "proper" classes (i.e. Java or C++) this wouldn't be possible, or at least more complicated and not the way to do things. Classes are not the ultimate solution and it's a good thing that Go tries a different approach to OOP.