

Can anyone explain why Ruby is so popular? - xkcdfanboy

It seems to me like a hybrid of python with perl. It does a ton of things and from what I've heard, it's slow as molasses because of all of the metaprogramming syntax that's built in. RubyMotion allows you to build iOS apps in Ruby. It doesn't seem like other languages get the attention that ruby does. It feels like a scripting language but gets the attention of a compiled one, I don't get it. Is it becoming the first programming language that some people learn? It's actually about the only language I don't know (and I know x86 asm, C, PHP, ObjC++, Python, Perl, C#, you name it.) Thanks in advance.
======
mjhea0
Ruby is popular because of Rails. If you're not going to use Rails, I don't
see much reason to learn Ruby as in my opinion Python is easier to learn and
is applicable to so much more than Ruby.

That said, I agree that the syntax did feel like a hybrid of Python and Perl
(with a bit of crack mixed in) - but once I started playing around with it, I
really started to appreciate the syntax.

~~~
rman666
Why do you say Python is applicable to so much more than Ruby? I don't see how
this can possibly be true since they are both powerful scripting languages.

~~~
lost-theory
They are both powerful scripting languages, but I think the ruby community
suffers from a monoculture around rails & web development. Python also has a
strong emphasis on web development (django, flask, pyramid), but there are
also large communities of people doing scientific / numeric computing (scipy,
numpy), bioinformatics (biopython), games (pygame, pyglet), networking
(twisted), education (MIT's 6.00 course), embedded stuff / robotics, etc.

------
spoiler
I love Ruby's syntax. I tries Python, but I didn't like it as much as Ruby,
what putt me off about python is the meaningful indentation (although I do not
mind that in CoffeeScript). Also, Ruby itself is not slow, but CRuby (MRI,
YARV, whatever you call it) is slow; Rubinius ("rbx") is a wonderful (and my
personal favourite) alternative for MRI. In fact, I use rbx and EventMachine
for a fun app that has a growing number of users! However, when I found some
things were too slow in Ruby I just wrote a C extension (yes, yes, I know it's
a bit of a controversy).

As to why I learnt it: it looked fun, and I was right, Ruby brings me
pleasure!

~~~
read
Can you elaborate on what put you off Python's indentation?

~~~
throwit1979
Not the OP, but meaningful whitespace is an abomination unto the world.

It's difficult to elaborate on something that is a matter of taste, but some
of us _need_ our code blocks visually bookended.

------
Skoofoo
"I hope to see Ruby help every programmer in the world to be productive, and
to enjoy programming, and to be happy. That is the primary purpose of Ruby
language." -Matz

Ruby and its ecosystem revolves around your happiness and productivity. Isn't
that great?

~~~
dylangs1030
I think most languages set out to achieve this. It's not a real answer.

For the record, Ruby is a great language, but a better argument for it would
be syntactical analysis or talking about features.

If Guido had this awesome quote about his goals for Python, it wouldn't make
Python a cool language automatically.

------
adrianlmm
I personally love the syntax, and in my own experience is not that slow, I use
it with Sinatra and my productivity is huge.

I'm also a C# and Delphi developer. I learned Ruby cause I had the need the
learn an scripting language, and the reason to not learn python was that it
looks like it is stock for ever in the 2.7 version, so I chose Ruby and I'm
very pleased with my decision.

~~~
xkcdfanboy
It's interesting that the two responses on here (yours included) so far
mention that it was learned for scripting. The main reason I made the initial
post is because I see it being used for much more than just scripting, ie.
rails and ruby motion. It seems somewhat naive to use a scripting language in
leui of a real language when coding something industrial. So I still am at a
loss... Thank you for your comment, yeah it does seem a lot more powerful than
Python. I am not a fan of python's requirement of object methods requiring the
self arg, dastardly!

~~~
zachlatta
Scripting languages are "real" languages. Also, RubyMotion projects are
compiled down to machine code, not interpreted.

------
jayferd
Metaprogramming syntax isn't built in to ruby. Instead, it's really internally
consistent and lets you leave out a few tokens, which means it's _really easy
to write libraries with beautiful interfaces_.

The built-in features usually try to solve the general case, rather than
focusing on specific use-cases. For example, in python you have iterators,
which make it easy to have a block of code that is run multiple times with
different bindings. In Ruby, you have block syntax, which solves the more
general problem of "let me pass this anonymous block of code to this
function", and they built iterators on top of that.

------
csense
I'm interested in the answers to these questions:

1\. What does Rails do that Django doesn't? (Feel free to substitute any other
Web framework for Django if you think it'll help your answer be more
illustrative.)

2\. Why hasn't the Python community seen whatever Ruby's doing and copied
whatever makes Ruby popular? Are there any Python/Ruby experts reading this
who are willing to port or reimplement the good parts of Ruby in Python?

3\. Are there any other reasons to prefer Ruby over Python besides Rails? For
example, do Gems do things that are impossible with Pip?

~~~
chc
> _1\. What does Rails do that Django doesn't?_

The answer is, basically, "Have a larger ecosystem without being Java." There
are a few things each has by default that the other doesn't, but by and large
I don't think people pick Rails because it has 8 million features and Django
only has 7.95 million.

> _2\. Why hasn't the Python community seen whatever Ruby's doing and copied
> whatever makes Ruby popular? Are there any Python/Ruby experts reading this
> who are willing to port or reimplement the good parts of Ruby in Python?_

Just about anything worthwhile already has an equivalent. The reason Ruby is
popular is not really about features. Ruby is popular because Ruby managed to
capture people's imagination. When the new generation of webdev was first
coming around in the mid-2000s, Ruby had a huge burst of enthusiasm. Everybody
was enamored with Ruby on Rails, and Ruby itself had lots of fanatical
evangelists like Why who were eager to teach people. Python, ironically, was
hampered by the fact that it was more mature and thus it was harder to get
people excited about it. Additionally, Rails was the killer app for Ruby,
while Python took a relatively long time to put out a comparable product. I
don't remember if Django existed, but there certainly wasn't the situation you
have today where Django is basically the "Python Rails" and they're seen as
being on roughly equal footing. Instead, Pythonistas were all talking about
how you should take Twisted and twelve other libraries and you just write all
this glue code and then it's sort of like Rails if you squint really hard —
and nobody really found that exciting either.

This isn't to say that Ruby doesn't have actual benefits to recommend it.
Rails is a very nice, mature environment for web development, and Ruby as a
whole has a very nice ecosystem these days. But the reason it got where it is
is because Ruby won people over eight years ago, and it's gotten where it is
today from that momentum. It isn't that Ruby is miles ahead and Python is
simply inferior, but that Ruby just got a head start in that field and inertia
matters a lot.

> _3\. Are there any other reasons to prefer Ruby over Python besides Rails?
> For example, do Gems do things that are impossible with Pip?_

The culture of the two languages is sort of different. Python invariably loves
explicitness. Ruby isn't as crazy infatuated with "magic" as it used to be,
but it's still much more acceptable over there to do weird tricks that let you
write code the way you want to (e.g. "this magically executes in a context
with functions that aren't available elsewhere") instead of the old-fashioned
way. A lot of people prefer the latter, so they like Ruby. A lot of other
people hate that kind of code, and they will be much happier using Python.

~~~
csense
> Python took a relatively long time to put out a comparable product. I don't
> remember if Django existed, but there certainly wasn't the situation you
> have today where Django is basically the "Python Rails" and they're seen as
> being on roughly equal footing. Instead, Pythonistas were all talking about
> how you should take Twisted and twelve other libraries and you just write
> all this glue code and then it's sort of like Rails if you squint really
> hard — and nobody really found that exciting either.

This is the most informative part of your comment. I came to Python around
version 2.6, and Django was already pretty near its modern form. I also first
started hearing about Rails at that time, so my _perception_ was "Python has
always had Django, and Rails is a new thing." If Rails is older than Django,
that explains much.

> Python invariably loves explicitness

Before I used Python, Java and C were my main languages. I was amazed at how
short programs became in Python. For this reason, saying "Python loves
explicitness" strikes me as strange, since it gets rid of braces, semicolons,
variable declarations, the 'new' operator...

> A lot of other people hate that kind of code, and they will be much happier
> using Python.

This is totally me. I've ranted elsewhere in this thread about Ruby's syntax.
Maybe some clever person will write a Python-to-Ruby translator someday so you
can use Rails without having to deal with Ruby syntax.

> inertia matters a lot

I'm just a little surprised the momentum isn't swinging back to Python. Since
IMHO Ruby's syntax makes the language...very undesirable, and if I was forced
to use it to take advantage of tools that only exist in Ruby-land, I'd be
looking to switch back to Python as soon as the tools were ported -- and even
devote effort to helping with ports.

Everybody was excited about Perl in the beginning, but very few people still
code in Perl these days. I think Ruby suffers from similar problems and will
eventually be eaten by Python.

~~~
chc
> _Before I used Python, Java and C were my main languages. I was amazed at
> how short programs became in Python. For this reason, saying "Python loves
> explicitness" strikes me as strange, since it gets rid of braces,
> semicolons, variable declarations, the 'new' operator..._

I think you have confused "explicitness" with "verbosity." Indentation is no
less explicit than braces.

> _I'm just a little surprised the momentum isn't swinging back to Python.
> Since IMHO Ruby's syntax makes the language...very undesirable_

That is very much a YMMV sort of thing. A lot of people actually like the Ruby
syntax because they find the greater flexibility and ability to define pseudo-
DSLs to be pleasant.

------
tudorconstantin
I am a perl dev for almost 3 years and i learned it at my job after i tried
ruby and python.

For more than a year i felt i should have chosen ruby because of how intuitive
it feels: you read the code always from left to right, whereas in perl you
often either go from right to left or from the center of the line outward.
Besides that, fuby also has that principle of less surprise.

However, after I got accustomed with perl, i started to love its
expressiveness and flexibility. And now, I almost got to love the "there's
more than one way to do it" mantra. Regarding Python, I see it more close to
Perl from a readingness perspective, but with much less flexibility embedded.

~~~
lsiebert
I know perl (among others) which I really like, but I feel like I have to
learn python or ruby to be competitive.

~~~
Mithaldu
That's only a feeling.

[http://www.indeed.com/jobtrends?q=perl%2C+python%2C+ruby%2C+...](http://www.indeed.com/jobtrends?q=perl%2C+python%2C+ruby%2C+php&l=)

~~~
lsiebert
Maybe so, but the who's hiring page from May has zero mentions of perl, and
quite a few of python and ruby. If there is a good internship for a perl
hacker in the Bay Area, I haven't seen it.

I got to meet Larry Wall, (was nice enough to come and talk to my class) and
even he seems to have had trouble finding work during his career.

Actually, from your comment history, you seem like a perl aficionado. Maybe
you could email me and let me know where I should be looking. I'd email you,
but you have no contact info supplied.

------
meerita
As designer who's learning to code, I find Ruby code more easy to learn and
read. Other programs are too, let's say, cryptic syntax. And for the projects
I am working for I don't need to work with another programming language.

If you let me chose, I would go all the way with Erlang or Go, but it's hard
to learn for a non-coder.

------
nayefc
Ruby is just beautiful. I learnt Python and Ruby last year, and even though
they're both really good, I find Ruby's syntax hard to resist.

Metaprogramming is also great (others have commented about that)

------
ksherlock
When I gave up on perl, I considered other scripting languages and it turned
out that ruby was the best match for my programming style. I think ruby users
and ruby on rails give it a bad name, though :)

------
chrisgw
I learned Ruby because of Rails.

If I need a scripting language, I prefer Ruby because I know it the best now.
I'm pretty good at Python, but feel more comfortable in Ruby because I use it
more often.

------
wgla
One word: Rails.

------
websitescenes
Thanks for what? Sounds like your opinion is made up. Still trying to figure
out if this is a question. I like Ruby about as much as PHP; I think it's more
about what you build on the language or what framework you use.

~~~
websitescenes
Lol, I put in my true opinion and constantly get down voted. Seems like people
would rather debate nonsensical things than face the truth. The original post
deserved the response it got from me and I will continue to call it how I see
it. If you want a real discussion then ask a real question. You didn't even
say what you are trying to do. Web apps? Desktop programs? The op is trying to
compare languages that are not even in the same domains. I like all the
languages you listed and think they have their place. Not sure why you are
comparing them to Ruby though.. I like Ruby mostly because of Rails but have
been playing with laravel. PHP is faster sometimes but so is Ruby if you know
how to program. Down vote me again haters. I'm starting to get off on it.

