Archive for the 'Lisp' Category

The Lisp Ducati

Came across Lisp: The Ducati of Programming Languages over at defmacro.org yesterday:

“When you drive a car”, he said, “there is a disconnect between your thoughts and the machine. You sense it, but you’re never really conscious of it until you get a bike. You want the car to accelerate, you add some gas, and then you have to wait for a split second before the car listens to you. On a bike this delay is so much smaller, your brain doesn’t really register it. You think of something, and you’re there. A bike becomes a part of you - an extension of your body. You’ll probably need a Ferrari to achieve such unity with a car.”

~drool~ :)

Goodbye, OpenLaszlo

After a month of OpenLaszlo, I’ve had enough. Coding in XML just isn’t my style, I’m afraid. (And yes, I know you do half the coding in JavaScript, but that doesn’t change anything.) I don’t think that means XML-based programming languages are inferior or anything like that — if I spent more time wrapping my head around OpenLaszlo, I could probably feel better about it (or I’d have one heck of a sore head). But I don’t have that kind of time. Nor was I getting enough of a “coolness” factor, the way I do when I work with Lisp. This experiment leads me to suspect that I probably wouldn’t like Flex much, either.

So, I’m going back to the basics. Simplicity is good, and so I’ve taken the app I’m working on and pared it down as far as possible. So far, in fact, that I’m pretty sure I’ll be able to do the whole thing with Javascript, HTML, and CSS, with a web service providing a connection to the server (written in ASP.NET most likely, though I’d prefer Python and may end up going that route), and anything else in Python. I might use MochiKit or Dojo to make the Javascript end easier to code, but I’m not sure yet if I really need it. (Why not Rails? Well, the server is unfortunately a Windows box running IIS, and I’ve heard that Rails doesn’t perform all that well on IIS. I wish I could get the server moved to Linux, but that’s probably not going to happen anytime soon. In the meantime, Python is still very nice to work with, and I haven’t caught wind of any performance issues with it on IIS.)

At any rate, this stack feels a lot better. When I was working with OpenLaszlo, I felt like I was in a straitjacket. Not much fun. Or “open.” (Again, keep in mind that these are subjective impressions; who knows, maybe OpenLaszlo is your style.)

In the meantime, I’m reading Paul Graham’s ANSI Common Lisp and liking it.

OpenLaszlo

I’ve been tinkering around a bit with OpenLaszlo, since here at work I’m about to start writing an RIA for doing online extraction of genealogical records, and it would be really nice not to have to re-invent the wheel. :) The advantages of OpenLaszlo are that it’s free, it compiles to Flash (which is on pretty much every computer out there) and soon DHTML, and it looks like it’s conducive to fast development. And there are a lot of high-profile apps using it (like Pandora).

So I spent half an hour throwing together a quick prototype of our app — no functionality, just the layout — and I think I’m liking it. It’s basically XML with a healthy dose of Javascript. Using XML this way feels almost like Lisp somehow, incidentally. :) So far I haven’t run into any huge roadblocks, so we’ll see if OpenLaszlo works for what I need.

(cons calculus (cdr ‘(eating is fun)))

Last night I spent an hour or so working through Calculus and Pizza: A Cookbook for the Hungry Mind. While I don’t care so much for all the pizza/food stuff (extra fluff that gets in the way of what I’m after), the math is good. I’ve relearned how to do derivatives, find local minima and maxima, use the chain rule and extended power rule, and so on. Still haven’t gotten to integrals yet, though. The calculus is pretty easy, I must admit; the only thing that keeps hanging me up is the algebra. Most of the algebra is a piece of cake, of course, but there are little bits and pieces here and there that I keep forgetting. But it’s coming back.

After that, I picked up The Little Schemer and spent a most enjoyable two hours working through the first 80 pages. At first I didn’t intend to actually write all of the little functions you’re expected to write, but I’m glad I did. And to my small surprise, I was able to write all of them without too much trouble. We’re talking functions like +, -, >, and < , folks. Simple stuff. It’s like writing the language from scratch yourself. (Yes, I know there’s more truth to that than there may seem at first. :))

The coolest thing is learning how to solve problems recursively rather than iteratively. Sure, some of this stuff would be far easier using a for loop, but using recursion like this means no side effects (at least if I understand correctly), and that’s sweet. I can’t wait to finish the rest of the book and move on to The Seasoned Schemer. (And I’ll be glad when we move on to higher-level programs, too.)

Oh, the parentheses in Scheme don’t bother me at all — in fact, I rather like them. :)

Functional programming

Today I came across Functional Programming for the Rest of Us, via Digg. Great article providing a nice overview of functional programming, including higher order functions, currying, lazy evaluation, continuations, pattern matching, and closures. And I’ve got to say that I’m finding functional programming pretty darn cool so far. I’m going to have to look into Erlang and Haskell. “Rock solid” systems? Definitely piques my interest. I wonder how Ruby fits into the FP paradigm. I know it does metaprogramming and closures, but I’m not sure on the other stuff. Anyway, I’m really looking forward to the next article, which the author says will probably cover “category theory, monads, functional data structures, type systems in functional languages, functional concurrency, functional databases and much more.” Good stuff. Drool.

And now that finals are over I’ll have more time to learn Lisp/Scheme via SICP. Speaking of Lisp, the same guy who wrote this functional programming article also wrote a great article on The Nature of Lisp. Here’s the quote that hooked me:

I was baffled. Many extremely intelligent people I knew and had much respect for were praising Lisp with almost religious dedication. There had to be something there, something I couldn’t afford not to get my hands on! Eventually my thirst for knowledge won me over. I took the plunge, bit the bullet, got my hands dirty, and began months of mind bending exercises. It was a journey on an endless lake of frustration. I turned my mind inside out, rinsed it, and put it back in place. I went through seven rings of hell and came back. And then I got it.

The enlightenment came instantaneously. One moment I understood nothing, and the next moment everything clicked into place. I’ve achieved nirvana. Dozens of times I heard Eric Raymond’s statement quoted by different people: “Lisp is worth learning for the profound enlightenment experience you will have when you finally get it; that experience will make you a better programmer for the rest of your days, even if you never actually use Lisp itself a lot.” I never understood this statement. I never believed it could be true. And finally, after all the pain, it made sense! There was more truth to it than I ever could have imagined. I’ve achieved an almost divine state of mind, an instantaneous enlightenment experience that turned my view of computer science on its head in less than a single second.

So yes, I’m definitely going to keep hacking away until I “get it.” Can’t wait for that moment of enlightenment. :)

Structure and interpretation of computer programs

I started reading Harold Abelson and Gerald Jay Sussman’s Structure and Interpretation of Computer Programs, the classic MIT computer science textbook. It’s good! And they use Scheme, which is very cool (although it’s certainly unlike most other programming languages). I started learning Lisp a long time ago but time has erased most of it from my mind, so it’s nice to review. (I’m not exactly sure what the differences are between Scheme and Lisp, but at this point they’re negligible. At least I think they’re negligible. Maybe I’m wrong.)