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





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.)


Log of recent changes


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.


Added getImage and drawImage methods to the graphics environment.


Safe, though dumb, to name programs String or Math.

Consolidated pdf and ePub environment documents.


Fixed handling of the NXT's enter button, by removing a lejos bug workaround no longer needed.


Fixed parsing of array initialisers with entra comma.


Debugger shows the value of loop/if conditions.

Debugger works properly for files environment.


Initialisation check bug fix.

Debugger handles for loop variables correctly.


graphics docs improvements.


Debugger copes with tabs in source files.

Now safe to name nxt programs Object.mash.


Cosmetic tweak to nxt environment.


Encountered a known bug in Lejos 0.85. Proximity sensors don't work in port 4. Updated the nxt environment to note this.


Type checking rewritten so its correspondence to the Java Specification is more transparent. Some cases where the Java compiler previously reported an error trapped.

Last modified Mon Jun 3 14:51:10 EST 2013 by Andrew Rock.