4 Key Things You Need to Know About Ruby on Rails
Whether you’re new to coding and trying to get the lay of the land, or you’re already active in web development and want to learn more, Ruby on Rails can be an elusive topic to pin down.
What is Ruby on Rails?
Elena Sokolyk, Ruby on Rails Developer at web development company RubyGarage, says that—at its most basic—Ruby on Rails (or Rails) is a web development framework that gives Rails developers a time saving method for writing code. Rails is one of many web frameworks in the world of app programming and web development. These frameworks are collections of code libraries that give app and web developers readymade solutions for time consuming, repetitive tasks—things like building menus, tables, or forms on a website.
While all frameworks by their nature help to make the development of complex websites more manageable, Jasmit Kaur, Founder and CEO at talent analytics platform Culturebie, says that Rails is particularly notable for its easy maintenance and the fact that it lends itself to collaboration. Kaur says this is a result of the two key tenets Rails is founded on: DRY (Do Not Repeat Yourself) and Convention Over Configuration. Kaur points to these two descriptions from the Rails website:
- “Don’t Repeat Yourself: DRY is a principle of software development which states that “Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.” By not writing the same information over and over again, our code is more maintainable, more extensible, and less buggy.”
- “Convention Over Configuration: Rails has opinions about the best way to do many things in a web application, and defaults to this set of conventions, rather than require that you specify minutiae through endless configuration files.”
In other words, not only does the Rails web framework cut down on the time sink of re-coding repetitive tasks, but—by using Rails code—Rails developers keep their overall work cleaner, less prone to bugs (bad, ineffective code), and easier to troubleshoot when problems do occur. At the same time, Rails subscribes to an overall method of best practices for Rails developers that removes the need to leave behind instructions and rationale for your coding decisions (through configuration files) in the code you write—instead, Rails developers work from the shared common ground of Rails conventions.
“In the past I’ve built web applications that became unwieldy pretty fast, even when they were not big projects,” Kaur says. “Rails’ two tenets help prevent that, along with a terrific Rails community of users and great open-source libraries (Rails is open-source, meaning its source code—the code that makes it work—is open to the public and the framework itself is free to use).”
Finally, Rosie Thomas, Ruby Engineer at financial data software company MX, adds that—as a web framework—Rails is most commonly used to build full web applications (web apps like GitHub, Basecamp, and Kickstarter were all built using Rails) and APIs (systems of tools and resources that are then used by developers to create software applications). Because of this, Thomas says, tech jobs that focus on providing browser-based applications or APIs are likely to use Rails and hire developers with Rails experience. As of this writing—Glassdoor lists nearly 6,000 open jobs for Ruby on Rails Developers.
Is Rails Okay For Beginners?
While HTML and CSS (markup languages used to define the parts of webpages and to adjust colors, fonts, etc.) are often pointed to as gateways for becoming a web developer, where does that leave web frameworks like Rails? Is Rails something to tackle only after you’re deep in the throes of tech skills, or is it something that’s in reach for a beginning web developer, too?
According to Laura Bârlădeanu, Tech Lead at mind mapping software company MindMeister, Rails is actually very beginner friendly. In fact, Bârlădeanu says, Rails is SO beginner friendly that she and other program organizers are able to teach women and girls who’ve never programmed before how to use Rails in only one day during Rails Girls workshops. Rails Girls is a global, non-profit volunteer community dedicated to helping women understand technology, and the entire enterprise was founded on the back of Rails as an instructional tool. “I’ve coached at several of these events, and I can safely say that Rails is a very suitable framework to learn as an entry into programming,” Bârlădeanu says.
However, to talk about Rails and its relevance for beginners, it’s important to take a step back and understand that it’s not just the Rails framework that’s beginner friendly, but the Ruby language it’s built on as well. “Rails IS Ruby,” Bârlădeanu says, “or it at least exists on top of Ruby.” According to Bârlădeanu, this means that understanding Rails will involve learning at least some parts of the Ruby programming language—though nothing beyond basic concepts and syntax. “Ruby is a scripting language that has more applications than using it through Rails,” Bârlădeanu says. “For instance, Ruby developers can use it to write a script that moves all your music files that have the name of your favorite band into a folder with that band’s name.” Bârlădeanu says to think of the Ruby language like flour—you can use it to make bread (or Rails), but also pizza, shortbread, etc.
Thomas reiterates that the Ruby language itself—and not just the Rails web framework—is a solid choice as a beginning coding language. “It’s what I started with!” says Thomas. “It’s easy to read and does a lot of the work for you. Other languages, like C, require a lot more code to do something you can accomplish in a few lines with Ruby.”
While Thomas says this isn’t without some drawbacks—more complicated programming languages ultimately offer more options and control—it works out well for someone just getting started with web development. Thomas also says that Ruby is more than capable of carrying you through to an intermediate level of programming. “I’ve been using Ruby and Rails for three years now, and I don’t see myself stopping any time soon,” Thomas says. “Rails is like an extension of Ruby—once you’ve learned Ruby basics you can start to learn Ruby on Rails.”
What Makes Ruby and Rails Different From Other Programming Languages and Web Frameworks?
Sokolyk says one of Ruby’s key characteristics is that it’s an object-oriented programming language. Unlike some languages that function by giving a computer a list of tasks to execute, an object-oriented programming language lets a developer create virtual objects in their code. Each object can have its own specific attributes and abilities and can interact with other objects to perform actions. Groups of objects can then be given instructions based on those attributes and how they relate to one another.
If you think of objects like virtual building blocks, a group of A blocks can be used to build a tower, while a group of B blocks can be instructed to create steps leading to the top of the tower. An object-oriented language makes development less complex by giving programmers structures to work with that resemble building in the real world. Objects can also be easily reused in future programs.
To give an example of what programming with Ruby looks like, compare writing a simple function in Ruby with writing the same function with PHP (another scripting language that can be used for similar functions as Ruby).
To print the worlds Hello World on a web browser screen in PHP you would need to write:
echo “Hello World”;
Notice the non-intuitive use of a semicolon and the command “echo.”
On the other hand, to do the same thing with Ruby you would simply write is
puts “Hello World”
Ruby lacks the extraneous semicolon, and uses the more spoken-language-like “puts” command. Extrapolate this small example into hours a day writing code with increasingly longer and complex functions, and you can see how the Ruby interface can save time and boost efficiency.
Where Rails comes into play is that if you were to simply write “puts “Hello World”” in an HTML document, if would show up exactly as written in a web browser. Rails provides the framework for entering these Ruby commands into the code of a website or web application.
What Are Some Ways to Learn Ruby on Rails and How Long Should You Expect it to Take?
When it comes to learning Ruby on Rails, you can start picking up skills from the usual suspects—you can take a free Ruby on Rails tutorial from sites like Udemy and Code Academy, enroll in a paid online class with instructor support, or learn tips from forums on programming sites like Stack Overflow. Because of Rails’ strong community support, there are also dedicated Rails organizations (like Rails Girls mentioned above, and RailsBridge) that offer Rails classes, meetups, and workshops.
Sokolyk says that she learned Rails through courses organized by RubyGarage, the company she now works for. This led to an internship after she graduated, and eventually a full-time position as part of their web development team. Meanwhile, Thomas learned Ruby and Rails by attending a three-month long bootcamp program with two instructors and about 20 other students. Thomas worked as a TA at the bootcamp after she completed the program, and says that teaching helped solidify what she learned.
As far as how long you should expect the Rails learning process to take? When it comes to nailing down the basics you can expect a relatively short learning curve. Bârlădeanu wrote her first lines of code in Rails on her first day of working with the framework and was able to build a Rails application after one month, while Kaur says it took her about five days to familiarize herself with Rails to the point where she could make a simple web app. However, once you have the basics handled, Thomas says working with Ruby and Rails will be a constant learning process. “I still learn things I didn’t know, and that’s half the fun,” says Thomas.
Category: Blog, Coding Languages and Tools, Learn to Code