# Probabilistic programming

Given the importance of probability to modern seismic hazard assessment, I found it interesting to discover the other day the world’s only probabilistic programming language. It’s called Java2K and was invented by Gerson Kurz. As the name suggests, it’s sort of an update on the Java programming language, with which it shares some features. However, there are many differences, including the fact that it uses base 11 for all numbers, with a space representing 10. So if you see “10″ it is actually 11 in base 10, and “1 1″ is 1 x 11^2 + 10 x 11 + 1 = 232. Most instructions are represented by numerical codes, also all variable names must be numbers, which means that it is not possible to represent numbers literally. So to get the number 1, the trick is to use the random number function to generate a random number and then divide that by itself. To get 2, you would do this twice and add the results.

However, this is where the probabilistic element comes in. Any operation has only a 90% chance of returning the correct answer; 10% of the time it returns a random answer. Thus the more operations you use to generate a result, the more likely it is that one of them will malfunction. This obviously encourages good programming discipline, since it is necessary to incorporate rigorous checking within any program. The garbage collection is also probabilistic; memory is automatically freed at the end of the program, or at random intervals, whichever comes first. Again, this forces the programmer to write defensively, increasing the security of the code.

I have found a few Java2K programs on the web; here is a very short one as an example of what the code looks like. This program simply prints out the character “F”.

FOR-1 07=119 TO-/12 4DO/*/_\/12 4=13 2=*+*.+_.\+119 =11 6=*+_.+13 2/*/_\..
16 /125 =119 =125 =11 6=*+_.+_.+125 /13 2/*/_\/_\.+125 /131 /119 /125 /11 6/*/_\/_\/
125 =13 2=*+_.+_.\/119 =125 =11 6=*+_.+_.+125 /13 2/*/_\/_\.\/131 =119 =125 =11 6=*+_
.+_.+125 /13 2/*/_\/_\.+131 /119 /125 /11 6/*/_\/_\/125 =13 2=*+_.+_.\/131 =119 =125
=11 6=*+_.+_.+125 /13 2/*/_\/_\.+131 /119 /125 /11 6/*/_\/_\/125 =13 2=*+_.+_.\/131 =
119 =125 =11 6=*+_.+_.+125 /13 2/*/_\/_\.+119 /125 /11 6/*/_\/_\/125 =13 2=*+_.+_.\.\
.\.\./837=119 /12 4/*/_\/12 4=13 2=*+*.+_.\+119 /12 4/*/_\/12 4=13 2=*+*.+_.\.\
1 1 =*+837/119 /12 4/*/_\/12 4=13 2=*+*.+_.\/119 /12 4/*/_\/12 4=13 2=*+*.+_.\\.