Hacker News new | past | comments | ask | show | jobs | submit login
Think in Go: Go's alternative to the multiple-inheritance mindset. (groups.google.com)
92 points by peregrine on Sept 17, 2011 | hide | past | favorite | 26 comments



This is an interesting discussion -- interesting in part because it addresses a mindset that I don't seem to have.

C++, for example, has multiple inheritance, and I have used it to good effect. OTOH, if I needed to implement Dijkstra's Alg in C++, then I don't think it would even occur to me to inherit from both a priority queue and a directed graph base class. (And even now that it does occur to me, it doesn't seem to be a good idea.) Rather, I'd use something akin to the interfaces presented here. Of course, interfaces are not formalized in C++, but the C++ culture does include the notion of a concept, to be used with a template.

If the language were Python, I'd proceed similarly. And then there's Java, which doesn't even have multiple inheritance. I've never heard anyone claim that Java is somehow ill-suited for the implementation of graph algorithms (but maybe it is -- never thought about it).

Perhaps what this discussion is overturning, is not so much a multiple-inheritance mindset, as an Eiffel mindset. (But I don't know much Eiffel, so it's hard to say.) And the discussion also suggests that Go's formalization of interfaces can be a Good Thing.


I also don't know much Eiffel, but I believe this 1988 article is the canonical pro-multiple-inheritance-in-Eiffel piece (by Eiffel's creator): http://archive.eiffel.com/doc/manuals/technology/bmarticles/...


I think there are many who doesn’t split types and algorithms, and something like Java does/did make it cumbersome plus its standard library doesn’t do it — but the C++ comity adopted STL into the standard library 13 years ago, which is all about separating algorithms from their types, and was actually born out of Alexander Stepanov’s work with graph algoritms, so I was also a little surprised by his generalizations and specifically calling out C++ (twice).


Slightly off-topic: the web in general seems broken for mobile. To get this content on my iPhone, I had to concoct this URL:

https://groups.google.com/forum/?nomobile=true#!msg/golang-n...

Then, I discovered that to see more content, I had to swipe up with two fingers. There were no scroll indicators. This and the scaling problem ("you cannot rescale this web site. We have decided for you that this size is perfect. And no scrolling to see the words that run off the edge of the screen.") are...well, problems.


As with all of their other products, Google is in the process of breaking the Groups UI by adding useless frames and whitespace. Try this instead:

http://groups.google.com/group/golang-nuts/msg/7030eaf21d3a0...


Russ, Ken, Rob and the other guys are making a great work in Go. It's weird that people are not yet paying much attention to it - and to Plan 9 as well.


Does what he's describing as the Go Way basically equate to generic programming in general, or is there something specific to Go about it?


It's sort of Go-specific, but the same style is also used in Haskell using typeclasses, Scala/Ruby/etc using mixins/traits, and C++ using templates.

Rather than inheriting from some base class, you just make sure your class can do certain operations and then other stuff works on that- it's good way to decouple algorithms, containers, etc. from the types they work with.


The comments in his code are reminiscent of programming by contract (an idea I believe Djikstra himself was fond of). In Go the types of the interfaces are statically checked, which is good (in Python or Ruby, this isn't the case), but the contract the interface represents has to remain in comments and unit tests.

It would be nice to be able to specify tests that every implementor of the Heap interface must pass?


I am a fan of programming by contract myself, but I'm not quite sure it could be pasted onto Go's interfaces quite so simply. In the case of Heap perhaps it could be done in a straight forward way, but what about more generic things that have more to do with side-effects?


Alan Kay talks about field effects but maybe what he really means is that "everything is an object" is a mistake. Not everything is an object in real life. For example, a sound wave is not an object but objects can react to it (or it can manipulate them, whichever you prefer). Maybe emphasizing this in a programming language can be done as simply as you have described it is done in go. ( I have always found objects expressive and useful but when overused they feel like a straitjacket)


A sound wave may not be an object, but it is a noun and has properties such as frequency and amplitude. Though I could imagine defining a sound wave as a function.


A sound wave could be considered an object depending on your problem ___domain. The point is that operations should be able to work with anything that has the operations it needs defined. A sound wave could have several operations defined on it, including one(s) that let it behave as a function.


It's also often described as duck typing...


Duck typing is one form of it, yes. But interfaces are not always inferred- Go has you specify the interfaces themselves, Haskell typeclasses have you specify the implementation, but it's still the same idea.


This requires me to sign in to a Google account (I don't have one). Bring back usenet!



Thank you - much appreciated :)


They're free, and it takes ~45 seconds to get one. You should probably just make one.


I'm sure they know how to get one, and whatever reason they have for not getting one, you've not addressed.

Given those circumstances, refrain from responding if you aren't going to be genuinely helpful.

Nobody likes a comment from the peanut gallery.


Thank you for saving me the words.

The reason I don't have a Google account is that I don't like being profiled and tracked as I go around the Internet and I believe that pay-walls should not be in front of free information.

A Google account is a pay-wall. You pay by providing them with some information about you.


"I don't like being profiled and tracked as I go around the Internet"

Nobody does, so don't provide identifiable information.

You are always being tracked on the Internet. Get over it. Nobody is interested in you personally, just your aggregate patterns of behavior with millions of others. Your only solution in-line with your personal philosophy is to go off-the-grid and live in a tree house in Borneo. Anything else is just half-assed conspiracy rantings for the purpose of getting attention by drawing an arbitrary, useless, but terribly noticeable line in the sand that requires you to inconveniencing others.

There's a terribly obvious two part solution to your problem (with an optional third)

1) Use your browser's incognito mode/private browsing mode so tracking you becomes hard/impossible

2) Don't provide your real information when creating accounts, they don't need to know your info, so don't provide it. I can count the number of sites I've provided real information to on one hand, and all of them were e-retailers so I can have them ship me something.

3) (Optional) In the event that you are important enough for somebody to bother being interested in your on-line shopping habits, surf behind VPNs then TORs then Proxies. Your experience will suck, but it will be a multi-m/billion dollar national government level effort for somebody to personally identify you that way. It's good enough for the intelligence agencies of the world, it's good enough for you.

"I believe that pay-walls should not be in front of free information."

Agreed with an excruciatingly simple solution.

1) Go here

https://accounts.google.com/NewAccount?service=mail&cont...

and fill it out with whatever information you feel like, it doesn't even have to be your real info (mine isn't), and boom, you've provided nothing of value to Google and you can access an entire universe of information while making your philosophical point that information wants to be free and that you are specifically important enough for anybody to care about what you are doing. You even get a free email address!

Even better share that login with your friends, get lots of people using the same account. Provide so much noise in the tracking logs that it's impossible to tell your specific information anybody else's. And since you'll be doing this all from behind a few VPNs, TOR and various other obfuscation and encryption technologies, you'll be able to finally, at long last, surf safe and read that post on Google groups.

Oh, and BTW Usenet activity is traceable.


It's not about aggregate behavior with millions of others at all. It's about profiling.

Consider the case of clicking a link in an email someone sent me for a joke. My google account thereafter managed to associate me with bestality [1]. Fun eh?

Now ironically, over a year later, I was still getting rather awful targeted Google Ads advertising and SPAM to a supposedly unrelated email account (on Windows Live with no associated Google account). The persistent google cookie from hell dragged that information and my three static IP addresses across multiple sites and managed to basically bombard me with shit.

Something somewhere managed to make the associations and send directed advertising. They had me profiled.

That in my mind is unacceptable, which is why I don't want to sign up for another profiling account.

It's not paranoia or conspiracy crap - it's fact.

Regarding usenet: there's no reliable way to profile people on it due to its architecture.

[1] I accept some responsibility for clicking a link in an email of course.


Regarding usenet: there's no reliable way to profile people on it due to its architecture.

Fun fact, I used to work an ISP years and years ago as a tech support peon, but I remember a couple cases of police visiting us working child porn cases with subpoenas for a copy of our access logs for dial-in lines and our Usenet server. Both times the suspect was successfully prosecuted because we and the two other usenet servers he used logged activity, so we could demonstrate what posts he had made, when and from which IP.

Many Usenet servers, especially these days, require a user/pass to gain access, which is probably logged (like we did back in the day).

Also, since your profile contains minimal information the weight of your accidental bestiality hit is magnified. So for a lack of other things to show you, they show you ads for local donkey shows. Fill your profile up with more legitimate activity and that will become a rounding error.

Plus, it's associated your IP address, or some other aspect of your profile, not you personally. Which is the thrust of the rest of my response. The activity is associated with your clothes not the person.

Finally, your lack of profilable activity is in and of itself more profilable. "Oh, he's the guy that doesn't want to be profiled." Is more notable than "He's the guy that uses the Internet just like everybody else."

Weird usage patterns are one of the first things network analysts look to establish when tracking people. You for example, would be great to advertise to about security and identity protection products.


That's a fair statistical analysis so I get your point. With respect to Usenet, I'd fully expect that the endpoint logs, but not every intermediatary who happens to have an agreement with another intermediatary, which is the issue with tracking on the web. Distribution of information is no longer controlled by the endpoint or by contract, but rather by coincidence via any nefarious method possible.

If I did something naughty, I'd expect to get caught. This is not about anonymity, but about the assumptions that people draw about you based on unrelated information tracked from multiple sources.

However, I'd rather be an obvious objector than annoyed by donkey porn adverts :)

I don't see ads either (Firefox+Adblock+ghostery+noscript).


I don't share those concerns because I don't give a fuck about anything that isn't code, motorcycles, guns, or my cat almost to the point of pathology, but I understand and respect your decision to avoid them nonetheless.

Because I understand your reasons, I really hate it when people like the guilty party above choose to pitch in their half-pence without actually knowing why you didn't have one.

Last thought: I work in the ads industry (without really meaning to), and I can say without doubt that your concerns are 100% valid.

That said, you'd have to do a lot more than not have a Google account to avoid being monetized informationally speaking.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: