Giter VIP home page Giter VIP logo

gosu-jsr223's Introduction

#-------------------------------------------------------------
OVERVIEW
#-------------------------------------------------------------

This is a partially-functional JSR 223 implementation for the Gosu language.

I threw this code together after I first discovered the Gosu language:

http://gosu-lang.org/

Gosu itself is a finely designed, practical blend of Java and C#
with some Ruby/Groovy closures + parse-time dynamicism
(final types can be enhanced at parse time).

Unfortunately, as of 2011-05, while much of Gosu is open source (Apache
Licensed), the open source parts depend on closed-source internals, which
complicate the process of creating a full JSR 223 implementation.

I wasn't aware of how much was closed source until I had already thrown
together this partially-working implementation. I'm publishing it mainly to
give someone else a jump start if they want to create a complete JSR 223
implementation. See the java code for additional notes.

#-------------------------------------------------------------
BUILDING
#-------------------------------------------------------------

NOTE: You cannot compile this with maven without defining dependencies for 
gw-gosu-core-api.jar. You can alternatively create an eclipse project with:

mvn eclipse:eclipse

compile in eclipse, and then package with

mvn package

#-------------------------------------------------------------

Once you build a jar, put it on your classpath along with:

GOS_LIB="/path/to/gosu/jars"

CP=.

### This is the jar 
CP=gosu-jsr-223.jar

### Core gosu jars:
CP=$CP:$GOS_LIB/gw-asm-3.1.jar
CP=$CP:$GOS_LIB/gw-gosu-core-api.jar
CP=$CP:$GOS_LIB/gw-gosu-core.jar
CP=$CP:$GOS_LIB/gw-commons-cli-1.0.jar

### These might be needed for some scripts ???
# CP=$CP:$GOS_LIB/gw-asm-analysis-3.1.jar
# CP=$CP:$GOS_LIB/gw-asm-commons-3.1.jar
# CP=$CP:$GOS_LIB/gw-asm-tree-3.1.jar
# CP=$CP:$GOS_LIB/gw-asm-util-3.1.jar

### Execute with:
java -cp "$CP" YourGosuBootStrapper

#-------------------------------------------------------------

/*
*   Sample java JSR 223 code:
*/

import javax.script.ScriptEngine;
import javax.script.ScriptEngineManager;
import javax.script.ScriptException;

public class YourGosuBootStrapper {
    public static void main(String[] args) {
        ScriptEngineManager mgr = new ScriptEngineManager();
        ScriptEngine engine = mgr.getEngineByName("gosu");

        try {
            // This will correctly print HELLO WORLD
            // On my machine, the initial evaluation takes about 2 seconds,
            // and subsequent calls to eval (once the Gosu internals are
            // initialized), run in between 14 to 25 milliseconds
            Object ret = engine.eval("print(\"HELLO WORLD\")");
        } catch (ScriptException e) {
            e.printStackTrace();
        }
    }
}

gosu-jsr223's People

Contributors

gorlowski avatar

Stargazers

Vladislav Bauer avatar Dariusz Debowczyk avatar  avatar

Watchers

Dariusz Debowczyk avatar  avatar James Cloos avatar

Forkers

jeffklein

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.