What is Ruby?
Ruby is an open-source object-oriented scripting language invented in the mid-90s by Yukihiro Matsumoto.
Unlike languages such as C and C++, a scripting language doesn’t talk directly to hardware. It’s written to a text file and then parsed by an interpreter and turned into code. These programs are generally procedural in nature, meaning they are read from top to bottom.
Object-oriented languages, on the other hand, break out pieces of code into objects that can be created and used as needed. You can reuse these objects in other parts of the program, or even other applications.
Yukihiro wanted to create a scripting language that leveraged object-oriented programming and increase code reuse to help speed up development. And so the Ruby programming language was born, using simple language and syntax to handle data and logic to solve problems.
What can Ruby be used for?
The Ruby programming language is a highly portable general-purpose language that serves many purposes.
Ruby is great for building desktop applications, static websites, data processing services, and even automation tools. It’s used for web servers, DevOps, and web scraping and crawling. And when you add in the functionality of the Rails application framework, you can do even more, especially database-driven web applications.
Ruby on Rails
Ruby stands alone as a high-level programming language. But you really can’t talk about Ruby without mentioning Rails.
Ruby on Rails is the application framework that thrust Ruby into the spotlight, boosted its popularity, and made it a great language for the cloud.
According to the fine folks at rubyonrails.org, Ruby on Rails is “an open-source web framework that is optimized for programmer happiness and sustainable productivity.”
The Ruby on Rails framework consists of pre-written Ruby code for things like communication, file handling, database connections, and more. It takes care of the tedious items, so you can focus on solving problems. One of the key concepts of Rails is DRY — Don’t Repeat Yourself — which is key to the framework’s efficiency.
There are over a million websites written in Ruby on Rails — a wide range of heavy-hitting business and entertainment sites, including GitHub, Twitch, Bloomberg, SoundCloud, Hulu, Square, Basecamp, Airbnb, Hulu, The Weather Channel, Instacart, and Twitter.
Ruby vs. Python
One of the languages Ruby gets compared to most often is Python. Ruby and Python have a lot in common and can be used for many of the same purposes, which can make it hard for developers who are deciding which language to learn or which to use for a specific project. Both Ruby and Python are high-level server-side scripting languages with clear and easy-to-read syntax, but there are some important technical differences.
Differences between Ruby vs Python
Some of the differences between Ruby vs Python include:
Then there are the more subtle differences, too.
Some developers find Ruby more difficult to debug but more flexible in general.
Some find Python easier to learn initially but more stifling in the long run.
In many ways, it boils down to a basic philosophical difference between the two: In Ruby, there are many ways of doing things, many solutions to one problem. In Python, there’s a best way of doing things, and that’s the way you should do it.
Why should I learn Ruby?
The Ruby programming language is designed for programmer productivity and fun. Developers like using Ruby because it’s high level and has a simple syntax. You have less code to write and can focus on finding a solution to your problem.
Because of the high level and abstracted nature of Ruby, this adds up to a language that is easy to learn and put into practice. While many low-level languages require lines and lines of code for the smallest thing, with Ruby, you can write your first cloud application in just a few hours.
The 2020 Stack Overflow Developer Survey names Ruby the 14th most popular programming language in the world with 7.1% of respondents being Ruby on Rails developers.
It’s also an excellent choice for building applications quickly and definitely has the edge over Python when it comes to web development. Hundreds of thousands of Ruby websites can’t be wrong!
Looking to learn more about Ruby? Check out Pluralsight’s new course Ruby: The Big Picture for a quick crash course on this fun, useful language. Or get a deeper dive on Ruby development in Ruby Fundamentals.