QuickSilver Smalltalk-to-JavaScript Compiler

February 2, 2011

QuickSilver Compiler

QuickSilver Compiler

http://www.silversmalltalk.com/index3.html

Above is an image of the current QuickSilver test environment.

QuickSilver is a Smalltalk-to-JavaScript compiler which is written entirely (hand-coded) in JavaScript. It should be complete in a few more days and I estimate that the compressed final version will be about 20kb in size.

Smalltalk applications compiled with QuickSilver run at the full speed of native JavaScript since it is just compiled JavaScript code that is produced – there is no interpreter present.

The language syntax is that of Squeak Smalltalk with one minor adjustment – anything between braces “{” and “}” is simply inserted unchanged into the compiled output. This lets you intersperse native JavaScript into your code; there is no need for “primitive” functions.

For example:

| x pi |
x := {[3, 4, 5, 6, ‘hello’, ‘world’]}.
pi := {Math.PI}.

QuickSilver will be released as “Public Domain” software when completed. I will be adding a code viewer and a test area to the main Silver Smalltalk page tomorrow.

A couple of days ago, I received an email from a developer whose team had also developed a Smalltalk-JavaScript compiler that they were using internally and planned to release sometime as open source. It appears that the details of our two approaches are slightly different but our conclusions are the same – it is entirely (100%) practical to run Smalltalk in a JavaScript environment.

That means that as of today (Feb 2, 2011) there are *at least three* ways to run Smalltalk in a JavaScript environment:

1) the SST.js interpreter which executes Squeak bytecodes
2) QuickSilver in a few more days
3) the other team’s approach that I mentioned above

It doesn’t really matter to me which of these becomes the most popular as long as developers start using *some* online Smalltalk environment for deploying applications in JavaScript.

The number of Internet users in the world has just pasted the 2 BILLION mark – and the number of mobile users is now estimated at over 5 BILLION.

And how many of these devices are running Smalltalk applications? Even if you include server-side VisualAge, VisualWorks, Dolphin, Squeak and everything else my guess is that the total is in the thousands – say somewhere between 5 thousand and 100 thousand.

And how many of these devices are running JavaScript? Probably most of them – say between 2 BILLION and 5 BILLION.

So getting Smalltalk to run in the JavaScript environment is not an academic exercise – it is a way of opening up huge new markets for Smalltalk application developers.

I need help developing the Smalltalk class libraries tailored to JavaScript and I will be making online accounts available free for anyone wanting to contribute.

Also, if any Smalltalk gurus want to point out why it is impossible to run Smalltalk in JavaScript please post an example and I will respond.

15 Responses to “QuickSilver Smalltalk-to-JavaScript Compiler”


  1. Hi,

    Excellent work! This might just be the most promising Smalltalk implementation I’ve seen in a long time.

    Thanks for your time and effort.

    I tested this in every browser I could get my hands on and unfortunately there were a few errors in Safari:

    vm.js:28 SyntaxError: Parse error
    startup.js:3 TypeError: Result of expression ‘Smalltalk.Vm’ [undefined] is not a constructor.
    quicksilver.js:3 TypeError: Result of expression ‘Smalltalk.fns.openTranscript’ [undefined] is not a function.

    I know it’s not finished yet but I wanted to pass this info along :).

  2. John Dougan Says:

    Howw does this compare to Avi’s Clamato?
    http://clamato.net/

    • Peter Fisk Says:

      Hi John,

      I briefly looked at Clamato.

      There are several departures from Smalltalk’s syntax and semantics. The most notable of these are: no explicit returns, 0-based indexing, no metaclass hierarchy, special syntax for instance variables.

      Both the SST interpreters and the QuickSilver compiler support the entire Squeak syntax including returns, metaclasses, and standard Smalltalk variable syntax. The only modification that I made was to add a new syntax element “{}” for inlining JavaScript code.

      — Peter


  3. Hi Peter,

    very nice Smalltalk you’re building there 🙂 While there have been quite a number of Smalltalk-on-JavaScript demos, having a full environment is great.

    Your point about “how many of these devices are running Smalltalk applications” is well taken, it’s a small fraction of the total. However, your guesstimate is still off by an order of magnitude: Etoys (written in Squeak) comes pre-installed on every OLPC XO laptop, and there are well over a million in use. To my knowledge this is the largest Smalltalk deployment in existence. The full Squeak environment is included (hidden, but accessible).

    – Bert –

  4. Alex Schenkman Says:

    Hi Peter,

    Great work!
    What is the relation between Quicksilver and Silver Smalltalk?
    I saw in some older post that the code for Silver costs u$s 99.

    Thanks!

  5. Peter Fisk Says:

    QuickSilver is a new project which consists of a hand-coded compiler in JavaScript.

    SST/Silverlight, SST/JavaScript, SST/Java, and SST/ActionScript are cross-platform Smalltalk interpreters.

    The $99 is the source price for all of them.


  6. Is there any way to get my hands on the code?

    I’d be interested in helping, if it would be a substantial step toward running Scratch in the browser.

  7. Steffen Says:

    Dear Peter,

    after quit a while without any news on Quicksilver/Silversmalltalk, I’d like to ask whether development is still ongoing?

    Regards, Steffen

    • Peter Fisk Says:

      Hi Steffen,

      Development of the libraries has been on hold pending the release of a stable version of ExtJs 4.0; there are still some issues with some parts of the Ext SDK.

      I will be moving this blog from WordPress to a forum on my own site probably in early June.

      The focus will be on tools for rapidly creating client interfaces for web applications.

      — Peter

  8. Sebastian Says:

    Hi Peter,

    I was wondering the same as Steffen (above me).

    Was following the development of Silversmalltalk with great interest. I still think your vision is on the spot and has great potential.

    Regards,

    Sebastian


  9. Hello Peter,

    I would like to contact you via email to see if we can co-operate in EXT JS / Secha run by Smalltalk. Would you please respond to my email address.

    Thank you very much
    Gerd

  10. PeterO Says:

    Hello Peter,
    Can you please provide an update to the development of SilverSmalltalk? Thank you.

    PeterO


Leave a comment