When tackling programming for the first time, many of us wonder “what language should I learn?”
The first language you learn will impact your perception of what programming is. Due to this, I believe many of us can be intimidated by the seeming finality of that decision. Truth is, while your first language is very impactful, it is a very limited glimpse at what Web Development has in store for you.
Given the range of languages available, many of us will be influenced by what we hear or read online on our initial research. The purpose of this short account is to help new Web Developers in having a more complete overview of Ruby and it’s framework before dismissing them.
First off, what is Ruby/Rails?
Ruby is an interpreted, high-level, general-purpose programming language. It was designed and developed in the mid-1990s by Yukihiro “Matz” Matsumoto in Japan. Ruby is most used for building Web applications but as a general-purpose language, it has many other applications like data analysis, prototyping, and proof of concept.
Rails is a server-side Web application framework written in Ruby. It is a Model-view-controller framework that provides default structures for databases and web pages.
As someone that only started learning Web Development in 2020, I’ve been told that learning Ruby/Rails should not be one of my aims. Many perceive it as aged and expect it to slowly become obsolete. Luckily, my teachers at Lighthouse Labs did not think this programming language was without merit and decided to keep it in our curriculum.
One of the main reasons for Ruby’s popularity is how easy to read it is. The language was designed in a way that makes it very similar to reading plain English. Some even say it’s syntax is very much like a conversation.
One of the common ways we introduce Devs to new languages is by having them write a program that outputs “Hello, World” to the terminal.
You may think it’s strange to start this by showing you code from other languages but bear with me, it’ll all make sense. our goal is to output:
First, let’s take a look at how this would look in Java:
We would then need to compile it. This serves to convert this code from text to machine language the computer understands. We do this by running the “javac” command that stands for Java compiler and giving it the name of the file like so:
Once this is done we can run the program by running the command “java” with the name of the class it needs to run. Since the class is named “Hello”
We’ll simply run our program by typing:
This runs our program and outputs “Hello, World!” to the console. While it’s great that it works it would not be an easy read for someone that has no previous coding experience.
You would then need to call it from the command line by typing “node” followed by the file name. In this case, it would be: “node hello.js”.
We can agree that this is much simpler than the previous example.
It’s quite easy to explain to new developers and would take them no time at all to implement. That said, Ruby’s even simpler.
Finally, here’s how you would write this same program in Ruby:
Is this not a thing of beauty? To run it, you only need to call “ruby hello.rb” in your terminal, and Voila!
Ruby was designed to be written in a simple and pleasant way and this philosophy extends to every corner of the language. It is extremely flexible and lets you code the way you want. If this sounds appealing to you, then you should give Ruby a try.
It’s also important to note that the language powers Ruby on Rails which is arguably one of the world's most powerful frameworks.
I believe that Ruby on rails Maturity, tools, and community support makes it useful, beginner-friendly, and worth learning. In my opinion, this is why this framework is still being used by many big companies like Airbnb, Github, Shopify, Twitter..etc.
Here are some of the pros of the language:
- Ruby is great for making MVP(minimal viable products) in a short amount of time to its easy syntax. This limits development time by 25%–50% compared to other programming languages. Rails offer many tools that help developers deliver more features in less time
- Ruby has proven to support heavy traffic which is great for E-commerce & social media apps. This is most likely why Ruby/Rails is still used for Shopify.
- Due to its maturity, Ruby benefits from a huge community and an impressive number of resources and gems to assist in making development easier.
- Ruby on Rails is known for its apps. It’s an extensive internet advance framework technology that diagnoses and optimizes manufacturing.
- Ruby operates mostly with free databases and web servers. This allows for a quicker growth process and reduced overall costs
While I firmly believe that Ruby is Magic and is very much worth your time and attention, I would be doing you a disservice if I didn’t address many of the perceived cons.
First off, let’s address the two most common argument:
1-“Ruby on Rails is slow”
A lot of people seem to have the idea that Ruby and Rails are slow but when benchmarked against other interpretive languages, they’re about the same. C++ would be the main exception in which performance is a lot faster than Ruby but the likelihood of you writing an entire website in C++ is very low.
2-“Ruby is not scalable”
This idea seems to stem from the fact that Twitter stated this some 8–9 years ago as the reason for changing their codebase. The reality is that Ruby has proven time and again that it can scale hence why it’s used by huge companies like Airbnb and Shopify.
Now let’s address the real cons of the language:
- Boot Speed. The boot speed of the Rails framework can take some time to start depending on the number of gem dependencies and files. This can be frustrating and hinders a developer's performance but is somewhat fixed by the introduction of the application preloader Spring, which keeps your applications running in the background to avoid this boot issue.
- Due to the staggering amount of gems, it can be difficult to find documentation for the less popular ones or for Libraries that use mixins(most of Rails does)
- Multithreading is support by Rails but some of the IO libraries do not. This means that if you’re not careful, requests will get queued up behind the active requests and can slow down performance
- ActiveRecord is used a lot within Ruby on Rails. It is a dependency for many of the gems and although the design pattern is great, it has the drawback that your domain will become coupled to a persistent mechanism. This can lead to bad architectural decisions.
My main worry with new devs learning Ruby first is that due to the simplicity of the language and the fact that Rails gives you so much, it is easy to write functional but syntactically bad code. This can introduce bad coding practices that would be carried over to other languages.
Ruby and its Rails framework are both easy and fun to learn. Ruby positions are amongst the best-paid jobs in the industry.
I believe it is indispensable for any good developer to have a basic understanding of it but that being said, I do not recommend it being the first language you pick up.
I do hope this post serves to guide new Web Developers and Students alike.