Smalltalk

Difference between version 47 and 48 - Previous - Next
[http://www.smalltalk.org/%|%Smalltalk] is a pure [object orientation%|%object]
environment and [programming language].
   ''The thing that I'm most proud of at Smalltalk, pretty much the only thing, from my standpoint, that I'm proud of, is that it has been so good of getting rid of previous versions of itself until it came out into this world. ... Squeak is not an attempt to give the world a free smalltalk, but an attempt to give the world a bootstrapping mechanism for something much better than Smalltalk, and when you fool around with Squeak, please, please think of how you can obsolete the damn thing by using its own mechanisms for getting the next version of itself.'':   Alan Kay, [https://www.youtube.com/watch?v=oKg1hTOQXoY%|%The computer revolution hasnt happened yet], OOPSLA 1997.


** See Also **

   [XOTcl]:   an [object orientation%|%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] provides Smalltalk-like [IDE] (Squeak, Version Control as in Envy)



** Reference **

    [http://propella.sakura.ne.jp/earlyHistoryST/EarlyHistoryST.html%|%The Early History Of Smalltalk], Alan C. Kay, 1993:   

    [https://www.youtube.com/watch?v=BbwOPzxuJ0s%|%Alan Kay - 2012 SCIx Keynote Presentation], 2012:   



** Description **

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

Almost all good things known in currently-hyped languages come from Smalltalk. For example:

    * [virtual machine]
    * [garbage collection%|%garbage collector]
    * reflection ([introspection])
    * dynamic [object orientation%|%object system] (object can change the [class], [metaclass%|%metaclasses])
    * [IDE%|%Integrated Development Environment]

Also many popular program-techniques were developed under Smalltalk first:

   [Extreme Programming]:    (with Unit-tests)

   [Refactor]ing Tools:   
   
   Visual Programming:   
   
   [Model / View / Controller]:   

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

[TpP]:   My first OO languge was Smalltalk.  [http://squeak.org%|%Squeak] 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.

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

    * for 30 years computers were too slow for [virtual machine%|%virtual machines].
    * the first Smalltalk systems were too expensive for normal folk.
    * Smalltalk was too closed (not open) to another systems or languages.
    * No [type%|%types]. Some managers believe that typed languages can save them from ignorance.
    * 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...''

[RLH]:  Deployment is a lot better in Smalltalk (though still a little clunky).
Here [http://www.whysmalltalk.com/smalltalkcomparisons/elastolab.htm] is a
little walkthough on how a developer decided between C++ and Smalltalk.


----

Talking of syntax, here's a snippet from
[http://www.cosc.canterbury.ac.nz/~wolfgang/cosc205/smalltalk1.html] -
double-quoted strings are just comments:

======none
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 `#` 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.

======none
| 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"

"method chaning java myVar.getAnotherObjekt().callThisObjectWith(23)"
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 | Transcript 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]....

----

[Shin The Gin] 2007-01-4:  If you are addicted to the convenience of a common
Smalltalk environment, give [Tcltalk] a try! You'll find workspaces and
browsers and even logging of changes, all without object orientation.

----

[RS]: Could one say that Smalltalk's "blocks with parameters" correspond to Tcl's upcoming [apply] lambdas (starting from 8.5)?

[NEM]: Yes and no. As I understand it, Smalltalk blocks are full lexical
[closures], so they are a bit more powerful than Tcl's lambdas. Smalltalk is
actually quite a nice [functional programming] language as well as [object
orientation%|%OO].

----

RJH 2013-05-15:

Forgive my confusion; but the original author appears to claim that 'garbage
collection' originated in smalltalk. I was under the impression that smalltalk
originated somewhere around the early 1970s and that garbage collection
originated with Mr. McCarthy's LISP in the late 1950s...

Have I misunderstood the history - or is the claim that smalltalk originated GC
a little ''overenthusiastic''?

Thanks, R.


** See Also **

   [XOTcl]:   an [object orientation%|%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] provides Smalltalk-like [IDE] (Squeak, Version Control as in Envy)



<<categories>> Language | Object Orientation