jScheme

I bumped into this very interesting scripting language while browsing the web:

http://jscheme.sourceforge.net/jscheme/main.html

There are some interesting thigs about this language.

The interpreter is little more than 50kb.

The language was writen by Peter Norvig one of the autors of the book “AI a modern aproach”. A AI book of reference for many univs.

There is a nice way to access java called dot java:

http://jscheme.sourceforge.net/jscheme/doc/javadot.html


;; Jscheme example 
(import "java.awt.*")
(import "java.awt.event.*")


(define win (Frame. "Hello"))
(define b (Button. "Goodbye"))
(.add win (Label. "Hello")
      BorderLayout.NORTH$)
(define p (Label. 
  (string-append "sin(PI) = " 
    (Math.sin  Math.PI$))))
(.add win b)
(.add win p  BorderLayout.SOUTH$)
(.addActionListener b
  (Listener. (lambda (e)
    (.hide win))))
(.pack win)
(.show win)
(.println System.out$ "Done")

The same code with JLIB for jScheme:


;; Jscheme/JLIB example 
(load "jlib/JLIB.scm") ;; load jlib from jscheme.jar file
(define win (window "Hello"
  (border
    (north (label "Hello"))
    (center (button "Goodbye" (action (lambda(e) (.hide win)))))
    (south (label (string-append "sin(PI) =" (Math.sin Math.PI$)))))))
(.pack win)
(.show win)
(.println System.out$ "Done")

Try it here with this applet:

http://jscheme.sourceforge.net/jscheme/contrib/jswebapp/jscheme/demo/JSchemeEvaluator.html

It’s a bit incomplete for a java user needs. It lacks run-time compilation of functions to java classes for instane. But it looks like a good scripting language. I’m think about using it with one of the opengl bindings to finnaly learn opengl.

waaay too many parenthesis!

It’s only to aficionados.