by petercooper · 14y ago · 0 comments
Or is it that classes in Python specifically aren't that much of a win over the language's implementation of other paradigms? I sure haven't hit into any problems using classes or objects in Ruby, even when sometimes the use feels a little contrived to begin with, but.. I also have no choice :-) (maybe Rubyists have a Stockholm Syndrome with OO ;-))
In Python, it's reasonable to have a package with just functions in it, whereas in Ruby, writing a top-level method means polluting every object in the system. You can write modules that have singleton methods on them, but you still don't have anything as flexible as Python's "from pkg import foo, bar"—the caller needs to either write "ModuleName.my_function" at every call site, or use "include" and end up with the module's methods as part of the consuming class's interface.
After working with Perl (which has a similar namespacing), I must it's something I really miss when I come back to Ruby.
Python - take your __init__+1 method class and just make it a function
Ruby - take your initalize+1 method class and just make it a static method (and maybe make that class a module instead)
It's more that Python programmers prefer not to proliferate excess complexity or layering. They hate ravioli code.