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.

-

Examples

Java MaSH
/*
** file:       Sum1.java
** 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.in);
      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: ");
      System.out.println(z).
   }
   
}
/*
** 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: ");
println(z);
/*
** file:       GoUntilPush.java
** 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 {
      Sensor.S1.setTypeAndMode(
         SensorConstants.SENSOR_TYPE_TOUCH,
         SensorConstants.SENSOR_MODE_BOOL);
      Motor.A.forward();
      while (Sensor.S1.readBooleanValue()) {
      }
      while (!Sensor.S1.readBooleanValue()) {
      }
      Motor.A.stop();
   }

}
/*
** 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);
waitForPush(1);
motorStop(A);
Degugger window for Hanoi.mash

-

Downloads

-

License

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

2013-06-03

Added atan2 to all environments.

2012-05-25

nxt documentation fix.

2012-03-05

nxt environment bug, affects motor selection, fixed.

2012-02-07

mashn.bat fixed for Lejos_NXT-0.9.

2011-12-08

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

2011-06-09

Examples for the format functions.

2011-06-08

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.

2011-05-31

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

2011-05-29

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

Custom Show instance for Blocks to prevent looping.

2011-05-24

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.

2011-05-22

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

2011-05-10

Added parseInt() etc to all environments.

2011-05-09

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

2011-05-03

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

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

2010-12-07

Added sound loading and playing to the graphics environment.

2010-11-29

Added mouse and key event handling to the graphics environment.

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

2010-11-26

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

2010-11-22

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.

2010-09-29

Added getImage and drawImage methods to the graphics environment.

2010-08-28

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

Consolidated pdf and ePub environment documents.

2010-07-12

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

2010-06-23

Fixed parsing of array initialisers with entra comma.

2010-06-10

Debugger shows the value of loop/if conditions.

Debugger works properly for files environment.

2010-06-10

Initialisation check bug fix.

Debugger handles for loop variables correctly.

2010-06-04

graphics docs improvements.

2010-04-17

Debugger copes with tabs in source files.

Now safe to name nxt programs Object.mash.

2010-03-02

Cosmetic tweak to nxt environment.

2010-02-03

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

2010-01-21

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.