5 ms·
Think in Go: Go's alternative to the multiple-inheritance mindset.
- ggchappell 15y agoThis 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.
- _delirium 15y agoI 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/joop/multiple.html http://archive.eiffel.com/doc/manuals/technology/bmarticles/...
- sorbits 15y agoI 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).
- supersillyus 15y agoDoes what he's describing as the Go Way basically equate to generic programming in general, or is there something specific to Go about it?
- Rusky 15y agoIt'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.
- dochtman 15y agoIt's also often described as duck typing...
- Rusky 15y agoDuck 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.
- caffeine2 15y agoThe 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?
- burgerbrain 15y agoI 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?
- pointyhat 15y agoThis requires me to sign in to a Google account (I don't have one). Bring back usenet!
- dchest 15y agohttp://pastebin.com/iPibD66C http://pastebin.com/iPibD66C
- pointyhat 15y agoThank you - much appreciated :)
- bane 15y agoThey're free, and it takes ~45 seconds to get one. You should probably just make one.
- alnayyir 15y agoI'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.
- pointyhat 15y agoThank 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.
- bane 15y ago"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&continue=http://mail.google.com/mail/e-11-2d55d3e63032790c10978aed66ede-76ddc16504dbe3a0aaecbdea52d3783a1d8232e4&type=2 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.
- deleted 15y ago[deleted]
- delinka 15y agoSlightly 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-nuts/Rj5t1h_ztxI/Fgs6HfLqMHAJ 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.
- p9idf 15y agoAs 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/7030eaf21d3a0b16 http://groups.google.com/group/golang-nuts/msg/7030eaf21d3a0...
- zanst 15y agoRuss, 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.