Recently I’ve been repeatedly asked how to get started with programming, especially Ruby and Rails. To keep things DRY and make sure I always include all great resources for learning, I decided to write this blog post. Most of people who asked me had never programmed before or had done some coding before in other languages, but are not (yet) proficient developers, so if you are a total beginner or just started learning Ruby / Rails and you are not sure what the next step is then you came to the right place.
Starting is always the hardest part and to make it smooth you will need the best possible resources for learning. The problem is that there are plenty of tutorials and it may be quite overwhelming and difficult to pick the right one. Of course I don’t know all of them, but based on my exprerience the best Ruby tutorial for learning programming from scratch is Learn Ruby The Hard Way by Zed Shaw, which I used myself some years ago when starting with Ruby. The great thing about it is that it starts slowly and from absolute basics, so it won’t be that overwhelming if that’s going to be your first code ever written. It also teaches how to think, attention to details and after each exercise there are some study drills that will make you reflect on the code and force you to do some further exploration on your own. And it’s simply fun to do.
Before you start: I can imagine many of beginners have Windows as the operating system. Well, Ruby may work on Windows, but more likely something will go wrong and it will take forever to fix it. I would advice to install some Linux distribution first (unless you have Mac, which is perfectly fine) before you start learing Ruby. Ubuntu will probably be the best option. You may want to set up virtual machine with Linux under Windows instead of installing it as an independent operating system, for that purpose you can use VirtualBox or VMware, but the setup itself is beyond the scope of this post.
It would be nice to learn some basic terminal magic as well. I would also recommend one of the Zed Shaw’s courses for that: The Command Line Crash Course. It’s pretty short, but will give you everything you need to start learning Ruby.
Ok, so you have now some coding skills and know Ruby a bit. What to do next? There’s one more great resource for learning Ruby: The Bastards Book of Ruby. It also teaches basic programming (good to revise at this moment anyway), but focuses on real-world use cases. Besides knowing Ruby better, you will also learn some regular expressions, do some web scraping, image manipulation and even learn basics of databases and SQL.
At this moment you can go beyond just Ruby. But it’s not the time for Ruby on Rails just yet. You will need to learn some basics of HTML / CSS first. There are plenty of various tutorials, but I tend to recommend this one - it offers pretty much everything you need at the beginning and gives solid foundation to learn more concepts later. You’ll always be able to google any unknown term that appears on the tutorial, it’s written to be beginner-friendly.
Now it’s time to pick up Ruby on Rails. I can definitely recommend Ruby on Rails Tutorial by Michael Hartl - I learnt Rails with this wonderful tutorial myself and I couldn’t be happier with it. The content is always up-to-date, which is really important, especially when you are at the learning phase, shows Rails from broad perspective, teaches basics of Git, deployment, even covers testing and really gets you excited when you see how much you learn in so little time.
After finishing Ruby on Rails Tutorial it would be great time to start working on your own project. The best choice would be something you will enjoy working on and challenging as well. An idea would be to develop e-commerce platform. It may sound really difficult at that moment, but remember that Google is your friend and you can find plenty of answers in RailsCasts.
What to do next
After polishing your own project you should have enough knowledge and skills to start working as a junior developer or ar least take an internship. That’s probably going to be a period of the most intensive learning so far. The good news is that you are going to make a huge progress.
But still, you shouldn’t forget about developing skills on your own. There are many other things you can do to work on your programming skills. An idea would be to start doing some exercises from Project Euler - they all are mathematical exercises, but are quite enjoyable do and require some deep analysis and force you to think really hard, especially the further you go. Another idea is exercism.io - for me it’s #1 place when it comes to learning a new language. The idea is that you get an assignment with explanation what the exercise is about. Along with the assignments come tests. Your task is to write code to make these tests pass, but that’s not enough - your code should be as beautiful and readable as possible. After finishing an exercise and submitting code it can be reviewed by other developers who participate in exercism.io, which is really beneficial for learning - you will discuss your choices and really think about writing code one way and not the other way. Don’t worry though, of course your code will not look that great when starting, but no one will criticize you for that as the community around exercism.io is aware that many developers start journey with new language by solving these exercises and no one ever starts with writing super clean code. You will also learn plenty of new concepts by reading and reviewing other developers’ code when checking how they solved the same problem. I used it myself for several languages and still use when learning a new one. It had a great impact on how I write my Ruby code today.
There are plenty of awesome books you can learn even more from. You should definitely read Practical Object Oriented Design In Ruby by Sandi Metz. It’s an amazing book for learning object-oriented design, which is essential if you want to write maintainable and clean code. It also covers testing to some extent - and the more you learn about testing, the better.
The great thing about Ruby is metaprogramming, which is an extremely powerful weapon when you know how to use it. You can learn it from Metaprogramming Ruby. Some examples may be outdated a bit (there are real-world examples of metaprogramming e.g. from Rails 2.3.x), but the content is great and walks you through some more advanced Ruby concepts.
Another classic one would be Growing Object Oriented Software Guided By Tests. Yeah, I know it’s in Java which is widely hated in Ruby community (for no reasons at all in most cases) so it may be a good idea to get familiar with the syntax first and approach it without any prejudice, but it’s amazing for learning ideas behind Test Driven Development and how the tests can guide your code design. It’s definitely one of the most influential softwarte development book I’ve read.
Learning how to use specific design patterns is quite a valuable skill. But not all them make sense in Ruby. However, Russ Olsen in Design Patterns in Ruby explains the patterns that are especially applicable to Ruby langugage and shows some pretty useful examples. If you’ve never read anything about softwarte design patterns then it’s definitely worth reading.
Beyond Ruby and Rails
In most cases when dealing with databases ActiveRecord will be enough (assuming you are using some SQL database). However, in more complex cases you will be forced to write the statements entirely on your own, which requires some SQL knowledge. You should already know basics from The Bastards Book of Ruby, for learning little more advanced concepts PostgreSQL exercises is a great choice - you have an assignment with an expected result and your job is to write a query that will give the expected answer. Everything can be done in the browser, after each exercise all new concepts are explained in detail and if you get lost, you can always get some hints.
Learning programming may be quite overwhelming at the beginning, especially the web programming, which requires to learn plenty of technologies to develop any meaningful application. Hopefully you will find it much easier after reading this post. It is entirely based on my personal experience and worked perfectly for me. Looks like it works pretty nice for other developers (or developers-to-be) to whom I already have recommended some of these resources. Getting through all these books and tutorials should take you at least 1 year, maybe 2 years, and by that time you will be advanced enough to know better yourself how to continue your journey of being programmer :).