Getting Started

Install the SubScript compiler and Library

SubScript is currently (20 February 2013) available a branch of the regular Scala compiler and library. This is hosted at GitHub.

To get this branch of the compiler and library running you will need to build it on your computer. The available build script works well for Linux and MacOS, but not for MS Windows (that is, at the moment of writing. The Scala team at EPFL may fix the build script for Windows anytime).

First make sure you have both Git and Ant software. On the Macintosh system there is a nice Git client named SourceTree. Get the latest SubScript version from http://github.com/AndreVanDelft/scala/tree/develop. Install this in a local directory, say ~/workspace-subscript. This will result in a folder ~/workspace-subscript/scala.

The scala GitHub site says in https://github.com/scala/scala/blob/master/README.rst

  • A Java runtime environment (JRE) or SDK 1.6 or above.
  • Apache Ant version 1.7.0 or above.
  • bash (via cygwin for windows)
  • curl

Actually, the JRE should be version 1.6, not 1.7, since the latter is not yet supported by the scala.swing package.

Before you build the SubScript-Scala compiler, make sure that environment variables ANT_OPTS and JAVA_HOME have been set appropriately; the following lines should for this purpose be in your .bash_profile file:

export ANT_OPTS="-Xms512M -Xmx1536M -Xss1M -XX:MaxPermSize=128M"
export JAVA_HOME=/System/Library/Frameworks/JavaVM.framework/Versions/CurrentJDK/Home

In folder ~/workspace-subscript/scala build the SubScript-Scala compiler using the command

ant build

This goes wrong if the current Git branch is the Master branch. Note that the command “git branch” lists “development” as the current branch. If not, you should make it the current branch, using the command

git checkout develop

At such moments it may be good to clean up the generated class files. This seems possible using “ant clean”, but that command is often too weak; use “ant all.clean” instead.

Compile the examples

This builds the compiler in directory ~/workspace-subscript/scala/build/quick/bin, as explained in the README.rst file. To get easy access to scalac you may issue the command

ln -s build/quick/bin qbin

The SubScript examples are in directory ~/workspace-subscript/scala/src/subscript/subscript/examples The Life example is in subdirectory life/ You can compile SubScript including the examples using

ant quick.subscript

Run the examples

All class files reside in directory ~/workspace-subscript/scala/build/quick/classes/library

You can run the Life example using

qbin/scala \
  -classpath build/quick/classes/library:build/quick/classes/subscript \
  life.LifeFrame

Sometimes (?) there is no scala executable in the qbin directory; then the previous command will fail.
You can then probably recreate the scala executable using

  ant quick.bin

Debug the examples

To start the graphical debugger for SubScript programs, use as main class:

subscript.swing.GraphicalDebugger

Fill in the name of the application’s main class as run time argument. You can also prepend an extra “-s descriptionString” argument pair, to specify a description to be shown by the debugger. E.g., to invoke the SubScript debugger on Life, execute:

qbin/scala \
  -classpath build/quick/classes/library:build/quick/classes/subscript \
  subscript.swing.GraphicalDebugger -s "Life example" life.LifeFrame

Leave a Reply