
Ask HN: As a Python developer, what am I missing for not using Ruby? - 15DCFA8F
Over the last couple of years I have been programming in Python almost exclusively (and some JavaScript, Bash and Go for some specific tasks, easily chosen for the task at hand instead of Python).<p>What I found with Python is that it is a great platform for doing my things, like web services, data transformation, general Linux automating, infrastructure monitoring, and so on.<p>As it is good enough for 90% of my needs, I settled down on it and now I feel that I am missing opportunities of being more productive and getting more knowledge from other languages.<p>I looked at Ruby and found some interesting aspects (as a former Perl programmer), with its expressiveness. I learned a bit of Ruby, but I keep doubting myself if Ruby language and platform would bring me more value or that would only bring fragmentation on my projects.<p>I do not look to replace Python, but want to know if there would be some clear decisions points to take when choosing between Python and Ruby for my next projects, or both are more or the less a tool to solve the same problems.<p>If any of you worked or work with both languages, sharing your experiences would be greatly appreciated.
======
webmaven
I'm a mostly Python / occasionally Ruby web developer.

There isn't much you're missing. About the only use-case I can think of where
Ruby has a clear advantage is in creating a DSL.

Other than that, there are differences in what already exists in the two
ecosystems, but (at least for web development) generally there are equivalents
available (eg. Nokogiri vs. BeautifulSoup). The Rails and Django frameworks
are roughly comparable, for example, with Rails being more 'magical' vs.
Django being more explicit. Which one is better for you may just come down to
your personal tastes.

Now, outside of web development, Python has a clear advantage in areas such as
scientific computing, game development, machine learning, and many other areas
in which Ruby doesn't really have much of a presence. This isn't due to any
inherent quality of the two languages, just historical contingency, as Ruby's
emergence from obscurity was a result of Rails taking off, whereas Python grew
a large and eclectic user community (of which web development was a small
part) more slowly, but starting years earlier.

~~~
paulddraper
> About the only use-case I can think of where Ruby has a clear advantage is
> in creating a DSL

Yep. Chef and Puppet (machine configuration tools) are written in Ruby.

~~~
cweagans
Ansible is written in Python and they didn't have to invent a DSL to make it
work ;)

~~~
paulddraper
Ansible is written in anything that generates json

~~~
cweagans
Ansible itself is written in Python, but yeah, the plugins can be written in
pretty much anything.

------
FraaJad
As a python programmer for over 15 years, you will be better served by
learning a PL from a different paradigm

* Erlang/Elixir -- concurrency

* OCaml/Haskell -- static typing etc.,

* Typescript/Elm/Purescript -- better Javascript

* You get the idea ...

more so than Ruby. Ruby lives in the same neighbourhood in the galaxy of
programming languages. You are not missing much by ignoring Ruby.

------
hodwik2
If you're going to learn another language, learn something from a different
programming paradigm, or one which is lower level.

Learning Ruby would be an absolute waste of time.

This isn't a hip or cool answer, but I'd suggest learning Java. It's one of
the most popular languages by a large margin, and knowing it will help you
speak the object-oriented lingua franca. If you only write Python, you're
probably mostly writing procedural code. Learning OO is a good idea.

~~~
odinho
This is so wrong I don't even know what to say.

Python is a beautiful object oriented language. Very much so.

Java is not different at all, I'd say go for Haskell or similar to get
something really truly dif

~~~
hodwik
Python has all of the constituent parts of an OO language, save explicit
types, but it is never written in an OO style.

Using classes != OO.

Generally, Python programmers treat objects as structs with associated
methods, basically the Go model. Python programmers rarely encapsulate at all.
At best, they use a bunch of accessors (which is not itself OO).
Implementation details are rarely hidden.

That's because dynamically-typed languages, the interpreter, and the Python
culture, lend themselves more to exploratory programming, rather than a UML-
design, with objects that relate to real-world entities, that are implemented
after careful planning.

If you can show me a Python program where objects are really encapsulated, and
aren't chock-full of accessors, I'll stand happily corrected.

------
schappim
I've been a Ruby (not rails) developer for 10 years and use python when
hacking together hardware projects.

Generally speaking Ruby has a better standard library, the major libraries
(gems) seem to be better built with nicer APIs and unit tests.

I think the best example of Ruby at it's best is the Sinatra web framework.

Having said of this, I don't think that Ruby is the language of the future.

In my humble opinion the language combination of the future is going to be
Python as my interpreted language of choice + Swift* (for when I want a more
strongly typed / functional language or when I need things to be fast).

* Swift could be my only language if they had an interpreter.

~~~
jboy
Hi Marcus, have you ever taken a look at Nim? It's quite similar to Swift in
several respects, but it has a primarily Python-like syntax (including
indentation by blocks rather than braces) with bits of Ruby & others mixed in.

Useful links: [http://nim-lang.org/](http://nim-lang.org/) , [http://nim-
lang.org/docs/tut1.html](http://nim-lang.org/docs/tut1.html) , [https://nim-
by-example.github.io/](https://nim-by-example.github.io/) , [http://nim-
lang.org/docs/manual.html](http://nim-lang.org/docs/manual.html)

At work, we use Python as our interpreted language & Nim as our fast,
strongly-typed, compiled language. We created Nim-Pymod to enable Nim code to
be compiled into Python modules: [https://github.com/jboy/nim-
pymod](https://github.com/jboy/nim-pymod)

There's also a web-framework in Nim called Jester, which describes itself as
"a Sinatra-like web framework":
[https://github.com/dom96/jester](https://github.com/dom96/jester)

~~~
laingc
> At work, we use Python as our interpreted language & Nim as our fast,
> strongly-typed, compiled language.

You most likely didn't mean to, but your sentence implies that Python is not
strongly typed.

~~~
JustUhThought
Just in case anyone else is tired and drew a blank and needs to google that,
the confusion was that of strong vs weak not dynamic vs static. Strong vs weak
applies to explict vs implicit type changes. Dynamic vs static applies to run
time or compile time type assignment.

[http://stackoverflow.com/questions/11328920/is-python-
strong...](http://stackoverflow.com/questions/11328920/is-python-strongly-
typed)

------
amorphid
I like what a friend of mine who went from Ruby to Python said... "Python is
easier to understand, harder to love."

For me personally:

* I like Rubygems & Bundler more than Pip

* I find the split between Python 2.x and 3.x to be obnoxious

* Python whitespace indentation bugs me a lot

TL;DR -- Python isn't much different than Ruby in terms of what it can and
cannot do. Personally, my new favorite language is Elixir, which does a whole
bunch of stuff neither Ruby or Python does particularly well.

~~~
xkcd-sucks
I hate whitespace indentation on principle (and practice of copypasting code
written in a different editor). But after spending too much time trying to
parse endless )})})}}} in JavaScript, the Python approach seems like a much
better way of doing it.

It seems like pure C programmers are pretty well behaved with their curly
braces through.

Any radically different blocking paradigms besides indentation and
parenthesis-like things?

~~~
stephenr
The same indentation Python uses in lieu of closing curly braces, can help
your issue, so instead of:

    
    
        [].map(function (foo) {baz(bar(foo))});
    
    

You could write:

    
    
        [].map(
            function (foo) {
                baz(
                    bar(foo)
                )
            }
        );
    

Alternatively (or in addition to that), use a decent IDE, which will highlight
matching parenthesis, curly braces, allow code folding, etc.

I've never heard a builder say "I don't like screws, nails are better because
they work better with my hammer".

------
atrudeau
From a practical point of view, I'd agree with others: you're only missing a
checked box on your resume.

From a non-practical point of view, you're missing out on the pure joy of
writing Ruby. Everyone should try it at least a couple of times to see just
how expressive and fun programming can be. As someone who programs regularly
in Python, Go, JavaScript, and Java, Ruby blows them away in FUN points.

As a side note, it would be awesome if someone wrote a Ruby -> Python
compiler. I would love to be able to call NumPy from Ruby code. I would even
be happy with a (generous) subset of the language. I think gluing together
Python libs with Ruby would be a pleasure, and people could start using DSL
magic to implement better APIs for existing libraries.

------
danso
I was a Rails dev for a few years and have now moved to Python, but only
because I now do more data analysis and little web dev.

You're not missing much...in terms of practical benefits, you're missing out
on putting Rails on your resume. In terms of programming experience...you're
missing out on the meta-programming and fun monkey-patching that Ruby's syntax
invites. And multi-line lambdas.

As someone who loves Ruby, I could not argue that learning Ruby is an optimal
use of time for the Python programmer...you'd be better off focusing on
something lower level, like Rust, or highly differentiated in paradigm, such
as Elixir. FWIW, a notable number of well-known Ruby devs have left the
fertile life of Rails dev to pursue those two languages.

~~~
sevensor
You basically have multi-line lambdas in Python, it's just not anonymous
anymore -- you can define function bar inside of function foo and then pass it
to another function or return it from foo. I've used this to make a function
that builds functions for you.

------
kennell
I use Python whenever i can, but had some Jobs where i was doing mostly Ruby
on Rails.

For me some of the differences are:

* gem > pip

* Ruby on Rails is much more mature than Django. The framework itself and the surrounding gem ecosystem... it's like its 3 years ahead of Django. Don't get me wrong, you can get anything done i either framework, but Rails just gets it right more often and is better suited for modern web development. You get a testing/dev/production setups, a asset pipeline and a lot of other stuff right out of the box, where as in Django you find yourself fidling with third-party packages of varying quality. * you can build very neat DSLs if you are into that

On the other hand:

* Outside of web development; Python seems to have a broader selection of high-quality libraries (especially in the analytics/datascience category)

At the end of the day, i think both are pretty much equal suited for most
tasks.

------
imauld
IMO Ruby and Python are two sides of the same coin. They have their
differences but whatever you can do in one you can usually do in the other.
I'm a Python programmer myself and I find the "magic" of Ruby code I've seen
slightly unsettling at times, explicit is better than implicit after all ;-).

One of the main disadvantages to Ruby, based off my limited knowledge of Ruby,
is that if you are making a web app with Ruby you are making a Rails app. With
Python Django is probably the most popular but it's far form the only one
(Flask, Bottle, Falcon, Web2Py, CherryPy, Pyramid, Zope, etc.).

If you are interested in learning another language I would suggest Go. The
syntax is easy to pick up if you are a Python dev and it can do a lot of
really cool things with a pretty small amount of code.

DISCLAIMER: I have only done the most basic of Ruby tutorials but none of them
have inspired me to learn more.I also hate ``end``.

------
nurettin
Ruby can be used the same way as perl when building commandline tools that use
repl and regex. ($~,$1,$2, etc.)

You can also add new methods to classes and you can override callbacks such as
method_missing to respond to method calls at runtime.

You also have a choice between lazy and non-lazy versions of
map/reduce/select.

You also have a rust interface to create gems that run native code.

You also get an extensible build tool called rake.

You also get RoR5 if you enjoy that kind of thing.

~~~
steveklabnik
You can write Rust extensions to Python as well, though the higher-level
interfaces aren't quite as far along in Python yet. There was a talk about it
at PyCon last year.

~~~
nurettin
Ah, I actually forgot about the rust-cpython package. The project is alive and
it works with python3, too.

That brings me to another point I want to make. There is no community-breaking
divide between ruby versions. People usually pretty easily port their 1.9 gems
to newer 2.x APIs without breaking much.

------
probinso
Tokens insread of strings as keys. Ruby has :tokenname instead of “tokenname“
as option for key like parameters

~~~
sevensor
Possibly the Ruby feature I miss most in Python.

------
anilgulecha
There's on beautiful thing you're missing at the language level:
method_missing. So much of ruby's power is derived from this one feature.

------
kristianp
I'm in the reverse position of knowing Ruby but not knowing Python. What am I
missing out on by not knowing Python?

It seems machine learning is one thing, that is much better supported from
Python, but anything else?

~~~
gravypod
There is a wide range of scientific computing libraries for Python. I'm fairly
sure none of them have been ported over to Ruby.

If you're not interested in that not much.

I'd say the only thing that's different between the two languages is when you
ask "How do I write fast Ruby" the people who work on the VM and libraries
yell back "Here are N fixes that improved the speed of the runtime two fold."

When the same question is ask, but as "How do I write fast Python" there is a
resounding "You write C/++, not Python."

I think that's, in my opinion, the biggest differences between the languages:
their community's and their community's attitude to optimizations.

~~~
hcarvalhoalves
> When the same question is ask, but as "How do I write fast Python" there is
> a resounding "You write C/++, not Python."

Cython and PyPy get you pretty far.

------
bobwaycott
The only thing I've ever felt I'm missing in Python, in comparison to Ruby, is
the 'unless' keyword and much nicer metaprogramming.

------
boraturan
I am on Win/.NET, am I missing something?

------
collyw
Thick rimmed glasses and a bushy beard.

