« January 2007 »
SunMonTueWedThuFriSat
    
1
2
3
4
5
6
7
8
9
10
11
12
14
15
17
18
19
20
21
22
23
24
25
27
   
       
Today
XML

Blog::Navigation

GetJava Download Button
Get the Source
Personal Blog

Blog::Referers

Today's Page Hits: 302

Powered by Roller Weblogger.
« Previous month (Dec 2006) | Main | Next month (Feb 2007) »
20070228 Wednesday February 28, 2007

Updated JSR-223 engine for Scheme

From "Script_on_Java", I came to know about new release (1.16.6) of SISC - Java based interpreter for Scheme. I updated the JSR-223 engine for Scheme @ scripting.dev.java.net to use SISC version 1.16.6.



( Feb 28 2007, 10:00:44 AM IST ) Permalink del.icio.us | furl | simpy | slashdot | technorati | digg

20070226 Monday February 26, 2007

Sun Tech Days Hyderabad 2007 - trip report and slides

As I mentioned earlier, I spoke at Sun Tech Days 2007. About 10000 folks attended Sun Tech Days. Approximately about 2000 folks attended each talk (at least in the ones in the "main" room where key notes talks were given). Very nice to see so many developers at one place! I think over the years, Sun Tech Days is growing to become like JavaOne. Kannan and I traveled from Chennai to Hyderabad to attend this event.

This year I gave two talks. In the talk titled "Java SE Language Features - JDK 5.0, 6 and Future", I covered mostly the language features of JDK 5.0. Because there are no Java language features in JDK 6, I covered javac's APIs (JSR 199, JSR 269 and Tree API). For JDK 7, I gave few web references (on closures etc.). The scripting talk is the one we (Mike Grogan and I) gave many times :-) Good news - we won't be talking on scripting in JavaOne 2007 :-).



Q&A

I didn't have time for Q&A after the scripting talk. We [Charles Nutter and I] answered few scripting questions outside the lecture hall. Summary of the Q & A:

What are the typical use cases of Scripting API?
JSR-223 is applicable where "Java code calls scripts". Say, you have a big Java application. You want to support customization of it. Instead of inventing an ad-hoc, home-grown (and possibly expression-only!) language for that purpose, you can use any JSR-223 scripting language. Your user will have the choice of scripting language. Examples: Scripting SVG with JSR-223. Another example: The Phobos project uses scripting API to support any jsr-223 language in it's web application framework. Yet another example: jconsole script shell plug-in.
Should I've to learn more languages in addition to Java?
It depends on your project! Most projects already involve more than one language (Java, XML, SQL dialect(s?), XPath/XQuery/XSLT ....) anyway. If your project requires, you may add scripting to the mix!
I just prefer to use another language on the Java platform. Do I still have to use JSR-223?
No. JSR-223 is meant for the use cases where you want to call/eval script from your Java code. If you just want to code in another language and still want to use Java platform (for portability, platform API or for any other reason], you can do so without getting into the JSR-223 API. For example, you can use JRuby or Groovy or any other language that runs on the Java platform.
How does the invokedynamic (JSR 292) relate to JSR-223?
A scripting or dynamically typed language may be implemented in many ways: interpreting the abstract syntax tree directly, interpreting it's own bytecode [like JavaScript] or generating JVM bytecodes. If a language is implemented by generating (JVM) bytecode (like Groovy, Pnuts ...), invokedynamic would help there. Whether or not the language runtime implements JSR-223 interface is another (unrelated) matter.

Slides

The slides are usually posted at Sun Tech Days site few days after the event. But if you are impatient, you can download the slides for the talks that I gave :-)



( Feb 26 2007, 04:53:32 PM IST ) Permalink Comments [1] del.icio.us | furl | simpy | slashdot | technorati | digg

JSR-223 variable access in Scheme, Tcl and F3

jsr-223 defines scripting API for the Java platform -- so that Java programs can execute scripts written in various scripting languages. As you'd probably know already, JDK 6 includes javax.script API and JavaScript engine in it. One of the facilities of javax.script API is script Bindings. Through the javax.script.Bindings interface, you can expose your application objects as global variables to your scripts. Ideally, you want to access global variables by the same name as key names in Bindings. But, there are some language specific complications in exposing global variables. Not every language has global scope - for example, Java. So, the script engine for Java looks for special setScriptContext static method to expose current context to the "script". In JRuby, global variables are always "$" prefixed - the prefixing is done by jsr-223 script engine for JRuby - so that your Bindings may have "foo" as key and your JRuby script may use "$foo". In addition, there are also some implementation specific complications in implementing JSR-223 Bindings. We will look at some specific cases below.



JSR-223 Bindings implementation for Scheme

SISC implementation has been used to implement jsr-223 engine for Scheme. The way jsr-223 Bindings works in Scheme script engine is as follows:

Scheme user has to use "var" procedure to access/update the variables exposed by jsr-223 bindings. To access variable "foo" from Scheme, you use (var 'foo). To update variable "foo", you need to use (var 'foo <value>). For example, you can use the following expression to print the current file name.


    (display (var 'javax.script.filename))

The following expression


    (var 'context) 

can be used to access the current script context from Scheme.



JSR-223 Bindings implementation for Tcl (Jacl)

TCL (Jacl) user has to use "var" procedure to access/update the variables exposed by jsr-223 bindings. To access variable "foo" from Tcl, you need to use [var "foo"]. To update variable "foo", you need to use


    var "foo" <value>; 

For example, you can use the following expression to print the current file name.

    echo [var "javax.script.filename"]

Similarly, the following expression

    var "context"

can be used to access the current script context from Tcl.



JSR-223 Bindings implementation for F3

F3 is statically typed language. You may want to refer to F3 and JSR-223 to check how jsr-223 Bindings is implemented in F3.



( Feb 26 2007, 11:57:42 AM IST ) Permalink Comments [2] del.icio.us | furl | simpy | slashdot | technorati | digg

20070216 Friday February 16, 2007

Meet you at Sun Tech Days, Hyderabad (Feb 21-23)

Have you registered for Sun Tech Days - Hyderabad - Feb 21-23? Meet you at Hyderabad....



( Feb 16 2007, 10:52:46 AM IST ) Permalink del.icio.us | furl | simpy | slashdot | technorati | digg

20070213 Tuesday February 13, 2007

Updated Jython jsr-223 engine with Jython 2.2b1

Jython 2.2 beta1 has been released recently. I updated jsr-223 script engine for Jython @ scripting.dev.java.net to use Jython 2.2 beta1 version.



( Feb 13 2007, 12:31:25 PM IST ) Permalink del.icio.us | furl | simpy | slashdot | technorati | digg

Programming by Scratch!

No, this is not about scratching head when your manager asks for status :-) I'm talking about the M.I.T Scratch programming language which is based on Squeak. I just downloaded Windows version and played with it for sometime. My son played with it too! They have a very nice Getting Started Guide!



( Feb 13 2007, 12:24:53 PM IST ) Permalink del.icio.us | furl | simpy | slashdot | technorati | digg

Copyright (C) 2005, A. Sundararajan's Weblog