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

Re: X bindings in Scheme?

We apologize for not replying earlier. We are in the middle of a period of
exams right now...

In article <4803@hplabsz.HPL.HP.COM>, mayer@hplabsz.HPL.HP.COM (Niels Mayer) writes:
> should be written in C. I may prototype low level routines in XLISP,
> but the ones that matter end up in C. IMHO, hybrid programming is the
> way to go.

Of course it has to be hybrid programming, as Scheme does not have any
primitives for interprocess communication ;-) The question is on which level
the conversion between C and Scheme structures should occur, provided that
one wants to be able to manipulate the data as standard Scheme objects. In our
system it is done at a very low level. This enables us to have an environment
much more suited for Scheme.

We are not saying that our approach is the right one, but rather that there
is use for both the WINTERP and the SCIX solutions to the problem.

> So H}kan, are saying that the compiling scheme system is fast enough?
> I guess I need to read Bartlett's paper...

Yes, it is fast enough to be useful. The speed of SCIX is roughly equivalent
to that of CLX (a well known binding to Common Lisp). We haven't done any
formal benchmarks, this is based on elementary comparision of a few example
applications. The main difference between CLX and SCIX is that CLX is an
imperative interface on which object oriented layers (CLUE) can be/has been
added. SCIX is thoroughly object oriented from the inside and out. A SCIX
application runs between four and six times slower than the C equivalent.
This can be disastrous for an application that mostly consists of a speedy
user interface, but is not unusable in other situations. We also have ideas
that will hopefully speed up the eventhandling considerably in the future ;-)

The big problem with the C binding to X is that C isn't really suited to the
task of modelling a window system. The result is a very large system that
is used in different ways on different levels (Xlib vs the toolkit layer).
This makes it cumbersome to write X code in C. Much of the elegance of the
underlying X protocol has been lost among the deficiencies of a particular

When using a more powerful language, like Scheme, it was interesting to try
to redo it all, with the X protocol as a starting point. The result is much
cleaner and much easier to understand as the SCIX environment is consistent
on all levels.

Yes, SCIX is definitely slower than an application written entirely in C, but
if speed is crucial then maybe the entire application should be written in C.
For applications that need to be written in Scheme, however, I think that the
power of the SCIX model of X can outweigh the speed gains that would come from
using the C bindings from within Scheme. 

Yes, we do widgets in Scheme as well. They are typically quite easy to write.
A set of buttons (generic-, text- and pixmap-buttons) that we wrote currently
consists of 70, 35 and 20 lines of Scheme code each. The latter two inherit
the former...
Johan Ihren
Dept. of Computer Science,
Royal Institute of Technology, Stockholm, Sweden
Email: johani@nada.kth.se -or- <backbone>!sunic!nada!johani