× {{alert.msg}} Never ask again
Receive New Tutorials

Q&A with Ruby on Rails Tutorial’s Michael Hartl

– {{showDate(postTime)}}
This article is based on the office hours hosted by Michael Hartl, author of Ruby on Rails Tutorial and co-founder of the Softcover self-publishing platform. Michael answers some beginner questions about whether Rails is a good language to learn for a programming newbie, whether it’s appropriate to Ruby through Rails, and common beginner mistakes.

The Ruby on Rails Tutorial: an Overview

Ruby on Rails Tutorial (3rd Ed.)

The Ruby on Rails tutorial is designed to be introduction to web application development. So, rather than being specific to Rails, the 3rd edition of the Ruby on Rails Tutorial will be focusing on the things you’d have to learn no matter what if you’re going to build web applications. Rails happens to be one of the best tools to use in terms of learning these things.

Generally speaking, I try not to assume anything about the reader’s background, but I think it can be a little rough if the reader doesn’t know a bit of HTML and programming. It’s aimed at intermediates in the sense that by the time you finish the tutorial, you should be good enough to consume pretty much any other programming resources out there. That being said, a lot of people told me they got through the book as a total newbie to coding, and some people told me their strategy was to read the book twice to get a better understanding.

Ruby as a Beginner Language

I would say Ruby is one of the best languages to start with, but the other two big contenders in the modern day are Python (which is the first language I really loved), and JavaScript (which I don’t think is a particularly pretty language, but is ubiquitous since it runs on every browser and in every web app code base.) So, it would be difficult to go wrong with any of the three choices.

If you really go deep into programming, you’ll find that the lisp programming language is an ideal and no so much a programming language as it is a model for computation. Lisp is, of course, implementable as a programming language. The closer you get to lisp, the more power you have over the computer. Yukihiro Matsumoto, the guy who developed Ruby, described Ruby as his personal lisp. He basically took lisp and another powerful tool called Smalltalk, and combined it with some other stuff from Perl, Eiffel, and Ada to come up with a package of something with great power, readability, and expressiveness.

Lisp has a problem in which it is too powerful so you can do anything with it, so every programmer ends up doing their own thing. Ruby dials back a little in terms of power, so it’s a lot cleaner and more generally accessible to a larger group of programmers. So, with Ruby, there are a lot of people collaborating on software that will last for a while, but it’s harder to point to lisp projects that have the longevity.

Learning Ruby through Rails

For people who are excited about building web apps, I generally recommend getting going with Rails and knowing just enough Ruby to get by.

However, I wouldn’t say you can really use Rails to learn Ruby. Nonetheless, I understand if you don’t want to read a 500 page book and spend potentially weeks or months of effort learning Ruby before you get to Rails, especially since the parts of Ruby that Rails uses are different from what you’d get from a general introduction to Ruby.

In Ruby, every method and every function returns some value for the most part, while a lot of functions in Rails apps consists of controller actions where nothing is being returned. Instead, those functions contain implicit behavior—for example, if you had an action called index, and you go to the URL called “example.com/index”, / hits an action called index. It won’t return anything you can see to the index function, but would render a template called index.html.erb that gets returned to the browser as a string. So, in terms of functions, you’d probably find this kind of behavior in Rails weird if you come from a pure Ruby background.

All in all, part of the issue here is just motivation, so it’s certainly not wrong to learn Rails primarily. Personally, I wanted to learn Ruby solidly before I learned Rails, but this was back in 2005 when there was hardly any learning resource out there.

Keeping Motivated after Tutorials

There is no one-size-fits-all answer, but I think the key is to work on things you’re interest in, and to find something you care about, a project where you want something to happen and you feel motivated about building it. You’d almost have to get to the point of being angry the project doesn’t exist so you’d do anything to get it done.

That being said, I think it’s important to break out of the tutorial mindset and reach out to other people. Go to meetups, find online communities like Codementor and find a mentor to help you get past sticking points, as it’s a big challenge to go from something very structured to just looking at a blank window and wondering what to do next.

I do this in the tutorial to help the transition by providing exercises that gives readers tips on how to take the next step, but the truth is that it’s not going to be easy to go from a structured learning environment into the wild west. It’s great that computers can do anything, but it’s also a curse because you won’t know where to start.

In conclusion, the best way to get your hands dirty is to find something you care a lot about, and find a community where you can get advice and mentorship. Those are the two crucial things you should do to keep yourself motivated after you’ve finished the tutorials.

Going from Noob to Experienced:

How Long Does it Typically Take for a Noob to Start Developing Large Web Apps?

It really depends on your background. Assuming you’ve had a little bit of programming experience, you can certainly get really good in a matter of 6 months, and you can probably get good even quicker than that. If you learn full-time on a daily basis, you’d probably be good to go within four months, so it really depends on how dedicated and determined you are, and also how much time you’ve invested. I don’t think learning how to code will take years and years—you can certainly look back and the old code you’ve written before and find it awful, but that’s a natural part of the learning process.

To be really good, I’d say it’s going to take ten years, and I don’t consider myself good. I’m skilled at making tutorial materials for Rails, but if someone wanted to hire me as a developer, I’d have to spend a few months getting up to speed on whatever their technology stack is. However, if you’re just speaking of being able to work on large projects, it’s a matter of months if you’re determined.

Most Common Beginner Mistakes

The biggest problem I’ve seen is that people seem to expect things would be going smoothly all the time. I get emails from people complaining how they’ve spent 2 hours on “one” thing, and how they can’t believe they’ve spent so much time on it. They actually don’t realize this is very normal.

I’ve flushed days and weeks down the toilet trying to debug stupid things. So, it doesn’t matter how smart or experienced you are—you will run into things that will just kick your butt. In that context, it’s important to develop an awareness of when you should power through the problem, and when it’s time to take a break.

Just to pick a stupid and almost embarrassing example, a couple of months ago I was trying to install a new version of Ruby on an iMac, and I couldn’t figure out how to do it since I think I installed OpenSSL with homebrew incorrectly. It’s pretty ridiculous because I should be an expert at installing this stuff, but you know what? I spent an hour on it and I still couldn’t do it. So, I decided to quit, came back a week later, and found another way to make things work. The point of this example is these stupid moments happen to everyone. Expect something t go wrong and that you’d probably blow 2 hours on just spinning your wheels.

I think this is one of the downsides of learning from a carefully managed environment where you do everything in the browser. Things can go wrong, but you’re still not in the wild, so to speak. It’s good to get people motivated and to hold their hand early on so they don’t freak out from all the things that go wrong, but eventually beginners would need to realize that’s just the way things, preferably as soon as possible.

Evaluating Rails for a Project

Since I don’t actually do contract web development anymore, I’m probably not the best person to ask this kind of question. However, that being said, I have observed what people do. Generally, if you want to make something that’s essentially a desktop app in your browser, then you’d really have to use JavaScript as that will be what’s executing in the browser. However, if you want a CMS lead-gen app, for example, Rails would be an outstanding option. Furthermore, if you’re going to be rendering information based on things in the database and you’d require some sort of login and authentication, Rails is a fantastic choice.

Does Rails have Scalability Problems?

A lot of people mention Twitter when they say Rails has scaling problems, but I actually have inside information on this, as I know people who work at Twitter. Basically, Twitter’s scaling problems had nothing to do with Rails. Instead, there were architectural problems, though basically any language or framework operating at that scale would need lots of customizations. If you think PHP must be scalable because Facebook uses it, you should also know Facebook does some crazy stuff with PHP since they’re operating at an enormous scale. So, the same goes to Twitter—they had architectural problems that weren’t really related to Rails.

Ruby is not a particularly fast language, but that rarely matters to development. In addition, the default way of setting things up is much faster than what it used to be, so it’s funny how people are still worried about scaling with Rails. There is no way scaling is going to be the problem that kills you if you use Rails, especially not at this point where there are so many huge sites that use Rails on the back-end or some closely related technology such as Sinatra (a minimalist Ruby micro-framework). Last I checked, Disney.com runs on Sinatra and all of its subproperties are similar to that of a Rails app’s, and Airbnb is also a big Rails app. It should be clear at this point you can still operate at an enormous scale with Rails being your principle technology.

Of course, you don’t actually scale a framework—you scale the system around the framework. I understand why people worry about scaling, but you will solve that problem when you get to it. At any rate, Rails is not going to be the limiting factor.

I personally have experienced problems handling the traffic with a Rails app before, but this was back in 2004, and we didn’t have Amazon Web Services back then. Now everyone’s on Heroku or something, so you can throw money at the problem (which is also unbelievably inexpensive in many cases).

Other Tools to Use with Rails

I don’t have a lot of experience with coding products, but I know people use Go alongside a Ruby/Rails web stack. Nowadays many web software have communication between different pieces in the project through a well-defined API. One technique I know people use when they run into production bottlenecks is that they’d get a hack out of a prototype, peel off a narrow piece of functionality from their original app, rewrite it in a faster language, and have it communicate with the original app through the API.

The Future of Rails

Where do You think Rails is Headed? Where Will it be in 5 Years?

One of the major things I’ve seen over the past nine years is that Rails is always adapting to the changing landscape, so I’m optimistic Rails will continue to a major player in web apps and software developers in general.

The Rails community is one of the best aspects of Rails, as people have really come together around this framework. I think it’s one of the big advantages Rails has over JavaScript, since there’s no clear winner in the JavaScript in terms of framework. For a while it seemed Angular may be winning, but now there’s a new version that won’t be backwards compatible. On the other hand, I feel Rails has a continuity where things will move forward and quickly, but not so fast to break things.

However, in terms of where Rails will be in 5 years, I feel that in technology 5 years is a lifetime, so my predictability would be pretty bad. I’d say the kind of applications that just involve a series of web pages where people fill out forms and click on things to get a document back… those cover a lot of different uses. I get a lot of questions about JavaScript front-end and single-page applications, but those things still need a back-end to handle authentication, talk with the database, and so on. Rails is great for doing such things, so a lot of people use Rails as their back-end for a JavaScript front-end.

Anyhow, in the future, Twitter and Facebook will continue to have a lot of fancy stuff where things get pushed client-side and have super-optimizations. However, the truth is you can start the next Twitter or Facebook by using a straightforward web app. The MVP (minimum viable product) doesn’t have to be anything great… unless you’re trying to replicate a desktop in a web browser.

So, on one hand I don’t want to try to predict where things are going, and on the other hand the basic model of web app development that has come into existence since the last decade or so is not going away.

If anything, Python is a just bit lagging when it comes to web development. The closest analog for web developing with Python is Django, which is the most popular Python web app framework. So, in terms of Ruby on Rails vs. Django, I get the sense they’re not moving quite as fast, and that they also have problems with compatibility in terms of Python 2.x and 3.x—they’re having some real trouble with the adoption rate because Python 3.x breaks some important libraries, whereas in the Ruby world, libraries are almost instantaneously up to date with the latest version. All in all, I think the Ruby world moves at just the right pace. Fast enough that it’s a little scary, but not so fast where things will always pop up as being in an error state because you have the wrong version installed.

Michael Hartl is the author of the Ruby on Rails Tutorial, one of the leading introductions to web development, and is a co-founder of the Softcover self-publishing platform. His prior experience includes writing and developing RailsSpace, an extremely obsolete Rails tutorial book, and developing Insoshi, a once-popular and now-obsolete social networking platform in Ruby on Rails. In 2011, Michael received a Ruby Hero Award for his contributions to the Ruby community. He is a graduate of Harvard College, has a Ph.D. in Physics from Caltech, and is an alumnus of the Y Combinator entrepreneur program.

Michael Hartl (Office Hours)
Michael Hartl (Office Hours)
Author of Ruby on Rails Tutorial
** This account is managed by the Codementor Team ** ** Michael is currently unavailable for live help ** Michael Hartl is the author of the Ruby on Rails Tutorial...
Hire the Author

Questions about this tutorial?  Get Live 1:1 help from Ruby on Rails experts!
Arup Rakshit
Arup Rakshit
Passionate Ruby on Rails developer
I am a freelance web developer working out of India. My weapons of choices are : HTML, CSS, Javascript, Ruby, Ruby on Rails. I literally spend as...
Hire this Expert
K M Rakibul Islam (Rakib)
K M Rakibul Islam (Rakib)
Top Ruby on Rails Mentor of January, February, March, April & May 2017 | Experienced (7+ years) and friendly Ruby on Rails Developer (with passion for helping others learn) | 650+ Sessions
I am the Top Ruby on Rails Mentor of January, February, March, April, May, June, July and August 2016 (8 months in a row) and January, February,...
Hire this Expert

Or Become a Codementor!

Live 1:1 help from expert developers

Codementor is your live 1:1 expert mentor helping you in real time.

comments powered by Disqus
Codementor is your live 1:1 expert helping you in real time