Preferences

As someone who doesn't do enough web dev to justify learning Ruby just for Rails: how does it compare to Django? That's the only batteries-included web backend framework I'm familiar with...

Asking out or curiosity.


Having years of experience in both, though not recently in rails, these are some of my thoughts:

Obviously Django ties you into python and its ecosystem while Rails means ruby (and its gems). The ecosystem is more important than the language. This can either impact your project a lot, or not much at all, depending on context.

Rails doesn't have the equivalent of Django's admin CMS. There are gems but Django is still much stronger. A lot of orgs have their entire CMS / administrated-by-staff part of the product written in it.

Rails, otoh, has a very powerful scaffolding cli. If you are proficient, you can generate some basic crud stuff in minutes from A to Z.

In general, I think Rails is at an even higher level of abstraction than Django. A lot of the architecture or structure is more or less given with rails, whereas you need to make a lot more choices with Django yourself. Routing is a good example. The 'batteries' that are included are also a bit bigger and seem to be in much more active development than Django.

Also a generalization: rails/ruby seems to value brevity and the DRY principle a lot more than is common in django/python. There's a split in taste on this, often python devs find the 'magic' of Rails rather frivolous and unreadable - even though django has a fair bit of metaprogramming itself, whereas Rails devs think the 'pythonic simplicity and straightforwardness' is actually rather crude. Or to be a bit more precise: in the rails world, code duplication seems to be thought of as a greater evil than semantic coupling.

I realize these are all quite subjective, and probably reflecting my own development experience more than being an accurate feature-by-feature comparison.

This is my go to line and nobody has challenged me on it thusfar:

If I was building a web ‘app’, consumer facing product, I’d reach for Rails. I think scaffolding up to ‘market ready’ seems easier in Rails. I say this having never really done this in production.

For internal tooling (using the admin panel), data based work, or geospatial work, stick to python

The biggest difference is python vs ruby. Python’s ecosystem is massive, so if you want to pull in any third party libs you have plenty of choices for whatever you may need. Django also has auth and the admin interface built in, both of which are very nice.
Python might be bigger outside of the web but for any Web app, Rails wins hands down on the amount of battery included software that exists in my opinion.

I've done both and I find that in Django I had to resort to more manual steps than what I'd do in Rails.

The testing story is also better in Rails compared to Django, that's not even close.

Ruby and rails’ ecosystems are also massive. Devise and ActiveAdmin are options for those two, though I haven’t used either in years.

With much of the AI development happening in python and typescript, you might be right about those areas.

RoR's ecosystem is indeed massive - for web apps. But if you want to make an app that integrates with an existing domain, Python is just so far ahead. Numpy, SciPy, Pandas, basically the entire field of astronomy and biology, data science and FinTech... the list goes on.

But if you are sticking to basic web/database stuff it's hard to go wrong with RoR.

All of that extra stuff can still use Python and integrate easily with an RoR app. Typically your astronomy/biology/ata science stuff isn't needed in the context of a request and is done asynchronously
This is just not true. I’ve worked with many scientists, none of them want some complicated micro service architecture they have to deal with. They just want a page that displays their data or whatever, and that means using Django or flask and using whatever library they write directly. Most people haven’t even heard of ruby.
a best of both worlds solution might be to have a Rails web app and Python services. Of course if you like Django/Python better anyway, then just use those.
One place that I think there is a big difference in developer experience is in testing. Rails, as described in the article, comes with CI setup and corresponding tests are automatically generated when using rails generators.
Historically, Django Admin is better (in terms of ease of use and flexibility) than anything equivalent in Ruby, but Rails has better conventions for tests and routing. (Or at least that's my opinion.)

I also like ActiveRecord + Arel more than the Django default ORM, but that's more so preference driven by like the Ruby AR syntax more than the Python. (And a general unsupported opinion that Ruby is a slightly better/more pleasant language for writing code than Python.)

I would say that Avo is by far the best Rails admin-like solution out there. It's beautiful.

https://avohq.io/

Ruby doesn't really have a learning curve... Maybe block syntax but that's super easy.

Rails gives you way more structure than Django.

I tell people that Ruby is a language optimized for reading. Things just make sense when you are reading what someone else wrote, but it can be much more difficult to write something from scratch with no guidance. Take dates, for example. Let's say you are fixing an issue, validation was set to accept one week in the future, but should have been one day in the past. 1.week.from_now becomes... well, how do you look that up? You head to the Ruby Lang site and look up Integer, but Integer doesn't have `.week`, so now you have to rely on Google-fu to find what you need, but you'll get a mix of base Ruby and Ruby on Rails, which modified base classes with some syntactic sugar. Eventually you find 1.day.ago and file that away, only to go through the same research for the next line you need to change.

It can be one of the most pleasant languages to read, but a lot of hidden knowledge is required to write it like Ruby wants you to.

Literally everything you described is fixed by reading the documentation.

Using Rails? Read Rails documentation.

Using bare Ruby? Read Ruby documentation.

And literally every programming language is like this. C# won't contain Unity C# classes. Basic Python won't have Numpy classes. JS won't have React functions. And so on. Also it's not like Ruby is the only language to ever have monkey patching...

It's absurd that this is being brought up as a Ruby weakness when both the Ruby website and the Rails website each have amazing documentation and if you actually read the documentation, go through tutorials, it's all laid out very clearly.

https://www.ruby-lang.org/en/documentation/

https://rubyonrails.org/docs

Dunno, whenever I learn a new language, I read the official docs. When I learn a new framework, I read the official docs. Even when I was an absolute newbie, I learned from the resources on the official website.

That isn't Ruby, that's Rails. Ruby doesn't have nearly as big of a learning curve as Rails.
You may be overestimating the rest of us. It took me years to get fluent and I'm still learning after 12 years full time in Ruby. Sure you can learn the basic syntax in short order, but for us muggles, not the quirks of the standard libraries, let alone the whole ecosystem.
There's always things to learn. Ruby does have enough features that you can take years to memorize things, sure. But to learn enough to make a program that does useful things doesn't take long. If you already know how to program in a different language, maybe a weekend at most.

Ruby was my first language and it didn't take me long (maybe a week of very part time tinkering) to learn how to make a basic 2D platformer game, or scrape the web for financial data and throw it into a database. The first time I made a Rails app it took maybe 30 minutes, to go from nothing to a basic CRUD app that does things and is online on Heroku.

In a professional context, I've heard of non Ruby devs getting up to speed pretty quickly. And as much as there might be to learn mastery, it's still a dynamic language that takes away most details for you (like managing memory) so you can definitely be useful far quicker than if you were to learn C, Rust, Haskell or shudders C++.

Ruby _definitely_ has a learning curve
Especially reading other people’s code.
Not my experience
If you are coming from a standard C family language like Java(script), Python, or anything really, Ruby looks weird AF. It for sure has a learning curve. No parens around function arguments? WTF is that?
Interesting. When I first learned programming in the 90s as a kid, it was Visual Basic (no braces). A good friend of mine was super into Lisp. My dad (who was a programmer) also had loads of Delphi (Pascal) books, apparently it was the language to use in the 90's for quickly building apps. Again, no braces. So definitely not something I really cared about when I started learning Ruby (among other things) in the 00's.

When they taught us programming in school, Scratch was the first thing they taught. Then Python. I was in Econ as opposed to CS so then it shifted to Stata and R (for those who didn't want to pay for Stata and were more into current trends). For dropping down to low level, Fortran.

I guess where I'm getting at is maybe I just learned at a particular time when there were lots of programming languages that didn't have braces and were popular? Dunno. C was seen as low level sorcery, C++ was for games, Java I guess did become popular by the time I was in university but only the CS kids destined to become enterprise programmers used it.

All the "learning" languages I encountered didn't have braces. Nodejs didn't exist yet. So yes, Ruby was very intuitive. It read almost like plain English, had very consistent syntax and was very accessible on Linux systems (which were becoming more common and already very good by this time). Being able to just "blah install Ruby", then open a REPL, have an interactive environment and run things immediately was very easy.

This item has no comments currently.

Keyboard Shortcuts

Story Lists

j
Next story
k
Previous story
Shift+j
Last story
Shift+k
First story
o Enter
Go to story URL
c
Go to comments
u
Go to author

Navigation

Shift+t
Go to top stories
Shift+n
Go to new stories
Shift+b
Go to best stories
Shift+a
Go to Ask HN
Shift+s
Go to Show HN

Miscellaneous

?
Show this modal