“object-oriented design is the roman numerals of computing.” - Rob Pike (http://harmful.cat-v.org/software/OO_programming/)
Some other gems from that page:
“Object-oriented programming is an exceptionally bad idea which could only have originated in California.” – Edsger Dijkstra
“The phrase "object-oriented” means a lot of things. Half are obvious, and the other half are mistakes.“ – Paul Graham
“I used to be enamored of object-oriented programming. I’m now finding myself leaning toward believing that it is a plot designed to destroy joy.” – Eric Allman
“The problem with object-oriented languages is they’ve got all this implicit environment that they carry around with them. You wanted a banana but what you got was a gorilla holding the banana and the entire jungle.” – Joe Armstrong
Which is weird because Pike's Rule 4 is one of the fundamental principles of OO design.
The irony is that Python has more ways of doing things in general and often the choice is very much non-obvious, compared to a language like Ruby which is supposedly embracing TIMTOWTDI. In other words, that Python rule doesn't match reality and I've always found it funny.
The statement in question is from The Zen of Python and is more of a guiding principle for the design of Python than a rule.
The usual observation with Python is that it can have many libraries and frameworks which are quite similar and choosing one can be hard (e.g. web frameworks). This is a function of popularity and not something which can fairly be subject to that principle.
On a different note: missing is the Zen of Python's following line:
Although that way may not be obvious at first unless you're Dutch.The language itself is a prime example of a language with features that aren't orthogonal. For example count how many features in Python are solved in other languages just with proper support for anonymous functions.
I find python's restriction in this case fairly strange. If I wanted to do that in python I'd have to just declare a function body for what I want to put in the anonymous function elsewhere, which defeats the purpose.
def some_method(...):
avar = aval
.... (some code)
def throwaway(x, y):
....
something_else(avar, x+y)
some_obj.somefunc = throwaway
The major difference is you do the function definition just prior to the assignment. The "namespace pollution" is literally limited to the scope of "some_method", so you have an extra local var in a function somewhere. The semantics of python mean that the function is created on the stack, and a closure is created each time the some_method is called, and the closure is later GCed as any other object would be, so there is nothing fundamentally different about the "named" function, and the "anonymous" function in you example, except a single local variable.https://talks.golang.org/2012/splash.slide#55
https://talks.golang.org/2012/splash.slide#56
https://talks.golang.org/2012/splash.slide#57
From this talk: http://www.infoq.com/presentations/Go-Google
12 minutes where Pike talks about a few things, that seem to be wrong in our software world: https://www.youtube.com/watch?v=5kj5ApnhPAE
I don't think so. To me Python's design rule implies there should be one way clear path to solve a specific problem and generally you'd also want to stay as consistent as possible with other similar solutions.
The "one true way" argument is to force everything to fall into a pattern even when it's a less than ideal way to solve a problem. An example would be trying to force everyone to use the same language/database/framework combination in a company for everything. Sometimes you want to be flexible and use the right tools for the job (while also accounting for the cost of deviating from the general accepted standard in making that decision).
Nope, that's a design guideline, it's not taking choice away. A rule like "Python is the only language you'd ever need" would contradict it.
edit: Really? Downvotes? Not cool.
As for co-author, the Cambridge dictionary says:
"To write a book, article, report, etc. together with another person or other people:"
Which given Pike's participation on what defined the initial UNIX graphics userland, makes him a co-author.
If you exclude one person because they disagree with X and don't know Y, then you must equally disregard all who agree with and disagree with X, because they don't know Y. Otherwise you're just cherrypicking :)
However, it has become quite trendy to bash OOP itself, especially here on HN, without acknowledging that there are less awful ways of doing it that just aren't mainstream. Try making similarly blanket criticisms of FP here using Python (Why, it has lambdas and list comprehensions after all--isn't that enough?) or some other impure language and see what happens.
> Rule of Diversity: Distrust all claims for “one true way”.
Although, does the python rule "There should be one-- and preferably only one --obvious way to do it." contradict this one ?
> Rule 5. Data dominates. If you've chosen the right data structures and organized things well, the algorithms will almost always be self-evident. Data structures, not algorithms, are central to programming.
I wonder what rob pike has to say about OOP or java, I wish I could listen to it.
Also it says that text is a good representation of data, but I think he meant it as intermediary. I don't think xml or html are really good choices when you see all the CPU cycles spent parsing those.
> Rule of Economy: Programmer time is expensive; conserve it in preference to machine time.
I prefer this rules versus the "no premature optimization" rule.