views:

2810

answers:

15

When you decide to learn a new language what do you do?

I tend to do a small amount of reading about said language then write a few simple "standard" programs -- typically raytracers and parsers because they're what i'm conceptually familiar with -- so that a can get a feel for the language and learn to use it without having to think about how to do the task at hand.

Once I've got to that point it just degenerates into the more boring process of just using it on a regular basis for whatever I need to do.

+8  A: 

I usually play a few rounds of Anarchy Golf and solve some puzzles from Project Euler. Doing both usually gives me a fair idea of what the common idioms are in a language, as well as some of the less well known tricks--especially in the case of Anarchy Golf).

Patrick
+1  A: 

I typically only learn a new language when I have a problem that it solves better than the ones I already know. Then I read an introductory book about that language to get a feel for it, and do some of the sample exercises.

Then I write whatever program I wanted to learn that language for in the first place. I can't learn a language any other way, really. I need a problem to solve, and that focuses the learning. By the time I've gotten my target program written, I've usually got a decent handle on the language, not to mention any other features it has, and I've got other ideas to use it for.

mabwi
A: 

I tend to just jump in and use it for something real. I don't write many throw away programs or solve puzzles. Instead I'll apply the language to an actual project, either at work or possibly something personal. I find that actually using a language this way brings me up to speed a lot quicker. Especially if it's for work, I've got to come up to speed, because I've got to get the job done.

Derek Park
A: 

@Patrick: those look like great fun, although I am now worried that they'll consume all my spare time :D

olliej
+5  A: 

I got my start with game development, so it's starting to become a trend that I try to do something game development related. The best possible way to learn a new language is to:

  • Learn the Syntax: Review basic tutorials
  • Work on a practical project of some sort, and finish it

I just recently picked up Python. I spent a few hours learning the syntax, and then began working on an XML based adventure game for which I spent a few days creating.

Working on puzzles and logic things are great to build your aptitude, but I believe learning a new language is best served with making something practical.

But all in all... Everybody is different, and we all learn differently.

David McGraw
A: 

Write a unit testing framework for the language.

Esteban Araya
+3  A: 

The obvious thing. Try and write a Seven Day Roguelike. Well not really. But I did do this with C#, and I found it helpful. Usually once I've got the basics of something, I'll try a little project using it or something like that.

Bernard
+2  A: 

Generally the first thing I do is find a good online tutorial to get me through a realish-world example. For Rails, it was the bookstore application in Agile Web Development with Rails book.

After that, I try to watch screencasts as much as I can. When I was learning ASP.NET, it was ScottGu's stuff, when it was Rails, it was Railscasts and PeepCode. Not doing the code they were showing, but just absorbing as much as I could.

Then, into the breach. Dig in, decide something real-world that I want to solve, and just have at it.

I recently read Brain Rules, and one of the things in that is to use multiple media when you learn -- don't just read, or just do, or just watch videos, but do all of the above. And do it repeatedly, review frequently and keep at it.

Tim Sullivan
+1  A: 

I think it's a two step process for me...

  1. Look at the language, what is the statements, expressions and control construction
  2. What tools are available? I.e the API's and compilers. Are there frameworks to access disk, ports and gui etc and are they easy and nice
epatel
A: 

One of the good practices is making errors on purpose. Go for it, make syntax errors, use non-referenced objects, divide by zero. See the reactions of the compiler and the framework so when you encounter an error in a complex situation, you can have an idea of what may the cause be.

Serhat Özgel
A: 

I will try to make a small application in it, for Python I tried to make a basic version of twitter. This taught me database and cookies where some applications may not have.

Make sure to pick a project that's not crucial (incase you muck it up) but one that you will enjoy and possibly have a rough idea of how you are meant to solve it, that way you will not be worrying about the problem itself and can spend all your time learning the language in question.

Teifion
A: 

I've found that writing a (basic) compiler really helps you learn a lot of features of that language. I've recently re-done one of my old University projects (see http://www.cs.bris.ac.uk/Teaching/Resources/COMS22201/assign.html) in Python for this exact reason.

A: 

I tend to avoid 'Hello World' examples, mostly because they're uninspiring and don't really tell you very much, other than how to do basic output.

I would think up a smallish project to do, one that's not too trivial and would give you a sense of satisfaction on completion. Writing a version of Tetris always works for me!

I would just start writing (given that the correct environment has been set up) and have a good book or use the web extensively as you code. When you come across problems don't let it beat you, have a clear idea of what you want and make the new language work for you, not the other way around. That's when you really learn something new.

Jonathan Swift
A: 

When I learn a new language, I find a tutorial.

First, I read half of the tutorial. Then, I create an overly-complex application which stretches my knowledge about how much I learnt. Afterwards, I look through the rest of the tutorial to find out why it didn't compile.

Finally, I create a program which will actually do something I need.

+1  A: 

When I learn a new language, I have a habit of writing a small program when the class is over to help solidify the learning in my memory. My favorite is what I call 'dirsize'. Dirsize recursively traverses the directory structure and produces the sum of the sizes of all files below a given starting place. The starting place is usually hard coded at first. When it is working, it can be changed to use an argument to the program or to provide some user interface to select the starting directory.

A side benefit of programming 'dirsize' is you come to appreciate recursion and understand that a directory is not just a special type of file.

Kelly French