107 points · by morecoffee · 10y ago · 40 comments
> - new methods can be added to a struct outside the package where the struct is declared (need to think through all implications)
--- (edit)
The example, while being possible, looks quite improbable.
If it is only a matters of conflicting names, qualified names should be able to resolve the ambiguity; here I suppose you imagine implementing the same interface for the same type differently in two packages.
That a package implements an interface for the same external method for a third-party type is already dubious. Now, you have two packages like this and you want to import them both. That's quite a corner case.
Practically, the last package that is imported could "win" (so you can decide which you want). The compiler has to register all the possible implementations anyway, so a warning is trivial to emit on redefinitions.
----
I'd guess the restriction is to allow compilation of dynamic dispatch on a package basis (think separate compilation) instead of waiting till all possible files have been processed.
You can certainly imagine schemes like specifying in the import which types to extend, but that seems complex enough that I'm not surprised a language as radically devoted to simplicity as Go left it out.
A method defined in a new package might break a type switch (or some reflection-based code) in another package.
Plus it's unclear what should happen with interfaces when multiple packages define methods with the same name.
In that case the code would break because it assumes too much. If the language was designed differently, people would code differently too. This is like having a Java abstract class which "knows" all the possible subclasses in advance: if it breaks, it is the responsibility of that abstract class for having too much coupling.
> Plus it's unclear what should happen with interfaces when multiple packages define methods with the same name.
I am not sure I understand: if methods are defined in different packages, they have different qualified names, don't they? is there any ambiguity here?
Since you write the implementation of the method inside your struct's package, you have the right to manipulate private data there as you would do with any function. I don't understand the problem.
https://github.com/golang/go/tree/cb87526ce3531557ccf69969de...
Git was written in 2005.
What did these hello world commits have to do with go? Why are they in the git history?
It's a joke basically saying "First, there was B, and it looked like this. Then, there was C, and it looked like this. Finally, there was Go, a new evolution of our work".
The git dates were clearly faked and created entirely for the purpose of this joke.
If you wanna know how to edit dates, this blog does a slightly better job than the `git-commit` man page: https://alexpeattie.com/blog/working-with-dates-in-git#chang...
I guess they decided to include a history of "Hello World" as the path to Go.
See https://en.wikipedia.org/wiki/%22Hello,_World!%22_program#Hi...
> Git was written in 2005.
Not sure about this specific case, but it isn't uncommon to migrate from another version control system (e.g. Subversion) to Git while maintaining the past history.
My oldest email in Gmail is from 1996.
My oldest file in Google Drive is from 1998.
All of which pre-date their current storage (and some of which pre-date the company that created the current storage).
None of which is as important as anything in a VCS in terms of wanting to keep history intact.
BTW: If any Google engineer is present: Gmail search over mail older than a decade is terrible. Just terrible.
If it was migrated to CVS from RCS on the day CVS was released, that gets us back to 1986.
If it was migrated to RCS from SCCS on the day RCS came out, that gets us back to 1982.
SCCS showed up in 1972, just in time for this commit.
These commits are obviously jokes, probably by Ken Thompson or Rob Pike.
> Was Go something that was brewing for a long time prior to its development and debut at Google?
Its an evolutionary descendant of Bell Labs languages: B -> NewB -> C -> Newsqueak -> Alef -> Limbo -> Go. (The channel-based concurrency model was introduced in this line with Newsqueak)
> Also, Kernighan? Maybe I live under a rock, but I wasn't aware of his involvement.
He is peripherally involved as the co-author of 'The Go Programming Language' book: http://www.gopl.io