Next Generation HyperTalk as scripting language inside Field

100 views
Skip to first unread message

Tom Fuerstner

unread,
Jul 11, 2011, 10:51:50 AM7/11/11
to Field-development
hi,

recently and by surprise a remarkable new version of HyperTalk calles
OpenXION, implemented as Java compiler, appeared online. As the source
code is also available it was simply to tempting to embed this next
generation HyperTalk inside of Field. ... and it's amazing, cause it
opens up the possibility to combine a very user centric and easy to
learn scripting language with flow/node based, graphical programming
languages like Field and Max/MSP and with finita state automate driven
graphic environments like Processing and Nodebox2.

To embed OpenXION into Field is straight forward. I simply loaded the
necessary Lexer and Parser classes from the openxion.jar (already
placed inside the Field package ) and then handed over a HyperTalk
structure for execution. To hand over the results of the HyperTalk
processes i simply used to write to and read from the file system
following a predefined naming scheme. Everything works as expected and
it's a joy to use HyperTalk this way.


########## example code start ######################

import os

from java.io import FileWriter
from java.io import FileReader
from java.io import BufferedWriter
from java.io import BufferedReader
from java.io import StringReader
from com.kreative.openxion import *


hyptlkCmd ="""

global Fabuloes

on field var, varName
put "/tmp/f" & varName into varPath
open file varPath
write var to file varPath
close file varPath
end field

put 3 + 4
put "hello world from hypertalk" & return & "und so weiter" into world
put world
repeat 10
put world
end repeat
put "a" into z

field world, "world"



"""


ui = XNNullUI( )
context = XNContext( ui)

context.setSecurityProfile(XNSecurityProfile(XNSecurityValue.ALLOW))

print " XNMain.readEnviron( contxt): "
print XNMain.readEnviron( context)

context.loadModule( XNStandardModule.instance())
context.loadModule( XNExtendedModule.instance())

interp = XNInterpreter( context)
print "XNInterpreter( context)"
print interp

lexer = XNLexer( hyptlkCmd, StringReader(hyptlkCmd))
print "XNLexer( hyptlkCmd, StringReader(hyptlkCmd))"
print lexer

parser = XNParser( context, lexer)
print "XNParser( context, lexer)"
print parser

program = parser.parse()
print "parser.parse()"
print program

result = interp.executeScript(program)


reader = BufferedReader(FileReader("/tmp/fworld"))
while 1:
s = reader.readLine()
if not s:
break
else:
print s
reader.close()

########## example code end ######################

Naturally these first experiments are encouraging to go forward.
Therefore my question: "As there exists access to the OpenXION source
code, which runs inside Field, what is the best way to directly call
into Field's Jython environment?". Of special interest are calls into
the DrawingPLines code. This way it would be easy to set up a
HyperCard-ish environment inside of Field! Which Field classes have to
be loaded inside the OpenXION runtime and how can it be assured that
the Field drawing calls get executed inside the canvas of the active
Field instance?

OpenXION is available at Google Code: http://code.google.com/p/openxion/

I went through the whole source code of Field, but without advice it
will get to cumbersome to find the right implementation strategy.

Regards,

/tom fuerstner



Marc Downie

unread,
Jul 11, 2011, 11:24:51 AM7/11/11
to field-de...@googlegroups.com

Tom,

Pretty interesting find. 

Here's what we need: to call into Field is to call into Java. This is up to the client runtime, not Field. 

What I'm not finding after a quick look at their website is any interface back into the host VM. In fact, I find a declaration that the next version of OpenXION is going to be written in c++, so maybe their dev team isn't interested in interacting with the host VM. 

(In this specific case PLine is just a python wrapper around some Java classes — the wrapper is written in Python, but other languages could make their own wrappers. The core functionality is there for all languages to use.)

If you can track down some example code where:

1. existing java instances are injected into a running XNInterpeter's namespace which is maintained across invocations to .executeScript(...). We really need an interpreter.setVariable(name, value) where value can be any Java Object or, failing that, methods to wrap and unwrap java objects to XOMVariables.

2. methods are called on those instances from OpenXION scripts inside .executeScript(...)

then we'd be basically done. It wouldn't take any work at all to add OpenXION to the list of languages offered in Field's "lambda" palette. 

Otherwise, we're looking at RPC tricks a la the MaxPlugin / JavaScript work which are generally less satisfying and ask more of the client language — you have to effectively run a network accessible REPL inside a OpenXION script which you talk to via Field. More work for sure, and a shame, considering it's implemented on the VM.

Marc.




--
You received this message because you are subscribed to the Google Groups "Field-development" group.
To post to this group, send email to field-de...@googlegroups.com.
To unsubscribe from this group, send email to field-developm...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/field-development?hl=en.


Tom Fuerstner

unread,
Jul 11, 2011, 11:51:06 AM7/11/11
to Field-development
Marc,

there is no functionality inside OpenXION to call back into the Java
VM. But I will try to extend the OpenXION's "do script as 'Programming
Language' " to enable this functionality. HyperCard compilers are not
new to me and this Java implementation is the most sophisticated one I
ever saw.

I know the original Hypercard's innards, a mess, MagicTalk the
scripting engine once driving General Magics TeleScript environment
and Apple's mythical Sk8Script, implemented in Macintosh Common List.
Will come back when the very moment i established calling back into
the VM.

Thank you!

/tom

Tom Fuerstner

unread,
Jul 13, 2011, 4:48:12 PM7/13/11
to Field-development
 So, started to enhance the XNExtendedModule.java class to enable callback back into the VM using reflection and method invocation code. This way it is possible to make calls like: do “javaClassName, methodName, args” as “javaCallBack”. Something that was really missing inside the OpenXion code. Now Rebecca Bettencourt , the owner of OpenXION just has to accept my code.

Anyway HyperTalk is now a "real Field language" ;-)

/tom
--
Tom Fuerstner

-------

(c)2010  ><{{{{{{°> tom surfs along!

-------

Keep it private!  So, please use my PGP public key for important messages!

-----BEGIN PGP PUBLIC KEY BLOCK-----
Version: GnuPG/MacGPG2 v2.0.16 (Darwin)

mQENBE0AguYBCACs8I7yPOBywdSD/NK6egvugcPv4uRMdcA2rpKOfJpLAVJRE7gj
RYiV/kujaO/vXylBekzwVP18S1RiCDVWpvlBDhpINX4ot25Uylg0GGReASNTqEC5
hadf78E3opU8KryPPb6LTZCjfNrvUjbDB+FyLAWbFbIjrPE1hLVwBl6ScYWmYytt
ZRYYe6x3J6pJ8rNP5HDv/9hCxlysayQkqvNwaL7H6OlzehD1GozDEldX53lkD5Nv
pajk7SnJAWIFigi+b+jd2YkXAbckMPxKngbqYs16xbBcDLjIQEFjIehiLEG+792p
8rFlOnVRLES5IIrL7IPgmoXkXzX9/DvAy5erABEBAAG0IE5lc3RvciBTaWxrIDxp
LnNjcmlwdEBnbWFpbC5jb20+iQE4BBMBAgAiBQJNAILmAhsvBgsJCAcDAgYVCAIJ
CgsEFgIDAQIeAQIXgAAKCRC4if464wm3EFo3B/sGCAsh60b+xv/CJ3rsvlIXMlXU
mUblS24cPxo87z7sli+y8w30NIHpvUOXZNgxBeLIYeSajcefpP73RKJNz1RG48iH
yUUkHTApfvP3ELXyNC5AmGfUYJpbXJqNtm+KL/48/QKfNpszvYuV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8L4GCmvhxezBORXKmvhjgu6GkhsWA
Jtu0edRs8hixA2vZCyPHXNu5OqIJQ1V3v8HTswC1mWLX7gvMF1NgIn1Cfo46cYVP
piafgtN1XYBI9oY0VpuIra1jJJmunamJhCMxKFIhPSs3VVUs1gjaK8qGhxWApxyn
nAMbTzyeVoIdeDvm8E9j0hfJ0UqpSIfJy/W6MJ3bp7+5CuJlDEZz0nRQfKsHo2EM
fW9k6abAY/0+HGyGu5c7RjqDWOdXIvvfLC5792kr
=aiEC
-----END PGP PUBLIC KEY BLOCK-----

Chris Marsh

unread,
Jan 10, 2012, 7:58:44 AM1/10/12
to field-de...@googlegroups.com
I'm very excited by all of this. I've just arrived at Field, and it looks fabulous. My main interest is in secondary school educational programming. Integrated, live Hypertalk would make it even easier to get younger children involved.

I've only just starting playing with Field, so this isn't really anything beyond a "Hi, Wow, Great!" comment to the thread and the project. And thanks also for the comprehensive tutorials -- these, along with the live coding IDE, have made Field my new priority playground. :-)
 
Reply all
Reply to author
Forward
0 new messages