

A Ruby, Io, and Ocaml Programming Pattern - silentbicycle
http://weblog.raganwald.com/2006/10/ruby-io-and-ocaml-programming-pattern.html

======
iamwil
Problem is often what to build so that it's simple enough, yet significant to
learn something.

Fizzbuzz is simple, but not really substantial to really learn anything about
a language (unless it's low level assembly, I guess).

I've seen someone say they use "Petals around the Rose" game to learn.
However, not all problems will show you the neat and special things about a
programming language.

Currently, I'm taking a hard look at Lua and Love a la HN. I've decided to
replicate Pong, and the Hungryboids example from Ruby and Shoes.

Since Lua is a prototype object system, it's a little bit of getting use to,
especially since my use of Javascript has been minimal. Just writing a Vector
class has been enlightening as to how to construct objects in Lua. Like
Javascript's objects, Lua uses tables.

In a way, it's fairly elegant that complex language conventions can be built
from the ground up using just tables. But on the other hand, everyone has to
build it from the ground up every time, and scoping rules are a bit of a
headache.

~~~
silentbicycle
Have you looked at Project Euler (<http://projecteuler.net>)? It's a series of
math puzzles, solvable in any language. Once you solve each, you can read
other people's solutions, which is a great way to to learn algorithmic tricks
(and humility!). You can also compare similar code across a dozen or so
languages. I started doing PE to brush up on math, but it's a great
programming warm-up.

FWIW, you can build a class-based object system in Lua pretty easily.
Prototype systems are largely a superset of class based systems -- make a
Class object. (I prefer prototype to class systems, personally. Also, Lua is
one of my favorite languages.)

 _> everyone has to build it from the ground up every time_

Don't forget about libraries. Check out LuaRocks.

~~~
iamwil
Yeah, come to think of it, I have heard of project Euler. I've always
forgotten about it, however. I'll try to keep it in mind.

I finally got a basic barebones class system up and running in Lua (without
inheritance though). I can see the flexibility and power of the thing. But
with power, well, you kinda have to reinvent the wheel for the tools that
you're use to. I figured it was a good exercise anyway.

I was tickled by the name LuaRocks. RubyGems. We're getting better at naming
things...

~~~
silentbicycle
The Lua way is to add a few meta-features to the language that let you extend
it with other features as necessary, rather than building it in.* It keeps the
core language small, fast, and easy to understand. You can build an object
system, complete with an elaborate meta-object protocol or whatever, and then
just shove in a library and take it for granted, if you want. (Where you felt
an acute lack of an OO system, I was missing map, fold, and the maybe monad.)
Besides, having the flexibility to reinvent means you can also invent.

Sometimes an object system is useful, but sometimes it just gets in the way,
and I don't think such things should be in the core language.

------
jon_dahl
Thanks for the reminder, Raganwald and silentbicycle. Time to close Hacker
News and open up my editor.

