5 ms·
Ruby is a beautiful language, but it lost the race against Python long ago. - When I first looked into both some ten years ago, I was undecided what to choose.
by submeta 4y ago
Ruby is a beautiful language, but it lost the race against Python long ago. - When I first looked into both some ten years ago, I was undecided what to choose. But even back then googling problems led to much more professionally written blogs / articles about Python. Articles about Ruby were not as profound. That’s when I decided to go with Python. And it was the right choice.
## Edit
What I miss in Python: Ruby always returns a value and does not change structures in place. For instance `data.sort()` in Python will return `None` and change the order in `data`. Ruby won‘t do that and will return a sorted copy. Like Scheme (a Lisp dialect). In Scheme methods changing data have an exclamation mark as suffix: `(sort! data)` vs `(sort data)`, and it will always return a value. Unlike Python.
- msbarnett 4y agoWhat “lost”? They’re both Top 10 most used languages with tens of thousands of open positions currently available for someone competent in either. Python’s the more frequently used of the two industry-wide, but it seems like they both won, just with different crowds.
- disgruntledphd2 4y agoAs a professional data scientist, I kinda wish ruby had won for this area, as it's much closer to R conceptually. Python is fine, the metaobject model is pretty nice, and I've stopped noticing the double underscores ;)
- dehrmann 4y agoI think it's that Ruby has mostly been relegated to Rails, while Python sees use in backend systems, data science, scripts, and as a popular first language.
- tomstuart 4y agoYou may be making a point about what happens by default (and perhaps Ruby’s similarity to Scheme?), but in Ruby you can also say `data.sort!` if you want the `data` array modified in-place. It’s still returned, though.
- disgruntledphd2 4y agoThe hardest thing for me to understand in Python was the baffling tendency of methods to return None.
- teddyh 4y agoI think I have read somewhere that they return None in order to explicitly signal that the object has been modified in-place. For example, if you want to have one method which sorts in-place, and another which returns a sorted copy, if then both methods returned a sorted object, it would be too easy to mistakenly call one instead of the other, creating a bug which might not be found for years.
- cortesoft 4y ago> Ruby always returns a value and does not change structures in place The not changing structures in place bit is only for std library things… nothing is stopping code you write from modifying structures in place. Ruby has the ‘! means it mutates’ convention as well, and the built in methods use it (for example, .sort! on an array modifies the array in place just like your Scheme example). However, again it is just a convention… nothing stops a ruby developer from modifying something in place without a !, or making a method that ends in ! that doesn’t modify in place. The common theme in Ruby is ‘nothing stops you from…’
- deleted 4y ago[deleted]
- deleted 4y ago[deleted]
- deleted 4y ago[deleted]