The Artima Developer Community
Sponsored Link

Agile Buzz Forum
The "Magic" of Smalltalk

0 replies on 1 page.

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 0 replies on 1 page
James Robertson

Posts: 29924
Nickname: jarober61
Registered: Jun, 2003

David Buck, Smalltalker at large
The "Magic" of Smalltalk Posted: Apr 7, 2006 7:04 PM
Reply to this message Reply

This post originated from an RSS feed registered with Agile Buzz by James Robertson.
Original Post: The "Magic" of Smalltalk
Feed Title: Cincom Smalltalk Blog - Smalltalk with Rants
Feed URL: http://www.cincomsmalltalk.com/rssBlog/rssBlogView.xml
Feed Description: James Robertson comments on Cincom Smalltalk, the Smalltalk development community, and IT trends and issues in general.
Latest Agile Buzz Posts
Latest Agile Buzz Posts by James Robertson
Latest Posts From Cincom Smalltalk Blog - Smalltalk with Rants

Advertisement

Keith Braithwaite has an excellent article up on the "magic" enabled by having objects all the way down. He uses the classic explanation: how #ifTrue:ifFalse: works in Smalltalk:

Anyway, imagine that Java were an OO language and that if, therefore, were a method. There would be a potential problem (assuming the near universal eager evaluation of function arguments). Our imagined ObjectJava code might look like this:
if(condition, {doOneThing();}, {doAnotherThing();});
which kind-of suggests that both the one thing and the other would get done.
...
The syntax of our invented ObjectJava is pretty bad there, );}); isn't a thing of beauty, although it's not much worse than the way some real Java looks. The Smalltalk equivalent is much neater. Continuing with our janitorial example:
aDoor isAlarmed ifTrue: [self disarm: aDoor] ifFalse: [self openNormally: aDoor].

It doesn't look a lot different, but the fun is in the implementation (which is right there in the base libraries, not baked into the language syntax:


ifTrue: t ifFalse: f
  ^ t value

ifTrue: t ifFalse: f
  ^ f value

As Keith says, the beauty of that is this: the power involved in having that in the standard library is not closed off as a "language implementor only" feature - anyone can create code like that, and it ends up living at the same level as other library code. For instance, there's a method in the Collection library called #select:, which is used like this:

someCollection select: [:each | "each object that satisfies the condition here ends up in a new collection"].

That answers a new collection, where the members satisfy the boolean condition in the block. Want a new collection method that can be used against any collection? Just go ahead and add it to class Collection and boom - there it is, same level as #select:. No "helper" classes, no piles of code to get around the fact that it wasn't where it belonged. Going back to Keith's article:

Perhaps most astonishing about the Smalltalk approach is that Boolean values and selecting different actions based upon them is not part of the language. These are facilities provided by methods of classes in the Smalltalk standard library! This library (the "standard image") turns out to contain a large number of overlapping Embedded Domain Specific Languages--one of which, provided by the classes Boolean, True and False is specific to the domain of two-valued logic. That's a very remarkable thing. Most remarkable is what it says about the business of writing programs in Smalltalk.

There is no mechanism available to the Smalltalk programmer to create programs other than the creation of EDSLs

What that means is that the DSL tools that many vendors - like Microsoft - are pounding sand to create in languages like C# and Java - can be easily created in Smalltalk. Just ask Steve Kelly. Smalltalk isn't just another language - it's a level up, where you can set your amp to 11.

Read: The "Magic" of Smalltalk

Topic: A wise man once said Previous Topic   Next Topic Topic: Format Wars: Who Wins?

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use