New Blog – SIMPL/PHP

January 20, 2012

Hello again,

I have started a new blog at http://simplphp.wordpress.com.

SIMPL/PHP is a complete “Smalltalk-like” online environment for developing Internet applications.

And I will keep this blog alive as well for discussing Smalltalk…

Form Panels and Signin Window

February 22, 2011

QuickSilver Signin Window

QuickSilver Signin Window

http://www.silversmalltalk.com/

There are several new Smalltalk classes that have been added to base library.

FormPanel
FormPanels can contain multiple data fields that will be processed simultaneously – similar to HTML forms. The Smalltalk FormPanel class has methods for assisting in layout and defining block handlers for processing the data.

Signin Window

SigninWindow allows users to sign-in to their accounts. It is invoked from the desktop menu and uses a FormPanel to present the needed data fields.

Today, I will be adding file editors to manage Smalltalk code in the Google database.

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

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.

Source code for all current versions of SST is available for $99 from http://www.silversmalltalk.com/purchase.html.

The license is commercial – you may not redistribute the source code itself but you can sell or freely distribute binaries built from the source code.

You will be also be able to download source code updates for one year including the sources for any versions not yet released. The two versions currently available are C#/.Net and Java/JavaScript using Google’s GWT compiler.

These are the complete project sources for building the Silverlight/.Net and the JavaScript interpreters.

Site Layout Changes

January 30, 2011

The default page for http://www.silversmalltalk.com is now the JavaScript version of SST while the Silverlight version has been moved to http://www.silversmalltalk.com/index2.html.

There will be more emphasis on documentation and user feedback on the site and these changes will make it easier for general access.

A third startup page for SST.swf (Flash) will be added during the next few weeks.

— Peter

The JavaScript implementation of Silver Smalltalk is now working well enough to implement some basic tools. But the code is still very much alpha quality and contains many inelegant “hacks” and undoubtedly numerous bugs as well – it is still weeks away from being production quality.

However, it does work and it proves the feasibility of using Google’s GWT compiler to create a not-so-simple implementation of a Smalltalk interpreter running entirely in JavaScript (GWT converts Java source code to JavaScript).

There are now four separate implementations of the Silver Smalltalk interpreter:
— stvm.exe and stvm.xap in C# for .Net and Silverlight
— stvm.jar in Java targeting Google’s Android
— stvm.swf in ActionScript 3 targeting Flash player and Adobe AIR desktop
— stvm.js in JavaScript target any JavaScript environment (smart phones, tablets, browsers, etc)

My guess is that the JavaScript implementation will prove to be the most popular and the most flexible. Partly this will be due to the continuing performance improvements in the JavaScript language. And partly it will be due to the ability to access many of the new HTML5 features which are beginning to appear in WebKit-based devices. Sencha talks about HTML5 now becoming the *minimum* for mobile devices.

JavaScript can also be easily compiled dynamically in the client device (unlike C#, Java, and AS3). This will allow me to add some extra capabilities to the SST compiler.

1) multi-line compiled JavaScript primitives
currently SST primitives can call external JavaScript functions. I plan to extend this so that primitive methods can consist of multi-line JavaScript code.

2) generation of JavaScript code from Smalltalk
last year, I released GWT Smalltalk which converted Smalltalk code into JavaScript. I will add the same capability to SST/Js. The advantage would be that you could prototype in Smalltalk and produce JavaScript for production (speed, project requirements, etc).

I am *not* saying that any arbitrary Smalltalk code can be converted to JavaScript – there are some well-known issues that make this impossible. However, if the Smalltalk code is very carefully written to avoid these issues, then conversion is feasible – I will discuss this in future posts.

So, it should be largely possible to obtain compiled JavaScript speed within the highly productive Smalltalk development environment.