To learn more
Although graphics programming is naturally event-driven, the
associated style of programming being imperative, it is not only
possible but also often useful to introduce more functional operators
to manipulate graphical objects. A good example comes from the use of
the MLgraph library,
Link
http://www.pps.jussieu.fr/~cousinea/MLgraph/mlgraph.html
which implements the graphical model of PostScript and proposes functional
operators to manipulate images. It is described in [CC92, CS94]
and used later in [CM98] for the optimized placement
of trees to construct drawings in the style of Escher.
One interesting characteristic of the Graphics library is that
it is portable to the graphical interfaces of Windows, MacOS
and Unix. The notion of virtual bitmaps can be found in several
languages like Le_Lisp and more recently in Java. Unfortunately,
the Graphics library in Objective CAML does not possess interactive
components for the construction of interfaces. One of the applications
described in part II of this book contains the first bricks of the
Awi library. It is inspired by the Abstract Windowing
Toolkit of the first versions of Java. One can perceive that it is
relatively easy to extend the functionality of this library thanks to
the existence of functional values in the language. Therefore chapter
16 compares the adaptation of object oriented
programming and functional and modular programming for the construction
of graphical interfaces. The example of Awi is functional and
imperative, but it is also possible to only use the functional style. This
is typically the case for purely functional languages. We cite the systems
Fran and Fudget developed in Haskell and derivatives. The
system Fran permits construction of interactive animations in 2D
and 3D, which means with events between animated objects and the user.
Link
http://www.research.microsoft.com/~conal/fran/
The Fudget library is intended for the construction of graphical
interfaces.
Link
http://www.cs.chalmers.se/ComputingScience/Research/Functional/Fudgets/
One of the difficulties when one wants to program a graphical interface
for ones application is to know which of the numerous existing libraries
to choose. It is not sufficient to determine the language and the system
to fix the choice of the tool. For Objective CAML there exist several more or
less complete ones:
-
the encapsulation of libX, for X-Windows;
- the librt library, also for X-Windows;
- ocamltk, an adaptation of Tcl/Tk, portable;
- mlgtk, an adaptation of Gtk, portable.
We find the links to these developments in the ``Caml Hump'':
Link
http://caml.inria.fr/hump.html
Finally, we have only discussed programming in 2D. The tendency is
to add one dimension. Functional languages must also respond to this
necessity, perhaps in the model of VRML or the Java 3D-extension. In
purely functional languages the system Fran offers interesting
possibilities of interaction between sprites. More closely to
Objective CAML one can use the VRcaML library or the development
environment SCOL.
The VRcaML library was developed in the manner of
MLgraph and integrates a part of the graphical model of
VRML in Objective CAML.
Link
http://www.pps.jussieu.fr/~emmanuel/Public/enseignement/VRcaML
One can therefore construct animated scenes in 3D. The result is a
VRML-file that can be directly visualized.
Still in the line of Caml, the language SCOL is a functional
communication language with important libraries for 2D and 3D
manipulations, which is intended as environment for people with little
knowledge in computer science.
Link
http://www.cryo-networks.com
The interest in the language SCOL and its development environment is
to be able to create distributed applications, e.g. client-server, thus
facilitating the creation of Internet sites. We present distributed
programming in Objective CAML in chapter 20.