Settings

Theme

Has Python killed Ruby?

28 points by Pishky 9 years ago · 63 comments · 1 min read


If chosing to learn one or the other why would anyone choose Ruby?

Thanks

LyndsySimon 9 years ago

I've used Python for about about eight years, and Ruby for right at six months. It took me about a week to feel competent in Ruby, and about a month before I was really comfortable with all of the metaprogramming functionality. Add another month to that before I really grokked ActiveRecord.

I much prefer Python. I thought for a long time that this was because I learned most of the fundamentals of computer science and professional development in the language, but I'm at the point now where I'm sure that's not the case. The Zen of Python really shows the differences between the two of them - "explicit is better than implicit", versus Ruby's "convention over configuration". I don't mind writing some boilerplate in Python, because the boilerplate is itself fairly terse and fully informs you of your system's architecture in the process.

I hate that functions aren't first-class objects in Ruby. Hate it. The subtle distinctions and behavioral differences between blocks, Procs, and lambdas are infuriating.

There are many things I would change about Ruby, but there's nothing wrong with it. It's just not a good fit for my way of thinking.

All that said, the question was "Has Python killed Ruby?" No, it hasn't. Ruby is still popular, and I think it very much fits the manner of thinking of many developers. For them, thinking in Ruby is natural and wrangling Python into submission would feel like writing Ruby does to me.

  • mfdavid 9 years ago

    I think you mixed things a little bit. Where does ruby (the language) uses "convention over configuration"? I see frameworks using this but not the language itself. If you dont like ruby on rails, thats fine, I dont like either. But that has nothing to do with the language itself.

    When you talk about "functions are not first class objects", do you mean you cannot assign it to a var? Well thats because they are not functions, they are methods. I think thats great. A method belongs to a class. Thats how Smalltalk also implemented it, as far as I know. In fact Ruby and smalltalk (the mother of all OO languages) shares a lot in common.

    If you like functional programming style, thats fine, but yeah then maybe you should use haskell, erlang, elixir, ...

  • mmyoung2 9 years ago

    When you mention grokking Active Record and Ruby's "convention over configuration", it gives the impression that you are conflating Rails with Ruby. It's similar to if someone in the Ruby camp were to conflate Django or Flask with Python. Also, functions very much are first-class citizens in Ruby, otherwise blocks, procs, and lambdas wouldn't work!

  • bigkm 9 years ago

    Python's philosophy of "explicit is better than implicit" kind of dies when you get to types. Even the docs are quite vague on this too.

    • nnq 9 years ago

      It's a dynamic languages... what would you expect?

      For most boring everyday cases Python's "type system" (it's too much to call it so, but anyway) is quite ok, catches lots of bugs that would seep through in Javascript or PHP, plus functions as first class objects to match everyone intuition and it's quite a pleasant experience.

josephorjoe 9 years ago

I use both fairly regularly, and they are very similar.

Where they are different in terms of syntax or capability or philosophy, I nearly always prefer ruby.

I find bundler/Gemfile/rvm to be less headachy for project dependency management than pip/requirements.txt/venv.

For me, ruby code is easier and more pleasant to read.

When I need to write a quick bit of temporary code or do some simple data parsing/file management, I nearly always use ruby if it doesn't matter which language I use.

But if I had to choose one of them to learn, I would focus on python -- even with everything I said above and the really long and drawn out (and still unsuccessful) transition to python 3.

Python has much stronger non-web app libraries and perfectly adequate web app libraries and is definitely much more widely supported in academia. Ultimately there are more things you can do with python and more python job opportunities.

  • mercer 9 years ago

    Do you have experience with NPM and Yarn (javascript/node) and if so, how do the package managers and ecosystem compare?

    I'm asking because I'm primarily a js dev with a bit of Ruby and Ruby on Rails experience, and I'm wondering if Python/Ruby are worth investing in at this point and if perhaps instead it makes more sense to stick with js (Yarn in particular for package management) and explore more fundamental (C/C#/C++/Swift/Objective-C) or exotic (Haskell, Clojure) communities/languages/environments at this point.

    • nnq 9 years ago

      Imho it's greatly valuable to have a "real scripting language" in you tool-belt. Node doesn't qualify like one to me, unless you're one those mutants with brains twisted in particular ways that actually like explicit-async code everywhere. Considering the age we live in, one with good interfaces to machine-learning stuff would be great, so Python is great to know well imho.

      The kind of prototypes that I can hack together with Python + whatver frontend in a day can take 4x as much to do with Nodejs for me, simply because there are so many micro-decisions to make at every point (libA or micro-libC + micro-libB or mega-lib-D kind of stuff). And the way it leaves you with you "brains fried" after wrangling with some async bug... not worth it imho. Better to have the boring technical micro-decision made by someone else for you so you can concentrate on the cool stuff.

      If you're working on anything where the product OR idea OR algorithm OR ux-process is much much much more important that "ecosystem" or scalability bulshit, nodejs will always feel at least 2x slower to develop in than either Python (if you're into AI/ML-ish things) or Ruby or Go or Elixir...

      For web apps my alternative receipe would be to keep the web app nodejs and more the smarter-than-crud stuff to microservices written in anything but Nodejs.

    • josephorjoe 9 years ago

      Yeah, I have worked with js/npm more than ruby or python lately. I've looked into yarn, but haven't used it on a project yet.

      I like npm. For package management, I think npm is on par with bundler (ruby) and thus a bit better than pip. I like the ease of use of package.json scripts and find myself using them more and more. They feel lighter and easier to set up than the ruby equivalent (rake tasks, usually), although when you start doing fairly complex stuff (e.g., custom asset management), they can get a bit unwieldy.

      As for the ecosystems, I find javascript is more in flux. It is more work to keep dependencies up to date or to decide what library to use when you need one, and I've had apps break on minor and patch updates to dependencies fairly often.

      There is also a focus on small libraries that just do one thing. Nothing wrong with that, but the number of dependencies some projects have is a bit crazy.

      If you work with Ruby or Python for web stuff, you inevitably end up using JS for the frontend, so it is certainly a reasonable choice to use Express as the server and go full Javascript.

      And my company does that a fair amount, but when we need an app to do something more complicated than serve web pages and talk to the database, we end up moving over to flask/python to take advantage of python's better libraries (esp. for math/science/data stuff).

      So, I still see some value in picking up python. Nothing wrong with any of the other languages though, and you can learn a lot from any language. Depends on your interests and needs really.

      • mwpmaybe 9 years ago

        > For package management, I think npm is on par with bundler

        NPM is non-deterministic and doesn't have lockfiles, so it's a bit of a stretch to say it's on par with Bundler.

        Yarn solves both those problems for JavaScript projects, and it's much faster.

        • josephorjoe 9 years ago

          Right, you have add on npm-shrinkwrap if you want to lock everything down (which I do use for some projects).

          Yarn may well be better than npm, in fact, as far as I can tell it is, but, frankly, npm works well and I'm tired of switching js dependencies, especially really core dependencies like a package manager.

          I'm hoping npm just steals whatever yarn does better than it so that I never need to switch...

          Bundler is pretty great.

          pip... pip... I don't know what to say about pip. It's probably my fault, but I can never seem to get pip to fully understand that what I put in requirements.txt should always always always be used for the project no matter what system level libraries are installed. If yarn were available for python, I'd switch to it today...

          • chucksmash 9 years ago

            > Yarn may well be better than npm, in fact, as far as I can tell it is, but, frankly, npm works well and I'm tired of switching js dependencies, especially really core dependencies like a package manager...

            Yarn still uses your package.json. I think it will definitely win out over directly using npm since it is better in a couple of ways and, from a user perspective, is just a thin wrapper around the things you're already used to doing. Ways my workflow has changed:

            npm install . -> yarn

            npm save --dev pkg -> yarn add --dev pkg

            npm save pkg -> yarn add pkg

            npm run command -> yarn run command

            If you start using it and dislike it, just npm uninstall -g yarn, rm the yarn.lock file and bam, you've still got a normal npm dependency management setup.

            > If yarn were available for python, I'd switch to it today

            Project worth keeping your eye on: https://github.com/kennethreitz/pipenv/blob/master/README.rs...

rudyonrails14 9 years ago

If going with the web, I'd go with JavaScript, to a degree you have to learn it anyway. Python and Ruby are both relevant for web as well. Rails vs Flask/Django - both will get the job done, plenty of use cases of major corporations using one or the other.

If you're doing DevOps, you should probably learn both.

Everything else, which is more backend, APIs, data, data science, AWS, Google Cloud, Big Data databases, etc - Python over Ruby. You may want to consider Java here tho depending on how much performance is required due to many of those aforementioned Big Data platforms having the JVM underneath the hood.

So all things being equal, Python, and then for all things not being equal, Python.

  • mercer 9 years ago

    To add to that in regards to web development: you're going to need JS anyways much of the time, so learn it. You Don't Know Javascript and Eloquent Javascript are respectively good starting points and good but tough starting points.

    But as of yet there's nothing in the JS ecosystem that compares to Ruby on Rails or Django for back-end stuff, so it's worth learning one or both those two as well.

    For finding work: learn both, or pick the one that is more popular in your desired field, geographic location, etc.

    For improving yourself as a programmer: go for Python first but learn both (good introduction to how programming languages are both different and alike). If you can't be bothered by or interested or learning both, reconsider your field of work, because both are fun.

    For anything else: if you're capable of weighing the pros and cons of either in regards to support (hiring coders), project size, level of complexity needed etc.: Python strikes me as the slightly safer / more robust choice, especially in academia, but I'm not confident about recommending either one primarily.

dasdhrub95 9 years ago

Ruby is commonly used by programmers along with Ruby on Rails for Web Development so it's scope is very limited. Python on the other hand has been widely adopted by the academia and has become pretty much essential to startups in the big data/AI sector, additionally Python can also be used with Django for web development (Instagram's website is built in Django). The pip library is vast and the Django community is on par with the Ruby on Rails community. I dont see any reason to stick with Ruby.

  • bdcravens 9 years ago

    > Ruby is commonly used by programmers along with Ruby on Rails for Web Development so it's scope is very limited.

    Not correct. Its primary use case doesn't limit its scope, and there's tons of utility programming done in Ruby. (for example, Chef and Puppet are written in Ruby)

dkarapetyan 9 years ago

Ruby is a much simpler and more aesthetically pleasant language. Python has all sorts of sharp corners. You really should learn both but I think Ruby is a much easier starting point.

Also, a lot of research on dynamic languages is being done with Ruby, e.g. TruffleRuby, JRuby, RubyOMR, and probably a few more I'm forgetting. Each of those projects is an impressive body of work in and of itself that points to Ruby being very alive and well. Oh, almost forgot about MRuby. I don't think there are similar efforts for Python. In some sense Python is much more stagnant these days in terms of innovation at the language level.

  • mamcx 9 years ago

    > Ruby is a much simpler and more aesthetically pleasant language

    That is open to disagreement. I will say the same, but of python.

    HOWEVER, among the languages that put "aesthetically pleasant" as part of the charm, I think is safe to say that python/ruby are from the top 5.

    Any of both will be a good choice using that criteria (and even considering the troubles with BOTH), so in my mind is hard to go "wrong" with any of them. Both have other features that could weight in the choice, but at level of language are more brothers in spirit than enemies.

    ---

    I don't see ruby "killing" python, (I'm more a fan of python, ok?); just for the look of it the niches of both are more defined now.

    SADLY, js is what is killing all the other languages in the web space. I wish a better language was the cause, but not, must be the far worse, more terrible, but the NON-choice.

    • mercer 9 years ago

      Without any strong feelings for or against a particular language, I suspect Ruby is hurt more by this than Python, at least in the future, on account of being more web-focused. Can people in both communities confirm or deny this (and as I said I'll happily use Ruby in many of my use cases)?

      As for JS; what with TypeScript and ES6 (despite the worry of clutter) I can't help but wonder if it's the best non-choice we could have hoped for.

      • mamcx 9 years ago

        I think that is a side-effect that ruby in rails was ruby in the mind of many, and python was weak at first in web (before django).

        In the meantime, python get a lot of love for scientific computing and other stuff, but ruby (and others, I think no even java or .net) not and then get behind in this area.

        So now, when the web side have more viable options and ruby is just one of many, the effect of web on ruby is felt more, but python have a good fallback on the rest.

        Python have a more diverse portfolio of options ;)

        • gspetr 9 years ago

          > I think that is a side-effect that ruby in rails was ruby in the mind of many, and python was weak at first in web (before django).

          Django was actually released first.

  • meowface 9 years ago

    I agree Ruby is visually nicer and more aesthetic (though that will always be subjective), but I'd say it's probably harder for a beginner due to all of the metaprogramming constructs.

    Python is also very much not stagnant. Look at all of the major changes and feature additions in Python 3.3, 3.4, 3.5, and now 3.6.

    • _qc3o 9 years ago

      Not just visually. It is also conceptually much more aesthetically pleasant. I still don't know how metaclasses, descriptors, __magic__ methods, multiple inheritance, all the different string formatting schemes, generators/co-routines, etc. work in Python. The amount of stuff you have to learn in Python is a lot more than in Ruby.

      • LyndsySimon 9 years ago

        > The amount of stuff you have to learn in Python is a lot more than in Ruby.

        I couldn't disagree more with this.

        Python is pretty thin when you get down to it. Magic methods alone are 80% of the way to knowing how everything in Python works.

        Multiple inheritance in Python is way simpler than the two-pronged inheritance scheme of Ruby, where you have both a parent class and modules (which can be loaded either before or after the parent class) to deal with. Want to see what order ancestor classes are applied? `object.__class__.__mro__`. Done.

        Meawhile, in Ruby, you can call a function like this - `my_function(a, foo: 1, bar:2)` - and it feels like you're passing keyword parameters... but Ruby doesn't support keyword parameters. Instead, it's implicitly creating a Hash that's getting passed as the second parameter. Even more confusing, every function has an implicit "block" parameter that can be passed to it, and is silently ignored by default.

        • dkarapetyan 9 years ago

          Ruby has had keyword arguments for a while now: https://robots.thoughtbot.com/ruby-2-keyword-arguments

          • LyndsySimon 9 years ago

            Interesting - I remember reading a proposal for this, but I've never seen them in production code.

        • mercer 9 years ago

          It's odd... I have relatively little Ruby or Python experience, but I have a kind of undefined affection for Ruby but if I'd have to choice at gunpoint I'd go for Python.

          I think the reason is that while Ruby does feel more 'pleasant' to me, especially the me that is new to programming, Python feels less vague, and I've grown to hate vagueness in my code.

          I'd probably recommend Python to new coders at this point, but for web development I would probably still opt for Ruby on account of Rails and the Rails Tutorial. If there was an equivalent to the latter, I'd go for Python though (suggestions?).

        • dragonwriter 9 years ago

          > .. but Ruby doesn't support keyword parameters

          Your information is outdated, and only applies to Ruby 1.x. Ruby added real keyword arguments in 2.0, and declaration of mandatory keyword arguments in 2.1.

  • mercer 9 years ago

    > Python has all sorts of sharp corners

    Could you elaborate on that? I've used more Ruby than Python, and I'm aware of the fact that it's often more 'pleasant', but I'm very curious what you can tell me about Python's sharp corners, because even without using it I've been very attracted to the 'explicit over implicit' mantra after being bitten quite a few times by Ruby's ease (quote unquote, perhaps?).

    (As in, so far Ruby feels like a good choice in general, but especially to someone new to programming, but I've grown to love explicit over implicit, not to mention functional over non-functional, and so but even without using Python I'm positive I might prefer it. I'd really love to hear what the gotcha's are in that particular ecosystem)

  • dragonwriter 9 years ago

    > In some sense Python is much more stagnant these days in terms of innovation at the language level.

    Python may be more stagnant and the implementation level (at least, in terms of experiments outside of the main interpreter like the ones you describe for Ruby), but the language itself seems to be advancing much faster than Ruby right now.

erkose 9 years ago

Actually, Ruby failed to kill Python.

allan_wind 9 years ago

No.

I wrote a small Rails project a while back and along with it small non-Rails utility that made used a couple of generic modules (mail, config). Both the Rails project and the utility bit-rotted faster than anything anything that I ever written. Ruby, the language, is pleasant, and you can write beautiful, terse, expressive code. Functional constructs are nice, etc. Soured me on Ruby, I am afraid. I liked Perl too, and Ruby is not that different.

Python... I don't care for the significant whites space. lambda is crippled because it has to fit into a single line, tertiary operator is weird, and compressions reads backwards to me. Haskell has the same problem. It is nice how you can start with a class, then wrap attribute access later. Writing a simple new style class is verbose. The version 2 to 3 was rough, not sure if it's done by now. There is a lot of libraries, some parts of the standard library are nice.

JavaScript to me is mess with classes being bolted on, different ways to build an object, different ways to handle errors, different ways to handle callbacks. The write it once and run it either in browser and server ignores that version differences (i.e. what is the crappiest browser you have to support), and in general that environment is different. node.js with the async is an interesting experiment. To me it becomes difficult to read and reason about. To me, it was surprisingly difficult, to write a small sync util in node.js. There is a metric ton of libraries. I quite like JavaScript, but to me its becoming complex (as in C++) instead of burning off the bad parts (as in C). The language will be around "forever" due to the web, so that is what I use if possible.

  • mercer 9 years ago

    While I'm nowhere near a 'fan' of JavaScript, I do feel like defending it by pointing out that there's a difference between the language and the browser issues. The latter are maddening and the former is less bad when you separate the two.

    That said, while I personally fell JS is decent with the ES6/ES2015 additions, I do share your worry that it erred on the side of complexity by adding a shit-ton of stuff that maybe should have been more carefully considered. It appears modern JS is and will become the kitchen-sink language, which I suppose is fitting.

    But once again, that's still pretty cool. I love how I can introduce someone to programming using JS nowadays and actually be able to teach a whole bunch of different syntactical concepts. I also love how what you can do with JS directly impact the one thing most of us are constantly staring at (web pages). All in all I think things turned out better than I expected as far as the web ecosystem goes. Programming wise. Don't get me started on my worries about the increasingly walled-garden world we appear to live in...

thescribe 9 years ago

I've never had a language click with me the way ruby has, I use it for basically any task that isn't low level. I have never liked python at all despite them being quite similar. Do whatever makes you happiest and most productive.

SwellJoe 9 years ago

Either is fine as a learning language. I'd pick Ruby if I wanted to learn how to make web apps, and Python if I wanted to work on scientific or AI projects. But, either is a very good learning language with excellent resources.

mamcx 9 years ago

As a fan of python -and think python is overall better-, but also as someone that have learned (and used professionally) many languages, learn both. Even take a look at erlang/elixir or any other you think is interesting.

Ruby on Rails was a eye openner (my exposure to web was ASP classic (auch!!!) and ASP.NET (auch!!)) and the tutorial of

http://poignant.guide/

Was something good. I choose later python just because I think is a better overall language, but I have always read what the other side have to say. I will not hate to work on ruby, in contrast to, let say, js or java.

Not hate a language is probably a more nice thing that just like it ;)

----

You must balance much more that just the superficial aspect of the syntax, despite that I agree syntax MATTER A LOT. With time the superficial syntax will become a more deeper aspect of the experience (when you truly understand the language and see the semantic behind the words), but the ecosystem, the thing you plan to build, how well you absorb the knowledge, etc are also important.

Even when 2 languages look "nice" is possible that down the road one be "better" in your mind and other "harder" or the opposite. For example I get lost reading C-like languages and get easy Pascal-like language for the same thing and the same level of difficult.

For example, I read

http://learnyouahaskell.com/

And I loved it, but I can't make haskell work for real (to me). The language look nice at first, but it not "connect" to me. Instead I get F#.

jampa 9 years ago

Answering directly to the question: no, both languages coexist for so long. I don't see "Python killing Ruby".

Learn Ruby if you want to get started in web development, most of Ruby development projects is based on Ruby on Rails, and as a beginner is VERY easy to get started, you will get things done very quickly once you set it up.

Learn Python if you want to do... well, between the two of them python is way more popular in everything but web development. There's web frameworks with Python but I wouldn't recommend them for someone who is starting now (personally, I gave up on Django for Rails).

Nowadays it is better to start with javascript. It's not "beautiful" like those two languages, but is very forgivable and node.js is all the hype right now.

rudyonrails14 9 years ago

If going with the web, I'd go with JavaScript, to a degree you have to learn it anyway. Python and Ruby are both relevant for web as well. Rails vs Flask/Django - both will get the job done, plenty of use cases of major corporations using one or the other.

If you're doing DevOps, you should probably learn both.

Everything else, which is more backend, APIs, data, data science, AWS, Google Cloud, Big Data databases, etc - Python over Ruby. You may want to consider Java here tho depending on how much performance is required due to many of those aforementioned Big Data platforms having the JVM underneath the hood.

If you know exactly what you want and it's web, then Ruby, otherwise, all things being equal, Python, and then for all things not being equal, Python.

ndesaulniers 9 years ago

Node.js killed Ruby IMO.

_uhtu 9 years ago

Ruby still has significant use in web development due to the huge popularity of Rails. Startups and established companies continue to start and maintain projects in Rails.

Beyond that Ruby isn't used much. But a language that's extensively used for one very common purpose is very very far from dead.

ahmgeek 9 years ago

One doesn't simply choose a language, language choose person.

athenot 9 years ago

From a devops perspective, both may be needed depend on your approach to configuration management.

- Ruby is used for Chef.

- Python is used for Ansible.

  • im_down_w_otp 9 years ago

    Not much of Python is exposed through Ansible. Almost none in fact. Unless you're deciding to write your own modules, and even then you don't have to use Python. From a user's perspective Ansible is mostly YAML and Jinja2 filters.

    Chef on the other hand is Ruby. Pretty much fully exposed as such.

al2o3cr 9 years ago

Which version of Python? ducks

amerov 9 years ago

Ruby created to build a DSL and accordingly allows to patch all that is possible and it sometimes causes a long search for bugs.

Python quality libraries seems better. for Example: I have not found a good HTTP client like Python's Requests or Guzzle from Php

sairamkunala 9 years ago

Its like Rock, Paper, Scissors. One beats the other all the time. Its like a loop of Programming languages.

A programmer chooses a languages which is convenient for the task at hand. Ruby/Rails are amazing to lift off projects in hours.

gremlinsinc 9 years ago

if anything kills python or ruby it'll be golang or erlang/elixir ..my money is on Phoenix Framework / Elixir eclipsing a lot of the ruby on rails environment -- a lot of core rails devs have already begun building all new apps in Phoenix. I haven't really grokked elixir yet, but it's on my todo list someday when my day job eases up a bit.

Grue3 9 years ago

Python 3 killed Python. Ruby died by itself.

nnq 9 years ago

No, but JS will kill them both :)

</not the answer you/anyone wanted to hear>

iLemming 9 years ago

No. I think Clojure and Elixir slowly "killing" Ruby.

NoCanDo 9 years ago

No, but hopefully soon-ish.

vgy7ujm 9 years ago

Between those two Ruby. But always Perl first if using dynamic programming languages. Never Python.

kapauldo 9 years ago

Who flagged this?

  • gspetr 9 years ago

    HN tends to be SF-centric and SF is RoR-central, probably the reason why they flagged it.

Keyboard Shortcuts

j
Next item
k
Previous item
o / Enter
Open selected item
?
Show this help
Esc
Close modal / clear selection