public
Description: The Moby Scheme Compiler for Smartphones
Homepage: http://world.cs.brown.edu/
Clone URL: git://github.com/dyoo/moby-scheme.git
name age message
file .gitmodules Tue Oct 13 17:06:25 -0700 2009 Removing submodules. [dyoo]
file .project Tue Jan 13 15:35:41 -0800 2009 [Zhe Zhang]
file README Tue Oct 13 17:12:41 -0700 2009 Adjusting the README. [dyoo]
file bootstrap.ss Wed Nov 11 22:38:07 -0800 2009 Adding bootstrap [dyoo]
directory doc/ Fri Nov 06 10:38:33 -0800 2009 Added hash tables. [dyoo]
directory examples/ Wed Nov 11 20:12:07 -0800 2009 broken code removed. [dyoo]
file info.ss Sun Nov 22 15:54:36 -0800 2009 updating the info on string-ref. [dyoo]
directory lang/ Fri Nov 13 12:32:53 -0800 2009 Found bug in reading of decimals as inexact rat... [dyoo]
file make-planet-archive.sh Sun Nov 22 15:54:52 -0800 2009 bumping up version number. [dyoo]
file manual.scrbl Mon Nov 16 18:33:59 -0800 2009 more documentation [dyoo]
file moby-lang.ss Fri Sep 11 22:00:49 -0700 2009 Adding more to make the moby bindings visible f... [dyoo]
directory sandbox/ Wed Sep 16 08:44:59 -0700 2009 moving the tsrj examples to the sandbox, and bu... [dyoo]
directory src/ Sun Nov 22 15:42:44 -0800 2009 partial fix for equal? on functions. [dyoo]
directory support/ Sun Nov 22 16:03:20 -0800 2009 Correcting the test case on string-ref. [dyoo]
README
Moby
------
Danny Yoo (dyoo@cs.wpi.edu)


----------------------------------------------------------------------

What is Moby?

Moby is a project from the PLT Scheme team.  The Moby compiler
consumes Intermediate Student Language (ISL) programs that use World
primitives, and produces applications for mobile platforms.  The
current prototype supports the Android platform and desktop browsers.
Our long-term goal is to make Scheme the premiere reactive scripting
language for mobile phones.

Shriram Krishnamurthi presented the ideas behind Moby at ILC 2009;
his talk "The Moby Scheme Compiler for Smartphones" can be found here:

    http://www.cs.brown.edu/~sk/Publications/Talks/Moby-Bootstrap/


----------------------------------------------------------------------

How does it work?

The compiler takes a ISL program and translates it to Javascript code.
We've reimplemented the ISL primitives in a Javascript runtime library
that's included with the compiled application.  (See
doc/moby-developer-api.txt for more details.)

To support Android, we use a bridge library called Phonegap, which
provides access to the native facilities of several cell phones.  In
this way, we should be able to support multiple platforms with a lot
of code reuse.  We handle the other libraries (tilt, location, sms,
music), though with support only for the Android platforms for now.


----------------------------------------------------------------------

Dependencies

Moby is mostly written in PLT Scheme, and the project sources are
hosted by github.com.  To develop with Moby, you will need the
following:

  PLT Scheme >=4.1.3 (http://plt-scheme.org/)
  git (http://git-scm.com)



If you wish to generate programs for the Android+Phonegap backend,
you'll also need:

  Java >=1.6 (http://java.sun.com/)
  Apache Ant >=1.7.1 (http://ant.apache.org/)
  Google Android SDK >= 1.5r3 (http://developer.android.com/)


----------------------------------------------------------------------


To install Moby from the development sources:

    1.  Grab the Moby source, currently hosted on github at:

        http://github.com/dyoo/moby-scheme/tree/devel

    and place them in your PLT Scheme collects directory.


    For example, 

        $ cd ~/.plt-scheme/4.2.1/collects
        $ git clone git://github.com/dyoo/moby-scheme.git moby

    Also, do a 'setup-plt -l moby' so that PLT Scheme compiles the
    Moby source code.



    2.  If you're going to do Android development, make sure that
        'ant' and the 'android' binary are in your path; Moby will use
        your PATH variable to find Apache Ant and the Android SDK.

    You can verify that android and ant can be found with the following:

        $ which android
        /usr/local/android/tools/android

        $ which ant
        /usr/bin/ant

    The path values you get back may differ according to your
    system's configuration.



----------------------------------------------------------------------

Running Moby from DrScheme



To use Moby from DrScheme, create a file in the Module language, and
at the top of your program, include the following language line:

    #lang moby

followed by the program.  For example:

    #lang moby

    (define initial-world 0)

    (js-big-bang initial-world (on-tick 1 add1))


When this program is run, a web browser should fire off with the
program running from the web page.




----------------------------------------------------------------------

Running Moby from the command line


You can run the Moby command line utility (moby/src/moby.ss) on a Moby
program to produce a compiled version of your application.  Moby
supports two output backends, both which rely on Javascript:

    * js: compiles to a web page application, which can be deployed on
      any web server.

    * js+android-phonegap: compiles to an Android .apk application
      package; can also use features of the mobile platform.


By default, the command line utility will use the js backend.

Let's run moby on the falling-ball.ss example in
moby/examples/falling-ball.ss.  We can first generate a web program.

    $ cd moby/examples
    $ mred ../src/moby.ss falling-ball.ss
    $ cd FallingBall/
    $ ls
    index.html  main.js  runtime  test

If you open up index.html from your web browser, you should see a red
ball falling down the screen.


Furthermore, we may want to generate an Android application.

    $ cd moby/examples
    $ mred ../src/moby.ss -t js+android-phonegap falling-ball.ss
    $ cd FallingBall
    $ ls
    AndroidManifest.xml  build.properties    gen               res
    assets               build.xml           libs              src
    bin                  default.properties  local.properties  tests

    $ ls bin
    classes  classes.dex  DroidGap.ap_  DroidGap-debug.apk

DroidGap-debug.apk is the compiled Android binary.  The Ant build.xml
build-script in the FallingBall directory can install, uninstall, and
reinstall the application if the Android emulator is online.

    $ ant install
Buildfile: build.xml

[some output cut]

install:
     [echo] Installing bin/DroidGap-debug.apk onto default emulator...
     [exec] 1594 KB/s (120997 bytes in 0.074s)
03:38 I/ddms: Created: [Debugger 8610-->1641 inactive]
03:38 I/ddms: Good handshake from client, sending HELO to 1641
     [exec]   pkg: /data/local/tmp/DroidGap-debug.apk
     [exec] Success
03:39 I/ddms: Closing [Client pid: 1641]

BUILD SUCCESSFUL
Total time: 6 seconds


After this, you can look at the Android emulator, which should now
have the FallingBall application installed.


----------------------------------------------------------------------