3 ms·
In 2005 I had to choose to invest in learning either Ruby or Python as a primary language for writing a fairly complex piece of technical software. I looked in
by wenc 8y ago
In 2005 I had to choose to invest in learning either Ruby or Python as a primary language for writing a fairly complex piece of technical software.
I looked into Ruby and it struck me as being a truly aesthetically pleasing language, and since it espoused the "principle of least surprise" -- with caveats, naturally -- most Ruby code tended to be straightforward to read.
Python on the other hand, while clean -- I came from Perl -- had a fair bit of ugliness like the "self" argument in class methods, and the "dunders" in dunder methods (__init__). That said, the Python ecosystem, especially in the numerical computation space, was far ahead of Ruby's at the time, so I chose Python. It worked out really well and allowed me to accomplish what I needed to. To this day I have no regrets choosing Python.
Compared to many languages (like Haskell etc.) Python's design isn't the most aesthetically pleasing or orthogonal or clean. But being a Dutch design, at least initially, it was very pragmatic. And Python is by no means ugly on an absolute scale, on the contrary. It’s just not as beautiful as some others.
Python's main advantage is the energy behind it: to this day there are no converged alternatives to Numpy or Pandas on Ruby.
I can't help but wonder that if in an alternate universe/timeline, Travis Oliphant, Pearu Peterson, Wes McKinney and others happened to have encountered Ruby first, we might have a different de facto language for scientific computing and data science.
- h8hawk 8y agoI don't understand why people bashing self argument. It's part of best design decisions in python. Methods in languages such Java or JavaScript always have hidden argument called 'this'. In js this actually become messy duo to binding of this. In python you can easily find this method is bind to instance of class aka 'self'. It's not always self, It could be cls for classmethods or nothing for static methods.
- wenc 8y agoMost languages have an implicit “this”/“self” which works well. This makes it easy to convert functions to class methods and vice versa without using any editor refactoring features. It also makes it easier to refactor (no need to search and replace every reference to foo within an object to self.foo —- the only time this might be iffy is if there’s a global function foo, but in practice it’s not onerous to handle) Also beginners don’t have to mentally blot out in their heads the self argument when calling a method (“you mean self isn’t the first argument?”). Debug messages are also more consistent (“the debug message says my method needs 1 argument. Isn’t self right there?”) I accept Python’s explicit self for what it is (Python’s philosophy prefers explicit over implicit), and don’t have trouble with it but aesthetically it deviates from most OOP languages out there. It’s a valid choice for practical reasons but I would also say that an implicit “this” is an equally valid choice for aesthetic reasons. Here’s a survey of this/self choices: https://en.m.wikipedia.org/wiki/This_(computer_programming) https://en.m.wikipedia.org/wiki/This_(computer_programming)
- type0 8y agoPython is like a dutch windmill and Ruby is like a japanese origami. Python is robust and Ruby is elegant.