New GNU Smalltalk Site Launched
By Ramon Leon - 22 September 2007 under Ruby, Smalltalk
GNU Smalltalk has launched a new site. I thought it was about time to give it a try so I can write my shell scripts in Smalltalk. I work in Windows but I use Cygwin so I can have a real shell handy, fortunately GNU Smalltalk runs under Cygwin. So I fire up a shell and grab the latest version, unzip and untar it...
wget ftp://ftp.gnu.org/gnu/smalltalk/smalltalk-2.3.6.tar.gz gunzip smalltalk-2.3.6.tar.gz tar -xf smalltalk-2.3.6.tar
So far so good. The instructions say I need autoreconfig, so I fire up Cygwin setup and hit the Devel category and install it, just to be safe I install gcc compilers for C and C++ as well. Time to build Smalltalk (that sounds weird to me).
autoreconf -fvi ./configure make
Takes a minute, checks a gazillion things, but all is well, build seems to work fine. Time to run the unit tests...
make check
Good to go, so lets install...
make install
OK, now just type "gst" to get a REPL, play around for a bit, and write my first simple shell script, a quick loop printing 1 to 10000 on stdout...
#!/usr/local/bin/gst -f (1 to: 10000) do:[:it | it printOn: stdout]. !
Sweet, works like a charm. I can now fall back on Smalltalk for shell scripting instead of ruby or pearl when I need more power than simple bash scripts.
Stealing a sample from the Wiki shows a nice scripting syntax making use of blocks for declaring class and method bodies...
Object subclass: Person [ | name age | Person class >> name: aString age: anInteger [ ^(self new) name: aString; age: anInteger; yourself ] name [ ^name ] name: aString [ name := aString ] age [ ^age ] age: anInteger [ age := anInteger ] printOn: aStream [ aStream << ('%1 (%2)' % {name. age}) ] ]
I think I like it! Only time will tell, but I think this will be my new scripting language of choice.
Comments (automatically disabled after 1 year)
The Person example only works in 2.95d (that's where the new scripting syntax was developed).
Ah, OK, I went with the latest stable, but I guess I'll load up the latest dev build when I want to play with the scripting syntax. In any case, it's very cool to be able to write shell scripts in Smalltalk finally.
A quick question from a complete newbie: does GST support regular expressions? What about regex literals? It would be tempting to migrate my stuff from Perl.
It claims to, but you'd have to find out by experimenting. I'm just learning myself and know nothing of the basics.
This is good news for me. Is very common to need to setup some backup mechanism in a linux server and the backup scripts are usually a mess or a syntax nightmare. Now the sun is starting to shine in shells too ;). I'll certainly give a try on this one
Yea, same feeling here, though I wish the database support were better.
I downloaded gst 2.95d and I'd like to play with the new subclassing syntax. Is it documented anywhere? I searched the wiki and can find references to the new syntax, and the one example, but no doc per se. In particular, I'm interested in how you'd define a class with instance, class, and/or class instance variables with this syntax.
You'll have to ask that question on the Wiki, I haven't tried the new version yet.
[...] also have gnu-smalltalk-el packages with an Emacs major mode for your coding pleasure. [via On Smalltalk] Post a comment | Trackback [...]