Rather than requiring the programmer to declare ahead of time that two types are related, in Go a type automatically satisfies any interface that specifies a subset of its methods. Besides reducing the bookkeeping, this approach has real advantages. Types can satisfy many interfaces at once, without the complexities of traditional multiple inheritance. Interfaces can be very lightweight—having one or even zero methods in an interface can express useful concepts. Interfaces can be added after the fact if a new idea comes along or for testing—without annotating the original types. Because there are no explicit relationships between types and interfaces, there is no type hierarchy to manage or discuss.Um... OK, so you have this sort of loosey-goosey approach to interfaces (if I have the methods, I satisfy the interface), but what about super class constructors and concrete (non-abstract) methods? I'm having trouble imagining libraries such as UI toolkits (WPF, Flex, Swing, etc.), which effectively make heavy use of relatively deep inheritance trees, being written in as elegant a manner in Go. Those super classes are doing a lot of work, and the type hierarchies provide a nice taxonomy for the API. Perhaps Go is advocating the use of a different paradigm to accomplish the same thing, but it doesn't seem to be readily evident from the docs.
Comment
Tim Dysinger: I program my scheme in lisp. I program my editor in lisp (elisp). I program my java in lisp (clojure). I program my erlang in lisp (LFE).This sounds like a great talk for one of the local coder groups.
There is state strewn everywhere in OO apps and shared-state threading tools in OO rely on locks to make sure you don't have threads clobbering each other's shared state. It's very difficult for the average programmer not to hang him/herself.True. Concurrent programming is hard, and Java's approach certainly has its drawbacks.
To me this is Java and C# and co are antiquated and why I don't code in OO langs anymore very much.I think we will have to agree to disagree on this. Thats OK - forums are boring if everyone agrees :-) I think OO solves a lot of problems very elegantly. It really depends on the domain.
argh no prevews before postsI agree - this is annoying. Hopefully it will be rectified soon.
colors := new(Set<Color>);
m := map[string]int{"one":1 , "two":2}, but you can't define your own generic types (types that have type parameters.)
Generics may well be added at some point. We don't feel an urgency for them, although we understand some programmers do. Generics are convenient but they come at a cost in complexity in the type system and run-time... (clip) ...This remains an open issue.
Tim Dysinger: "but what about super class constructors and concrete (non-abstract) methods?" this is OO thinking.Yes, it is. I think the complete rejection of OO concepts by folks purely on the functional side is a bit premature.
Everything new coming out of language research is moving away from OO and towards functional programming.Well... its certainly fashionable ;-) I think there are a lot of interesting concepts in the new (and not so new) functional languages, but there are many tasks that lend themselves better to OO systems (UI libraries, for example.) Also, languages like C# 4 are evolving in interesting ways, incorporating concepts from functional programming and other approaches. There is plenty happening outside of functional programming. I think you will see many systems that use a hybrid. We already see this with Facebook and Ginx.
"The lack of generics." It's pretty generic to not have Types.I'm assuming you know this, but I was referring to the ability to do things like specify the type constraints for elements in a datastructure.
"The lack of exceptions" exceptions are just message-passing - you can pass errors back to callers in Erlang without exception classes.You could say that nearly everything (method calls, operations, assignments, etc.) are "just message-passing". Exceptions are messages that are routed and handled in a structured, predefined manner designed for error handling.
© 2025 Created by Daniel Leuck.
Powered by
You need to be a member of TechHui to add comments!
Join TechHui