I am a big believer in learning by doing. Basically the best way to learn a new programming language, or any other skill for that matter, is to dive in, find a project you are interested in building and just start. Sure you'll get plenty of things wrong but everytime you do you'll have a better understanding of why things failed and be better equipped to not make the same mistakes later on.
Compared to other people I know I started out programming relatively late. Before starting university in 2006 I hadn't really done any kind of programming. The language of choice at my university was Java so that was the first language I started programming in.
I didn't have anything to compare it to but I loved programming Java because it, put simply, allowed me to make my computer do things. I was studying math at the time so the first programs I wrote were relatively math heavy. A simple calculator and an RSA encryption tool were among my first programs.
I quickly pivoted to writing more advanced things. I took a "Introduction to Computer Networking" class where the professor showed how you could connect two different computers on a local network using a tcp server and client. It was crazy inspiring!
Writing networked things in Java was a bit complicated. I would use a lot of abstractions (interfaces, abstract classes, big class hieracies) but things still didn't always work. Writing networked programs are hard and I had very little experience and made a lot of beginners mistakes. This was around 2009 and a friend showed me an article about this new thing that had just come out called Node.js
We basically had no idea what we were doing. We grokked through some of the examples on the Node.js website and figured out how to create http servers. Node also had a file api and we would write files and userdata to files on the harddrive. Neither of us had at this time had ever really used a database before so just decided on using the file system for all user data.
More and more of the code we wrote looked alike so we started to copy-paste code around. This, of course, quickly turned into a mess and was hard to maintain. When we fixed a bug in our shared code we had to re-copy-paste it multiple places all over the code base. Node had just gotten the
require call so to solve this we decided to write a module. Our first main module was called
common. The code is actually still online on Github, https://github.com/gett/common and you can still download it from npm (we put it up there later when npm became a thing). It was a utility grab bag module full of a bunch of convenience functions.
The main problem with having a utility grab bag module was that it was really hard to decide what went into that module and what didn't. At that point our metric was that if code was being used twice it would go in the common module. Basically an anti copy-paste pattern. Today I just split everything into a bunch of small modules instead.
I don't use any flow control libraries any more. I just use named functions and put more things into modules.
A bunch of people started using it. Soon we discovered that our approach of using the file system as a database didn't really work that well when multiple people were using the site at once. We decided we needed to understand how to use a database. After some quick research we set up a MongoDB instance which was all the hype at the time. We didn't really understand how it worked but it used JSON as a query language for storing documents. We knew that JSON was easy to write in Node. That was the killer feature for us. There was already a driver written for it Node called mongodb-native but it was a bit hard to use. We decided to write a wrapper for it that would make it a bit more user friendly. The wrapper was originally just called "db" (which was available on npm at the time!) but I soon renamed it to mongojs.
So to sum up my experience
- Find a project that motivates you.
- Writing bad code is better than not writing any code. Learn from your mistakes.
- Read other people's code.
- Don't listen too much to other devs / books / blogs. Do things your own way. Again, learn from your mistakes.
- Don't be afraid to reinvent the wheel. You'll learn a lot doing so.
- Always publish your code to Github. It doesn't matter if you think it's bad. It gives you a notion of finishing things