What is it good for?

I was thinking about Lisp again today, and I was reminded of a popular Edwin Starr song of the 1970s: War. I think the Lisp version would go something like this… “Lisp! Huh! What is it good for? Absolutely nothin.” Obviously, this isn’t true. Paul Graham would disagree with this obviously, as would the many many programmers who assert that Lisp is the best language ever made.

I came across this page while looking for Lisp tutorials:

Now, it’s mostly true that you won’t find Lisp in consumer products like spreadsheets, databases, word processors, and games. But then, that’s not the kind of work that Lisp does best. You will find Lisp in products that must reason about and control complex systems and processes, where the ability to reliably arrive at useful conclusions based upon complex relationships among multiple sources and kinds of data is more important than lightning-fast numerical calculations or spiffy graphics (although modern Lisp systems come pretty close to the leaders even in the latter two categories).

So what is the point I’m trying to make? Certain languages are more appropriate for certain domains. (And as a corollary, Lisp is not the “best” language, since such a language does not exist) Every domain of problem has a set of criteria that determine the optimal language. Here are a few examples:

  • Kernel Code/Drivers/Modules

    Kernel coding has very strict requirements. For one thing, it needs to be highly performant. Secondly, it has very high requirements for correctness. The obvious choice would be C, since it is extremely close to the hardware. However, it may actually be the case that a language with, say, a program-by-contract design (Like Spec#) would be ideal. This idea has been explored in the Singularity project.

  • GUI applications

    GUI applications are very varied, but all require a language that facilitates an event-driven architecture with an extensive standard library for UI elements. Note that the choice for the optimal “language” may be dependant on more than the purely semantic and syntactical facets of a language. Computer Scientists very rarely look at more than the semantics and syntax, while a Software Engineer must see the larger picture.

  • Web Apps

    “Web applications” is another broad category, but there are some factors that are common. For one thing, there is a strong need for a framework that is secure against common scripting vulnerability (XSS vulnerabilities and SQL injection for example). Also, nearly every web application follows a similar pattern of view/update/query on a database, so strong high-level database integration is a necessitiy.

What I’ve described is only a very small number of domains, and there are hundreds of mini-domains where a mini-language may be appropriate. Could all of these domains be satisfied with a single language? I won’t rule out the posibility, but it is certainly not the case with modern languages. One reason I think that is likely impossible is that the idea of an “optimal language” for a domain is very dependant on underlying class library/runtime support. Trying to provide a single platform and environment for every domain is most definately an impossibility.

Every project should seriously consider the key requirements of a language for the project’s domain, and choose a language based on these requirements. A language choice should not be made based on what everyone else is doing. Because if you always copy what everyone else is doing, you’ll never have a competitive advantage.

~Tim