Labels: CHAM , chemical programming , GAMMA , javascript
I have been experimenting with an implementation of the GAMMA formalism in Javascript. It is a VERY naive implementation that uses setTimeouts to mimick parallelism. Still it allows experimentation with the GAMMA and the chemical programming paradigm.
The current implementation can be found here. It provides a graphical representation of the multiset status (via the canvas element). A sample application is provided. An application that calculate the value for PI in a parallel way.
For the uninitiated, GAMMA provides a chemical like reaction model. For example, imagine that you have the following set (multiset) of numbers:
A GAMMA program to compute the max of this set would look something like this:
in GammaScript this can be written as:
As you can see, none of these dictates how the set should be traversed. It is totally left to the implementation. The current Javascript implementation provides pseudo (fake) parallelism.
I am considering a new implementation that utilizes Google Gears for true parallelism. And I need to refactor the view code from the core of the implementation.
*UPDATE*
To get the thing running you need to add data (comma separated) in the left box and click the (add) link. Then you should click the start button.
For the PI calculation programs that are supplied, you need to add a single element (the tuple [0,1]) and click add then start.
The current implementation can be found here. It provides a graphical representation of the multiset status (via the canvas element). A sample application is provided. An application that calculate the value for PI in a parallel way.
For the uninitiated, GAMMA provides a chemical like reaction model. For example, imagine that you have the following set (multiset) of numbers:
S -> 1,2,1,5,4,3,7,7,3,5,9,8,3,2,2,1,5
A GAMMA program to compute the max of this set would look something like this:
max(S):
C: x >= y
R: x,y -> x
or the more concise:
x,y -> x for every x >= y
in GammaScript this can be written as:
var max = {
condition : function(x,y){
return x >=y;
},
reaction : function(x,y){
return x.consume(y);
}
}
As you can see, none of these dictates how the set should be traversed. It is totally left to the implementation. The current Javascript implementation provides pseudo (fake) parallelism.
I am considering a new implementation that utilizes Google Gears for true parallelism. And I need to refactor the view code from the core of the implementation.
*UPDATE*
To get the thing running you need to add data (comma separated) in the left box and click the (add) link. Then you should click the start button.
For the PI calculation programs that are supplied, you need to add a single element (the tuple [0,1]) and click add then start.