3 ms·
I notice no mentions of Ruby yet, and I wonder if this discussion is pretty much impossible to have in the Ruby world, given Ruby is solely an object oriented l
by petercooper 15y ago
I notice no mentions of Ruby yet, and I wonder if this discussion is pretty much impossible to have in the Ruby world, given Ruby is solely an object oriented language, even if you try to use it procedurally. Not writing classes would be against so many Ruby conventions and accepted style that it's a non-topic?
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 ;-))
- ryanf 15y agoI think part of the reason this doesn't come up in Ruby is that Ruby doesn't have Python's powerful namespacing system. 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.
- judofyr 15y agoImplicit self and late binding in Ruby makes it hard to implement a proper namespacing system without breaking other semantics :( After working with Perl (which has a similar namespacing), I must it's something I really miss when I come back to Ruby.
- heretohelp 15y agoEverything in Ruby that is an object, is an object in Python as well. It's more that Python programmers prefer not to proliferate excess complexity or layering. They hate ravioli code.
- jamie_ca 15y agoI think the appropriate translation would be: 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)