Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

After poking around the site, I can't see any specific reference—which makes me suspect it was an independent discovery of a cool idea—but this is very similar to a deliberately-constrained version of the Join Calculus https://www.microsoft.com/en-us/research/wp-content/uploads/... which uses a similar chemical-ish model of computation. There's an implementation of the Join Calculus in an OCaml-like language called (of course) JoCaml. Where Alchemist would write

    2H + O -> H2O
JoCaml would write

    def h() & h() & o() = h2o();;
One of the big differences is that JoCaml allows you to embed payloads inside your atoms, e.g.

    def a(x) & b(b) = c(if b then x else 0);;
will consume an a with an integer payload and a b with a boolean payload, and produce a c with an integer payload. It also lets you include computations as reactions happen, e.g.

    def a(x) = ( Printf.printf "Reacting!\n"; b(x + 1) );;
which lets you use this "chemical soup" model as the basis for concurrent programming.

There is a very detailed tutorial (which appears to have sadly half-broken formatting) which explains JoCaml in more detail here: https://sites.google.com/site/winitzki/tutorial-on-join-calc...



Yeah, Stochastic Pi-calculus and chemical reaction networks simulators are doing this this too. They actually precisely define the probabilities of reactions based on the current amount of different molecules and their reaction rates. For instance, I used the tool called Beta Workbench (BetaWB) and hand-written simulators for modeling systems like this. It's a really cool computational model, I think.


Adding relative weights to each rule would be a simple extension to the grammar. If only integer weights were permitted it could be a simple preprocessor.


Grammar yes, but sampling reaction with appropriate rates makes the choice of the next reaction a little harder than arbitrary selection.

The time to each possible event must be drawn from the exponential distribution (https://en.wikipedia.org/wiki/Exponential_distribution), and the event with the smallest waiting time fires next.


I believe this language is based on the "chemical programming" model as described in http://pop-art.inrialpes.fr/~fradet/PDFs/RULE04.pdf and https://www.researchgate.net/publication/225418037_Higher-Or....

I hadn't thought of the connection to the join calculus - that's pretty cool!


Here's the author's github with the reference implementation.

https://github.com/bforte/Alchemist




Consider applying for YC's Fall 2025 batch! Applications are open till Aug 4

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: