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 552404
To view parent comment, click here.
To read all comments associated with this story, please click here.
RE[11]: My thoughts on Go
by satsujinka on Wed 13th Feb 2013 23:25 UTC 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[13]: My thoughts on Go
by satsujinka on Thu 14th Feb 2013 18:48 in reply to "RE[12]: My thoughts on Go"
satsujinka Member since:
2010-03-11

Why are you being obtuse?

I've already covered that it's not necessary to know whether a type implements some interface. The only time you need to know that is when you're passing an object to a function and that's a comparatively small amount of usage compared to what the function in question will actually do.

So, most of the code that you will read is going to be code that uses an interface to do something. Exactly like the function I gave. So it is always crystal clear what capabilities are at hand.

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

RE[13]: My thoughts on Go
by satsujinka on Thu 14th Feb 2013 18:53 in reply to "RE[12]: My thoughts on Go"
satsujinka Member since:
2010-03-11

Um... I haven't given any personal preferences. I'm just defending Go because someone has to in order for a debate to occur.

On the note of optional interface implementation. Is that really very different from just adding a comment? Sure the compiler does stuff (like tell you that you need method X) but you'd run into issues anyways if you tried to use an object that didn't actually support the interface. And I'm pretty sure the error message would still make it clear what the problem is (object Y is not a Z.)

Reply Parent Score: 2