Theresa O’Connor

Intralanguage migration means no migration at all

The reason (or, at least, one of the main reasons) we code in high-level languages is the tremendous gain in programmer productivity — the (relatively) small amount of time it takes to go from nothing to a program that gets the job done. But often this first cut at a solution doesn’t have the performance characteristics that we’d like. What’s to be done?

As scripts grow into full-fledged applications, programmers should want to port portions of their programs from scripting languages to languages with sound and rich type systems.

— “Interlanguage Migration: From Scripts to Programs” (via ΛtU)

Skipping over the whole type theory aspect of this, and just thinking of it as porting portions of large programs written in ‘scripting languages’ to C — the low-level language most ‘scripting languages’ are written in, you see the need for this frequently come up in the Python/Ruby/Perl/PHP worlds. Basically, the P-language (Ruby is an honorary member) solution to this problem is to rewrite the inner loop or other performance-critical compontents in C.

But now you have two problems. The reason you used a P-language instead of C in the first place is because, well, making complicated stuff in C that also works is hard, time-consuming, and a pain in the ass.

/me puts his smug Lisp weenie hat on

Suppose you had written the program in Common Lisp. You get all of the programmer-productivity benefits of a P-language — arguably more such benefits. But when push comes to shove and you desperately need to improve performance, Common Lisp allows you to selectively and judiciously annotate your program with type information, thus allowing the Lisp compiler to compile faster code. This plus many other such features mean that both the “high-level, low-performance” parts of your program and the “low-level, high-performance” parts are in the same high-programmer-productivity programming language. You don’t have to be a Lisp guru and a C guru — simply being a Lisp guru will do.

Why give up the productivity boon of your high-level language when performance matters? With Common Lisp, you don’t have to. Why jump through so many hoops to perform an interlanguage migration when you can have intralanguage “migration?”