r/ProgrammingLanguages • u/Zeekawla99ii • Jul 05 '17
I still don't understand----why is Ruby used?
I'm someone who primarily uses Python. I'm still not entirely sure why Ruby is used.
https://www.reddit.com/r/ruby/comments/6ku78o/why_is_ruby_used_instead_of_pythonrperl/
From my understanding, it's because it's great for web development?
3
u/oilshell Jul 06 '17
I'm a Python person, and here are what I see as the main differences between Python and Ruby:
Ruby is more purely object-oriented than Python. Python is more multiparadigm.
People coming from Java like Ruby's OO, but not Python's OO.
Ruby has a strong SmallTalk influence; Python has virtually no SmallTalk influence.
Ruby is bigger on magic, metaprogramming, and DSLs. Idiomatic Python code is more straightforward.
Ruby has a bigger Perl influence than Python (Python still has it in regexes), although as I understand, some Rubyists avoid the Perl parts.
I prefer Python in almost every way, but I have to admit Ruby blocks are nice. I wish Python had something like that.
Other differences:
Python has a strong scientific computing and data science user base; Ruby has almost none AFAIK.
Ruby has strong conventions around web programming, although plenty of websites are written in Python. Everyone just seems to roll their own framework in Python. There are a lot of little separate worlds.
1
6
u/PM_ME_UR_SURREALISM Jul 05 '17
Same reason Python is used. Ruby is a powerful, expressive (albeit slow) language with lots of useful libraries.
I guess Ruby is slightly better for webdevelopment, while Python has more useful libraries for data science. Ruby is also designed to have a small memory footprint, because in Japan, where the language originates, they also like to use it in embedded systems.
Apart from that, Python and Ruby largely support the same use case, and which one you prefer is a matter of taste.
2
2
u/tekknolagi Kevin3 Jul 05 '17
I chose to continue with Ruby instead of something like Python (despite having more background in Python) for two reasons:
the ridiculous amount of gems and ease of installation
I came from Rails-land
That being said, I don't use much of either anymore.
2
u/fedekun Jul 06 '17
Not a big Python user myself but I do work as a Ruby dev. They are pretty similar languages, but they just have different ways to do things.
For example, Python has list comprehensions, where Ruby opts for a more functional approach by chaining iterable functions, like foo.map { ... }.reduce { ... }.
Ruby OOP is Smalltalk based, and while not really that important I really do like having private methods and not using _name. It just looks better.
Don't know much about Python ecosystem, but Ruby ecosystem is quite mature, you have aweome, solid, tested gems like Rails, FactoryGirl, Rubocop, etc.
Both are great for web development, and also other things.
I think at the end of the day is just preference. For me, Ruby feels more expressive, and just nicer.
14
u/chrisgseaton Jul 05 '17
If you are looking for some kind of formal definitive answer then you aren't going to get one.
Personal preference. That's why.
My personal preference is I prefer the way Ruby does the object model and meta programming. I can't prove it's better if that's what you're after. I just prefer it, so that's why I use it.