MaSH (Making Stuff Happen)

About MaSH

MaSH introduces new programmers to Java using staged subsets of the language. The system specifies several clearly specified subsets of the Java language that eliminate the boilerplate that interferes with early learning of the purely procedural aspects of the Java language and a precompiler that adds the required boilerplate to produce a working Java program. The boilerplate that the precompiler adds is specified in an auxilliary source file. Therefore programs can be created that run in diverse environments: on a console; on a robot; or in a graphical user interface.



Java MaSH
** file:
** created:    25/5/8
** author:     Andrew Rock
** purpose:    A program to read two numbers
**             and print their sum.

import java.util.*;

public class Sum1 {

   public static void main(String[] args) {
      Scanner sc = new Scanner(;
      System.out.print("Enter a number: ");
      int x = sc.nextInt();
      System.out.print("Enter a number: ");
      int y = sc.nextInt();
      int z = x + y;
      System.out.print("The sum is: ");
** file:       Sum1.mash
** created:    25/5/8
** author:     Andrew Rock
** purpose:    A program to read two numbers
**             and print their sum.
** MaSH level: statements

import console;

print("Enter a number: ");
int x = readInt();
print("Enter a number: ");
int y = readInt();
int z = x + y;
print("The sum is: ");
** file:
** created:    25/5/8
** author:     Andrew Rock
** purpose:    A program to drive a motor until
**             a touch sensor is pushed.

import josx.platform.rcx;

public class GoUntilPush {

   public static void main(String[] args) 
   throws Exception {
      while (Sensor.S1.readBooleanValue()) {
      while (!Sensor.S1.readBooleanValue()) {

** file:       GoUntilPush.mash
** created:    25/5/8
** author:     Andrew Rock
** purpose:    A program to drive a motor until
**             a touch sensor is pushed.
** MaSH level: statements

import rcx;

setUpSensor(1, TOUCH);
motorForward(A, 7);
Degugger window for Hanoi.mash



Binary bundles

All you need to download if you're a student. Pick the one for your operating system.

platform GHC version package date
Windows 32-bit 7.6.3 2014-07-30
Mac OS X (Snow Leopard or later) 10.6.4 Intel 7.6.3 2014-07-30
Ubuntu (10.04) Intel 7.6.3 2014-07-30




MaSH is available for use and modification under the terms of the GNU General Public License, version 2. That means any student or teacher can download and use this software for free, though there's no guarantee that it's going to work or be useful. The source code is provided, and you may modify it. Teachers are especially encouraged to develop new MaSH environments.

If you do find MaSH useful, please let me know, and I'll let you know about MaSH developments.

If you find a bug or deficiency in the MaSH tools or environments, let me know. (I'm not implying that the bugs will be fixed on any timescale that will suit you.)


MaSH Online

Try MaSH Online.


Log of recent changes


console2 environment added.


javaj implemented.


MaSH Online completed.


Made the debugger window slightly bigger.

Made it easier to find the downloads that matter.

More math methods added to all environments except RCX.


mashj tool complete.


All MaSH Haskell modules compile without any warnings.


Added atan2 to all environments.


nxt documentation fix.


nxt environment bug, affects motor selection, fixed.


mashn.bat fixed for Lejos_NXT-0.9.


nxt environment now compatible with Lejos_NXT-0.9, and no longer compatible with Lejos_NXT-0.85 or previous.


Examples for the format functions.


Fixed an error in initialisation check. (Kudos to Carl Lusty, who found it purely by code inspection!)

Fixed debugger wrt array initialisers for constant arrays.


Fixed an error in the debugger wrt array initialisers for local variables or in no-method programs. (Thanks Bent!)


A little polishing after the internal reorganisation of error handling in the compiler.

Custom Show instance for Blocks to prevent looping.


Internal reorganisation of error handling in the compiler, making it possible to use compiler phases in other tools without them exiting the whole program on an error.


Made the String.format bindings a bit more robust with parentheses around the parameters.


Added parseInt() etc to all environments.


Added log() and exp() bindings to all environments.


Added String.format bindings to PC environments. (Not supported in Lejos.)

Added \textbar to mashdoc's LaTeX to HTML converter.


Added sound loading and playing to the graphics environment.


Added mouse and key event handling to the graphics environment.

Added the missing formal parameter substitutions to the rendering of rewrites.


Programs that don't implement rewrites marked mandatory will no longer compile with mashc, avoiding very confusing Java error messages.


Added a warning when the name of a MaSH program collides with a class name in java.lang.

Changed code generation so that MaSH global variables and constants and methods are qualified by the program name, resolving name clashes that arise by using subclassing in an environment's definition.

Last modified Wed Jul 30 16:36:31 EST 2014 by Andrew Rock.