loading...
Cover image for Why should I not choose Ruby on Rails ?

Why should I not choose Ruby on Rails ?

martyonthefly profile image Sylvain Marty ・2 min read

Hi everyone!

Over the past months, I have worked on backend specifications for a personal project. I must now choose the framework I’ll be using.

On the one hand, I’ve been working on a system built with Java Spring for the past 2 years, and I have been wondering if knowing a technology is a good enough reason to chose it over other languages and/or frameworks. Still, I know that Spring is stable, fast and adapted for big project and can save me a lot of time.

On the other hand, I know that some big companies use Ruby on Rails to build their services (like Gitlab, Airbnb, 37 Signals, etc.). From what I know, RoR seems to be a stable and strong framework.

I looked at some benchmarks between those two on the net (links at the bottom), but I find myself more lost than I was previously.

Here’s my question: Why should I not choose Ruby on Rails ?

Here are my project’s needs:

  • must deal with a big amount of data and entities

  • will connect with a GraphQL API (more than 70 endpoints)

  • public and private endpoints over HTTP and HTTPS

  • OAuth2 authentication provider

  • probably a few WebSocket endpoints too

For me, this framework choice is very important because it will help me decide what language I need to use to make internal and external services around the final product. For example, if in the future I need to make a program to control hardware or device like printers, I will use the same language I used to develop the backend in order to make maintenance easier.

I know my question isn't very specific so maybe a list of features I’m interested about will help:

  • maintenability: code quality, number of line of code

  • reusability: make the code more modular, generic

  • performances: HTTP(S) request (JSON or HTML responses), databases

  • templating: what engine can I use (what is the best ?)

  • unit testing, code coverage and Selenium test

  • scalability

  • continuous integration

Some benchmarks found on the web :

Credits :

  • cover image from perfectial.com
  • A great thanks to Thierno which helped me to review this article <3

Discussion

pic
Editor guide
Collapse
bgadrian profile image
Adrian B.G.

Quick answer, because Go is better.

It is just me or all your needs are met by Go? You do not need a framework, making backends is very easy.
Server intro example

It's low level so your future hardware control should be easy to add.
Scalability is one of the key factors of Go
Testing - it has builtin unit testing and benchmarks tools
Large amount of data & performance - see 1M requests per minute with 2 servers
Reusability - the languages enforces the usage of small packages.
Continuous integration - yes. It's light, you do not need a container, you will have only 1 binary file
templating - it has a builtin simple template system

You will learn it fast.

Collapse
martyonthefly profile image
Sylvain Marty Author

Hi Adrian,

Thanks for the sources, they are very helpful.

I am currently interested by Golang and the performance that it provides. To be honest, I love how so easily the language deals with stuff like routine, code coverage, cross-platform development, etc.

Nevertheless, I am a little worried about two things that slows me a lot to choose this language : dependency management and the project's files structure. I know that dep is in the good way but I am used to Maven and its stability, so
it frightened me a little. About the files structure, I don't want to mess with packages arborescence and I didn't find a good example of file structure on the web yet. :/

Thanks for your reply !

Collapse
bgadrian profile image
Adrian B.G.

Hi, the official dependency management is almost launched, see here.

The structure I find to be a plus, packages == your business logic == your structure. In Php/Ruby etc you have to obey a Frameworks structure, not your business one, which I think is a big flaw.
repo/user/project/
repo/user/library1/
repo/user/entities/entity1

Collapse
martyonthefly profile image
Sylvain Marty Author

In addition about the lack of dependency management, I would say that it frightened me because Go provide a large ecosystem that contains certainly all my needs (OAuth2 provider, GraphQL implementation, etc.). So, if my system have to be based on other's work, I really want to have a good and stable dependency management. :)

Collapse
lpasqualis profile image
Lorenzo Pasqualis

RoR is great to get started. It allows you to make great progress quickly, and get a service up and running in no time. It can save you a ton of time and money. However, since you are asking "why not," here are a few major pains:

  1. Rails is upgraded with little regards for backward compatibility. Major changes can be made from version to version, and the upgrade cost can be significant. Sometimes it is almost a rewrite.
  2. You can scale applications written in Rails, but it is expensive. It is quick to get started, and it can scale somewhat easily to medium sizes, but at some point in your growth, you'll find yourself spending an amazing amount of time optimizing. The best way to approach the problem is to write very efficient code from day one, but it takes some considerable effort in RoR given that the language and the framework are pretty slow compared to other choices.
  3. Compared to other technologies, you'll need more machines to serve the same amount of traffic. Ruby is slow, and Rails is heavy, so you need a lot of hardware to scale.
  4. RoR code tends to be very "magic." Maintainability is not a great strength of the framework and the very weak typing of the language also makes the code increasingly difficult to maintain over time.

That said if I was starting a project I'd probably choose RoR. It gets you started and going quickly and you can worry about scale to the next level when you get there. At that time, there will probably be something new and better anyway.

Collapse
tracypholmes profile image
Tracy P Holmes

And #4 is currently what perplexes me! SOOO much magic. I'm in bootcamp right now, and the curriculum is fine. Actually on my first Rails project. However, my brain can't deal with the magic at times and it's slowing me down! I've had people tell me to look at GO (like many folks in here), but I really do want to understand Rails. Maybe I just need to walk away from it for a while...

Collapse
lpasqualis profile image
Lorenzo Pasqualis

They call the pattern "convention over configuration". You could name it "magic over logic", but that wouldn't sound too good :-)
The major issue I have found is that when something is magical, the way the magic works can change over time, and there is nothing that tells you. That is one of the reasons why upgrading to new versions of Rails is never too easy.

Thread Thread
tracypholmes profile image
Tracy P Holmes

(had profile issues, but it's me!) Thanks! I actually like "magic over logic". It's a good band name - but also very true.

Thread Thread
lpasqualis profile image
Lorenzo Pasqualis

It is a good band name, isn't it? :) Also, it the domain name is not taken :)

$ whois magicoverlogic.com
No match for "MAGICOVERLOGIC.COM".
>>> Last update of whois database: 2017-09-12T22:06:14Z <<<
Thread Thread
lpasqualis profile image
Lorenzo Pasqualis

It didn't take very long :)

$ whois magicoverlogic.com
   Domain Name: MAGICOVERLOGIC.COM
   Registry Domain ID: 2162361165_DOMAIN_COM-VRSN
   Registrar WHOIS Server: whois.namecheap.com
   Registrar URL: http://www.namecheap.com
   Updated Date: 2017-09-12T22:15:12Z
   Creation Date: 2017-09-12T22:15:10Z
   Registry Expiry Date: 2018-09-12T22:15:10Z
   Registrar: NameCheap Inc.
   Registrar IANA ID: 1068
   Registrar Abuse Contact Email:
   Registrar Abuse Contact Phone:
   Domain Status: clientTransferProhibited https://icann.org/epp#clientTransferProhibited
   Name Server: DNS1.REGISTRAR-SERVERS.COM
   Name Server: DNS2.REGISTRAR-SERVERS.COM
   DNSSEC: unsigned
   URL of the ICANN Whois Inaccuracy Complaint Form: https://www.icann.org/wicf/
>>> Last update of whois database: 2017-09-12T23:36:14Z <<<
Thread Thread
tracypholmes profile image
Tracy P Holmes

:kaff:

I wondered if you were going to see that! LOL. Just know it's in good hands! Thank you so much for the idea. I feel like we could make a twitter account for it that....oooh. Give me a sec. I feel a project coming on!

Thread Thread
lpasqualis profile image
Lorenzo Pasqualis

Haha, that's cool. When you bring up the side just consider adding a link to my blog somewhere. That's all I ask :-) ;-)

Thread Thread
tracypholmes profile image
Tracy P Holmes

Will definitely do!

Thread Thread
lpasqualis profile image
Collapse
martyonthefly profile image
Sylvain Marty Author

Hi Lorenzo and thanks a lot for your reply !

When I posted this post on dev.to, this is the type of answer I have expected :)

I didn't know that Ruby and RoR were slow !

About your last sentence, I'm also reading about GoLang to see if it can be a good choice. I didn't find a good framework yet but it seems like the ecosystem contains a lot of modules that can be used to build backend services. Any idea about this language ?

Collapse
lpasqualis profile image
Lorenzo Pasqualis

GoLang is new(ish) compared to other languages. It was developed by Google and it is quite low-level. It is very fast, mostly because it is a compiled language that compiles to native code.

I don't have any direct experience with it, I only worked with it for small experiments. I am aware of the existence of a framework called revel, but I don't have any direct experience with it.

I also heard people say that you don't necessarily need a framework with Go, because it was created with modern Web development in mind. Here is an article on the topic.

If I had to start a project I'd choose Ruby on Rails if I want to get something running quickly. I'd choose GoLang or Java if I wanted something fast that can scale well.

That said, note that there are several very large websites built in RoR (including GitHub). So, it is possible to do it. It just takes some work a good design. Another example is dev.to itself, that is also built on RoR, and it is nice and fast.

Collapse
rossbates profile image
Ross Bates

Hi Sylvain - integration with external services and 3rd party APIs is something that's a strength of Ruby/Rails that's often overlooked when people are comparing web frameworks.

Browse rubygems.org to get a sense of the size and scope of the contributions made by the community. As your app grows and you look to connect with other services for authentication, storage, monitoring, etc... you'll find that someone has already written a gem for that service resulting in less code that you need to implement.

I won't lie, this can lead to dependency hell if you start adding others to the dev team. But in the long run you're still more productive than writing everything from scratch.

Collapse
dakull profile image
Posăceanu Marian

The best way to approach the problem is to write very efficient code from day one

or you could just start with JRuby from day one :-) i.e. have your cake and eat it too

Collapse
lpasqualis profile image
Lorenzo Pasqualis

Yes, starting with JRuby is a good strategy as it allows you to write parts in Java, if you need the speed. You give up compatibility with some gems, but if you start that way it should not be a huge deal. Regardless, it is still slower than other technologies and you have to deal with Rails, which is still heavy (but things are getting better overtime.)

Thread Thread
dakull profile image
Posăceanu Marian

you have to deal with Rails

Rails is quite modular [0], [1] - one can easily strip the heavy parts or replace ActiveRecord with Sequel; bonus: with concurrent-ruby [2] things get fast real quick.

[0] - modular Rails controller
[1] - modular Rails
[2] - ruby-concurrency gem

Thread Thread
lpasqualis profile image
Lorenzo Pasqualis

It is definitely improving. Version 5 is quite modular. It is a new(ish) thing and it has indeed changed the game quite a bit. Before version 5 it was just mostly a big fat thing :) It has been a slow progress, and I hope they don't screw it up. The unfortunate way they tend to deal with backward compatibility is still somewhat of a concern, but maybe they'll figure it out. If one is willing to always upgrade to every new version religiously, then things get easier. The major problem I have seen is when people stop keeping up.
Threading in Ruby is not real parallelism. Also, most gems out there are not thread-safe, which makes it difficult to work with threads in Ruby.
That said, I am far from being bashing Ruby on Rails. I have been coding in RoR for 10 years, and I like the framework. One just needs to be aware of the tradeoffs and cost at scale. I have been through that pain with versions 2, 3 and 4 and it wasn't fun :) Version 5 promises to do better, but I don't have much experience with it yet.

Collapse
hrishio profile image
Hrishi Mittal

I’ve been working on a system built with Java Spring for the past 2 years

Stick to what you know. Use Java Spring.

I say this as someone who does not like to touch Java and uses Rails for a living.

The no.1 thing that will kill your project is not language/framework slowness, but messing around with tools instead of shipping software.

Collapse
martyonthefly profile image
Sylvain Marty Author

Hi Hrishi,

This is a side project that I work on my free time. So, I have the time to choose, try and learn the most adequate language for my project. :)

But yeah, you are right, if a project need to be shipped in a short time, I would rather use Java Spring to avoid messing around with tools !

Thanks for your reply !

Collapse
hrishio profile image
Hrishi Mittal

Ah I see. If you want to explore, then go wild! I'd say try Node as well as Rails.

Collapse
bgadrian profile image
Adrian B.G.

Basically you recommend the "when you have a hammer everything looks like a nail". Not a good approach for professionals.

Anyway Java can do web services, but shouldn't.

Collapse
lluismf profile image
Lluís Josep Martínez

Or maybe because both Spring and RoR are swiss knifes, not hammers. Both perfectly valid for the task.

Collapse
soundstruck profile image
Dina Gathe

Have you had a look at Phoenix/Elixir? It checks off many of your boxes. When I was hunting for a framework I had criteria very similar to yours, and I ended up with Phoenix/Elixir.

Here are some interesting links to check out:

Phoenix/Elixir Overview
Pinterest re: Elixir gains
Bleacher Report 18 months in Production
Moz.com use

I've been developing side projects with Phoenix/Elixir (and Vue) for about a year now...happy to connect if you're interested in delving any further. My projects are smaller and don't yet have the scaling requirements, which is why I included those links above as those companies are using it at a much larger scale in production.

Collapse
enether profile image
Stanislav Kozlovski

Unfortunately this requires a shift in programming paradigms, something that will severely slow most developers. The framework is new-ish as well and support (e.g stackoverflow answers) is still not up to par with RoR.
I'd argue it is not worth it unless the author really needs to scale his application.

Otherwise, I agree, Phoenix is an amazing framework!

Collapse
aghost7 profile image
Jonathan Boudreau

From what I've read it seems that most large companies have more than one application component in their stack. For example twitter uses RoR for its frontend but the API is written in Java/Scala (using finagle framework IIRC).

To me it sounds like one of the major deciding factors will be the ability to process large amounts of data. The only two languages which I can think of that have a proven track record for this is Python and Java. I don't recommend going with something risky like Go or Elixir for a project that sounds fairly large.

Collapse
martyonthefly profile image
Sylvain Marty Author

Do you have sources that explain how they manage their stack of applications ? I would love to see how those companies deal with differents runtimes ! :)

And yeah, I know that Java can deal with a large amount of data but I don't want to be stucked in a language that I choose because I know it. ;)

Thanks for your reply !

Collapse
aghost7 profile image
Jonathan Boudreau

Their setup is pretty complex to say the least. IIRC they're using puppet, mesos, etc as part of their infrastructure.

If you're looking for how to manage this on your own project I recommend just learning a configuration management tool like ansible, saltstack, puppet or chef. I personally prefer ansible.

Thread Thread
martyonthefly profile image
Sylvain Marty Author

I didn't know the existance of that kind of tools! I will take a look, thank you. :)

Thread Thread
aghost7 profile image
Jonathan Boudreau

Its a bit like a script runner. For ansible its just a YAML configuration and setting it up is pretty simple. You just need ansible of installed on the machine you're executing your "scripts" (they're called playbooks in ansible world) from and ssh configured for all of the servers you want to automate.

Collapse
rhymes profile image
rhymes

If you want to delve in Ruby/Rails performance I would start here:

Scaling Ruby Apps to 1000 Requests per Minute - A Beginner's Guide
Is Ruby Too Slow For Web-Scale?

Obviously each app has its own requirements, traffic and consideration but one thing I've learned over the years in web development is that Donald Knuth's "premature optimization is the root of all evil" still holds ;-)

Start with what you know. Analyze each requirement and see if your platform of choice has all the tools and the libraries you need. Also consider if the app is going to be developed by you or a team of people and so on.

Finding people to help you with Java or Ruby is way easier than finding talent in Elixir.

As with most "is this better than that?" questions the answer is almost always: it depends.

Collapse
martyonthefly profile image
Sylvain Marty Author

Hi,

Thanks for the links, I will had them in my research ! I know that optimization is evil when we start to develop a project. But like others said in their replies, if the language and/or the framework are slow, optimization will be needed earlier than with other languages.

About the question "is this better than that?", it was the first title of this post. I thought that it wasn't the good question. Then I asked myself "Why do you want to compare Java Spring with Ruby on Rails?" and I knew that it would be a debate that I had already read on the internet ! ;) What I really wanted to know is the experience of others about this language : why they left it or why they chose it. I'm glad to see that the community bring me a lot of answers that I didn't find on the internet before. :)

Thanks for your reply !

Collapse
rhymes profile image
rhymes

No worries.

I think it's important is to find the balance between speed of development, time to market and available skills. If it takes you double the time to develop in Elixir instead of Spring and then you have a system that only you can work on, the "superior speed" might not matter.

That's my point, sorry if it wasn't clear earlier.

Collapse
gregopet profile image
Gregor Petrin

Because Ruby is wacky? :) (sorry, personal distaste for Ruby :p)

But you could try Grails as a mix of both worlds: inspired by Ruby on Rails, powered by Spring Boot, in active development since 2005, uses Groovy as its language (Groovy is like injecting Ruby mojo into Java).

I've completed several projects with Grails and while I'm increasingly using micro-frameworks lately for web, Grails is still a very fine framework.

Collapse
martyonthefly profile image
Sylvain Marty Author

Hi Gregor,

I will take a look on Grails to see how it works ! I already tried the Kotlin implementation for Spring and it was very cool to use :) Nevertheless, I don't know if Grails is similar to Kotlin...

Thanks for your reply !

Collapse
gregopet profile image
Gregor Petrin

Grails is a framework while Kotlin is a language so you can't directly compare them.

You can compare Grails vs. Spring Boot (regardless of the language in use, and you have quite a few to choose from) in which case Grails is a more opinionated, convention-over-configuration framework with lots of helpers, integrations and concepts that would be left for you to implement on your own in Spring Boot. It has, for instance, its own persistence framework, based on Hibernate down below but looking a lot more like Rails' active record to the programmer. There's plenty more: centralized URL mappings, command objects, a service layer, HTML helper tags and JSON & HAL renderers come to mind first, but do take a look at the docs yourself (and the docs are pretty good btw, which is a huge bonus).

As for the languages, Groovy and Kotlin are loosely related; Kotlin actually took a few of its concepts from Groovy (as did Swift). Groovy is a bit wilder, optionally typed, script-like language, comparable to Ruby. Crazy productive! .. though sometimes its wild side is a bit too much. Kotlin on the other hand is strongly typed, with extra strictness added on top (e.g. null safety and immutable variables). Personally I prefer to use Groovy for scripting and the view layer, and Kotlin for the business logic.

Theoretically, you could use Kotlin to write Grails code, but it's probably not optimal because a lot of the Grails magic relies on Groovy's concepts.

Collapse
tomerbendavid profile image
Tomer Ben David

I would go with RoR if Ruby was a statically typed language. As it's not I'm afraid that in most cases dynamically typed language can only be maintained (in really most cases) only by the developers who wrote the code.

Collapse
faustinoaq profile image
Faustino Aguilar

I would go with RoR if Ruby was a statically typed language

Oh, check Crystal [0] and Amber [1]

[0] - crystal-lang.org/
[1] - amberframework.org/

:)

Collapse
tomerbendavid profile image
Tomer Ben David

i see that both are "inspired" by ruby or RoR which means I won't have all the ruby gems (if i'm not mistake) and will not have all the RoR plugins... so i would still in that case unforutnately do the same and cannot go with them but prefer something more official which has more plugins like an official nodejs + typescrypt (because of the types in typescript) and then go with a major framework like angularjs/react/vue but this is only and only because ruby is not a statically typed language.

Collapse
kr428 profile image
Kristian R.

Well...... I'm more a Java and Python guy but I'd be extremely pragmatic about that: Choose whatever you get along with best right now and keep open to re-evaluate a given framework decision. Yes you might hit a wall using Ruby. Maybe you might end up in performance pitfalls, you might see certain requirements (like low-level development close to actual hardware) difficult to meet in your chosen tools.

Right now, it seems you're mostly in a draft / design state of your project, and I dare to say that (a) Java/Spring or any other Java based framework and Ruby On Rails would be able to meet your current requirements and (b) you could spend a few more weeks or months evaluating your framework of choice and still end up with a decision that will fall over two weeks after your project went "into production".

I'd rather, here, follow the agile approach of getting a "minimum viable product", a working early version of your desired application, out on the road as fast and with as little effort as somehow possible (including effort for comparing or learning languages and frameworks), let it roll for a few days or weeks, learn how it behaves, learn which trouble you will run into and which requirements actually will show up. By then, step by step your product will grow and you also will get a better idea of which problems you need to solve (including performance and stability requirements). By then, you also will have a much clearer idea of what your "ideal" programming language, the "optimum" framework, ... looks like. ;)

Collapse
martyonthefly profile image
Sylvain Marty Author

Hi Kristian,

Thank you a lot for your advices !

I am more and more thinking that it is the right decision : make a choice and build a minimum viable product then test it.

Collapse
faustinoaq profile image
Faustino Aguilar

Hi, I think you should try amberframework.org/ [*], It's similar to Rails, also you can try kemalcr.com/ if you like something more minimalist.

Here are my project’s needs:

  • must deal with a big amount of data and entities: I think crystal-db has this goal (created and maintained by core developers of crystal)
  • will connect with a GraphQL API (more than 70 endpoints): Well, a community active member is making things with GraphQL [0]
  • public and private endpoints over HTTP and HTTPS: Yeah,I think crystal support that, also a http2 lib was developed by a core member too.
  • OAuth2 authentication provider: Oh Yeah, crystal support that in the std, and a blog about that is here. [1]
  • probably a few WebSocket endpoints too: Yep, also in crystal std. Kemal and Amber support Websocket in a easy way.

[0] - github.com/ziprandom/graphql-crystal
[1] - auth0.com/blog/an-introduction-to-...

Also:

  • maintenability: crystal has good syntax, a few lines of code,
  • reusability: yeah, crystal is OOP and you also can bind C libraries easily.
  • performances: just see crystal-raw in latest TechBenchmark [0], simple as ruby but fast as Go, Rust and C.
  • templating: Crystal do have a embed template engine ECR (similar to ERB), Also Slang (similar to Slim) is a good template engine available as shard (library) for Crystal.
  • unit testing, code coverage and Selenium test: Crystal has a test suite in his std, similar to RSpec.
  • scalability: Crystal is improving compilation times and more platforms support is in the road.
  • continuous integration: Yeah, I think we are using that in crystal projects via CI and Travis.

[*] - Kemalyst was renamed to Amber
[0] - techempower.com/benchmarks/preview...

Goods points: blazing fast, compiled to binary, imperative Object Oriented (don't need to change paradigm), don't need a VM like Elixir, Ruby or even Java. Crystal is more like Go but with Ruby syntax.

Bad point: Crystal is a modern language but is still in development. I think we are moving fast and the community is growing more everyday.

Also see: dev.to/crystal-lang/we-created-the...

Official page: crystal-lang.org/

Collapse
martyonthefly profile image
Sylvain Marty Author

Hi Faustino !

Thanks for your reply, I didn't know the existance of Crystal and Amber Framework. I understand that many of my project's needs can be reached with a lot of languages and frameworks.

However, I wanted to know why I shouldn't choose Ruby on Rails, not what framework I need to choose in particular. :)

To me, this is very important because I'm already proficient on Java with Spring Framework but I didn't want to stop me at what I already know so, I learned how Ruby and RoR work. What I wanted to know is the experience of others on this framework and this language in particular.

Could you give me some sources about known companies that works with those languages and what difficulties have they faced with those technologies ?

Collapse
faustinoaq profile image
Faustino Aguilar

Yeah, Thanks you for your response!

I misunderstood the post, my bad :)

About Crystal, It was raised by manas.tech/ a company for unconventional projects.

Some companies are using Crystal to develop solutions in production see: github.com/crystal-lang/crystal/wi...

The main drawback they tell us in the community is Crystal isn't 1.0 yet. However We are joining efforts to bring an stable release as soon as possible, see: groups.google.com/forum/#!topic/cr... and salt.bountysource.com/teams/crysta...

Collapse
ksejka profile image
Collapse
enether profile image
Stanislav Kozlovski

The benchmarks here are two years old man :x