How did learning Ruby on Rails go?
7 months ago I've started an [[L31 ruby-why-learn-it|experiment in learning Ruby and Ruby-on-Rails]]. It was a challenging and interesting experience.
The challenge was because I wanted to learn the ruby "the right way". This is completely subjective, but I decided to set up a remote Ruby dev environment on a dedicated server.
The idea was to get as far as possible from my comfortable setup: a rich visual IDE on a desktop with intelligent completion and smart refactorings.
An alternative approach was to run vim on a remote server inside tmux (the screen multiplexer) while using mosh for a low-latency connection from any device.
A passable knowledge of tmux and vim, along with a more stable dotfiles collection were the first ongoing benefit of running the experiment.
While going through the "Eloquent Ruby" by Russ Olsen, I've discovered another side benefit: the pleasure of using iPad to actively read books by annotating them with a stylus. I had a setup that alternated between iPad in screen mode with a mechanical keyboard and iPad in hand. It was more convenient and distraction-free than using a laptop for the studies.
The biggest disillusionment of the experiment - Ruby didn't "click" as that beautiful dynamic language that lends itself to a prose. It is nice and Lispy, but I felt no magic between us.
Ruby-on-Rails (RoR) wasn't as magical as I've pictured it, as well. Perhaps, I was just unlucky to start learning it at version 6 (not as lean as the earlier versions). Using a freshly introduced ActionText module - didn't exactly help to fall into "the pit of success", either.
Yet, despite the rough start, Rails journey was a success. Somehow I was finally able to build a personal information system that I always needed (in essence, just a glorified private blog with a few outlining features from the org-mode).
I attribute that success to the fact that Rails are optimised for the developer productivity and fast iterations. I was able to apply dozens of tiny tweaks so quickly that I stayed in the creative flow all along.
To be more specific, here are a few things that helped to move forward:
- webpack is configured and bundled in;
- scaffolding generates the project structure from the start;
- Rails is so old that there are dozens of StackOverflow answers for pretty much any question;
- there are various flavours of rails generators can setup MVC components, individual models and tests;
- runtime dynamically reloads all changes from the files, there is no need to restart;
- rails console - is an interactive REPL that lets you try snippets of code, explore the database and modify it; it also picks up any changes to the code;
- ActiveRecord module is extremely powerful, albeit limited to CRUD;
- ActionText module is a great rich-text web editor that just works, supports attachments and mentions;
- Rails has a lot of things already solved and packed. This makes it more bloated and opinionated, but it saves time and preserves focus during the development.
There were a few things that I had to make peace with:
- Relative performance is slow (compared to .NET or golang).
- Rails 6 is a complex thing, one step in the wrong direction and you are debugging a webpack config or looking into the sources.
- With a CRUD system like ActiveRecord you have to solve puzzles in order to evolve your schema (unlike an event-driven solution).
- In Ruby nothing is what it seems. Modules could augment and change classes on-the-fly. Methods could be created on demand. The development experience is very different from a classical strongly typed language where the object is mostly frozen at the compile-time.
It worked out nicely in the end. I've dipped by toes in Ruby on Rails. It helped me to build a software that I've been using daily for the last months. Resulting codebase is tiny, compared to what I would get in go, Python or .NET.
I don't see any use of Ruby or Rails for the projects at work. There isn't enough synergy to justify it. However, I'll be likely using it on a weekly basis to tweak and evolve my journaling solution. It is so easy.
Published: September 27, 2020.
Next post in Opinionated Tech story: 🤔 Opinionated Tech
🤗 Check out my newsletter! It is about building products with ChatGPT and LLMs: latest news, technical insights and my journey. Check out it out