Express.js vs. Rails
Tags: ruby, rails, javascript, webdev
Published: 2020-05-22 22:55:44

### Why I Am Comparing These Frameworks

I am about to start working on a mobile application with another developer. We decided to use React Native for the front end since I already have experience with React. However, we have been trying to figure out what framework to use for our back end. Since I have never used Express before, I wanted to dive into the differences between Rails and Express. Additionally, during my job search I have seen more companies listing Node and Express in job descriptions rather than Rails. It seems like Express would be a good tool to learn and I really enjoy programming in JavaScript, however I also enjoy the simplicity of Rails.

### What is Express?

Express is a web framework for creating the server-side of web applications. It utilizes Node.js and just like Rails, it uses an MVC pattern to control back end application logic. It contains HTTP utility methods, a wide variety of middleware that can be included, and many other features to make building a web application with JavaScript easier. Some people have even compared Express to Sinatra which is more of a lower-level Ruby framework than Rails.

### Comparing the Frameworks

On first glance, it was pretty obvious to me that Express was much more minimalistic than Rails. Rails is a very large framework and is very opinionated about the way an application should be built. There are model files, controller files, view files, a routes file and much, much more. Express is much more lightweight and there is more flexibility on how you structure your application.

#### Rails Pros and Cons

##### Pros

Rails comes with everything you need to create a web application out of the box, including built in support for a SQLite database. Since it is optimized for web applications and has a lot of packages included, creating a standard web application is super fast for developers. Ruby syntax is very intuitive and easy to understand for developers. Since the framework is opinionated, if you look at another developer's Rails application it will be relatively simple to understand how it works.

##### Cons

Because Rails comes with so many packages, it can be quite slow and heavy. Additionally, since it is quite opinionated about the structure for your application, there is little flexibility and it can be frustrating to work outside of that box. Along with that, the highly abstracted code in Rails can be difficult to debug since the developer is so far removed from the underlying functionality of the framework. One more thing to note, is that it sadly appears that Rails is not being used by companies much anymore.

#### Express Pros and Cons

##### Pros

Express is super lightweight and fast. It comes with minimal packages out of the box and developers can add middleware as needed. It is highly customizable and flexible, unlike Rails which keeps the structure of applications relatively similar. It is one of the most supported Node frameworks, so developers can ensure that improvements are being made frequently.

##### Cons

Due to the fact that Express is lightweight, it can require more lines of code than Rails to create the same application. Rails comes with generators that allow you to build out models, controllers, serializers and more super fast. Express will require more time to code the application how you want it to be.

### Decisions

I think after all of my research, I am leaning towards using Express. Since it is lightweight, super fast, and built on top of Node, I think it will be a great tool to learn. We will probably end up using MongoDB / Mongoose along with Express to align with the MERN stack.

Let me know if you guys have created applications with Express and Rails and what your thoughts are on these frameworks. Thank you for reading!

![Napoleon Dynamite GIF](https://media.giphy.com/media/116wwYf3ajIvrG/giphy.gif)

##### Additional Resources

- [Medium Blog](https://medium.com/front-end-weekly/node-js-express-js-vs-ruby-on-rails-835a8112db1)
- [Express Docs](http://expressjs.com/)
- [Node JS Info](https://www.freecodecamp.org/news/node-js-what-when-where-why-how-ab8424886e2/)