Miles Per Hour

programming at the speed of 1011000.

Feb

17

How to Learn a new Language

By mike@mike-miles.com

Recently I started looking into learning some new programming languages (Like many programmers I know, I’m always looking for a new challenge).  The languages I’m interested in are Cocoa (Apple’s Objective-C based programming environment, for making an iPhone app) and Ruby (a language I’ve been wanting to pick up for a while).  Since I’m in the process of learning these languages, I’d thought I would share my practices for learning new languages.

First I always find it is important to  figure out why you want to learn that language. For example, I want to learn Cocoa so that I can build an actual, non-web based iPhone application.  Then read up on the language, learn the terminology, the structure, syntax, ect.  After that I believe in ‘learn by doing’, as in start developing with that language.  Here is the process of developing I usually follow for new languages.

Hello World

This is most likely the first piece of code you ever wrote, a simple piece of code that outputs the words ‘Hello World’ to the screen.  I like to keep up this tradition with every language I learn.  It’s basic, simple and produces something you can see.

Fibonacci Numbers

Next up, I try and output the fibonacci numbers (1,1,2,3,5,8,…).  It’s a simple sequence that involves using a for or while loop. Agan basic, simple yet a step up from ‘Hello World’.

FizzBuzz

Another classic programming example. If you dont know for fizzbuzz you output every number between 1-n (what ever you want your delimiter to be).  for every number that is a multiple of 3 you output ‘Fizz’, for every number that is a multiple of 5 you output ‘Buzz’, and every number that is a multiple of 3 and 5 you output ‘FizzBuzz’.  A more complex piece of code, that gives you practice with the languages if statments, loops and output, yet still simple enough to be easy to write.

Functions

Next up I take the last three examples and make them into functions.  First functions that have take no parameters (just to test function calls). Then into functions that take parameters (to test variable passing). And then finally functions that take user input.After those simple practices my methodoligy changes depending on the language, for example if it’s an object oriented language I’ll go ahead and try writing classes and objects. If not oo I’ll try writing more complex functions (recursive, sorting, ect).

Those practices usually give me enough practice with a language where I can start building simple programs, which I can then build upon and develop.  I also try to find online communities where I can find tutorial, examples and tips.

Comments are closed.