Monday, February 25, 2008

Scheme For Enlightenment Part Twenty Two Hackable By Extension

And yet, Guile makes sense when used as an extension language to C(++) applications. The user of a program should not have to modify the source code to that program to extend it a bit, if that can be avoided. The Gimp is written in C, but i'm not not that interested in grappling with such a huge chunk of code to add an image filter. The ability to do that in an extension language would be nicer. That language would have access to the Gimp's power, but would be protected from doing any lasting harm. It also is documented with a limited API of functions to use. (The Gimp uses Guile as an extension language.)

For simple tasks, like configuration (turn this feature on, turn that one off), using Guile is the nuclear bomb to swat a fly approach. This is what makes the Emacs startup file (in lisp) such a bear to deal with. Even Google doesn't always know the answer to what i'd thought were easy issues. Even an xml file is usually too much. But it might be good for allowing the user to add real functionality. Guile, an implementation of Scheme, is a somewhat simpler language than Lisp. It might have been a better choice for Emacs.

The Unix shell allows one to chain utilities together and provide new functionality easily. The shell itself doesn't have to be fast to make this work. It's much the same idea. But the Unix shell is a simple scripting language with relatively low barrier to entry. And yet, i've used the shell to create filter chains to do image manipulation (using pbmplus for a pool of the basic image manipulation commands), to resize an image to the current screen dimensions, changing the gamma to correspond to the monitor, and using the file name as a label in the corner. The simplicity of the Unix shell did not limit the task overmuch. These are things one might expect the Gimp to do. And, in fact, the Gimp has a command line batch mode, with commands in Guile.

So, Scheme might enjoy a niche as an extension language. Is it a very good extension language? Would Python, Java, Forth, or even BASIC be better? It seems that a very simple language, with very low barrier to entry, would be a win.

No comments: