26 points · by RiderOfGiraffes · 16y ago · 33 comments
As for my opinions now, I think classic Lisp is forever doomed to be a niche language. I think it's legacy will be contribution of ideas to mainstream languages.
Having said that, Clojure is fascinating and could prove me wrong.
http://www.cs.brown.edu/~sk/Publications/Papers/Published/
I thought Dr. Krishnamurthi finally saw the Dark ;-)
You can of course also start a new Lisp-like language with new primitives that do include immutability, but I would suggest that that shows Lisp moving forward by taking a feature from another heritage, which means you've no longer got all roads leading to Lisp/2006, you've got at least one leading away.
If there's anything strange about Lisp, it is that it really was a local optimum posing as the global optimum for so long. We should end up with a few more local optima before all is said and done; there aren't enough yet.
Examples: Lexical scoping (ALGOL)
The 'format' macro(I believe Fortran)
The 'loop' macro (COBOL? Pascal? not sure?)
Type systems ala Qi and Haskell (ML and typed lambda calculus influenced)
Optional type declaration are probably to approximate C.
You can implement prolog it...
I believe lisp machines even had GC'd versions of C, Pascal, and other languages written for them.
Personally, when I read "all roads lead to lisp," it is taken with tongue firmly in cheek. Lisp isn't really the 'best' language, it just ends up being able to subsume all of the ideas from them. In RPG terms, Lisp is the red mage.
This is why I like it a lot; given a certain problem domain, you can approximate the global optima that is reached in another language.
Kind of like the Katamari Damacy of programming languages... :-)
My own cursory examination of the clojure-contrib library's use of macros, for example, suggested to me that many of them wouldn't be necessary in a language like Scala, but I'd love to see a more rigorous study.
Lisp can't rest on its laurels here either:
EDIT: Ah, there was no Clojure back then ;-)
It's going well so far in testing. I suspect that over time I will migrate an increasing amount of system logic out of Perl and into Fexl, so eventually all that remains in Perl is the Fexl interpreter itself. Then I'll swap that out for my interpreter written in C and be done with Perl.
Don't get me wrong -- I've been using Perl for 12 years and I know how to write disciplined code in it, so I am grateful to Perl. But I find the pure functional approach to be liberating, making many tasks seem almost effortless.
In fact, I've even been applying the functional concepts to my Perl code itself, with great reward. For example, when I'm parsing text, I don't use the usual destructive position pointer. Instead, I use a functional representation of the text, with head, tail, prefix, suffix, and such. It's liberating.
Another example: when I use my key-value maps with automatic hierarchical structuring by disjoint prefix, I no longer use a destructive "put" operation to change entries. Instead, the "put" operation in effect returns a brand new key-value map with just that one entry changed. It's amazing how efficient this is because of structure sharing, and it also adds much clarity to the code and avoids a lot of thorny implementation issues (especially because I actually need a super-efficient "virtual copy" of large key-value maps for what I'm doing.)
So my main points here are:
1. You can deploy a small embedded interpreter for a purely functional language, inside a system written in any language (yes, even Perl). You don't have to rewrite your entire system in a "pure" language all in one fell swoop, or ever. You can just systematically migrate more logic into the functional side, completely at your leisure, in an evolutionary fashion.
2. You can apply functional concepts and techniques to code written in any language (yes, even Perl). That works even if you don't go as far as using an embedded interpreter.
I am finding both of these techniques to be highly rewarding, and the most exciting thing I've done since I started programming in 1975.
1. Use DeBruin notation for referring to bound lambda values positionally, instead of my current approach of actually using the lambda symbol in an associative list. (Don't laugh, it works.)
2. Change the C implementation so it just uses an array of longs for the whole working space, with integer offsets, instead of node structs with pointers. At that point the whole implementation will be "nothin' but int", and avoid malloc altogether.
3. Change both the Perl and C implementations so that I supply external function definitions as function pointers. Right now when a high-order function is reduced to a normal form (lambda form), I actually look at the name of the external function being called and do a big if-else on that. (Don't laugh, it works.) This will no longer be an option when I go with DeBruin notation. Besides, the function pointer approach will be a lot more solid, serious, and extensible.
Thanks for expressing an interest. When I'm a little more proud of my code and have something available for download, I'll announce it on HN.
Here is the basic Fexl language, which can express all computable functions.
expr = \atom expr
expr = factor
expr = factor expr
factor = atom
factor = (expr)
The full language includes two additional notations for convenience.
expr = \atom=factor expr
= (\atom expr) factor
expr = factor; expr
= factor (expr)