Thoughts Reading Practical Common Lisp

In my last post I mentioned reading Practical Common Lisp. I went on through several more chapters since I wrote that (quite a few more) and one practically made me stop. The first “practical” exercise is writing a library that makes it less horrifically painful to use Common Lisp to deal with reading directories.

It was a pretty quick little library and I’m sure effective, but at that time, I was kind of tired of hearing explanations of how “this has a meaningless name, for historical reasons,” or “this is completely contrary to how you’d expect it to be considering other parts of the language” or whatever. There’s a lot to just get used to in Common Lisp. Seeing an entire “practical” chapter devoted to creating a library to fix kludgy implementation problems stemming from Common Lisp’s advanced age was offputting.

But then I realized that a little ahead were the chapters on CLOS, the Common Lisp Object System, something I had always wanted to understand and never quite got. I didn’t really understand how Object-Oriented systems based on multi-method dispatch worked.

It was a really good explanation. I think I understand it now. One point that was made was that it is not a “message-passing” type of OO, the way Smalltalk and Ruby are. I realized that while CLOS is pretty cool, I really like the message-passing style of OO. It made me wistful for Ruby.

But CLOS is way powerful, and the book had a great explanation of it. Now if I take a look at other multi-method-dispatch systems I’ll have a better context from which to understand them.

The chapter on LOOP-fu was interesting. LOOP is a mini-language implemented with macros within common lisp that lets you write Python-like loop constructs (probably more powerful than Python’s loops) in a not-very-Lispy notation. It made me think Python might have been influenced by Common Lisp LOOPs.

I also wanted to check out the chapter on packages, because that was a big part of Common Lisp I didn’t previously understand. Turns out they’re a lot like Perl, but that it’s easier to shoot yourself in the foot using them than with Perl.

I still haven’t read most of the “practical” chapters yet. (I skipped forward to get to some of what I considered the good stuff.) But overall it didn’t make me want like crazy to program in Common Lisp. It made me feel like I could if I wanted to for some reason. It cleared up a lot of what was mysterious to me about Common Lisp. The only thing that Common Lisp has that I really desperately wish I had in other languages is its glorious macro system. I have a feeling that in terms of the “defining new syntax structures by being able to take unevaluated code chunks” aspect of macros, you can get a lot of mileage out of Ruby’s blocks for doing macro-like things. However, macros can do a lot more than that.

Overall it made me think fondly of Ruby, because Ruby uses a style of object orientation that seems more natural/intuitive to me, and can do a lot of (though by no means all) the spiff stuff Lisp can do.

It also made me think fondly of Scheme, because Scheme is a lot less ass-ugly than Common Lisp, and can do a lot of the same good stuff, though it doesn’t have even a tiny fraction of the built-in cool stuff in the standard.

It definitely made me open to using Common Lisp if I ever think of a project where it would come in really handy. And I do plan to finish the book when I get a chance.

Fun Fact about Common Lisp: standard Common Lisp has no networking libraries at all, but it does have a built in function to print integers as Roman numerals — using either the new style (14=XIV) or the old-style (14=XIIII) Roman numerals. Huh.

Thanksgiving, Computer Languages

I’m at the in-laws over thanksgiving; no high speed internet or anything like that (posting this over my FIL’s AOL account). I’ve got a lot of reading time, so I’ve been making my way through Practical Common Lisp, whose hardcover I bought back this summer.

My new hosts NearlyFreeSpeech.net happen to support Common Lisp as a CGI language, of all things, so the potential to have some fun with it is there.

I’m up to chapter 9.

Some parts of it make me want to run back to my old friend Scheme. The whole “function namespace” thing, having to refer to functions in a non-function-call context #’like-this. Goofy. But it’s a great book, and I’m really enjoying it. Taking it in small enough doses that my attention stays focused.

Finally having considerable real-world programming experience (in Perl) has given me an idea of just how useful something like Lispy macros could be… You can achieve something kind of like Lisp macros using source filters, but it’s far more hassle in Perl and far less powerful.

I also brought my Ruby on Rails book, but it’s not quite as interesting to me right now. Honestly, I know Ruby reasonably well, having played with it in work and home contexts since about 2001. I have never used it for full-time programming work, which would give me a serious knowledge of it, but I’ve used it for a lot of goofy little scripting. But I find Rails kinda hard to understand. I’m gonna have to put some serious attention into that Rails book and play with it a lot to “get” it.

I’m also a little worried about all the megahype Ruby’s getting. Pride goeth before a fall. It makes me kinda queasy to see one of my favorite languages get quite that level of buzz.

But my buddy Jim is interested in acquiring some Ruby-Fu, and he’s schooled in Java, so I wanted to pass along for him this link I found — 10 Things Every Java Programmer Should Know About Ruby. Looks pretty cool.

Catch y’all later.

Ask the Administrator: Stopping the Cycle of Abuse

Confessions of a Community College Dean: Ask the Administrator: Stopping the Cycle of Abuse

This cheers me up considerably about not having stuck it out and gotten a Ph.D. in Classical Languages.

On the flipside, I have several friends who did become professors and are pretty happy with their lives.

And it’s not like I got a real job till I was about 30 anyway.

Io 1.0 impending

ioblog:

The target date for a 1.0 beta is Jan 1, 2006 and the goal for this release is to clean up Io and make its implementation solid and ready for production use. This work involves a reorganization of the source tree, moving much of the implementation from C into Io, and extending the coverage of the unit test. Coroutines will be exposed within the language and actors, exceptions and the asynchronous networking control will be implemented in Io.

That’s cool to read. Especially the “moving implementation from C into Io.” I bet that really puts a language through its paces — insisting on pure language libraries instead of just wrappers of C libraries. (Of course I’m sure there will still be tons of C wrapper libraries — that’s something Io is very good at, and that’s a feature, not a bug.)

I haven’t done much with Io since I’ve been programming full time. Back when I was a sysadmin, a couple years ago, I was fascinated with different computer languages and kept learning new and interesting ones whenever possible. (That’s why I was writing Ruby scripts before everybody wanted to do Ruby because of Rails…) Now that I hack Perl full time, I don’t have the choice to say “hmm, I need a script, I could write it in bash or perl, but why not Python or Ruby?”

It’s nice to have gotten to know Perl much, much better than I had known it a couple years ago. I’ve learned some wonderfully cool things about Perl. But I miss those dillettante days. Maybe I eventually would have gotten to understand those wacky Haskell monads.

Now I find myself wanting to go back to Io and see what’s happened while I was away.

Ironically I’m doing something with Perl now (cooperative multitasking, using POE) which Io has always had built in support for.

Vim Experiment

I’ve been using Emacs for programming for years now. But I have been using old-school ‘vi’ for quick edits on configuration files and the like.

I know a lot of people who love the heck out of ‘Vim’, aka ‘vi improved,’ which is vi mutated to the point that it has capabilities comparable to Emacs’s.

I think I’m gonna try coding in vim for a while.

Any vim lovers who want to point me to good vim resources on the net or whatever, shout out in the comments.

UPDATE: I can’t do this right now. I need to be able to use my editor without thinking about it. I’m going to save the vim transition for a time I can afford to stop and think more.