CSE 151 - Essay #1 Ė Programming languages for Artificial Intelligence
While programming artificial intelligence applications is not fundamentally different from programming other types of applications, we still must choose the right tool for the job.† Not only can the right programming language provide speedups in writing and executing the code, but also using a language whose syntax is appropriate and natural for artificial intelligence applications can help increase readability.† This is particularly important since AI applications are often written as much to demonstrate principles to our colleagues as to actually accomplish work.
Having said this, what exactly are the features of a programming language that can give us the speed and readability that we are interested in?†
The first point we are interested in is rapid prototyping.† There are a few language features that make a language particularly easy to use for prototyping.† The first ďfeatureĒ we should look for is really a conglomerate of many features: those that take the burden of detail work off the programmer.† Examples are garbage collection, a good IDE for your chosen platform, support for objects, and strong high-level libraries for things like networking and graphical displays.
The second is an interpreter.† The use of an interpreter allows the programmer to escape the tiresome code-build-run cycle and check different values at run-time.† I would liken an interpreter to an extremely convenient debugger.† But not only can we make our programs correct easily by using the information gleaned from running the program in an interpreter, but we can test lots of data quickly as well.† For example, letís consider that our program reads in data, and constructs a model based on that data.† We could then have a separate step in which we feed data into the model and examine the results, but if we gain any new insight from the results, we would have to at least re-run the program to allow us to try new inputs.† The problem is especially bad if the data is represented in a complicated way.
Another feature that we look for is a language whose syntax is suited to recursion.† Of course, we can solve the same problems with either a recursive or iterative strategy, but some problems are naturally more suited to using recursion.† A language with support for functional programming, of which Lisp would of course be the archetypical example, can help make our recursive programs more natural and readable.† Beyond simply having a syntax that lends itself well to making recursion natural and readable, functional languages will allow for lambda expressions, and allow us to construct higher-level functions.† These can greatly increase the power of a language.
Now let us examine some popular languages for artificial intelligence and see how well they provide us with the features that weíre interested in.
First, of course there is Lisp.† Lisp is perhaps the canonical programming language for artificial intelligence applications.† It is a true functional language, and recursion lies at the heart of the language.† It is also interpreted, and a good interactive interpreter is usually available.† It is also relatively fast, with execution being about 80% as efficient as C.† Lisp takes care of garbage collection.
ML is in some ways a refinement of Lisp.† ML brings strong typing to the table, along with the ability to base its control flow on run-time types.† It also has a syntax that I consider to be more readable than Lispís parentheses-fest (thatís subjective).† For these reasons, itís one of my favorite languages.
Python is somewhat like ML in that it does many of the things that Lisp does well, while bringing in some newer concepts like good object support and strong networking libraries.† It is more or less equivalent in power to Lisp with support for advanced functional concepts such as lambda expressions.
Of course, we canít forget about C and C++, and their good friend assembler.† While they donít have any of the features that we talked about above as being traits of programming languages that are well suited to AI, they are about as efficient as you can get.† And sometimes thatís what is called for, especially in real-time control systems.† Speed isnít always the most important ingredient, but when it is itís good to know itís available.