duminică, 17 ianuarie 2010

Why yet another...

Short version: it is an educational toy project.

Longer version follows.

First, some bits of personal history. I've been programming in the usual imperative languages for about 15 years, longer if you count BASIC and Z-80 assembly. I'm using Linux since 0.99pl15 (funny how I remeber that) so I'm basically a UNIX and C type of person.

I started fiddling with computers at an early age; I think I was 4th grade when I went to one of the state-run hobby clubs for kids (long disappeared since) and joined the computer class. Other than playing games on the Spectrum clones we had, we were learning BASIC.

That's when I had my first computing BFG (big f*ing grin). One day I realised that I can draw a filled circle by drawing increasing radius circles up to the desired size. Silly, but I was 10yo and I have just understood algorithms.

Fast forward to high-school years, '93-'94. Since Romania, like most countries in communist eastern Europe, was cut off from western technology until the revolution of '89, that's when I first got access to a PC. Did some programming in MS-DOS, using Pascal and assembler. Later came email, the internet and Linux. On 40 floppy disks!

That was my second BFG. I skipped many classes sitting in the computer lab, going through the heaps of man pages, howtos and even the source code for the entire system. Everything was there! I was amazed. I learned C immediately, so I can stop reading the kernel source like poetry in a foreign language.

It's all been Unix and C for me ever since, with the occasional Perl, Python et al.

One thing I used to do a lot is to read other people's programs, out of curiosity and the desire to learn. While it is clearly impossible to learn how to program without writing programs, it is perhaps not so obvious that to write good programs you also need to read a lot. Read good programs. I acquired a taste for code beauty and elegance by learning from Unix. And C. You know where this is going.

Enter Lisp. I have heard of that before; it's that language dinosaurs used and AI is dead anyway. My first actual contact with Lisp was through arguments with a friend, which turned into some benchmarks. "It's dead, it's slow, it's useless.I can do that in C as well, that I can't do so easily but why bother, etc. You can't be serious". I guess he was serious and I should have listened.

Then, 1-2 years ago I became increasingly disturbed by the "Lisp is super-this, super-that, and it's actually not so slow" I kept hearing, so I started peeking. Read the Paul Grahams, the Peter Norvigs, the Richard Gabriels and many others. Went to #lisp on freenode and to comp.lang.lisp.

I have this simple theory that when a bunch of smart people care about X, that X is something usually worth caring for, so I was sufficiently hooked. Everything seemed so exacting and precise, yet I couldn't understand a word of what they are all saying. I decided it must be only jargon, and once I'm familiar with the language it will all make sense. So I picked Practical Common Lisp and did some scribblings in Lisp. Wow, this is easy.

Remember the part about reading other people's code? Take this guy, for example. By God, this man knows how to write beautiful programs.

Last autumn, I finally took the bait and started studying from Structure and Interpretation of Computer Programs, doing the exercises and all.

Alan J. Perlis (to whom the book is dedicated) said "I think that it's extraordinarily important that we in computer science keep fun in computing". I cannot describe how much I enjoyed this book. At first I had to twist my brain to see data as procedures; I was familiar with closures, but I've never seen them in such abundance, nor the elegance and simplicity of the constructs in this book.

For me, it finally clicked in chapter 4 where procedures become data. Procedures as data, data as procedures. eval and apply. So simple and beautiful! There it was, my third BFG. The rest of the book was just plain fun, eval-ing and apply-ing all over the place.

This has been my road to Lisp, so far. I cannot help but noticing that my story is not unlike many others' that finally found Lisp.

As for why another lisp from scratch, the answer should be obvious by now: I have an itch :-)

Next posts won't be nearly as melodramatic, or long. I promise.

Niciun comentariu:

Trimiteți un comentariu