QuickSilver Version 0.1 Download

February 2, 2011

QuickSilver Compiler Test

QuickSilver Compiler Test

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

Above is an image of some early testing.

Here is the Smalltalk code in the image:

| tr pi msg sin v |
tr := {Smalltalk.vars.Transcript}.
pi := {Math.PI}.
sin := {Math.sin}.
msg := 'The value of sin(PI/4) is: '.
v := sin value: pi/4.
tr println: msg+v

The transcript on the left shows the Smalltalk code, the generated JavaScript code, and the runtime output.

This is an example of mixing Smalltalk and JavaScript within a method.

Math.sin is a JavaScript function and I use it the same way as a block in Smalltalk by sending it a “value:” message.

Smalltalk.vars.Transcript is an ExtJs TextArea object and “println” is a JavaScript function in the object. I can treat “println” just like a Smalltalk method and send a “println:” message to it.

You can download the QuickSilver compiler version 0.1 here as an Eclipse project file. I use the very nice Eclipse Helios IDE for JavaScript.

I started coding QuickSilver in JavaScript on Sunday Jan 30 – so the current state of the compiler represents about three days of work.

There still remains the class system and “non-local-returns” and several other things to do. I expect it to be mostly complete by early next week.

— Peter

Advertisements

10 Responses to “QuickSilver Version 0.1 Download”

  1. Andy Burnett Says:

    One of the possibilities this offers is the chance to write browser extensions in Smalltalk. I think this could be really interesting. Maybe we should develop some Smalltalk/javascript class libraries to ease that process.

    By the way, is there a way of loading a library e.g. jquery etc., dynamically? Could be useful

    • Peter Fisk Says:

      Hi Andy,

      You should be able to do anything that can be done in JavaScript.

      Loading libraries dynamically? Sure – AFAICT, the most common way is to create a new tag and insert it into the header. Or you load the JS code and “eval” it.

      My guess (if everything works out) is that Smalltalk/QS may simply replace a number of JS libraries.

      — Peter


  2. Hi Peter,

    I downloaded the project and tried to get it up and running but I seem to be missing some dependencies. What’s required to run the demo in index3.html?

    I’ve downloaded ExtJS but some things seem to be missing, or are in the wrong places.

    Mark.

    • Peter Fisk Says:

      Hi Mark,

      There were two files missing:
      — js/start.js (sets up an ExtJs Viewport)
      — wallpapers/desktop.jpg

      I have updated the *.zip file, so please try it again and let me know if there are still problems.

      Dependencies on ExtJs are temporary.

      Once the coding is completed, I will produce a proper compressed *.js file with no external dependencies.

      — Peter


      • Hi Peter,

        Thanks for the quick reply.

        It’s working in Opera and Firefox.

        Now to make it work in Safari and Chome.

        I’ll let you know how it goes.

        Mark.


      • It turned out to be quite easy to make it work in Safari and Chrome: as it turns out “class” is reserved so changing:

        Array.prototype.class = function() {
        return ‘SMALLTALK ARRAY’;
        };

        to:

        Array.prototype.classString = function() {
        return ‘SMALLTALK ARRAY’;
        };

        In vm.js is all that’s needed. No more Parser Error.

        Now I admit that classString isn’t as nice as class but…

        Take care,

        Mark.

        P.S. What would I need to do to become an official contributor?


      • Please forgive the number of replies, but I wanted to point out that you can use ‘class’ if you want to but you need to do something like this:

        Array.prototype[‘class’] = function() {
        return ‘SMALLTALK ARRAY’;
        };

        I’m not sure if the WebKit guys plan to change this in the future.

        While I’m at it, Safari and Chrome both fail to find these resources –

        /_ah/channel/jsapi
        quicksilver/loader/imagebuilder.js
        quicksilver/object/object.js
        quicksilver/object/behavior.js
        quicksilver/object/class.js
        quicksilver/object/metaclass.js
        /js/channel.js

  3. Peter Fisk Says:

    Thanks for the update Mark.

    It seems that “class” was probably not the best choice.

    I will change it to something less likely to cause conflicts – maybe “smalltalkClass” or something like it.

    The site “http://www.silversmalltalk.com” will have a sign-in for contributors. It will take me a day or so to set it up once I finish the rest of the coding – next Monday most likely.

    — Peter

  4. Andy Burnett Says:

    I can see that we are going to have to create unit tests soon 🙂

  5. pmuellr Says:

    I believe the bleeding edge versions of the browsers will allow keywords as property accessors. But existing versions may not. In the future, shouldn’t be a problem using “class”, but today, practically, it is. The latest final ECMAScript std spec’d the use of keywords as property accessors.

    For contributors/contributions, may I suggest GitHub. Pretty please.


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: