Re: CLOS and databases

From: Pete Kirkham (pete-kirkham-2004_at_cafemosaic.co.uk)
Date: 03/26/04


Date: Fri, 26 Mar 2004 18:07:50 +0000

I've also been playing on some similar themes, and come to the
conclusion that to target Java/.net/Objective-C or C++ has too much of
an impedance match to use ANSI CL as source language.

Every library in the target languages (or for that matter python or
haskell) has a list model as a thing than has functions to access it's
members sequentially. Null and () are different. Even though you can add
wrappers and unwrappers to map cons'd lists onto functional lists,
automating them is a drag and the end code looks messy and runs slower
than pure Java; this gets very complicated if you are modifying a list
you have a reference to the head of elsewhere. It is also nice to use
the same iteration forms on functional lists, for example representing
the output of a streaming parser as a list of symbols- you don't want to
hold a 8GB AST in memory if you're only forward iterating over it's
contents, but you don't want to have to rewrite your code for the cases
where you do have the thing in memory.

The object systems in the target languages doesn't match CLOS. This
means if you want to use objects, you have to may from something other
than CLOS to the target language, or you can get lots of non-first arg
dispatch bugs. You can generate warnings for this quite easily at the
compile stage, if you also have a metaobject system in your generator.
As the computers on most people's desktops look like they are going to
be running a single dispatch object system as the core of their
operating system in a couple of years, downgrading from lisp's
capability is possibly the only pragmatic option. However, providing
auto-generation of the boilerplate for double dispatch is fairly
trivial, in the cases where the classes are in your control, so that can
be done transparently in most cases without a loss of conciseness.

Another thing I've played with is a lisp interface to a byte code
library, which had some success flattening OOT-OO Java and moving
branchs forward, detecting like clauses and other patterns as a
optimization process. That's implemented in Java, but with a lisp as the
control language, largely as I'd started it as a GUI based Java project,
but then decided that it would be easier to use with a command line and
scripting language, and if it's going to contain a scripting language
you may as well make it lisp. I'm planning to revisit that soon (I'm
writing an ASN.1 library for Java and want to be able to allow
flattening for the binary encoding cases but give a capability for
runtime configuration so you can read legacy file formats and arbitrary
XML), but is a bit too buggy for serious use right now, partly as I
tried to make its lisp too like common lisp so it ended up with lots of
impedance-management hacks, and more functionality than I could really
be bothered testing. I didn't want to reuse an extant cl implementation
as I hope to be able to reuse my little-lisp-on-java as a control
language for other Java tools.

Pete



Relevant Pages

  • Re: CLOS and databases
    ... > an impedance match to use ANSI CL as source language. ... But remember that Linj is not ANSI CL. ... Lisp's lists, nothing prevents you of using other Java containers. ...
    (comp.lang.lisp)
  • Re: Learning C++?
    ... >> an archive or a container, and you don't know its exact type, you must ... language like C++ is a pointer or reference to an object of the base ... Java or C++, and it is inelegant. ... Lists in ML are linked lists, ...
    (alt.comp.lang.learn.c-cpp)
  • Re: why java is not pure object oriented?
    ... possible way to learn Java programming -- as you are discovering... ... But learning Java isn't my main target, ... CU> using the wrong language. ...
    (comp.lang.java.programmer)
  • Re: tagged type as generic parameter
    ... What i wanted is not the "best" way to implement lists. ... The strong OOP orientation is due to the fact that i tried this example after a discussion with one of my student arguing that Ada is too complex compared to Java. ... When discussing language complexity, I think you should start from a real problem, code it in each language following each language's philosophy, and compare the result. ...
    (comp.lang.ada)
  • Re: survival of c++
    ... Is C a systems language? ... Systems is my loose term for a language whose primary intended target is ... low-level programming. ... > you can execute Java programs without having to recompile. ...
    (comp.lang.cpp)