[offtopic] marshalling

linas@linas.org linas@linas.org
Thu, 4 Jan 2001 14:03:09 -0600 (CST)


It's been rumoured that Tyson Dowd said:
> 
> On 03-Jan-2001, linas@linas.org <linas@linas.org> wrote:
> > How does the 'class factory' get the 'meta-class description'?
> > 
> > I know of only a few ways of getting the meta information:
> > -- use SWIG: it parses C header files and tries to guess.
> > -- use g-wrap & scheme forms to specify the interface
> > -- use (corba) IDL and a stub generator to get language bindings
> > -- write an XML schema that specifies the object.
> 
> You missed one:
> 
> -- use reflection on .class files (like Java)

Hmmm ...  I didn't know of reflection till I read this, but google
is good ...
http://developer.java.sun.com/developer/technicalArticles/ALT/Reflection/

I wonder if the perl folks are thinking of something like this for
perl ... 

> If you develop super-SWIG for N languages, either it
> 	(a) understands just one sort of "header file" (e.g. C header files)
> 	   and generates N different bindings 
> 	(b) understands N different "header files" and generates N
> 	   different bindings
> 
> Doing (a) is just the same as using an IDL, 

No its not; especially not if your code is native C.  No different as
saying that the output of reflection is the common intermediate form.

> Besides, as the implementor of super-SWIG, you have to maintain N
> different bindings, while those languages go their separate directions,
> which is a tough job.

But that is always the case, no matter what.  standardizing on a VM
or on some intermediate representation e.g. the output of reflection,
doesn't change that.

> Doing (b) is an N x N problem, where N is the number of languages that
> want to interoperate.  This is N times tougher than (a).

No its not. e.g. for the pnm image conversion suite: convert anything to
pnm, and pnm to anything; its a n+m problem.   Likewise, convert
anything to some intermediate reflection-like language, and generate
all bindings from that intermediate form.  The intermediate language
doesn't have to be standard, it just has to be malleable.


> > I think I got it now: viz. basically, a super-duper SWIG.
> >   
> > http://www.swig.org
> >   
> > The 'right thing' to do in the free software world would be to
> > write a module for SWIG that auto-generates SOAP schema &
> > perform the marshalling when invoked.
> 
> Well, this depends entirely on what you mean by right thing ;-)

especially, it seems, if it had some intermediate form that's a bit
righer than plain-old C.

> But I also think that a open-source universal VM for Linux et al would
> be a very nice thing too.  

Would it? Do you really think that you could convince the developers
of perl, tcl, guile and kaffe  to use this VM? or even one of them to
do so?  This seems highly unlikely to me.   First, there are social
issues (try convincing a BSD user to use linux: the kernels are
*almost* the same, and the libraries & apps really are the same).

Next, there are probably deep, powerful technical issues.  
I once partook in an effort to put opengl and phigs on top of the 
same 3D engine.  Despite both of them being 3D API's, its 
fundamentally undoable. Its undoable in the sense that you 
couldn't live with the result: you'd loose performance,
you'd gain extreme complexity, you'd loose ability to optimize 
certain parts of the pipeline, you couldn't implement certain
function in hardware.   I can't imagine that the issues confronting
programming languages are easier than 3D.

I would guess the reason that VB7 won't be backwards compatible with
VB6 is precisely because of these issues: they couldn't share a VM
with C# and still have it work.

But I guess we've really gone off-topic now.

--linas