[Claus Reinke] [Summary] [Background] [Source code] [Screenshots/examples]

FunWorlds -- Functional Programming and Virtual Worlds

Summary: FunWorlds is a currently dormant experiment (updated, as in "made to compile and run", for ghc-6.11) to investigate language design issues at the borderlines between concurrent systems, animated interactive 2&3d graphics, and functional programming. One of the aims is to get a suitable platform for expressing such things, preferably from Haskell.

Paper and Slides:

Background: This page is about the second generation of the project.

The first generation prototypes (in 2001) were based on a domain-specific language embedded in Haskell, which combined some ideas from Fran and VRML. Running dynamic scene specifications in that language generated combinations of VRML and ECMAScript, which implemented the specified scenes on top of standard VRML'97 browsers. If you are looking for those (I presented them here at the University of Kent, at IFL'2001 in Stockholm, and to some interested individuals;-), the pages discussing those experiments were moved to a subdirectory for FunWorlds/VRML.

In the second generation, I switched to a new implementation platform, Sven Panne's Haskell binding (HOpenGL) to the widely implemented industry standard for 2d and 3d graphics OpenGL. I'll refer to this new branch as FunWorlds/HOpenGL (or simply FunWorlds, as it is now the main line in this project).

The problem with the VRML-based approach was that it looked quite promising (see the interesting examples in the FunWorlds/VRML branch) while I focussed on Fran's characteristic features and on VRML-based extensions to Fran, but things became difficult when trying to map all those simple things that Fran inherits from its embedding in Haskell. VRML seriously lacks in expressiveness and elegance, it seems - as an example, try to come up with a general model for recursive scenes in VRML (not only simple spatial fractals, but recursions in time as well) without using the external authoring interface. You'll probably need script nodes, which is already a deviation from the otherwise declarative specification of scenes, but then, script nodes are embedded as strings, not sharing the scope of the scene in which they are embedded, and if you want to create new scenes inside scripts, you do so in the form of strings, which again form their own scope.. it isn't impossible to hack around all those limitations, but I never found a "nice" workaround, one that I'd be willing to use extensively in my scenes! Also, the program generator approach -attractive because it required only a VRML'97 browser at the client side- had its disadvantages, as the full expressiveness of Haskell was available only at compile-time, not at run-time (connecting Haskell to VRML's external authoring interface, while possible, seems to involve too many complications, as that is mainly targetted towards Java).

The idea of FunWorlds/HOpenGL is to get more direct control over graphics facilities from within a Haskell-DSEL. To start with, there is a scene graph, similar to static VRML. That is augmented by Fran-like behaviours (although I'm experimenting with some changes to Fran designs), both within scene graph node properties (as in FunWorlds/VRML) and in the form of scene graph behaviours. I'm also trying to use ideas from concurrency and communication research to specify those aspects of dynamic scenes more directly than in Fran. All of that is then translated into GL/GLU/GLUT calls and callbacks, providing a nice higher-level interface to the functionality. It's not ready for a general release yet, but the current experiments are encouraging, both in terms of expressiveness and in terms of performance (the latter being a standard problem in earlier Haskell embeddings of Fran-like ideas).

Source code:

Screenshots and example code: Some boring screenshots (click on images to see source code; the lift actually has some comments;-):