Many people ask me what is the best way to learn to code. After all, I have taught myself to code from scratch and later I found myself confident enough to teach others.
At least in my case, I found there was about 5 steps I went through:
- Find something you really want to build
- Learn HTML and CSS
- Try a framework
- Build your thing
- Build your thing again
Alright, let's look at each one of those one by one.
1. Find Something you REALLY want to build
This is probably the most important step. If you just want to learn the syntax, commands and other "programming" stuff without getting something off the ground, you will most likely lose interest really, really fast.
Never has coding been so accessible and easy to learn. There are a lot of great languages, frameworks, tools, tutorials and people willing to share their knowledge. But the thing is, coding is still a pretty damn hard thing to master. It is too easy to go to codeacademy.com, get excited and then get stuck once you want to build something bigger than 10 lines of HTML. If you have nothing that will make you persevere, learning to code will be harder and less fun than it could be.
Look around, what do you really care about? Don't think too much about the details of the thing you want to build. I guarantee that thing will evolve during the process. It doesn't mean that you'll change your mind. As you learn building, you will start to understand more about the nature of the thing that you're building. You will see the details most people miss, you will see ways you can make it better than anything you have seen before. It is really a lot of fun. As long, of course, as you care about the thing you're building.
So what is it?
- Expense tracking?
- Social Network?
- Project management tool for your company?
- Automatic reporting system?
- Some crazy idea no one has ever thought about?
2. Learn HTML and CSS
HTML and CSS are the languages of the internet. Regardless of what you would like to do in the future, HTML and CSS can't be avoided. They are everywhere. Every website on the internet is built using HTML and CSS. Millions of iPhone and Andriod applications are also in fact built using HTML and CSS thanks to platforms like PhoneGap.
Yeah, HTML and CSS are all over the place. But do you know what's the best thing about HTML? It's actually super easy to learn. That makes it at perfect starting point for your coding adventure.
Great places where you can learn HTML:
- www.codeacademy.com - free
- www.codeschool.com - better but not free
- www.peoplecancode.com - very basic but hopefully useful
3. Try a framework
Now, this is where it gets interesting. A framework is a set of tools that will help you build your app faster. Frameworks are basically placeholder programs written in a certain computer language. Some of them are very simple, some very advanced. Some give you flexibility, some make you write code in a very particular way.
Why jump straight into learning to build apps with a framework rather than learn syntax first? Well, let me ask you this: Imagine you have a chance to learn Chinese in school for 5 years in your home country (given, that you're not Chinese) -- OR -- you go for 1 year to China to study. Which approach, you think, will be more effective? The deal with frameworks is similar.
Instead of trying to build pointless loops or craft perfect class methods simply make it work with the least amount of effort, instead, break it, fix it and see it work.
The question therefore is: Which framework should I choose?
I'm biased, very biased. For me, the current answer will be Ruby on Rails. That doesn't mean I won't change my mind in the future. There are great frameworks out there, but Rails has proven itself as an excellent, reliable framework and it's easy to learn. In fact, there are new frameworks written in languages other than Ruby (Laravel build in PHP) that mimic Rails.
Some reasons to consider Rails as your framework:
- Easy to learn
- Ruby code is easy to read
- Requires minimal setup
- Secure out of the box
- Great and helpful community
- Great learning resources online
- Language of choice for Silicon Valley internet startups
Some of the reasons not go go with Rails:
- All you want to do is Android applications
Again, I'm biased. I have managed to teach myself to code after many trials and trying several languages and frameworks. Ruby On Rails turned out to be by far the easiest to learn for me.
4. Build your thing
Just go for it. After you learn the basics, maybe you go through the tutorial once and you start to feel comfortable - try building your own thing. Don't wait until you have 2 years of experience. Two weeks is, in most cases, enough. I guarantee you will have a lot more fun hacking your own thing rather than doing tutorials on codeacademy.com. BTW - you can find tutorials on this very website.
5. Build your thing again
Now, this is an important and probably underestimated bit. First iteration of your thing will be ... most likely, not exactly what you imagined. Perhaps you hit the wall and simply won't be able to move ahead. This is ok. In fact, this is absolutely normal. Take a deep breath, count to 10 and start over. Same tutorials, same idea. You would be amazed how much simpler everything will be the second time.
Most of all - keep pounding and ask for help if you're stuck. There are thousands of people that can and will help you.