/ rails

Rails is still King

I remember the day clearly. It was a nice, sunny day in Boston's neighborhood of Brighton. I was a lowly project manager working for a QA company. Back in college I wasn't sure what I wanted to do. I had a mix of computer science and electrical engineering classes, but nothing really "stuck" for me. On this sunny day, I strolled into the brick building of the company I was assigned to. I walked in, sat down in a rickety chair, and began my job of looking for bugs in this company's software.

It was then I noticed something. This team of engineers, what were they working on? It seemed very interesting and appealing to me, for some reason. They were creating these new features for a web application, and it was all coming together so quickly. I'll never forget the feeling I felt vicariously through this team of engineers. Being able to create something, play around with it, and ship it to actual end users. It was such a refreshing idea -- actually creating things.

This magical code these engineers were writing? Ruby (specifically Ruby on Rails version 2.3.8). I knew I had to pursue this magical field of writing software. This experience forever changed my professional life in a very positive and fruitful way. I have had an amazing, fulfilled, and intellectually challenging career so far thanks to Ruby on Rails, and I'll never forget that day.

Thanks Rails

Thanks for the career Rails, I'll never forget the day we met :)



Lately I've been reading more and more about how Rails is dead. It's old, slow, crufty, and dated. Personally, I think that's all crap.

Rails ain't dead, it's still the King

I love technology, programming languages, and new frameworks. But if I were to build a product today, nothing would come close to Rails for its productivity.

I want to take some time and talk about Rails, and why that magic has never left. There are many amazing programming frameworks and technologies that have popped up over the years. Many of these technologies are extremely good at solving specific problems:

  • Elixir and Phoenix: Amazing at creating scalable web apps with functional programming and very clear to use parallel primitives. Built on top of a tested and true VM that can scale very well very quickly
  • ES6+ and Ember/React/Angular: Javascript creates amazing user interfaces. There have been some huge improvements in this area of programming over and over again. Starting with ES6, javascript is really maturing and becoming amazing at building truly wonderful UIs.
  • Go: Excellent systems programming language that has some really nice feature for parallelization.

The list could go on and on forever it seems. But I want to take some time today to talk about what I feel is still the BEST technology you can use to write a full-stack application. I am talking a real product. Something that you build, scale, test, and deploy quickly to end users as a finished and complete thing. There is only one framework that I feels accomplishes this well, and its Ruby on Rails.

In this post I want to go over a few reasons why I think Rails is the best for making a product quickly. Some things I'll cover:

  1. community support
  2. tooling that make it easy to do things easily
  3. integration of the latest technologies
  4. ease of maintaining, extending, and scaling the application

Part 1: Community Support

If I were to quickly look at the tagged questions for some popular frameworks on Stack Overflow, this is what I'd see:

  1. asp.net: 330,000
  2. Ruby on Rails: 289,208
  3. Django: 165,000 (this was a bit of a surprise)
  4. Angular: 100,000
  5. reactjs: 65,000

Clearly, we can see that Rails has a massive following, rivaled only by asp.net. For any given question you may have about Rails, chances are that someone's already solved it.

I'd also like to point out that Rails was the beginning (at least in my opinion) of the surge in video casting. So many railscasts-esque sites have popped up after the first railscast by good ol' DHH. I personally felt that Rails is the biggest reason behind the rise of screencast tutorials for software development (personal opinion, of course).

Wether you need help with the basics, or something deep within the framework, the community has you covered.

Part 2: Tooling

To be really productive in an environment, you need really good tooling around you. Imagine being a plumber without a wrench. You can try to connect the pipes together, but you're not going to be productive without a wrench. Personally, I consider myself something of a web plumber, and I think Rails has some pretty great wrenches.

The quality AND quantity of packages in the Rails community is so large, and so diverse, it makes developing apps a breeze.

Gems

Ok fine, this isn't a rails feature; it's a ruby feature. Ok, you got me. But you know what? I think gems are so important, they deserve to be mentioned. Every language has their own form of packages and libraries, and they're all quite good. But the Rails eco-system has so much support with the gems that are produced. The quality AND quantity of gems in the Rails community is so large, and so diverse, it makes developing apps a breeze.

  • Do you need to integrate your app with Stripe? great! there's a gem for that
  • Need to add file attachments to your models? Sure! Theres a gem for that.
    • Side note: Rails is getting its own attachment processor in Active Storage in Rails 5.2 (as of this writing, 5.1.4 is currently out)
  • Need user authentication and authorization? Unfortunately there are no gems for that.... oh wait, nevermind, there are a couple gems for that.

The point is. If you need something important done for your new product, you'll find a well-supported gem that does it. And a lot of the larger gems are maintained by large companies that want to give back to the community. Many packages are well maintained and updated constantly.

Testing

A lot of modern frameworks and languages emphasize testing; however, Rails was one of the first web frameworks that really brought TDD to the limelight. Without Rails, I promise you wouldn't see nearly as much attention being paid to testing with any of the newer frameworks and languages that came out.

With very little setup, you can have a whole web application running with unit tests, controller tests, and behavior tests. Just install a few gems, and you're good to go.

Every new language seems to have built-in testing primitives and/or tooling. And I believe that is due to Rails popularizing of testing first. Rails set the benchmark when it came to code quality and code testing. All the new languages and frameworks adopted these techniques and principles in order to appeal to programmers who have gotten used to the Rails testing ecosystem.

Productivity

I believe Rails is on point with all the productivity tools it gives you. Generators, for example, give the user immense power when protyping out new features, or whole new applications. Let's look at an example.

      % rails g scaffold new-feature
      invoke  active_record
      create    db/migrate/20180316132644_create_new_features.rb
      create    app/models/new_feature.rb
      invoke    rspec
      create      spec/models/new_feature_spec.rb
      invoke      factory_bot
      insert        spec/factories.rb
      invoke  resource_route
       route    resources :new_features
      invoke  scaffold_controller
      create    app/controllers/new_features_controller.rb
      invoke    erb
      create      app/views/new_features
      create      app/views/new_features/index.html.erb
      create      app/views/new_features/edit.html.erb
      create      app/views/new_features/show.html.erb
      create      app/views/new_features/new.html.erb
      create      app/views/new_features/_form.html.erb
      invoke    rspec
      create      spec/controllers/new_features_controller_spec.rb
      create      spec/views/new_features/edit.html.erb_spec.rb
      create      spec/views/new_features/index.html.erb_spec.rb
      create      spec/views/new_features/new.html.erb_spec.rb
      create      spec/views/new_features/show.html.erb_spec.rb
      create      spec/routing/new_features_routing_spec.rb
      invoke      rspec
      create        spec/requests/new_features_spec.rb
      invoke    helper
      create      app/helpers/new_features_helper.rb
      invoke      rspec
      create        spec/helpers/new_features_helper_spec.rb
      invoke    jbuilder
      create      app/views/new_features/index.json.jbuilder
      create      app/views/new_features/show.json.jbuilder
      create      app/views/new_features/_new_feature.json.jbuilder
      invoke  test_unit
      create    test/application_system_test_case.rb
      create    test/system/new_features_test.rb
      invoke  assets
      invoke    coffee
      create      app/assets/javascripts/new_features.coffee
      invoke    scss
      create      app/assets/stylesheets/new_features.scss
      invoke  scss
      create    app/assets/stylesheets/scaffolds.scss

In short, the above command literally created everything you could possibly need for this new-feature object. I know many many other frameworks have code generators, and powerful CLIs. But I feel Rails does it best, and they (at least in my opinion, with web frameworks) did it first.

Part 3: integration of the latest technologies

OMFG, the Front-end Landscape

When making a product, I don't want to be left behind the curve when it comes to front-end technologies. However, I don't want to build a rigid, and hard to maintain system for a simple product.

Javascript has been making incredible improvements year over year. I love seeing the evolution and maturity of Javascript because I feel it is a really great language, and I love using it. When making a product, I don't want to be left behind the curve when it comes to front-end technologies. However, I don't want to build a rigid, and hard to maintain system for a simple product. Lets go over a scenario:

Story time, a tale of two projects

You're a developer, and you're working on a new product for a client. You want to use the latest javascript framework (lets say its Ember). Because you're so interested in Ember, you dive right in. You mock out a server using mirage, you create unit, feature, and integration specs with ember, mirage, sinon, etc..

You continue down this path until you're comfortable with how the application is behaving. But wait, you haven't actually built out an API yet. So you cobble together some API with rails, it works, and you ship it.

Now the client sees a bug, and you have to fix it. Instead of making a quick fix, you have to:

  1. trudge through code in TWO repositories
  2. track down the bug in both front-end and back-end code
  3. make the fix
  4. update specs in both front end and backend repos to handle the change
  5. update the mirage server you mocked, so it returns the new payload you expect from the api

This is just a simple scenario, but I see it all. the. time. Separating your environments like this is a novel idea, and with a large team it can work well. But when you're trying to build, ship, and iterate on a product, it holds you back.

The rails solution. Integrate front-end and back-end (Majestic Monolith)

Rails 5+ has the most amazing feature set (technically you can do this in older versions of rails, but 5+ brings more to the table natively). It's called webpacker. Webpacker allows rails to integrate seamlessly with a variety of front end technologies, here is a quick list:

  • Angular
  • React
  • Vue
  • Elm
  • Stimulus (haven't used this yet).

And there's surely more to come in the future!

When using webpacker, you only need a simple command to integrate your favorite front end technology and you're off to the races!

bundle exec rails webpacker:install:react

Once you run this command, Rails takes care of the configuration of webpack, installs packages with yarn, and gets you set up with React. Now you're running React, and Rails, in one repository. You can install all your own packages, configurations, etc... Essentially you get the best of both worlds.

In my perfect setup, I'm running rails to handle authentication, routing, and some simple views. And relying on React to deal with more complex user interations. Unit test with rspec on the rails side, and jest (or w/e the best testing framework for react is) for my React components. Then I can test my whole stack using capybara, and rest well knowing my whole stack is tested through and through.

If there are ever any bugs, or changes, I only look through one codebase to find the issue and make changes. This also cuts down on deployment complexity. I can deploy this whole stack to heroku and not have to worry about configuring two different projects to talk to each other in production. It all just works. This is called a majestic monolotih. and for a small team, it runs amazingly well.

Rails and webpack. It all just works.

Maintainence, scaling, and deployment (A.K.A. The Heroku section)

Question: what is the biggest, easiest to use, and (maybe) the most well known PaaS product out there today?
Answer: Heroku.

Question 2: What is the easiest way to deploy a Rails application today?
Answer 2: Heroku.


Heroku Logo

I Love U :)



Ok that may have been silly, but in my opinion, it doesn't get any better than Heroku. (Side Note: I am not affiliated in any way with Heroku, I've just used it a lot and really enjoy it). Heroku offers excellent tooling, and products for your Rails application.

Deployment is simple using build packs. Maintainence and logging are easy with NewRelic, and many other Heroku addons. Scaling is almost dead-simple with auto-scaling dynos and background jobs (using sidekiq or resque or delayed job) on their own dynos. And database maintaince is a breeze with Heroku's postgres tools. I have personally built products on Heroku that have scaled to millions of users on a single Rails app. And it wasn't even that difficult to do. Heroku offers amazing service, excellent products, and great tooling to deploy, and scale your application.

Wrapping it up

In short, I think Rails is still an amazing framework for building a product. It's still under heavy development, and making progress every day. It has amazing tooling, and community support. You can integrate your favorite front-end technologies easily. And you can deploy, maintain, and scale your application in a simple, and straightforward way.

I love technology, programming languages, and new frameworks. But if I were to build a product today, nothing would come close to Rails for its productivity.

chris power

chris power

Chris is a full stack engineer working on multiple JS, Ruby, and Elixir projects. He is also an avid snowboarder, golfer, and beer snob.

Read More