Functional Scripting Languages for the JVM

Per Bothner

<per@bothner.com> <bothner@portolagroup.com>

The Portola Group

September 1999

Other languages on JVM

Dynamic (Lisp-like) languages vs. Java

Scheme vs. Java Types

Numbers

Compilers vs. interpreters

ResponsivenessExecution
Interpreter written in Java:GoodSlow
Translate to Java source:PoorFast
Translate to Java bytecode:GoodFast

Procedures

Closures

(define (f1 a)
  (define (f2 b) (list a b))
  (cons a f2))
class F1 extends Procedure1
{
  public Object apply1(Object a)
  {
    F2 f2 = new F2();
    f2.a = a;
    return Cons.apply(f2.a, f2);
  }
}
class F2 extends Procedure1
{
  Object a;
  public Objet apply1(Object b) {
    return List.apply(this.a, b); }
}

Scheme class definition

Multiple inheritance

Multiple inheritance (continued)

(define-class S () a)
(define-class T () a b)
(define-class U (S T) c)
public interface U extends S, T
{
  public Object getC();
  public void setC(Object c);
}
public class U$class implements U
{
  Object a, b, c;
  public Object getA() { return a; }
  public void setA(Object a) { this.a = a; }
  public Object getB() { return b; }
  public void setB(Object b) { this.b = b; }
  public Object getC() { return c; }
  public void setC(Object c) { this.c = c; }
}

Multiple inheritance (usage)

Modules

Module instances

JEmacs - Kawa support for Emacs Lisp

Kawa not just for Scheme

Why Emacs in Java?

Classes for text editing

JEmacs Screenshot

The Emacs Lisp Core Language

Document generators

Abstract and concrete documents

Document generators and expressions

Document expressions in Scheme

Transformer expressions and combination

Constructing primitive documents

General filtering

Implementation: document specifiers

Final notes


Per Bothner
Last modified: Wed Mar 15 15:35:58 PST 2000