Free since 2005 · No login required
AT

Academic Tutorials

Learn at your own pace

site-mobile-top-banner · 320x50

Lisp and Java

Added 31 Jul 2008

Why learn a new programming language? Among other excellent reasons (such as good, old-fashioned intellectual curiosity), there's the opportunity to pick up useful techniques, tricks, and idioms that you can apply in your day-to-day programming life. At its best, studying a new language can give you the kind of conceptual shift that illuminates thorny problems in a new light. Even if your mainstream language of choice doesn't provide the special-purpose syntax that you find in a language you're exploring, you can often find a way to implement the underlying technique in a useful manner.

In this article, we're going to steal an idea from one of the most theft-worthy languages out there: Lisp. We're going to pick out one of its most useful features -- the ability to treat functions as data -- and talk about how to apply this feature, in a slightly different form, in Java. In the course of doing so, we'll give a very (very) brief introduction on how to read Lisp code. We'll also develop a small but useful library for JDBC and collections programming that you are welcome to use, abuse, and extend as you see fit. We're going to use the Scheme dialect of Lisp for our discussion, because it expresses the ideas we're interested in in a particularly clear and elegant way.