Updated: 11/5/2005; 6:05:58 PM.
Chris Double's Radio Weblog
        

Thursday, April 29, 2004

It's nice to use languages that 'just work' instead of having to code around border cases that the implementations don't handle. Take 'factorial' as an example. In Scheme:

(define (fact n)
  (if (= n 1)
       1
        (* n (fact (- n 1)))))

In Sisc Scheme this works for any number. The factorial of 100,000 is computed in about 9 seconds on my machine.

In Smalltalk it's the same. Ask for a factorial of a number and you get it back. No problems.

In Ruby, it's close. I got a factorial of 1,000 but once I hit 10,000 I got a stack overflow.

Slate works just like Smalltalk. Although quite a bit slower in its current alpha implementation.

In C, well, forget about factorials of big numbers. Either stack overflow or overflow of the integer number can be expected.

So in some languages you can write what seems to be the right code, but get wrong results (stack overflow, crashes, integer overflows).

11:55:53 AM      

[ Note build instructions have changed. Updated build instructions are here]

Brian Rice has announced an alpha release of the 0.3 version of the Slate programming language. This is the first release that contains the C based VM rather than the Common Lisp hosted system.

Using the latest source for Slate you can generate the C VM source code from inside the Common Lisp hosted system. The steps to do this are:

From Common Lisp (I used SBCL on Linux):

(load "slate.lisp")
'./src/init.slate' fileIn.
'./src/mobius/init.slate' fileIn.
'./src/mobius/c/init.slate' fileIn.
'./src/mobius/vm/init.slate' fileIn.
Compiler generateVM: 'vm'.
Compiler buildImage: 'vm.image' &littleEndian: True.

Changing the 'True' to 'False' on the last line generates a big endian image file. Compiling the generated C files with boot.c included with the announcement linked to earlier will give you a 'slate' executable. Running this, passing the image name as an argument, will present you with the Slate top level.

Slate is a prototype based object oriented programming language with multi-method dispatch. It draws influences from Self, Smalltak, Dylan, and CLOS I believe.

The C based VM is only an alpha release and doesn't include a lot of the functionality in the Lisp based system yet. Also note that the documentation on the web site is slightly out of date. The most notable differences that I hit were:

1) 'value', 'value:' and 'values:' have been renamed to 'do', 'applyWith:' and 'applyTo:' respectively.
2) You can't specialize dispatch on SmallInteger instances. So the following will not work:

n@1 fact [ 1 ].
n@(SmallInteger traits) fact [ n * ((n - 1) fact) ].

The first line will be accepted but not work as expected in the C VM. In the Lisp system it works fine. A couple of the examples in the manual use this and they won't work on the C VM as a result.


11:48:42 AM      

© Copyright 2005 Chris Double.
 
April 2004
Sun Mon Tue Wed Thu Fri Sat
        1 2 3
4 5 6 7 8 9 10
11 12 13 14 15 16 17
18 19 20 21 22 23 24
25 26 27 28 29 30  
Mar   May



Click here to visit the Radio UserLand website.

Listed on BlogShares

Click to see the XML version of this web page.

Click here to send an email to the editor of this weblog.