I first learned to write code at university, where we used a number of obscure (oberon, anyone?) and not-so-obscure languages. The different languages were used in different courses – Haskell for functional programming, Oberon for Object Oriented programming, C for signal processing etc. – so we learnt them alongside the rest of the theory. Since then, I’ve picked up other languages at places I’ve worked; mostly by having to extend code in a new language.
I’ve not yet worked out the best way to learn a language that I don’t have an immediate work-related reason to use. I’ve heard a lot of talk about Ruby recently, and wanted to know what it was all about. But finding out about Ruby proved to be a challenge!
Obviously the best way to learn a new language is to write code in it. But if you don’t have a project to work on, or the time to spare, then it can be difficult to start something complex enough to learn from.
I find online tutorials much too simple as they’re normally aimed at novices, and really only cover the basics. Places like Code Academy may be great for beginners, but the basics only really differ in syntax between languages.
Another technique I’ve read about is to port an existing project from one language to another. To me, this sounds like a potentially bad way of learning as you could easily just end up trying to emulate one language in another without understanding anything of the intricacies and complexities of the language you’re trying to learn. I can imagine that it’s really easy to directly port a project in C to Python without really learning anything about what more Python can offer.
In the end, I was pointed at ruby koans by my husband, which are inspired by the Zen Koans. These are a series of almost 40 files that you work through. Each contains tests that fail, and by correcting them you can learn something about the language. Every corrected test takes you one step closer to enlightenment. There are no explanations, so you can google as little or as much as you need, without having to wade through explanations of things you already know. I found these to be a good way to learn; I could easily complete lots of the tasks with a little thought, but every so often had to stop and google an answer to find out the theory. Apparently there are F# koans too, which might be my next challenge!