To view parent comment, click here.
To read all comments associated with this story, please click here.
OK. That is Prototype-based programming which is a kind of OO, but I don't see how is that more object-oriented than Java. Is JavaScript more OO than Java?
Unlike Go, in Java everything is an object and although you could write a procedural Java code by putting everything in one static class, all those "static" keywords scream that you are doing it wrong.
In Go, however, you can write very C-like procedural programs without even knowing that you can make objects.
The point is, I still don't know how Go can be considered more OO. In fact I argue that it is, in fact, just the opposite.
OO is (mostly) about leveraging polymorphism to create flexible code. Inheritance based polymorphism is probably the most tightly coupled and rigid form of polymorphism.
It's not something you really get until you fully implement something in a language that is not class oriented the way that most of the c++-ish systems languages are. Really grokking something like ruby or smalltalk will totally change the way you look at these things.
Also, dynamic dispatch + duck typing does not nessicarily mean prototypal. For example, ruby is a strongly typed language where objects can (and often do) vary from their type. In js, you can do
"".prototype.foo = new function() { .. }
that will add foo to all instances of string. in ruby, attaching a method to the string class is one option, another is to attach it to the instance, like
s = ""
def s.foo
..
end
s.foo # calls method
"".foo # method not found, only exists on s
Anyways, all that to say that while prototypal programming is one way to do this sort of thing, doesn't mean there aren't others.
Java's OO semantics have deficiencies that Go solves. To me it is equivalent to "Go can be considered more OO".
It doesn't mean that Java is bad - it's actually my favorite system-level language. But that's mostly because of its robust frameworks and the fact I've learned to live with its limitations.
The Java OO deficiencies (those that matter to me) are:
- non-OO primitive types,
- no multi class inheritance (for a good reason - it can get messy very quickly),
- limited interfaces (the only way to implement an interface is to write it by hand or inherit it from a (single!) base class).
Go simply doesn't have these limitations.
I agree with you that one can write procedural programs in Go (and Java, C++,...). However, this doesn't make the language non-OO, it's just user's choice not to use these capabilities.
---
Sorry about my comments regarding the Go syntax issues. I just can't help thinking that even a bad syntax (which it isn't) is at worst a nuisance.




Member since:
2009-06-30
It uses interfaces to describe capabilities (i.e. duck typing), not a rigid class hierarchy. With no restrictions on what you can attach methods to, it is much more flexible and simpler mechanism than subclassing. "Subclassing" is still available through type embedding, btw. Whenever you embed other types, you automatically "inherit" their interfaces and implementations (of course, you can redefine some of their methods if you choose so).