Learning Ruby and Rails in 2014

In the last few weeks, I have been approached by a couple of people who are interested in learning Ruby and/or Ruby on Rails. And for their sake, and for my own interest, I investigated what are the best resources at the moment. Ruby and Rails ecosystem is a one that evolves really fast, and while I like it a lot, because we have new toys to play with all of the time, it is not a great thing for new developers. Also Rails has grown to this big behemoth, and although I like Rails a lot, and will continue using it as long as I can, I’m not sure it is newbie friendly. But I’ll address that one later.

Before i list the resources, and their brief descriptions, there are a couple of rules you should follow, to have an easy ride with Ruby on rails. A basic understanding of HTML/CSS is needed, because, you are learning a web framework, which incidentally runs in the browser, which incidentally uses HTML/CSS to render the pages. I’m not telling you that you need to be a frontend developer/designer, just to have a basic knowledge of it. Ok, no more philosophy from now on. You should also be acquainted with JavaScript, not that you need to be an expert in it, but just have a basic knowledge of it. You are going to use it if you want to have any dynamic interactions in your web applications, but it is not as crucial as HTML/CSS. After you have your prerequisites in order (and it will probably take you a couple of days to get acquainted with HTML/CSS and JavaScript), you can start learning a new programming language, and a web framework. The basics will come in handy if decide to use any other programming language and framework, if your goal is to create web applications.

Learning Ruby on Rails is mostly done backwards, at least that is the way I’ve done it myself. I first “learned” Ruby on Rails, then started learning Ruby, because it was pretty stupid not being skilled in a language that runs your favorite web framework. Who would of thought that by learning the language, you get to understand the framework better. You should not be a fool that I was, and learn the language first. Also, learning Ruby on Rails is a really big bite to chew all at once. Here is a brief overview of the things you are expected to learn all at once:

  • A new language
  • A whole web framework and its abstractions
  • HTML/CSS (if you haven’t done web development before)
  • JavaScript (or CoffeeScript and its abstractions)
  • Probably much more stuff that I don’t remember anymore

Learning Ruby

First thing you want to know is how Ruby syntax looks like, and how it behaves. I think that the best possible way to find out is to Try Ruby. This is a great interactive tutorial, which helps you to learn the language basics. There is also one more site, which I’ve been using lately, to get an insight into other programming languages: Learn X in Y minutes and specifically their Ruby tutorial. After you have done the ruby tutorials, and at least grasped the language basics, you will be able to decide if you like it or not. If you chose not to experience the awesomeness of Ruby, and everything that comes with it, that is OK. To each their own. If you want to continue learning ruby, this is probably the best book there is: Programming Ruby or colloquially called “The Pickaxe book”, from which you will not only learn about the Ruby programming language, but there are also three Regex chapters from which you can learn to be a wizard.

Learning Ruby web frameworks

After you have learned Ruby, the next step on your itinerary is learning Ruby on Rails. I would like you to make a short break here, and learn something a bit closer to the metal. Sinatra is a great small Ruby web framework which will teach you how to build small and simple sites or API endpoints. Also, it is possible to mount Sinatra apps in Rails, and the Rails learning curve will be easier for you if you already know Sinatra. And maybe you decide that Sinatra, with some added libraries is enough for your project. So as a next step, I want you to look into Padrino which is built upon Sinatra, and it also gives you a predefined way to build your web applications.

Learning Ruby on Rails

Learning Ruby on Rails is a big task, and if you set out to do it, it can take you 15 minutes to build a blog, and probably half a decade to master everything that Rails can (and will be able to) do. In my opinion, the best resource to get you on the way is The Ruby on Rails Tutorial by Michael Hartl. A book (and videos) that have helped mold plenty of Ruby on Rails developers. There is also a free online version, if you are on a budget. There is of course the official Ruby on Rails Guides, and one of my favorite books on Rails, The Rails 4 Way which is a great resource, and each time I get through it, I find another new thing I should be using. There is (was) a great screencast resource packaged in Railscasts. Although it isn’t updated anymore (I really hope Ryan gets back soon), it is still a great asset for solving most of the specific problems you will encounter as a Rails developer.

I have focused mostly on free resources, although some of the books I recommend come with a price tag attached. The price, although it might seem a lot to you, is really reasonable, and is much lower than the value these books provide. Even if you don’t stick with Ruby, owning The Pickaxe Book, and going through the first part of it, will teach you some stuff you can probably employ in your language of choice.

I however, chose Ruby, and I’m happy with it. And it doesn’t mean I am, or will only be doing Ruby for the rest of my life (I probably could, if you don’t count JavaScript), but that Ruby on Rails solves the database backed web application problem in the best way I can imagine. And if that isn’t your game, you probably didn’t get to this part of the post. If you have, please try Ruby, it is a beautiful programming language that was designed to make developers happy.

I attended my first Coderetreat

As the title says, I attended my first (and definitely not last) Coderetreat. And we also made history, because it was the first one in Croatia. It was organized by Željko Filipin and Aljoša Mohorović, and we also had a great facilitator, Péter Zsoldos, who really made us think differently in solving an easy problem, at least it was easy on first sight. Also, his insights into our code and the ways we should think outside of the box, even if it doesn’t make sense in a given situation, really helped. Big thanks to Tentamen for sponsoring the event, and Aljoša for being a great caterer who transformed the sponsorship into enough food and drinks for everyone.

You are probably wondering what a Coderetreat is now. It is an activity that serves to teach us (the programmers) better ways of thinking, while doing TDD, and pair programming all the time. There were about 15 of us, and that was an ideal number. Not to crowded, and everyone had another pair for each session. Working with people you regularly don’t work with, switching between development environments, and sometimes languages can be really hard, if you don’t open yourself to accepting every possible way of stepping out of your comfort zone, so you can learn a thing or two. If you have never been to an event like this, I won’t spoil the fun, but you can always go and read about the Structure of a code retreat on their official website.

The problem to solve is always the same, it’s Conway’s Game of life. A simple mathematical problem, that only has four rules you need to obey. By using a simple enough, but not a trivial problem, one can focus on sharpening the skills as a programmer, which we tend to skip in our day to day lives. We “know” how to do our work, and rarely step out of the comfort zone, and do a thing differently, not because it should be done that way, but for fun, trying different things, and learning new tricks.

I learned a lot there, and had fun pair programming with people I never had a chance to work with, which is great by itself. All of us are quirky in our own way, and adapting to that takes some time, but it makes you a better person, not just a better programmer. I’m looking forward to attending the next event.

Learn a new programming language (basics) fast

While doing my best to understand Emacs, that I have been using as a primary development, writing, and play environment, I have felt the need to learn Emacs Lisp, or elisp. Because I didn’t know anything about lisps, aside from the basics learned while reading the SICP book, which I sadly have not finished yet. I could make a ton of excuses here, but I just found another, more interesting thing to read, or do.

What I wanted to do with elisp, as it is crucial to know it, before you can do any reasonable customization of Emacs, is to learn the most basic elements fast enough, without diving really deep into the language semantics and rules. I just wanted to be able to hack up a few functions, change a thing or two, and not feel like an idiot while looking at other people’s .emacs configuration files.

There is a really nice website I have found, to accomplish just that. To teach you the basics of almost any programming language (even brainfuck), in a reasonable amount of time. One pomodoro should be a reasonable amount of time for that. As there are only a couple of things you really have to know in the start, to grasp a language, and see if it is worth for you to dig in deeper, and explore it.

The site is called Learn X in Y Minutes, and it is a community site, which means, that if your favorite language is not included there, you can submit a pull request with the tutorial, and they will gladly accept it. I have only gone through the elisp tutorial, and it is well made, but as i glanced through some of the other ones, they seem good too.

In the start you should know how to assign variables, create methods, get some feedback in the REPL or the console, and maybe create classes if the language is one of the Object Oriented languages. Of course, I might be missing something, but those are the basics for me personally, to see if the language is worth learning, for me of course, not for you.

The site has made me wonder, if I could maybe come back to the dreadful C, and master it this time, after about a dozen failed trials over the years. I probably won’t be using it to program anything in it, but it is a magical unicorn for me, the thing i never did have the time to learn properly, maybe I will never need it, but there is no 32 year old who can say he won’t be needing a certain skill for the rest of his life. So I won’t say that either.

Here is the site link again, in case you don’t want to look for it in the text above: Learn X in Y Minutes

Weekly review: Week ending November 09, 2014

It’s been a couple of weeks without a (public) weekly review. And the main reason for that is, I’ve had almost nothing to report for them. Family, school, college, everything gets in the way and there is little else from regular work stuff that I have done. I’ve spent a lot more time with my son, and I’m considering opening an email account for him, or something similar, so I can send him emails, which he probably won’t read for at least 10 years more, as he is soon to be two years old. When I figure out the means, and the language I’ll be writing to him in, I’ll write up a blog post about it.

OK, enough about the excuses. On to the meaty stuff. I’ve finished one, and read another book this week. The first one is Think and Grow Rich by Napoleon Hill which was recommended on The Freelancers Show and Ruby Rogues a while ago. Two podcasts I listen to frequently, and can recommend to any Ruby/freelance developer. The freelancers show it especially good if you are a small business/consultancy owner. The book is really old, it was first published in 1937, and the things written in the book still stand today. It’s a lengthy read, and it’s basically a get rich slow book. But if you stick to it, it makes a lot of sense. And it should be read a few times, and discussed with a Master Mind group frequently. It teaches you the perils of fear, and what it can do to your ambitions, and how to focus your ambition, and to become everything you want in life.

The other book I’ve read (today, after lunch, because it’s really short) is How to Live on 24 Hours a Day by Arnold Bennett. And it teaches you how to better employ 7 more hours a week on average, because you are wasting time on meaningless things in your life. And because time is the only thing we can’t control, borrow, or save for later, I think it’s a really good read. And I’m happy to realize that I’ve been using some of the techniques in both of the mentioned books, to start doing what I do, and to still keep learning and moving forward each week.

Life does get in the way, there are family obligations, children will get sick, your car will break down, you will start loosing customers for no apparent reason, bad things happen to everyone. But you must stick through it, and just chug along, because there is light in the end of the tunnel, for those who know where they are headed, and go over all the barriers placed on the way there. And in the end, it’s all about trying to be a better person, day after day.

Dealing with procrastination

Have you ever been in a situation where you want to do anything but the thing you are supposed to do? Maybe there is a task of life importance, and you just seem to be stuck browsing Reddit, or Hacker News, or whatever time wasting site you are using to pass time. Procrastination is a hearth-warming practice, which keeps even the strongest of us from continuing to work on most crucial tasks, and spend time on menial tasks, or aimlessly browsing the Internets.

The best way I have found in dealing with was by pure luck. I started dissecting tasks into smaller, 30 minute long ones. The tasks are probably similar to any web application development process. A new recruitment comes in, we discuss it, and it end up in our project planning tool. I have my own to-do system, although I’m trying to switch to GTD, I’m still not there yet. I use Org-mode to handle my to do’s. And I’m trying to make it suit my work flow. Being disorganized in the past, meant that many tasks were left incomplete, or stale, just because of lack of will to finish that last hurdle.

And it is probably that last hurdle, just before you complete the task, that is making you go and slack off, instead of finishing the task at hand. Next time you are in a similar situation, try using my technique. If you have already split the assignment (or project in GTD terminology), into tasks that can be finished in 30 minutes or less, you are on a good way. If not, try doing that first, then come back and try my approach.

The basis of the approach is, when you are stuck working on the main task in your project, that is the most probable time you will want to slack off. Well, don’t do that. Pick up one of the easier tasks in the project. Or if you can’t do that, there is surely some untested part of the app, that really needs your attention. Whatever you do, don’t reach for your browser, and the sites that will suck the life (and time) from you. Hit that menial task for 15-30 minutes, get up and walk for a couple minutes. Then get back to your main task. If you still can’t make yourself work on it, repeat the procedure, until you have no tasks left, but the one task that is making you procrastinate. By then, you should finish the task with ease. You have already done maybe 90% of the assignment, you can surely do the other 10% with the same ease.

If you can’t do that, pick up a new language, or a new editor (hint: Emacs), and play with it, learn something new. Play a musical instrument, or exercise. Keep either your mind, or your body under pressure, because when you let yourself go, it is really hard to get back on track. I myself have lost countless hours doing “busy work”, while doing nothing in particular, just aimlessly browsing the Internet. Don’t be that person, be a Go-getter, finish your tasks, and go outside, have fun.