Thursday, February 22, 2007

Creative Programming

In some scattered spare moments I've been reading about Ruby, and starting to think about programming in it.

This is a recent goal, mentioned in All I want for Christmas. I've had the motive but not much opportunity for diving in to see what all the fuss is about. Fuss? Well, yes. Ruby is riding at the #10 spot in the TIOBE index of programming language popularity.

As I say, I haven't had the opportunity. This has to do with my house, where I'm essentially rebuilding the living room. Since I'm doing the work myself and with the help of friends, it's not the money pit exactly, but it is the time pit. I guess a well-known equation would say they're the same thing.

Anyway, I'd like to start writing programs in Ruby, but I'm stuck: what do I write? When one starts learning language after language, it'd be useful to have a stock of small but interesting or instructive applications to implement.

One interesting resource I found comes from the I'm Feeling Lucky link result from Google for "creative programming". You know, like "creative writing", only the writing is programming.

That link is Creative Programming Assignments from Princeton's CS department. Robert Sedgewick and others have put together a decent list of assignments for an "Introduction to Programming" course. They are relatively simple programs appropriate to the level, but still interesting, and best of all they cover a range of programming arenas, from algorithms to computer architecture. Here's a sampling of the titles:


  • Digital Signal Processing - Generate sound waves, apply an echo filter to an MP3 file, and plot the waves.

  • N-Body Simulation - Simulate the motion of N bodies, mutually affected by gravitational forces, in a two dimensional space.

  • Particle Collision Simulation - Simulate the motion of N colliding particles according to the laws of elastic collision. (Concepts: priority queue, event-driven simulation)


The N-Body simulation sounds a lot like the gravitational simulation Russ Olsen mentions in his post For the Joy of It, with a similar intent to mine, writing a familiar algorithm in a new language for fun.

So, as I get a few more spare moments hopefully I'll be able to try this experiment of doing some of the creative course assignments in Ruby. I guess I'll have to be careful about posting full source code, in case they want to re-target the course from Java (currently the #1 language in that TIOBE index) to Ruby in a few years.

3 comments:

Susan's Husband said...

What about a feed aggregator? I.e., it reads N RSS / Atom feeds and generates 1 unified feed.

A website archiver, which creates a local copy of a website with links re-written so you could, for instance, drop the file tree on a CD and have a working website without Internet access. For advanced effort, locate all IMG tags and localize those as well.

A weblog aggregator, to get the best of a group and individual weblogs. You and N-1 friends have weblogs, then the aggregator reads the posts on those weblogs and posts them on a aggregated weblog.

jfklein said...

Good ideas! I hadn't been thinking of network programming but I suppose it has its place even in beginning programs, here in the modern world. (This will probably look like a ridiculous statement in 5, 10, 150 years when people stumble across it in the Google web archives. Will things happening before the electronic age be considered pre-history in 150 years if they aren't accessible online?)

The feed aggregator rings a bell, I think the annual ICFP programming contest had something like that as its functional programming challenege in recent years.

Mark said...

Larry O'Brien has a 15 exercises for learning a programming language. He also has rationale for each exercise (that explains what aspect of the language is being explored)