[ANN] ST2JS - Smalltalk to Javascript translator

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
21 messages Options
12
Reply | Threaded
Open this post in threaded view
|

[ANN] ST2JS - Smalltalk to Javascript translator

Diego Gomez Deck
Hi folks,

To take full benefit of current internet browsers, tons of lines of
Javascript have to be written.

We (the Smalltalkers) don't like to edit files to program, we want to
code in the refactoring browser!

This project is an attempt to generated Javascript from plain-normal
Smalltalk code.

You can find an entry for the project at SqueakMap and SqueakSource...
Most of the times the newer version resides on Squeaksource.

http://map.squeak.org/account/package/11637941-682d-4ce3-bd4c-ba67afef47b5/default


The current version allows to host a TestRunner on browsers, full
written in Smalltalk code (and translated to JS).  It also includes a
set of "base" classes to simulated an small Smalltalk environment.
Inspectors are also available.

You can see how the TestRunner looks at:

http://photos1.blogger.com/blogger/8166/525/1600/St2jS%20-%20Test%20Runner.png


Also, just in case you don't want to install the package, you can see an
HTML (full generated from Squeak) including the generated JS code at:

http://minnow.cc.gatech.edu/squeak/uploads/5851/St2jS%20-%20Test%20Runner.html

More information (in Spanish) is available from:

http://diegogomezdeck.blogspot.com/2006/07/st2js-traductor-de-smalltalk.html
http://diegogomezdeck.blogspot.com/2006/07/st2js-traductor-de-smalltalk_28.html

Most of the Smalltalk semantic is respected in the translator, the
current absences are:
- Support for class variables.
- Support for instance-class variables.
- Support for "super" in class-methods. (super works fine in instance
methods)

All these points can be solved, and they will as soon as I need them.
BTW any collaboration is accepted ;-)

The generated code runs fine in Firefox 1.5, IE and Konqueror (May be it
also works on Safari).  It doesn't work on Opera.


My next goal is to create a set of widgets, for the browsers, using
ST2JS for the JS production and my previos Comet project to mount an
Observer-pattern distributed between Squeak and the internet browsers.

I think there are a good set of interesting things to try, like:

- Port the Spoon minimal set of objects to JS.  (I mean, translate ST to
JS).  The performance will be awful, but every internet-browser can be
converted in a Smalltalk environment!


Enjoy it!

-- Diego.st



Reply | Threaded
Open this post in threaded view
|

Re: [ANN] ST2JS - Smalltalk to Javascript translator

Howard Stearns-2
I've found http://www.quirksmode.org to be be a wonderful guide to
writing cross-browser-compatible Javascript in good style.
Particularly the concept of "object detection"
(http://www.quirksmode.org/js/support.html), and of course,
http://www.quirksmode.org/browsers/contents.html

"Object detection" isn't all that easy to write manually, but the
technique is great for generated code.

Diego Gomez Deck wrote:
> ...
> The generated code runs fine in Firefox 1.5, IE and Konqueror (May be it
> also works on Safari).  It doesn't work on Opera.
>
> ...
--
Howard Stearns
University of Wisconsin - Madison
Division of Information Technology
mailto:[hidden email]
jabber:[hidden email]
voice:+1-608-262-3724


Reply | Threaded
Open this post in threaded view
|

Re: [ANN] ST2JS - Smalltalk to Javascript translator

Lukas Renggli
In reply to this post by Diego Gomez Deck
Interesting!

I am unable to load in 3.8 and 3.9. There are several messages not
understood, such as #inlineDo:, #jsLiteral:inSmalltalk:,
#inlineIfTrue:, etc. What do I miss?

Lukas

--
Lukas Renggli
http://www.lukas-renggli.ch

Reply | Threaded
Open this post in threaded view
|

Re: [ANN] ST2JS - Smalltalk to Javascript translator

Diego Gomez Deck
Oops! My mistake.

Load the version 20 (from SqueakSource) and it will work fine.

If you want to try in 3.8, just copy the implementation of
String>>withoutLeadingBlanks from 3.9.

Cheers,

-- Diego


> Interesting!
>
> I am unable to load in 3.8 and 3.9. There are several messages not
> understood, such as #inlineDo:, #jsLiteral:inSmalltalk:,
> #inlineIfTrue:, etc. What do I miss?
>
> Lukas



Reply | Threaded
Open this post in threaded view
|

Re: Re: [ANN] ST2JS - Smalltalk to Javascript translator

Lukas Renggli
> Load the version 20 (from SqueakSource) and it will work fine.

- MessageSend>>value: is missing in my 3.9 image, but I could add that.

- Then I get in FireBug the error "S2SExampleTestCase is not defined"

- The test case #testMethodInstantiation fails in the Squeak TestRunner.

Lukas

--
Lukas Renggli
http://www.lukas-renggli.ch

Reply | Threaded
Open this post in threaded view
|

re: ST2JS - Smalltalk to Javascript translator

ccrraaiigg
In reply to this post by Diego Gomez Deck

Hi Diego--

     Neat!

> I think there are a good set of interesting things to try, like Port
> the Spoon minimal set of objects to JS.  (I mean, translate ST to
> JS).  The performance will be awful, but every internet-browser can be
> converted in a Smalltalk environment!

     That would be fun. Speaking of Spoon, I'd like to use your
translator to write a web-based Spoon installer. Have you successfully
translated any applications which use the network or spawn host processes?


        thanks!

-C

--
Craig Latta
http://netjam.org/resume



Reply | Threaded
Open this post in threaded view
|

Re: Re: [ANN] ST2JS - Smalltalk to Javascript translator

Diego Gomez Deck
In reply to this post by Lukas Renggli
Lukas,

The version 23 (on SqueakSource) works fine on 3.8 (6665) (all tests
green, squeak and JS-side). Version 23 removes the dependency with
#withoutLeadingBlanks.

> > Load the version 20 (from SqueakSource) and it will work fine.
>
> - MessageSend>>value: is missing in my 3.9 image, but I could add that.

It seems like a bug in Komanche. I see two possibilities: install
Seaside or implement:

MessageSend>>evaluateWithArguments:
        ^ self valueWithArguments: anArray

MessageSend>>value:
        ^ self evaluateWithArguments: (Array with: anObject)


> - Then I get in FireBug the error "S2SExampleTestCase is not defined"
>
> - The test case #testMethodInstantiation fails in the Squeak TestRunner.

Which version of 3.9 are you using? I just installed ST2JS (after
DynamicBindings, KomServices and KomHttpServer) in a virgin 3.9 (7045)
and works fine for me (green both sides).

Cheers,

-- Diego



Reply | Threaded
Open this post in threaded view
|

re: ST2JS - Smalltalk to Javascript translator

Diego Gomez Deck
In reply to this post by ccrraaiigg
Hi Craig,

> Hi Diego--
>
>      Neat!
>
> > I think there are a good set of interesting things to try, like Port
> > the Spoon minimal set of objects to JS.  (I mean, translate ST to
> > JS).  The performance will be awful, but every internet-browser can be
> > converted in a Smalltalk environment!
>
>      That would be fun. Speaking of Spoon, I'd like to use your
> translator to write a web-based Spoon installer. Have you successfully
> translated any applications which use the network or spawn host processes?

I didn't try anything of these.

In fact the current "Smalltalk environment" emulated on the browser is
very, very small and incomplete and it's getting bigger only when it's
becomes a need.

To use the network from JS in browsers, you have to hack over a HTTP
requests to a web server. Plain sockets are just not available for JS
code.

Firing processes from javascript (in browsers) is, AFAIK, not posible.
What can be done is a type of multithreading for javascript processes
(see: http://slipwave.info/#js.cps.Thread)

Cheers,

-- Diego



Reply | Threaded
Open this post in threaded view
|

Re: Re: Re: [ANN] ST2JS - Smalltalk to Javascript translator

Lukas Renggli
In reply to this post by Diego Gomez Deck
> > - Then I get in FireBug the error "S2SExampleTestCase is not defined"
> >
> > - The test case #testMethodInstantiation fails in the Squeak TestRunner.
>
> Which version of 3.9 are you using? I just installed ST2JS (after
> DynamicBindings, KomServices and KomHttpServer) in a virgin 3.9 (7045)
> and works fine for me (green both sides).

I downloaded the latest version from SqueakSource, but I still get the
same problems in 3.9 (7048).

Lukas

--
Lukas Renggli
http://www.lukas-renggli.ch

Reply | Threaded
Open this post in threaded view
|

Re: Re: Re: [ANN] ST2JS - Smalltalk to Javascript translator

Diego Gomez Deck
> > Which version of 3.9 are you using? I just installed ST2JS (after
> > DynamicBindings, KomServices and KomHttpServer) in a virgin 3.9 (7045)
> > and works fine for me (green both sides).
>
> I downloaded the latest version from SqueakSource, but I still get the
> same problems in 3.9 (7048).

I downloaded a virgin 7048 (Squeak3.9b-7048.zip), installed
DynamicBindings, KomServices, KomHttpServer and ST2JS (all from
SqueakMap, remember to update the map).

Then I implemented MessageSend>>evaluateWithArguments: and
MessageSend>>value:.

And I got both sides green.

We have to find what package, installed on your image, breaks ST2JS. Is
posible to upload your image somewhere? I'd like to try it.

Cheers,

-- Diego



Reply | Threaded
Open this post in threaded view
|

Re: Re: Re: Re: [ANN] ST2JS - Smalltalk to Javascript translator

Lukas Renggli
> > > Which version of 3.9 are you using? I just installed ST2JS (after
> > > DynamicBindings, KomServices and KomHttpServer) in a virgin 3.9 (7045)
> > > and works fine for me (green both sides).
> >
> > I downloaded the latest version from SqueakSource, but I still get the
> > same problems in 3.9 (7048).
>
> I downloaded a virgin 7048 (Squeak3.9b-7048.zip), installed
> DynamicBindings, KomServices, KomHttpServer and ST2JS (all from
> SqueakMap, remember to update the map).
>
> Then I implemented MessageSend>>evaluateWithArguments: and
> MessageSend>>value:.

Strange this is what I did.

> We have to find what package, installed on your image, breaks ST2JS. Is
> posible to upload your image somewhere? I'd like to try it.

There are no other packages in that image. You can download it from:

http://www.lukas-renggli.ch/dropbox/st2js.zip

Maybe I should just retry in a new image, probably the first time the
loading failed from SqueakMap skrewed something up?

Lukas

--
Lukas Renggli
http://www.lukas-renggli.ch

Reply | Threaded
Open this post in threaded view
|

re: ST2JS - Smalltalk to Javascript translator

ccrraaiigg
In reply to this post by Diego Gomez Deck

Hi Diego--

> To use the network from JS in browsers, you have to hack over a HTTP
> requests to a web server. Plain sockets are just not available for JS
> code.

        That's fine, I just want to download a VM and object memory from some
website and start it.


> Firing processes from javascript (in browsers) is, AFAIK, not posible.
> What can be done is a type of multithreading for javascript
> processes...

        Oh, by "spawning host processes" I just meant starting an application
on the host from JavaScript.


        thanks,

-C

--
Craig Latta
http://netjam.org/resume



Reply | Threaded
Open this post in threaded view
|

Re: ST2JS - Smalltalk to Javascript translator

Colin Putney

On Aug 2, 2006, at 2:57 PM, Craig Latta wrote:

> Oh, by "spawning host processes" I just meant starting an application
> on the host from JavaScript.

Can't do that either. If web pages could download and launch  
arbitrary programs on our local machines, we'd all be in trouble.

Colin

Reply | Threaded
Open this post in threaded view
|

RE: [ANN] ST2JS - Smalltalk to Javascript translator

Ron Teitelbaum
In reply to this post by Diego Gomez Deck
I get: Not Found
The requested URL (http://minnow.cc.gatech.edu/ShowJavascriptSource/Base.js)
was not found on this server. Click here to get a list of swikis on this
site.

For all the links on:
http://minnow.cc.gatech.edu/squeak/uploads/5851/St2jS%20-%20Test%20Runner.ht
ml

Ron


> -----Original Message-----
> From: [hidden email] [mailto:squeak-dev-
> [hidden email]] On Behalf Of Diego Gomez Deck
> Sent: Wednesday, August 02, 2006 9:39 AM
> To: Squeak developers list; seaside
> Subject: [ANN] ST2JS - Smalltalk to Javascript translator
>
> Hi folks,
>
> To take full benefit of current internet browsers, tons of lines of
> Javascript have to be written.
>
> We (the Smalltalkers) don't like to edit files to program, we want to
> code in the refactoring browser!
>
> This project is an attempt to generated Javascript from plain-normal
> Smalltalk code.
>
> You can find an entry for the project at SqueakMap and SqueakSource...
> Most of the times the newer version resides on Squeaksource.
>
> http://map.squeak.org/account/package/11637941-682d-4ce3-bd4c-
> ba67afef47b5/default
>
>
> The current version allows to host a TestRunner on browsers, full
> written in Smalltalk code (and translated to JS).  It also includes a
> set of "base" classes to simulated an small Smalltalk environment.
> Inspectors are also available.
>
> You can see how the TestRunner looks at:
>
> http://photos1.blogger.com/blogger/8166/525/1600/St2jS%20-
> %20Test%20Runner.png
>
>
> Also, just in case you don't want to install the package, you can see an
> HTML (full generated from Squeak) including the generated JS code at:
>
> http://minnow.cc.gatech.edu/squeak/uploads/5851/St2jS%20-
> %20Test%20Runner.html
>
> More information (in Spanish) is available from:
>
> http://diegogomezdeck.blogspot.com/2006/07/st2js-traductor-de-
> smalltalk.html
> http://diegogomezdeck.blogspot.com/2006/07/st2js-traductor-de-
> smalltalk_28.html
>
> Most of the Smalltalk semantic is respected in the translator, the
> current absences are:
> - Support for class variables.
> - Support for instance-class variables.
> - Support for "super" in class-methods. (super works fine in instance
> methods)
>
> All these points can be solved, and they will as soon as I need them.
> BTW any collaboration is accepted ;-)
>
> The generated code runs fine in Firefox 1.5, IE and Konqueror (May be it
> also works on Safari).  It doesn't work on Opera.
>
>
> My next goal is to create a set of widgets, for the browsers, using
> ST2JS for the JS production and my previos Comet project to mount an
> Observer-pattern distributed between Squeak and the internet browsers.
>
> I think there are a good set of interesting things to try, like:
>
> - Port the Spoon minimal set of objects to JS.  (I mean, translate ST to
> JS).  The performance will be awful, but every internet-browser can be
> converted in a Smalltalk environment!
>
>
> Enjoy it!
>
> -- Diego.st
>
>
>



Reply | Threaded
Open this post in threaded view
|

re: ST2JS - Smalltalk to Javascript translator

Diego Gomez Deck
In reply to this post by ccrraaiigg
Hi Craig,

> Hi Diego--
>
> > To use the network from JS in browsers, you have to hack over a HTTP
> > requests to a web server. Plain sockets are just not available for JS
> > code.
>
> That's fine, I just want to download a VM and object memory from some
> website and start it.

What is "easy" to do is to re-write (just in case it's needed) your
objects in a way that translation to JS becomes posible.

To do that, ST2JS uses a similar approach that SLang>>C translator.  You
can insert conditionals statements in this way:

   self
      jsLiteral: '/* plain JS code */'
      inSmalltalk: [ "Smalltalk code" ].

Of course you can put this type of statements only in "base" classes.

> > Firing processes from javascript (in browsers) is, AFAIK, not posible.
> > What can be done is a type of multithreading for javascript
> > processes...
>
> Oh, by "spawning host processes" I just meant starting an application
> on the host from JavaScript.

Not, it's not posible.

What is posible is to create an "ST process" inside the internet-browser
using just generated JS code.  It will be very slow, but any browser can
become a Smalltalk environment without any installation at all.

Let me stated in this way: If they like what they get with plain-JS
code, may be they'll motivated to download and install the "real" spoon.

> thanks,
>
> -C

Cheers,

-- Diego



Reply | Threaded
Open this post in threaded view
|

RE: [ANN] ST2JS - Smalltalk to Javascript translator

Diego Gomez Deck
In reply to this post by Ron Teitelbaum
Hi Ron,

I guess you're reporting errors from the static HTML I put on squeak's
wiki.

This HTML doesn't work for complete.  It's only useful to test ONLY the
internet-browser functionality for lazy people that don't want to
install the package.

To take benefit from this HTML you can take a look to the generated JS
code viewing the source of the HTML. The links named "(squeak: run
browse)", "browse" and browsing in general depends on the server-side
implementation.  You can only use the "run all" and "run" links to fire
local (browser side) activities.

Take in mind this HTML was generated with an older version of ST2JS.

> I get: Not Found
> The requested URL (http://minnow.cc.gatech.edu/ShowJavascriptSource/Base.js)
> was not found on this server. Click here to get a list of swikis on this
> site.

To see the generated code of Base, look for:

        <!-- Embedded: "Base" -->
        <script type='text/javascript'>
        /**-----------------------------------------------------------**/
        /** Generated from: S2SBaseClass **/
       
in the HTML source.

> For all the links on:
> http://minnow.cc.gatech.edu/squeak/uploads/5851/St2jS%20-%20Test%20Runner.ht
> ml
>
> Ron

I hope this help.

Cheers,

-- Diego



Reply | Threaded
Open this post in threaded view
|

re: ST2JS - Smalltalk to Javascript translator

Diego Gomez Deck
In reply to this post by Diego Gomez Deck
> To do that, ST2JS uses a similar approach that SLang>>C translator.  You
> can insert conditionals statements in this way:
>
>    self
>       jsLiteral: '/* plain JS code */'
>       inSmalltalk: [ "Smalltalk code" ].
>
> Of course you can put this type of statements only in "base" classes.

Oops, my english level is awful :-(

I wanted to say that is "convenient" to put this type of statements only
in "base" classes, to hide the complexity in "user" classes.

The framework allows to use this feature in any class, not only in
extensions to base classes.

Cheers,

-- Diego


Reply | Threaded
Open this post in threaded view
|

RE: [ANN] ST2JS - Smalltalk to Javascript translator

Diego Gomez Deck
In reply to this post by Diego Gomez Deck
Tom,

Take a look to:

http://minnow.cc.gatech.edu/squeak/uploads/5860/St2jS%20-%20Test%20Runner.html

It's a standalone HTML, generated with a newer version of ST2JS, without
any link to squeak-side.
Cheers,

-- Diego

> Hi Ron,
>
> I guess you're reporting errors from the static HTML I put on squeak's
> wiki.
>
> This HTML doesn't work for complete.  It's only useful to test ONLY the
> internet-browser functionality for lazy people that don't want to
> install the package.
>
> To take benefit from this HTML you can take a look to the generated JS
> code viewing the source of the HTML. The links named "(squeak: run
> browse)", "browse" and browsing in general depends on the server-side
> implementation.  You can only use the "run all" and "run" links to fire
> local (browser side) activities.
>
> Take in mind this HTML was generated with an older version of ST2JS.
>
> > I get: Not Found
> > The requested URL (http://minnow.cc.gatech.edu/ShowJavascriptSource/Base.js)
> > was not found on this server. Click here to get a list of swikis on this
> > site.
>
> To see the generated code of Base, look for:
>
>         <!-- Embedded: "Base" -->
>         <script type='text/javascript'>
>         /**-----------------------------------------------------------**/
>         /** Generated from: S2SBaseClass **/
>        
> in the HTML source.
>
> > For all the links on:
> > http://minnow.cc.gatech.edu/squeak/uploads/5851/St2jS%20-%20Test%20Runner.ht
> > ml
> >
> > Ron
>
> I hope this help.
>
> Cheers,
>
> -- Diego



Reply | Threaded
Open this post in threaded view
|

Re: Re: Re: Re: [ANN] ST2JS - Smalltalk to Javascript translator

Diego Gomez Deck
In reply to this post by Lukas Renggli
Lukas,

Recompiling the method VariableNode>>jsSourceOn:level:translator: your
image will work.

It seems like a problem with renaming of classes: STBaseClass changed to
STObject some versions ago.

Cheers,

-- Diego

> > We have to find what package, installed on your image, breaks ST2JS. Is
> > posible to upload your image somewhere? I'd like to try it.
>
> There are no other packages in that image. You can download it from:
>
> http://www.lukas-renggli.ch/dropbox/st2js.zip
>
> Maybe I should just retry in a new image, probably the first time the
> loading failed from SqueakMap skrewed something up?
>
> Lukas



Reply | Threaded
Open this post in threaded view
|

Re: Re: Re: Re: [ANN] ST2JS - Smalltalk to Javascript translator

Diego Gomez Deck
In reply to this post by Lukas Renggli
Hi Lukas,

Can you (or anybody) tell me if the generated javascript code works on
Safari? I tried it in Konqueror, but not sure about Safari.

Cheers,

-- Diego


> > > > Which version of 3.9 are you using? I just installed ST2JS (after
> > > > DynamicBindings, KomServices and KomHttpServer) in a virgin 3.9 (7045)
> > > > and works fine for me (green both sides).
> > >
> > > I downloaded the latest version from SqueakSource, but I still get the
> > > same problems in 3.9 (7048).
> >
> > I downloaded a virgin 7048 (Squeak3.9b-7048.zip), installed
> > DynamicBindings, KomServices, KomHttpServer and ST2JS (all from
> > SqueakMap, remember to update the map).
> >
> > Then I implemented MessageSend>>evaluateWithArguments: and
> > MessageSend>>value:.
>
> Strange this is what I did.
>
> > We have to find what package, installed on your image, breaks ST2JS. Is
> > posible to upload your image somewhere? I'd like to try it.
>
> There are no other packages in that image. You can download it from:
>
> http://www.lukas-renggli.ch/dropbox/st2js.zip
>
> Maybe I should just retry in a new image, probably the first time the
> loading failed from SqueakMap skrewed something up?
>
> Lukas



12