[Prev][Next][Index][Thread]

Re: Thanks for your reply Bruce



[Rob Myers and others may already have answered your questions but I'll
have a go too ...]

On Mon, 1 May 2000, Shawn wrote:
> > ... there exist compilers for [many languages] that produce output in
> > C rather than in machine code or assembly language:
> >
> > - it's easier
> >...
> > - every machine in the world has a C compiler
> 
> Then why not just use one of them ?

As Rob says, d2c just uses C as an intermediate representation because
it's an easy way for a group of (originally academics and now) volunteers
to do the back end of a compiler and gain free portability.  Native code
generation like FunDev does is harder for the compiler writer but (I'd
hope!) faster/smaller/etc. when executed.

> > > I would think C/C++ to Dylan would be more useful ? Can this take C
> > > and go the other way ?
> 
> This is an important topic I think, Eiffel has a C/C++ legacy interface as
> well as Dolphin, why not Dylan ?

>From looking at
  <http://www.eiffel.com/tech/questions/page.html>
and
  <http://www.eiffel.com/doc/manuals/library/cecil/page.html>
it seems that Eiffel does offer more than Dylan in terms of C/C++
interfacing.  As well as calling back and forth between Eiffel and C
(including manipulating Eiffel objects from C, I think), you can
instantiate C++ classes from Eiffel and even create Eiffel wrapper
classes.

(I found Dolphin Smalltalk (is that what you meant?) at
  <http://www.object-arts.com/DolphinSmalltalk.htm>
but couldn't find any details on their C/C++ interface.)

At the moment, the C-FFI supported by FunDev and d2c (I think they've
pretty much converged by now, no?) just lets you call C functions from
Dylan (with automatic type conversion) and present Dylan objects with
"C-callable" wrappers.  You can't mess around with the structure of Dylan
objects from C (but then you can't in Dylan either -- everything goes via
method calls) and you can't talk directly to C++ at all.

Why not?  It's just a development choice, I suppose.  I can't speak in
detail for anyone (I worked on Harlequin Dylan but didn't design tht
C-FFI!) but I suppose it was thought that a combination of C, COM and
CORBA interfaces would be good enough (for now).  AFAIK (which may not be
that far ;-) lots of other languages have done the same; e.g., Java has
the JNI, conceptually similar to Dylan's C-FFI, but no C++ interface.

> ... what about all the code written in C++ that could be used in the
> Dylan. I have about five different rendering libraries all optimized for
> speed that can not be used in Dylan because they are coded in C++. ...

As Rob said, all Dylan can offer you for now is interface via a COM
wrapper (which you'd have to write and I suspect might be too slow
and/or non-portable for you) or via an 'extern "C" { ... }' wrapper
(again, you'd have to write the C-to-C++ part of this yourself).

If you go the COM route, FunDev can automatically generate the Dylan
interface code.  There's a not-quite-finished project called "Pidgin",
which will be available with FunDev and d2c, to do the same for C.  At the
moment you have to translate the relevant C header file to Dylan C-FFI
definitions yourself.

(FunO have some tools to mostly-automate this internally at the moment,
which is how all the Win32 interface libraries were made -- perhaps you
could sweet-talk them into helping you do the translation, once you've
written the C-to-C++ part :-)

> ... I REALLY like Dylan and I am very happy using it, but I see so many
> other languages trying to bridge the barrier between C++ and themselves.

By all means provide us all the links/info you can find on languages which
already talk directly to C++.  The better we understand how to go about
it, the better we can estimate the effort involved, which would be the
first step to actually making it happen :-)

> I am not asking for a direct translation of C++ to Dylan in human readable
> form, just the same thing as the D2C, a compilation of a C++ project with
> headers etc. to a useable module that can be easily called and used in Dylan
> without having to manually code 100+ header files into Dylan equivalents.

Well, that isn't quite what D2C does (automatically make a C project
accessible from Dylan) -- as I've said, what you want for that is the
half-written "Pidgin" tool.  AFAIK, FunDev and the Gwydion volunteers are
co-operating on getting that finished but I don't know if it's actively
being worked on right now.  Both groups are eager to please Dylan users,
though, so if enough people ask for it (and/or offer development skills
:-) it could be pushed up the priority list, I'm sure.

> Please I am not trying to be rude its just ignorance on my part, why can
> we not use SWIG to generate interfaces or something similar
> automatically ? ...

No rudeness inferred, don't worry :-)  I confess I also know very little
about SWIG; but that may be something else you and others can persuade us
Dylan developers to devote our efforts to.

Hope that helps (and feel free to ask for more info),
Hugh





Follow-Ups: References: