June 28, 2009

Live SQL database schema updates

I previously wrote about managing live DB schema changes using protocols and context-oriented programming. About a month ago, I came across Jonathan Oxer's presentation about dealing with live schema changes to MySQL databases. The technique Oxer presents is a kind of obvious-in-hindsight thing that is beautiful in its simplicity: run update scripts and retry if an error (unknown table/column) in the query occurs.

Readers familiar with Geoff Wozniak's work will notice the similarity to his ideas about working with undefined functions (which, incidentally, was previously discussed on this blog in the context of using metaprogramming techniques to implement DB abstraction layers).

This is something I'm definitely going to try in my next SQL database based project.

June 8, 2009

Why your language needs macros

A couple of days ago someone posted yet another "why do I need macros?" thread on Hacker News. The usual arguments and unconvincing examples arguing for macros were posted. Noted absence were the arguments against macros (all of which seem to be of the variety "programmers are too dumb to understand someone else's macros" - if you were at the Great Macro Debate at ILC 09 you would have heard it stated more eloquently).

I've been thinking about macros in terms of domain-driven design lately, kicking around my idea of "domain onions" (I'll write more about this later), so I decided to post my current thoughts about why every programming language that aspires to be general-purpose needs macros.

Gelernter

Two years ago I posted a review of Nicholas Carriero and David Gelernter's How to write parallel programs. Today I came across an Edge roundtable discussion with David Gelernter (via Patrick Logan).

The entire discussion is fascinating, and I recommend reading up more on Gelernter's work if you are not familiar with it before watching the interview.

For me, there were three new insights from the roundtable:

  • Message passing is the assembly language of distributed systems.

  • Databases are a way to communicate through time. Networks are a way to communicate through space. Both are symmetrical. The point of Linda was to unify them.

  • The most powerful computers today are botnets. Botnets are also on the leading edge of distributed systems techniques.

In the second video, Gelernter discusses Lifestreams. It's amazing how closely FriendFeed, Twitter, and the new Facebook are all following the roadmap established by Lifestreams over a decade ago.

June 4, 2009

Debugging with H-toot

Andreas Fuchs shows how to get Hunchentoot 1.0 to go into the debugger on handler errors, like previous versions of Hunchentoot used to do when *catch-errors-p* was nil.

This should have come as part of the 1.0 release IMO.

May 21, 2009

That may be, but my library is your programming language

In another instance of look-what-I-can-do-with-closures-and-late-binding, Benjamin Pollack offers a criticism of C# and Linq.

May 4, 2009

On the value of metaprogramming

Several weeks ago I wrote about a way to implement Smalltalk-style predicate function-to-SQL translation in Common Lisp, so I was amused to come across Dejavu for Python (via Jonathan Ellis), which implements the same technique by inspecting CPython bytecode.

It's amazing what kind of dumb hoops people will jump through when they don't have a system that permits real metaprogramming.

April 22, 2009

Review: Let Over Lambda

So after a lot of not reading Doug Hoyte's Let Over Lambda, I finally did manage to read it all the way through.

My overall impression first: Hoyte styles the book as a successor to PG's On Lisp; I think Let Over Lambda falls short of that goal, although it does contain enough interesting material to make the book worthwhile.

The best parts of the book are the chapter on read macros and the subsection on sorting networks. Great, practical examples and illustrations of good programming style.

The worst parts of the book are the chapter on implementing a Forth interpreter in Lisp and the "caddar accessor generator" (it's ok for me to say this because the name of this blog is ironic).

The chapter on anaphoric macros has finally made me change my mind about those things. It's ok, use them when you need them. All the stuff about "sub-lexical scoping" (ie - various interesting ways of using macros to capture free variables) didn't really make a deep impression on me - maybe I'm just too dull to see any good uses for that.

As pointed out in other reviews, the book could have used a lot more proofreading (esp of the code) and editing. Hoyte chose to self-publish the book, which I think was a mistake (and just today Tim Ferriss blogged about some other reasons why it's not a good idea).

To cap the review, don't read Let Over Lambda until you've read On Lisp. It's a fun book about some interesting Common Lisp programming techniques, but it could have been shorter.