21st Century Smalltalk

June 13, 2007

Smalltalk/DLR - Class Browser Menus

Filed under: DLR, Silverlight, Vista Smalltalk — pfisk @ 8:00 pm

smalltalk18

Above is Smalltalk/DLR running in a Firefox browser with Silverlight 1.1.

There are two new popup menus added to the ClassBrowser. The method text panel now has a “Save” selection which compiles the method source code. Also, there is a popup menu in the method list panel with a single “Remove” choice to allow removing methods from a class.

Slowly, some basic Smalltalk tools  are becoming functional in the Silverlight environment. Most of my recent effort has been on numerous minor improvements in the “look-and-feel” of the various controls.

The next major tool in development is a DesignSurface for graphics and animations. I hope to post a prototype within the next few days.

June 11, 2007

Smalltalk/DLR - Class Browser Improvements

Filed under: DLR, Silverlight, Vista Smalltalk — pfisk @ 4:43 pm

smalltalk17

Above is Smalltalk based on Silverlight/DLR running in a Firefox browser. The tests in this example are validating parameter passing to instance methods.

The Smalltalk class browser now displays method source in the text panel. In the next release, I will add the necessary context menus to create, delete and rename classes and methods, thereby enabling the ClassBrowser to be used for program development.

Over the next couple of weeks, I will be adding additional tools such as inspectors and a simple graphical design tool - a debugging tool will have to wait until I understand the inner workings of the DLR in much greater detail.

Developing in a browser raises the question of where to store the source code when offline. There are several possible answers:

  • use the “local storage” features of Silverlight
  • store the code on a server
  • release a desktop version of Smalltalk/DLR (Vista and XP only)

The most practical solutions will only evolve through experience.

June 5, 2007

Smalltalk in Firefox

Filed under: DLR, Silverlight, Vista Smalltalk — pfisk @ 10:05 pm

smalltalk16

Above is Smalltalk based on Silverlight/DLR running in a browser.

Keystroke diagnostics that I recently added to the desktop menu have been very useful in correcting some problems in Firefox - above is a Smalltalk session working in a Firefox browser.

The startup file is now building the Smalltalk class hierarchy that can be seen in the ClassBrowser window.  It will be a couple more days until Smalltalk methods are working.

In the example above, I am testing some simple graphics in a “CanvasWindow”. This should become much more interesting when I add animation and a “physics engine” for effects such as gravity and collisions.

Sure beats HTML and Ajax.

June 4, 2007

Smalltalk in Silverlight - Startup Scripts

Filed under: DLR, Silverlight, Vista Smalltalk — pfisk @ 10:27 pm

smalltalk15

Above is Smalltalk based on Silverlight/DLR running in a browser.

Some recent changes to the Smalltalk environment:

  • there is now a help window
  • the “keycodes option shows keycode values as detected by Silverlight; this will help in diagnosing problems on Macintosh
  • importing classes is now working - example:
     ”Smalltalk import: ‘System.DateTime’
  • the interpreter now executes a startup file from the host site

The next area of focus will be creating Smalltalk classes.

May 16, 2007

IronPython Running on Mono

Filed under: DLR, Mono — pfisk @ 6:25 pm

Thanks to some very talented folks, it only took 16 days to get Microsoft’s IronPython with the “Dynamic Language Runtime (DLR)” working on Mono.

Congratulations!

This means that IronPython can now run in:

  • the Silverlight browser plugin
  • natively on Windows Vista
  • on Windows XP with WinFx
  • on Linux, BSD, and OSX with Mono

And all other DLR-bases languages (IronRuby, VBx, Smalltalk/DLR, etc) should be portable as well. It looks as though the DLR will shortly be portable “from cellphones through Solaris”.

My guess is that, over the next couple of years, DLR will become the default platform choice for most new projects requiring broad dynamic language deployment. It certainly has game changing potential.

Iterations in Smalltalk/DLR

Filed under: DLR, Vista Smalltalk — pfisk @ 4:08 pm

smalltalk5
Vista Smalltalk Site

This is an iteration test for Smalltalk running on the DLR. Click on the image to see a larger version.

For the moment, only “whileTrue:” and “whileFalse:” are implemented. The test shown above performs one million iterations in 2-3 seconds on a 3GHz Pentium.

Once class and method definitions are completed, all the elements will be in place to write complete Smalltalk programs.

Below is the code for the above test:

Workspace code

"-- Local variables --"
| index x y z |
"-- Import DateTime --"
Vm import: ‘System.DateTime’.
"-- Write header --"
Transcript clear.
Transcript show: ‘Starting 1,000,000 iterations’; cr; cr.
Transcript show: DateTime Now; cr.

“– Iterations –”
index := 0.
[index < 1000000] whileTrue: [
  index := index + 1.
  x := 3.45.
  y := 7.89.
  z := (x*x)+(y*y)].

“– Results –”
Transcript show: DateTime Now; cr; cr.
Transcript show: index; cr.
Transcript show: x; cr.
Transcript show: y; cr.
Transcript show: z; cr.

Transcript Results

Starting 1,000,000 iterations

5/16/2007 11:40:47 AM
5/16/2007 11:40:50 AM
1000000
3.45
7.89
74.1546

May 14, 2007

Imports and Branching in Smalltalk/DLR

Filed under: DLR, Vista Smalltalk — pfisk @ 8:02 pm

smalltalk4
Vista Smalltalk Site

These are some tests for importing modules and for branching control structures. Click on the image to see a larger version.

“Vm” is a utility class which acts as a receiver for certain system messages such as “import:”.  Since the tokenizer can not yet recognize “dotted names”, I am temporarily using string arguments for the “import” statement.

Most of the Smalltalk branching structures are now working: “ifTrue:”, “ifFalse:”, “ifTrue:ifFalse:”, and “ifFalse:ifTrue:”.

Tomorrow, I will be working on iteration structures starting with “whileTrue:” and “whileFalse:”.

May 13, 2007

Mono’s “Moonlight” Project

Filed under: DLR, Unix — pfisk @ 6:53 pm

Mono is an open source software project which provides .Net-compatible libraries, tools, and runtimes for Linux, BSD, OSX, and Solaris. They have recently started work on building a Mono-compatible version of Silverlight and the Dynamic Language Runtime (DLR) under a project named Moonlight. The project page gives a very good overview of the various technologies involved.

Also, there is a now a Usenet group discussing the current work on porting IronPython/DLR to Mono, and they seem to be making good progress.

At the moment, neither Silverlight nor the DLR work on Linux - but that is unlikely to remain the case for very much longer.

Block Functions in Smalltalk/DLR

Filed under: DLR, Vista Smalltalk — pfisk @ 5:55 pm

smalltalk3
Vista Smalltalk Site

I have completed an implementation of Smalltalk blocks for the DLR (Dynamic Language Runtime) and these are some of the tests. The code is included at the end of the post.

There still remain several items to be completed:

  • branching (ifTrue:, ifFalse:, etc)
  • iteration (whileTrue:, do:, etc)
  • keywords (self, super, true, false, nil)
  • variable scoping (local, global)
  • class definitions
  • methods definitions
  • module import mechanism
  • Smalltalk type extensions

All but the last of these should be completed during the next week.

The first code release will be for the Vista (or XP with WinFx) desktop and will be followed by a Silverlight version a couple of weeks later.

 Block test code

"-- block local vars --"
| blk1 blk2 blk3 blk3 blk4 blk5 blk6 blk7 |
"-- set block values --"
blk1 := [3 + 4].
blk2 := [:a | a * a].
blk3 := [:a | a * a * a].
blk4 := [:a :b | a + b].
blk5 := [:a : b | a + (b value: a)].
blk6 := [:a :b | a + (b value value: a)].
blk7 := [:a :b | (blk2 value: a) + (blk3 value: b)].
Transcript clear.
Transcript show: ‘– raw blocks –’; cr.
Transcript show: blk1; cr.
Transcript show: blk7; cr; cr.
Transcript show: '-- simple blocks --'; cr.
Transcript show: blk1 value; cr.
Transcript show: (blk2 value: 3); cr.
Transcript show: (blk3 value: 3); cr.
Transcript show: (blk4 value: 1200 value: 34); cr; cr.
Transcript show: '-- compound blocks --'; cr.
Transcript show: (blk5 value: 3 value: blk2); cr.
Transcript show: (blk5 value: 3 value: blk3); cr.
Transcript show: (blk6 value: 3 value: [blk3]); cr.
Transcript show: (blk7 value: 3 value: blk1 value); cr.

Transcript output for block tests

-- raw blocks --
<function <lambda$0> at 0×0000000000000048>
<function <lambda$6> at 0×0000000000000049>

-- simple blocks --
7
9
27
1234

-- compound blocks --
12
30
30
352

May 11, 2007

Calling Methods from Smalltalk DLR

Filed under: DLR, Vista Smalltalk — pfisk @ 7:17 pm

smalltalk2
Vista Smalltalk Site

Above is a test of Smalltalk/DLR calling string properties and methods. The Smalltalk/DLR parser can now handle cascades, keyword messages and calls to compiled methods.

In the test shown above, “Transcript” is a global variable referencing the transcript window which is coded in C#.  I am calling two public methods on the transcript:

  • public void show(object msg)
    – which prints “msg” to the window
  • public void cr()
    – which adds a linefeed to the window

There are then several tests which reference properties and methods on a string.

Note that the string property “Length” is defined in the .Net class “String”. However, the methods that I am calling — “title”, “strip”, “swapcase”, “zfill” — are all IronPython methods.

The Dynamic Language Runtime (DLR) makes use of  ”extension methods” which were introduced in C# 3.0. IronPython uses this capability with ”PythonExtensionTypes” to give strings (and other classes) additional Python methods. Over the next few days, I will start to define my own “SmalltalkExtensionTypes” for strings, integer, objects, etc. to add the appropriate Smalltalk methods.

So far, I have found that the DLR is quite easy to use. The next task is to add processing for Smalltalk blocks and classes to the compiler. With any luck, the compiler should be mostly complete sometime next week.

Older Posts »

Blog at WordPress.com.