Linked by Thom Holwerda on Mon 11th Feb 2013 22:59 UTC
General Development "I feel like writing about the Go programming language (or 'Golang') today, so instead today's topic is computer stuff. For the record, the language I've programmed the most in has been Python, so that’s the perspective I'm analyzing it from." Some good and bad things about Go.
Thread beginning with comment 552401
To view parent comment, click here.
To read all comments associated with this story, please click here.
RE[10]: My thoughts on Go
by lucas_maximus on Wed 13th Feb 2013 23:17 UTC in reply to "RE[9]: My thoughts on Go"
lucas_maximus
Member since:
2009-08-18

If you use interfaces as a primary means of tagging your objects then, yes you can't do that in Go.


However, interfaces aren't just a means of saying this object can do this, that, and the other. The methods of an object do that just fine; there's no need to be redundant. Instead, Go uses interfaces as a contract. If I need a Reader then I'm going to be using a Read method. Which object this is doesn't matter.


Except that contract isn't explicitly stated. I don't know that by looking at the code. I don't think that is helpful when it comes to code readability. I am big on that.

Reply Parent Score: 2

RE[11]: My thoughts on Go
by satsujinka on Wed 13th Feb 2013 23:25 in reply to "RE[10]: My thoughts on Go"
satsujinka Member since:
2010-03-11

What are you talking about? Of course the contract is apparent:

func Example(Reader r) { ... }

The contract of this function states that it's going to use a Read method provided by R (assuming typical Go naming conventions.)

Reply Parent Score: 2

RE[12]: My thoughts on Go
by lucas_maximus on Thu 14th Feb 2013 00:18 in reply to "RE[11]: My thoughts on Go"
lucas_maximus Member since:
2009-08-18

** GROAN **

There is no way for me to know unless I check every function in an object whether it is implementing the interface.

With something like the implements keyword is makes it crystal clear.

It is less obvious while reading the code whether a type is implementing an interface in than Java or C#. It is extra mental overhead that can be used on other things.

Reply Parent Score: 2

RE[12]: My thoughts on Go
by Alfman on Thu 14th Feb 2013 03:01 in reply to "RE[11]: My thoughts on Go"
Alfman Member since:
2011-01-28

satsujinka,

He's got a valid point though, there is a difference between explicit intent and inferred intent. Which you prefer is a matter of opinion. It's similar to the difference between loosely typed languages and strongly typed ones. Some of us might prefer loose typing with inferred conversions, others prefer explicitly strong typing. Regardless of your personal preference, can you see why others would have a different preference?

Interestingly just as go has both strong and loose typing, I wonder if it could also have both strong and loose interfacing. This way if it's explicitly specified, the compiler will enforce the interface or error out. And if it isn't specified it could infer a matching interface. Seems like that could be feasible to me.

Edited 2013-02-14 03:02 UTC

Reply Parent Score: 4