Best web application framework I like

So far, in my opinion, Ruby on Rails is the best web application framework that I have used. Compared to others, it is very complete (by installing extra gems) and mature, provides everything that I need.

Version manager

There are two version managers: rvm and rbenv. I prefer rvm. It allows to work on different projects with different Ruby versions. Node has similar manager, nvm. Python has similar feature, but acts differently, using venv or virtualenv. In Python, we need to install the specific version, and create the environment by specifying our Python version. Contrarily, rvm or nvm will download and build the corresponding version.

Lambda expression

Ruby supports lambda or anonymous function, which can also be seen in JavaScript, as callback function. Newer languages such as C# and C++11 also support the syntax. The syntax is so useful when handling array. Python can support lambda expression, but it cannot support multiple lines like JavaScript.

REPL

Ruby on Rails has also very powerful REPL. With rails console, you can access the models easily, and manage the database through models.

Node can do similar, but it requires to write the script to setup the context. Meaning, we need to write the script so that REPL can access the controllers and models.

Debugging

Debugging in Rails can be done like client side JavaScript debug keyword, which require byebug gem. By using pry-byebug, we can debug the script line by line easily.

Migrations

Migrations and ORM in Rails simplify the development, as we need not to take care how the database should be structured, but focus on the models design, especially relationships like one-to-one, one-to-many, and many-to-many.

Migrations is commonly used in various web application frameworks, including .NET, Django, Laravel, etc. Node can implement migrations using sequelize and sequelize-cli.

Pagination

Kaminari gem allows to access the ActiveRecord with pagination related methods.

Serializer

By using ActiveModel::Serializers, we can make our JSON output more consistent.

Mailer

Mailer, which act exactly like Controller. And greatly, we can write preview page for the emails, in HTML or text.

CSRF protection

For the security, we can do protect_from_frogery to protect from CSRF.

BDD/TDD

Since we always need to test our code, BDD or TDD makes our development more stable and interesting.

By using rspec and factory_bot gems, we can do our testing easier, including mocking data and stub the methods.

Time travelling

Related to BDD, by using ActiveSupport::Time, we can test our code by specifying the date. Need not to use a date parameter through out all the function calls.

Job

We can do background job by using ActiveJob and also SideKiq.

Cache (SQL)

By default, the ActiveRecord (model) querying will use cache, example.

Drawback

Though Ruby on Rails is powerful, there is one limitation. There is no official support on Windows, which we cannot find the binary installation of the latest version of Ruby and Rails for Windows.

The only workaround for Windows installation is using WSL (Windows Subsystem for Linux). And this feature only available on Windows 10 and Windows Server 2019.

Meaning in older version Windows, probably needs to use virtualization like Docker or Vagrant. (I never tried before.)

Advantages

I prefer Ruby on Rails over Node, because Node has too many modules doing similar jobs, for example crypto-js and node-crypto-js. Too many options cause me to use extra effort to find out which one is better.

I prefer Ruby over Python, because of the lambda expression.

In my opinion, the advantage of Ruby on Rails is because of Ruby language itself.

To print the output, we can do puts something, instead of console.log(something) (JavaScript). Parentheses are optional to call the function, similar to Perl.

We can pass the hash to the function without braces, such as foobar(a: 1, b: 2). But in JavaScript, we need to do foobar({ a: 1, b: 2 }); in PHP, foobar(['a' => 1, 'b' => 2]); in Python foobar({'a': 1, 'b': 2}).

When developing using Ruby on Rails, we can apply Twelve-Factor and Design Patterns. We focus on code readability (using RuboCop), refactoring, and testing.

You can find a curated list of useful gems as well.

Leave a comment