15 ms·
One correction I'd make to the article's taxonomy: Ruby is an object oriented language not an Algol. Its inspiration is Smalltalk, and much of the standard libr
by steve_gh 5mo ago
One correction I'd make to the article's taxonomy: Ruby is an object oriented language not an Algol. Its inspiration is Smalltalk, and much of the standard library naming comes from that route (eg collect rather than map).
Ruby is object oriented from the ground up. Everything (and I do mean everything) is an object, and method call is conceived as passing messages to objects.
While Ruby is most often compared to Python (an Algol), they come from very different evolutionary routes, and have converged towards the same point in the ecosystem. I think of Ruby as a cuddly Alpaca compared to Python's spitting camel.
- pjmlp 5mo agoSince Python introduced new style classes, it also became a pure OOP language, even though it might not look like it at "Hello World" level, all primitive types have become objects as well. I love to point this out to OOP haters, >>> type(42) <class 'int'> >>> dir(42) ['__abs__', '__add__', '__and__', '__bool__', '__ceil__', '__class__', '__delattr__', '__dir__', '__divmod__', '__doc__', '__eq__', '__float__', '__floor__', '__floordiv__', '__format__', '__ge__', '__getattribute__', '__getnewargs__', '__getstate__', '__gt__', '__hash__', '__index__', '__init__', '__init_subclass__', '__int__', '__invert__', '__le__', '__lshift__', '__lt__', '__mod__', '__mul__', '__ne__', '__neg__', '__new__', '__or__', '__pos__', '__pow__', '__radd__', '__rand__', '__rdivmod__', '__reduce__', '__reduce_ex__', '__repr__', '__rfloordiv__', '__rlshift__', '__rmod__', '__rmul__', '__ror__', '__round__', '__rpow__', '__rrshift__', '__rshift__', '__rsub__', '__rtruediv__', '__rxor__', '__setattr__', '__sizeof__', '__str__', '__sub__', '__subclasshook__', '__truediv__', '__trunc__', '__xor__', 'as_integer_ratio', 'bit_count', 'bit_length', 'conjugate', 'denominator', 'from_bytes', 'imag', 'is_integer', 'numerator', 'real', 'to_bytes']
- ang_cire 5mo agoThis is very cool, and I did not know this. Thank you! I wonder if my formal university python training predated this change (~2010), or if the professors were themselves unaware of this.
- pjmlp 5mo agoThey were unaware of it, or unwilling to talk about it, article from 2002, about changes introduced in 2001 https://gnosis.cx/publish/programming/metaclass_1.html https://gnosis.cx/publish/programming/metaclass_1.html https://www.python.org/download/releases/2.2/descrintro/ https://www.python.org/download/releases/2.2/descrintro/
- arijun 5mo ago> I love to point this out to OOP haters That seems like a pretty lame gotcha--saying "Aha! The language you write in uses your hated paradigm under the hood" seems to invite the immediate response of "So? I don't use it."
- pjmlp 5mo agoIt is more about those that proudly use Python because it isn't an OOP language, yep those do exist.
- the__alchemist 5mo agoI have found the definition of OOP to be fuzzy. For example, I don't see why having methods would make a data type object oriented. I associate OOP with factories, inheritance, using classes in places that might be functions otherwise, and similar abstractions. Perhaps this is the counterfactual: I program in Python regularly, but don't program in an OOP style; I use dataclasses and enums as the basis, in a way similar to Rust, which by some definitions can't do OOP. So, if Rust can't do OOP (assumption) and I can write Python and Rust with equivalent structure (Assumption), does that mean Python isn't strictly OOP?
- thesuperbigfrog 5mo ago> if Rust can't do OOP (assumption) Rust handles basic OOP, but not all of the characteristics seen in C++ or Java: https://doc.rust-lang.org/book/ch18-01-what-is-oo.html https://doc.rust-lang.org/book/ch18-01-what-is-oo.html
- pjmlp 5mo agoRust can definitely do OOP, not only I could easily convert "Raytracing in one Weekend" from C++ into Rust, while keeping the same design, Microsoft has no issues adding a Rust projection for COM/WinRT, which are OOP ABIs. However that is not the same as Python, which is 100% OOP, when using basic stuff like numbers, from Python language semantics those things are object, and there is the whole machinery in place even for basic stuff like addition. And yes OOP is fuzzy from CS point of view there are multiple approaches and it doesn't get reduced to the way C++ and Java do it, just like FP and LP are fuzzy as well. Some folks would swear if it isn't Haskell or Prolog, than it isn't FP or LP, when a CS book and programming language evolution will be more fuzzy.
- aidenn0 5mo agoIf that's enough to make a language pure OOP, then Common Lisp is also a pure OOP languge: CL-USER> (class-of 42) #<BUILT-IN-CLASS COMMON-LISP:FIXNUM>
- bitwize 5mo agoAren't camels a Perl thing?
- AdieuToLogic 5mo ago> Aren't camels a Perl thing? That's a deep cut. :-) For anyone reading this, O'Reilly was once legendary for their cover-art mascots.
- tialaramex 5mo agoI think the choice to identify a specific ur-language as "Object oriented" throws people off since OO is just a style of programming in the same way that procedural is. I don't think it's useful to say that Python and C++ are both the same kind of language because they both have multiple inheritance, rather that's just an observable commonality, like noticing that both Delhi and Vegas are too hot. Yeah, but I don't think that's because they're the same kind of place...
- narcraft 5mo agoYeah, but the thing about Vegas is that it's really more of a dry heat
- brucehoult 5mo agoCompared to Delhi? Ok. But I've had a soaking uncomfortable shirt every time I've been to Vegas, while in Phoenix it evaporates quickly.
- link89 5mo agoObject-oriented programming is less of a syntax and more of a philosophy. While Erlang’s syntax belongs to the ML family, its creator, Joe Armstrong, argued that Erlang aligns more closely with the original OOP philosophy defined by the inventor of Smalltalk than Java does: 'The essence of object-oriented programming is messaging, not classes and inheritance.'
- igouy 5mo agoBoth object oriented and an Algol.
- mid 5mo agoRuby keywords are not objects.