Computer programming is something that you learn by doing. To learn a programming language you need to use it. In this case we're talking about ruby, but it applies to all programing languages.
After going through a few of the tutorials mentioned elsewhere on this page you will probably feel like you're comfortable following tutorials, but that you don't feel like "you know ruby".
And you never will feel like you've truly learned the language until you start venturing out and using it without the hand-holding that most tutorials provide.
Here is what you need to do to actually learn ruby.
So shortly after completing a few tutorials, the approach you should take is the same approach that Japanese martial arts masters use to master their craft: kata.
If you're looking to become a Rex-Kwon-Do master, you'll practice reacting in response to a specific move an opponent makes with a certain choreographed patterns of movements until it becomes muscle memory. You'll want to do the same with coding challenges.
So from various tutorials you'll learn what different commands you can write. When you face your first problems it's common to feel overwhelmed. There is SO MUCH stuff in that this ruby programming language has to offer. Should you use an each command or a return one?
The nice thing about programming is that it is possible to solve all computing problems with a remarkably small number of commands – by mastering a relatively few commands you can glue them together to solve all your problems. Once you master the most important commands of the programming language – you can work on some of the other "cosmetic" commands, which might allow you to solve a problem with 1 line of code instead of 3.
The master has encountered every single variation of every problem countless times and immediately has the muscle memory of how to solve the problem. It's a reaction without even needing to think.
A beginner doesn't have these coding instincts. To develop them, but you can develop them using kata.
Kata in programming are coding challenges that will push you towards using a small number of specific pieces of the programming language at your disposal to give you this muscle memory.
Here's an example of a programming kata.
Reverse a sentence, for example the turn the text "bob likes dogs" into the text "dogs likes bob"
This is a relatively simple problem, but it will require that you know how to do the following steps:
- Covert text into a list of words
- Reverse a list of words
- Recombine the words together into a sentence
And the first kata you get will kick your ass! It may take you an hour or more and you might not be able to solve the problem. You'll struggle and the process will feel frustrated.
And eventually you might give up and ask for help. But then when you look at the code that solves the problem, you'll understand how and why it's working. By fully understanding the solution to each kata before moving on to the next you'll start developing this mastery of the craft.
You'll appreciate what each piece of the program is doing and be better prepare for next time, when you'll have a different, but similar problem.
And then when you tackle your next programming kata, for example:
Remove the word "likes" from a sentence, for example turn the text "bob likes dogs" into "bob dogs".
This is a problem that has similar steps as the previous problem:
- Convert text into a list of words
- Remove one word from the list
- Recombine the words together into a sentence
This second kata shares a lot of commonalities with the first one (it's 2/3's the same as the previous problem!). So by fully understanding how the previous program works, you'll be able to do something similar for this problem. You can re-use a lot of the same steps.
The key is to continue working through harder and harder challenges. After you solve a number of different programming challenges without instructions of exactly what to type you'll realize that problems that used to challenge you are now really easy for you to solve.
And when you finally start solving the problems it will feel so satisfying and fulfilling to conquer such a hard challenge.
If you're looking to land a job as a web developer, you'll notice that on the technical interview process you'll be given kata to test your ability as a programmer.
The kata you'll be given as part of an interview test will probably be a lot harder than the ones that you're starting out with, but you need to work your way up to this level of question slowly.
Tools like tryruby and RubyMonk can give you a 360° view of the ruby programming language. Learn Ruby The Hard Way is a good overview and I'd suggest completing the study-drills they have as well (the study-drills are kata at a timely fashion!).
From there, to take your ruby-fu to the next level, solve problems from sites like CodeWars and excercism.io. Codewars in particular is super cool because you can review solutions other people have written. Some people will use cool tricks on their solutions and you can learn from them.
Finally CodeAbbey has some really complicated challenges, which will help you really master the language.
Before you know it, you'll know exactly when it's the right time to: Sweep the Leg, Johnny.
[As a side-note this is a slightly different answer than How do I learn Web Development? which is a related question, since ruby is often used in Web Development]
I also can suggest going through the Intro course I've setup for my online coding bootcamp, Firehose. It's free and takes most people around 2 weeks to complete it. It's is a combination of instruction and coding challenges and whether you're looking to sign up for a coding bootcamp or not I think most people learn a lot from it.
Firehose Intro to Web Development Course – 2 Weeks Free
If you liked my answer, it would mean a lot to me if you upvoted it, by pressing the light blue button below.