4 ms·
Nope. Can't stand that Python uses built-in functions for basic things like list, map, fold, etc... instead of methods on base classes. Here's a super basic e
by Mikeb85 5y ago
Nope. Can't stand that Python uses built-in functions for basic things like list, map, fold, etc... instead of methods on base classes. Here's a super basic example. Add one to an array [1,2,3] and print results.
Python: print(list(map(lambda x: x + 1, [1,2,3])))
Ruby: print [1,2,3].map {|x| x + 1}
So much more readable, easy to write, etc... Ruby keeps it consistent by making pretty much everything an object and you just call methods. Even Haskell has dot notation to chain functions since it's just so much easier to read and write...
- j_mo 5y agoThis is what really put me off Python as somebody who learned Ruby as their first proper (professional 9-5 usage) programming language. There are other things too, like how print used to be written like a keyword not a function for some reason, and enforced indentation instead of braces or "end" keywords, all just really bugged me. It felt like somebody made YAML Turing complete...
- iterati 5y agoprint([x + 1 for x in [1,2,3]])
- KerrAvon 5y agoThis really goes to the heart of the problem with modern Python. It's lost the simplicity of the language which was the whole point of it in the first place. OO and functional paradigms were bolted on to varying degrees of success, but an outsider can no longer look at average Python code and understand it at a glance.
- gmfawcett 5y agoList comprehensions were added to Python in version 2.0, which was released 21 years ago. That was about six years after Python 1.0 was released. Are you seriously pining for the simplicity of Python 1.x? (Most of the "outsiders" you're talking about were in elementary school at the time, I don't think they were reading a lot of Python!)
- trufas 5y agoTo be fair, you almost never should use the map builtin instead of the pythonic equivalent, list comprehensions. `print([x + 1 for x in [1, 2, 3])` I agree that the ruby approach is better in terms of consistency, but most developers will be aware of the conventions python uses.
- Mikeb85 5y agoOk, that's a nicer result (obviously I don't write Python lol) but still seems inconsistent to me (putting the function before the array) considering Python is an OO language and most people are going to be writing methods for classes where you call methods with dot. I just remember list comprehensions from Coffee-script and not going to lie, I hate them. It's like reading backwards.
- iterati 5y agoPython is a multi-paradigm language, of which OO is one paradigm it supports.
- Mikeb85 5y agoRuby has map, filter, reduce and a bunch of other functional methods. It's more about the consistency of wondering what's a function versus what's a method and then things like list comprehensions and for loops. Python also doesn't have a lot of the goodies of a real functional language, it encourages for loops and seems to be even more procedural than Ruby but less OO?
- jimbokun 5y agoRuby is a strongly OO language, which arguably also has better support for functional programming than Python.
- cutler 5y agoYes, that's the Zen of Ruby and why I love it.
- regularfry 5y agoFor me it's annotations. Looked at from a distance, what appears to have happened is that the implementation hit a certain level of complexity before class methods got implemented, and it ended up being easier to do them with "@classmethod" than with "def self.foo", or to fix whatever reason it is that makes "def foo(a,b,c)" not act like a class method if "a" isn't "self".
- cutler 5y agoFor me it's crippled lambda and __dunders__.
- travv0 5y ago> Even Haskell has dot notation to chain functions since it's just so much easier to read and write... Are you referring to function composition?