Starting in MGS
Ok, you got a runable executable from the MGS distribution web page and you want to write your first MGS program. Before going further, note that MGS is an experimental programming language, mainly used as a vehicle to test and validate ideas in unconventional programming. So, beware that the syntax is especially fluctuating with the interpreters version. This warning done, here are some information to help you to write your first MGS program.
First Step
Long ago, we have started to write an MGS introduction:
- The seminal report on MGS (long) is available and introduce a lot of concepts. The pages 17 to 37 will be especially usefull.
- This tutorial in French is partial, unfinished and the syntax has dramatically changed, but it still gives a good flavor of the current MGS interpreter with a progressive learning curve.
- We have started an english translation but only 15 pages on a total of 115 have been translated.
Second Phase
In a second step, take a look at the example in the MGS gallery: all examples include snipets of commented code.
Then dowload the compressed tar file containing the complete coding of the examples presented and developed in the following two papers:
- scw 2012 for
- the normalisation of boolean formula (Disjunctive Normal Form)
- A Simple Space Subdivisions Scheme using a straightforward implementation of quadtrees using nesting
- the emulation of fraglets, a DSL developped for the programmation of active network
- interaction based modeling for 3 simulation of the same model: the growth of a “T”-shape.
After downloading the tarball (mgs_code_example.tgz
) you decompress it (on linux tar xvzf mgs_code_example.tgz
) which gives you a directory Code
containing the following file:
- Disjunctive Normal Form
fnd.mgs
fnd2.mgs
- Quadtree:
quadtree.mgs
- Fraglet:
fraglets.mgs
tshaped.mgs
contains the 3 models of the growth of a “T”-shape. The fileannotated-tshaped.txt
contains the same code but slightly edited and with comments. But read the corresponding report before readng this file.- The following files contain the trace of a model run. These trace can be played using the
jbview
viewer.jbview
is a Java programjbview.jar
ac.out
the output of the cellular automata modelgeoprox.out
the output of the model relying on geoproximal collectionchain.out
the abstract cellular complex model
- And there are even some associated movies
t-proximal.mov
t-shaped.mov
To go further
- There is an extensive tutorial presented at UCNC 2012 but it is oriented towards the motivation, not the learning of MGS. But take a glimpse on the numerous slides available from this page.
- The application page of this tutorial gives a lot of links
- MGS as a functional language: MGS is embedded in a dynamically typed functional language (higher order function, currification, functions are first class value, and all that kind of stuff). However, the thesis of Julien Cohen (in french) investigate a type inference systems for homogeneous and heterogeneous collections. The original MGS evaluator is also described in the thesis, but see the Generic Pattern Matching section.
- On collection and transformation:
- The first published paper on MGS: MGS: a rule-based programming language for complex objects and collections
- Data Structure as Topological Spaces developp the idea that usual data structure must be viewed as a space where the computation moves.
- They are several variation on the semantics of topological collection and their transformation:
- A first logical approach (i.e. not very constructive) has been developed in The topological structures of membrane computing (Fundamenta Informaticae, 2002)
- The most complete is in the PhD thesis of A. Spicher: Transformation de collections topologiques de dimension aritraire. Application à la modélisation des systèmes dynamiques
- An elegant approach, relying on the approach of set rewriting developped b Raoult, is used in Declarative Mesh Subdivision Using Topological Rewriting in MGS presentend at the Conf. on Graph Rewriting (ICGT 2010, LNCS 6372).
Related Web Pages
- This MGS tutorial http://www.spatial-computing.org/mgs:tutorial
- The MGS home page (new home page for the end of the year) http://mgs.spatial-computing.org
- MGS download (new home page for the end of the year) http://www.spatial-computing.org/mgs
- MGS example gallery http://mgs.spatial-computing.org/ImageGallery/
- MGS publications
- The Spatial Computing home page http://www.spatial-computing.org
- Last SCW conference http://www.spatial-computing.org/scw12:start