Ruby is "a dynamic, open-source programming language with a focus on simplicity and productivity. It has an elegant syntax that is natural to read and easy to write," according to its docs on ruby-lang.org. Developed in 1995 by Osaka native Yukihiro Matsumoto, who "really wanted a genuine object-oriented with easy-to-use scripting language" as an alternative to Python. Focused on "developer happiness," Ruby is a beginner-friendly language that was intended to be written more closely to human language than its predecessors, using verbs like 'puts' and 'do' for keywords.
Ruby is most commonly implemented with Rails, a framework that extends the language and provides structure and scaffolding to make writing code quicker and easier. It is considered an opinionated framework, as there is typically only one correct way to do a task, making it potentially easier for beginners to learn than a language/framework that has many different ways to achieve the same results. Ruby on Rails works on the backend of an application to fetch from databases and display data that contains HTML, CSS, and JS. With its database-driven design, model-view-controller (MVC) architecture, and built-in testing, Ruby on Rails allows for maximum productivity- one language to rule them all. Many of today's most popular websites were built on the Ruby on Rails framework, including GitHub, Airbnb, Groupon, Hulu, Soundcloud, and Kickstarter.
Every programming language must provide ways to iterate over data. Let's check out some simple while loops:
Pretty similar looking, but Ruby's syntax uses verbs that we really use in English, allowing us to tell at a glance what action each line will perform.
There's a lot of talk online in developer forums about whether Ruby's heyday is over, but the truth is that it doesn't appear to be going anywhere. It did enjoy a resurgence in popularity in the early 20-teens which has since waned a bit, but the language was recently given some tweaks that increased its already-great performance significantly, with a major update just released in May of this year. The language continues to evolve in response to trends and feedback, remaining a solid choice for developers who want to write concise and clean code that is readable and powerful.
Top comments (12)
Neat post, Christine! I love that you compared the syntax between JS and Ruby. What caught my eye was my that the first programming language that I spent significant time in was JS even though I had written some Basic, PHP, and Python before it.
A few things...
Sorry, I'm a bit of a pendant, but the relationship is inverse -- Rails is, more specifically, a web framework implemented with Ruby. To this day, though, I've always felt "Ruby on Rails" was such a cleverly chosen name that it still rolls off the tongue to this day...
Funnily enough, for as long as I've worked in Ruby, I never knew or ever paid attention to to year/time of Ruby's inception. I only knew about Matz and his motivations.
Might be a slight misinterpretation of "opinionated" -- there's a difference between the developer and their opinions when developing code/library/framework for use by other consumers, but there's also the opinion and interpretation of the consuming developers, like you and I that use it. I'm not sure that I've ever heard people say that Ruby is opinionated, but Rails, the framework most certainly is -- both a blessing and a curse as I've worked on small and currently work on a very very large Rails monolith.
I'll speak more to the users of the Rails framework, like you or I. Typically people, including myself, coming from JS will find Ruby's standard library "bloated". There are a multitude of ways to do things in Ruby, one simple example is: obtain the first element in an array:
How about determining if something is zero?
Glad that you pointed out that JS is a prototypal language compared to Ruby -- the class construct is literally syntactic only to make it more "welcoming" for OO devs
The last thing that I'll point out is that this post seems more of a comparison between JS and Ruby as languages rather than an intro to the Rails framework for JS devs without a JS analog (e.g., SailsJS, HapiJS, etc)
Thanks for your insights and perspective! I'm new to programming and have more experience with JS than Ruby, but I did experiment with it a bit back around 2015 when it was really hot. I'm curious how long you've been working with Ruby. As a new dev, I appreciate a framework that plays by tighter rules since I'm more apt to making mistakes, but I can understand that someone with more experience might find it limiting. Also, I have heard that many applications, especially those that must manage a lot of requests, would get bogged down with RoR, so Node.js is usually the speedier choice. In your opinion, what kind of applications are better suited to Ruby on Rails?
We all start somewhere and welcome aboard! :)
Yeah, Ruby and Rails has certainly lost some of its luster, but continues to make noise -- most recently, DHH (David Heinemeier Hansson), the creator of Rails and his company that's behind Basecamp spent two years on a brand new email service called Hey (hey.com). It is built entirely on with Rails and web-sockets via TurboLinks. It's not "cool" to start new projects today with Rails -- I wouldn't and I haven't, but I'll explain.
So that was a long-winded way to answer your question, but to get directly at: "what kind of applications are better suited to Ruby on Rails?" Probably apps where request/response latency is okay -- because NodeJS and its plethora of libraries surrounding the ability to provide more real-time and low-latency support for real-time features over web sockets has more developers doing it. For people that get into web programming and full-stack web development, I'd argue that Rails conventions are a GREAT starting point to go from. It's conventions, while at times restrictive, does provide a level foundation -- those starting out have little idea what to do and why people do things in a particular way and often just run off with a popular tutorial or blog post and think it's "good enough" while possibly learning a bad practice. At least Rails conventions have been vetted by one of the largest community of developers that have managed to "argue" with each other before ultimately deciding on a given convention.
I really appreciate this incredibly interesting and super thorough reply! I am definitely looking forward to exploring new languages once I get more programming fundamentals down. Thanks so much for taking the time to read and reply and for giving me ideas for new things to learn about.
You're welcome! Enjoy the journey -- it's never ending and keep writing. I find it a good way to collect and solidify thoughts :)
It appears to be really popular at least over here in Japan. Not sure about other regions.
Nice post, it really helps to get these kinds of 1:1 comparisons.
Yes, Adonis.js is your closest bet.
I'm learning a little about Express.js right now, and I've also heard of Sails.js, which is designed to directly emulate Rails.
Cool, thanks for the info! It's definitely helpful to see how pros are really writing their code.