views:

789

answers:

20

I have found the easiest way to learn a new language is to write something in it. Usually this works best when I find myself having to write a fairly involved application for my job, however sometimes you just want to pick up some new skills.

So my question is what kind of "sample" applications would you write if your sole goal was to learn.

Your answer might vary based on it being a web language or client language, if you think they are different please offer suggestions for both.

+1  A: 

This might be useful.

Other ideas include items from RubyQuiz which has stuff that can be done in various languages including Ruby.

robintw
+2  A: 

Well, I'm only a web developer, so I only have an answer there... but the first thing I wrote in PHP, and the first thing in Ruby, and now, the first thing in Python... a simple blog. Input, output, templating, database interaction, user management, etc, are all part of a blogging platform and all good things to learn early.

Steve Paulo
+7  A: 

I learned Haskell quite well by just answering a bunch of project euler problems in it... and my skills in it improved a lot because of the practice.

Mike Stone
+4  A: 

Larry O'Brien at has an excellent series of exercises for getting to know a language. They start with "Hello World" and end with a GUI for an image processing algorithm. (I guess that image processing is his thing, but you can adjust to suit your tastes.)

Unfortunately, his website is down at the moment, so I can't provide a link.

Update: knowing.net is back up, so here are the exercises:

dysfunctor
I've considered trying out his problem sets, but never got around to it... maybe I should learn a macro language via that, or erlang (both of which I've wanted to pick up)
Mike Stone
+2  A: 

I usually write these in order:

  1. Hello world (to learn output and how to compile/interpret a program)
  2. Guess the number (to learn random numbers, flow control, input)
  3. Brainfuck interpreter (to learn file input, arrays, etc.)
yjerem
A: 

a basic todo list:

  • would include add/edit/view/remove actions
  • basic database use

then build from there.

scunliffe
+1  A: 

I only really use web-development languages, and my first steps in new languages (after finding out basic syntax and so forth) is usually to create a simple blog application.

thesmallprint
+1  A: 

I would fine some application or functionality I need in my day to day at work, home or hobby and try and implement it using the new language/technology. You should find what is you pain - what application you need and go and write it.

Dror Helper
+6  A: 

Conway's Game of Life

toohool
+1 just cause the game of life is still cool after all these years
Cruachan
+2  A: 

Supposedly P.J. Plauger once said "My approach to learning a programming language is to write a compiler for it."

I would like to try this one day, both to learn how to write a compiler and to see the power of this approach...

Mike Stone
warning: you many never get past c++ (or perl) if you take this method. I actually like the idea of writing a simple interpreter (say for lisp) in the language.
James Brooks
+1  A: 

For me, the biggest factor in holding my attention is whether or not I think the problem at hand is interesting, and the biggest factor in me learning is having my attention held [grin].

When I'm learnings a new language, I try to do something that interests me. I like thinking about scaling internet servers to lots of simultaneous connections. Erlang seems like it has some interesting features (including its concurrency model). So, if I were wanting to learn Erlang I'd have a look at yaws or maybe think about what other kind of internet server would be fun to write.

I would pick something that interests me, that I'm likely to stick with.

Cheers,

-- Douglas Hunter

douglashunter
A: 

+1 for Conway's Game of Life. That's been my stock "first program" for years.

Electrons_Ahoy
A: 

Well, it depends what I'm interested in doing. If I just want to know about the language's features for academic reasons, I usually just run through basic stuff like fibonacci, Y combinator, etc. Maybe some hello world type things.

If I'm learning it because I actually want to do something, I usually follow a relevant tutorial, then dive in to doing my own version of what the tutorial did.

Marcin
A: 

I'd go with simply solving a real-world problem that you would have otherwise used whatever language you currently use to solve, but use the new language instead. In my experience, the best learning is from simply using it to do real stuff with.

Stephen MacDougall
A: 

Asteroids (but I skipped it when I learnt javascript)

mliesen
A: 

I like working from the Code Kata's that are on that website. They even work for practicing in your current main language, because they seem deceptively easy but will challenge you anyway.

MadKeithV
+1  A: 

I tend to write a compiler for a simple language like Scheme, or an assembler for a simple architecture like MIPS32, when I am learning a new language -- but it depends on the language. When I wanted to learn Ruby, I just wrote a bunch of shell-like scripts and some simple web applications.

Someone above me already mentioned Project Euler; I use that a lot, too, when learning a new language.

Beyond those two things, I just write whatever tickles my fancy. For example, when I wanted to learn Python (better), I wrote a D&D encounter simulator in Python.

mipadi
+1  A: 

This site

Gilles
A: 

I whip up a Roman Numeral conversion function, the way I code it exposes me to string and arithmetic functionality as well as conditionals and looping. Here's my one for TCL from earlier this decade:

http://code.activestate.com/recipes/68379/

George Jempty
Cool idea -- I've never thought of that!
mipadi
+2  A: 

The classic "simple" problems all come to mind (hello world, fibonocci, simple blog, etc) which are great for a first try, but then I always need something more. Things like Project Euler, Refactor My Code, or even random StackOverflow questions can give you some more substantial problems to try and solve. The only problem with these aproaches is that you don't care about, or need the answer to the problem your trying to solve. Your artificially looking for a problem. I find that I learn the fastest when I am trying to solve a real problem I have (or at least someone around me has).

A couple of guys at my work have been "swapping code" over the last few months. Whenever we find ourselves saying "I wish I had a quick program that would tell me X" or "It would be nice to be able to see this data like Y" we toss it over to one of our coworkers to take a stab at. You end up with small programs that are relevent to your real life and therefore much more interesting to solve. A great example of this was a guy I new wanted to go skating on a local pond when it froze over but would only feel safe if had been below freezing each night for the past 2 weeks. A bit of research and some hacking in ruby produced a script to tell him just that.

My two cents.

Benjamin Lee