Version 26 of Smalltalk

Updated 2003-07-18 17:56:20

Smalltalk [L1 ] is a pure object environment and programming language. Read the link to learn more.

Smalltalk is the oldest mature pure object-oriented language. It is brilliant, simple, and has only a few keywords. It is similar to Tcl in that the control structures are not part of language.

Almost all good things known in new hype-languages come from Smalltalk. That is

  • virtual machine
  • garbage collector
  • reflection (introspection)
  • dynamic object system (object can change the class, metaclasses)
  • Integrated Development Environment

Also many popular program-techniques were developed under Smalltalk first. That is Extreme Programming (with Unit-tests), Refactoring Tools, Visual Programming, MVC (Model / View / Controller).

Smalltalk has also well designed standard libraries (Collections, Process Control, I/O).

Squeak [L2 ] is a popular Smalltalk implementation with an active community, and several interesting features. If you want to play with Smalltalk, Squeak is a good start. - TP, whose first OO language was Smalltalk.

Why is not Smalltalk the first most popular object-oriented program language? The reasons could be:

  • for 30 years computers were too slow for virtual machines.
  • the first smalltalk systems was too expensive for normal folk.
  • smalltalk was too closed (not open) to another systems or languages.
  • has no types. Some managers belive that typed-languages can save them from ignorance.
  • it is too mature for making big money with consulting, i.e., it is on the trailing curve of the hype bandwagon.
  • jcw adds another - more technical - reason: deployment can be tricky...

XOTcl is an object-oriented extension for Tcl that has some characteristics from Smalltalk. It is also dynamic and has metaclasses and also have the same feeling. XOTclIDE provide Smalltalk like IDE (Squeak, Version Control as in Envy)


Talking of syntax, here's a snippet from [L3 ] - double-quoted strings are just comments:

       7   "a number"
       $z  "a character"
       'colourless ideas sleep furiously'   "a string"
       #(#tom #dick #harry)  "an array of 3 components"
       #(# one 'should shower at least' 3 'times a week')

# before a string turns it into a symbol (like quote in LISP); #(...) denotes what we'd call a list. RS can't help finding Tcl simpler, and better-looking...

Lars H: Does the # work like / in Postscript? In that language, /tom is just a name whereas tom is a command. Anyhow I agree Tcl looks better. - RS: Yes, #tom is the symbol tom, 'tom' is a string constant, and tom either variable or method/keyword.

Let see some sample program to show all main smalltalk syntax and look and feel.

      | myVar myVar2 |   " Variable Definition"
      myVar := SampleClass new. "Create Instance of Class Sample Class.
                                  new is simple method call on object SampleClass not special operator
                                  Everything is object"
      myVar setSample: 1.  "call method setSample: with one parameter"
      myVar setSample: 2 with: 3. "call method setSample:with: with two parameters"
      myVar getAnotherObjekt callThisObjectWith: 23. "method chaning java myVar.getAnotherObjekt().callThisObjectWith(23)"
      "Now Blocks"
      myVar isRead ifTrue: [Transcpript show: 'I am Ready] ifFalse: [Transcript show: 'Not Ready']
      "Or somethig like C operator ? : "
      myVar := myVar isRead ifTrue: [1] ifFalse: [2].
      "Collection"
      myVar := Array new.
      "Write Collection on stdout"
      myVar do: [:each | Transcript show: each printString].
      "Blocks are also objects. That can take parameters. see also Ruby language"
      "Blocks can be used do define new control stuctures or something like handlers"
      myVar := [:par1 | Transcipt show: par1].
      "Evalute Block."
      myVar value: 2.
      "same as"
      [:par1 | Transcript show: par1] value: 2
      "method cascading"
      myVar method1; method2; method3
      "equal to"
      myVar method1. myVar method2. myVar method3

Yes. It looks strange. It is not like Fortran, C, C++, Java or C#. It is also not like basic, perl, bash, tcl....


[ Category Language | Category Object Orientation ]