5 ms·
Can anyone explain why Ruby is so popular?
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.
- adrianlmm 13y agoI 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 13y agoIt'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 13y agoScripting languages are "real" languages. Also, RubyMotion projects are compiled down to machine code, not interpreted.
- csense 13y ago> python's requirement of object methods requiring the self arg I originally hated it too, but it's grown on me. I've come to the conclusion that it's good to have that explicit signal that something is a member variable rather than a local. And I've started adding explicit "this." to member variables in all my Java programs.
- dpritchett 13y agoRails helps minimize time to market. Any sizeable Rails app that gets market traction is likely to have its hotspots revisited and broken out into services. The services need not use Ruby at all. Edit: Ruby itself is just a language. If you're not building web apps or server scripts there's no particular reason to prefer it.
- websitescenes 13y agoYou can make iPhone apps with anything you want. You can even use plain html5 and js. There are many, many options to utilize your preferred language in app development. It's definitely not just Ruby.
- rman666 13y ago+1for Sinatra!
- chrisgw 13y agoI 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.
- mjhea0 13y agoRuby 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 13y agoWhy 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.
- rkda 13y agoIt depends on your field, I guess. Scientific computing for example uses a lot of Python. Ditto for the geospatial field where both the proprietary packages and the open source ones use Python. Sometimes, it's not the language's power that matters but the field of application and the existing libraries and community.
- lost-theory 13y agoThey 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.
- bigd 13y agoPython is much more complete when it comes to math and science.
- jgoldschrafe 13y agoRails is a big part of Ruby's popularity, but let's not forget the impact of Chef and Puppet as well.
- csense 13y agoI'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?
- spoiler 13y agoI don't know about the first question, but: 2) Because Python would become Ruby, or at least Pubython, then. What attracts most people to Ruby is its humanist syntax, not sure what Pythons guiding philosophy behind the syntax is, but I tried both and ruby was just a lot better. 3) There is loads of little things that are just personal preference for me, but the choice of language always boils down to personal preference one way or the other! Never really tried Pip, so I can't answer.
- csense 13y ago> Pythons guiding philosophy behind the syntax Python's syntax philosophy in a nutshell: The more your program looks like line noise, the harder it is to read. Operators should be simple and minimal, operations like list comprehension should match existing usage in English, mathematics, or C. > ruby was just a lot better Here's a Ruby snippet. I don't want to pick on this particular project [1], rather, I've found that this is typical of Ruby code: state_machine :state, initial: :active do after_transition any => :blocked do |user, transition| # Remove user from all projects and user.users_projects.find_each do |membership| return false unless membership.destroy end end Wow. There are colons, absolute value bars, implications, and who-knows-what-else flying everywhere! It gets worse, elsewhere in the same file there are messy lines like this one with single-arrow implications, question marks and ampersands [2]: scope :not_in_project, ->(project) { project.users.present? ? where("id not in (:ids)", ids: project.users.map(&:id) ) : scoped } Simple, intuitive syntax? From where I sit, the syntax of Ruby is worse than C++, and approaches Perl levels of awfulness. In most languages, I can at least sort-of grok what's going on from the context when I see unfamiliar operators, but not so in Ruby. [1] https://github.com/gitlabhq/gitlabhq/blob/4caaea824cf51670d11b409efa5701dd74614d2a/app/models/user.rb#L118 https://github.com/gitlabhq/gitlabhq/blob/4caaea824cf51670d1... [2] https://github.com/gitlabhq/gitlabhq/blob/4caaea824cf51670d11b409efa5701dd74614d2a/app/models/user.rb#L143 https://github.com/gitlabhq/gitlabhq/blob/4caaea824cf51670d1...
- ksherlock 13y agoWhen 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 :)
- spoiler 13y agoI 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 13y agoCan you elaborate on what put you off Python's indentation?
- throwit1979 13y agoNot 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.
- spoiler 13y agoWhen reading Python at anything over 3 levels of indentation I had to use a ruler to know what level I am currently in. Or similar, when there was multiple lines between two blocks or commands This was before I started using sublime text and I was very new to programming, also never tried Python in ST, to be fair! I mostly missed that visual cue where the block ends, I suppose.
- csense 13y agoYou should give Python another chance. Here's why: > meaningful indentation Indentation in other languages has meaning too. If you have Java code, for example, that looks like this: public static boolean isIncreasing(int a[]) { boolean result = true; for(int i=1;i<a.length;i++) if (a[i-1] <= a[i]) continue; else System.out.println("a is not monotonically increasing"); result = false; return result; } Can you spot the bug? The topic we're discussing is a huge hint as to what the bug is, but if the only clue you have is bad behavior in a longer program it can be much harder to spot. When skimming the code, the visual cue of the indentation is so strong that it's very easy for your brain to see what the programmer clearly intended to write rather than what's actually there. (The diagnosis of the above bug might be even hairier if the bug was introduced by inserting a "safe" print statement to help you debug an unrelated problem!) Forcing your code's visual cues and behavior to match defeats an entire class of bugs. And even if you start out hating it, ultimately it's like the required semicolons in C/C++/Java: It's an annoyance at first, but after a while it becomes so automatic that you no longer stop to think about it.
- Skoofoo 13y ago"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 13y agoI 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.
- websitescenes 13y agoThanks 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 13y agoLol, 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.
- tudorconstantin 13y agoI 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 13y agoI know perl (among others) which I really like, but I feel like I have to learn python or ruby to be competitive.
- Mithaldu 13y agoThat's only a feeling. http://www.indeed.com/jobtrends?q=perl%2C+python%2C+ruby%2C+php&l= http://www.indeed.com/jobtrends?q=perl%2C+python%2C+ruby%2C+...
- lsiebert 13y agoMaybe 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.
- jayferd 13y agoMetaprogramming 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.
- meerita 13y agoAs 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 13y agoRuby 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)
- wgla 13y agoOne word: Rails.