Chronos is one of the many Smalltalk-related blogs syndicated on Planet Smalltalk
χρόνος

Discussion of the Essence# programming language, and related issues and technologies.

Blog Timezone: America/Los_Angeles [Winter: -0800 hhmm | Summer: -0700 hhmm] 
Your local time:  

2007-09-23

Smalltalk: Getting The Message

[Updated URL; referenced document was relocated]

I have written a Smalltalk primer/tutorial. It takes a different approach than other programming language primers or tutorials I have seen on the web.

Firstly, it does not assume that the reader knows the syntax of any particular programming language, although it does assume that the reader either knows how to program, or at least that he is comfortable with the relevant mathematics and foundational concepts.

Secondly, it first explains the computational model of Smalltalk, before presenting any Smalltalk syntax.

Thirdly, it takes a bottom-up approach to the presentation of Smalltalk syntax, starting with lexical tokens and ending with method declarations.

Finally, it stresses the importance of messages above all else, and shows how and why those who have attempted to copy Smalltalk in other programming languages failed to "get the message."

Constructive criticism, suggested rewordings to improve clarity, and requests that additional information be included or that additional topics be covered, are encouraged. Such requests should be sent to the author, Alan L. Lovejoy, at the following e-mail address: smalltalk-tutorial (at) alan-lovejoy (dot) net.

Enjoy!




Smalltalk: Getting The Message
The Essentials of Message-Oriented Programming with Smalltalk


About Smalltalk

Smalltalk is a foundational programming language that is based on pervasive message passing, pervasive dynamic and strong typing, pervasive reflection and pervasive object orientation.


Message passing: Almost all computation in Smalltalk happens via the sending of messages. The only way to invoke a method is to send a message—which necessarily involves dynamic binding (by name) of message to method at runtime (and never at compile time.) The internals of an object are not externally accessible, ever—the only way to access or modify an object's internal state is to send it a message. So function and data abstraction are both complete and universal. Pervasive message passing is Smalltalk's most important feature—a point that was lost on most of those who have tried to emulate Smalltalk when designing other programming languages.

Dynamic and strong typing: Although any object can be assigned to any variable, the only way to access or modify the internal state of an object is to send it a message—and the sending of any invalid message is detected and prevented at run time. So, even though Smalltalk's pervasive use of dynamic typing enables the programmer to define highly polymorphic abstractions with an extremely high degree of applicability and reusability, it is impossible to apply a function to a value for which there is no valid, defined behavior.

Reflection: In most programming languages, the specifications of types, classes, functions and subroutines exist only in the source code, and so are not accessible at runtime. But in Smalltalk, all specifications of all program constructs (classes, methods, etc.) are live objects that exist both at compile time and at runtime—and those objects are fully accessible to a running program, and can be queried or modified by sending them messages. So a Smalltalk program can not only fully introspect on itself, it has full power to change itself.

Object-orientation: In Smalltalk, all values are objects—even integers and other numbers, characters, strings, classes and blocks of code. Smalltalk is one of the first object-oriented programming languages. Its design was influenced by Lisp, Logo, Sketchpad, Flex and Simula. Smalltalk was developed as a research project at Xerox PARC in the 1970s by a team whose members included Dr. Alan Kay, Dan Ingalls, Adele Goldberg, Ted Kaehler, Scott Wallace and others.

Warning: Terms such as "object," "class," "type," "method" and hence "object-oriented programming" itself, as used in the context of Smalltalk, do not have the same meanings as they do when used in the context of other programming languages. The term object-oriented programming ("OOP") was coined by Dr. Alan Kay, the inventor of Smalltalk. He intended the term to describe the essential nature of Smalltalk. Unlike Smalltalk, most of the programming languages that market themselves as "object oriented" do not satisfy Dr. Kay's definition of object oriented programming:

"OOP to me means only messaging, local retention and protection and hiding of state-process, and extreme late-binding of all things. It can be done in Smalltalk and in LISP. There are possibly other systems in which this is possible, but I'm not aware of them."

The full import of "object-oriented programming" as originally defined by Dr. Kay—and how and why the meaning of "OOP" as it applies to Smalltalk differs from the meaning of "OOP" as commonly understood outside of a Smalltalk context, is fully explained in the sections that follow. In addition, Dr. Kay's article "The Early History of Smalltalk" is highly recommended reading for anyone who wants to gain an even deeper insight into why and how Smalltalk came to be what it is, and why it is so different from the mainstream programming languages.

Continued...


2 comments:

Alan Lovejoy said...

Ramon Leon posted an entry to his blog about this primer/tutorial: http://onsmalltalk.com/programming/smalltalk/an-excellent-smalltalk-tutorial-by-alan-lovejoy/

Ramon's blog post also has some interesting discussion in its comments section.

Alan Lovejoy said...

You can vote on this article at dzone.com, reddit.com and digg.com:

dzone.com:
    http://www.dzone.com/links/smalltalk_getting_the_messagethe_essentials_of_me.html

reddit.com:
    http://programming.reddit.com/info/2sw3l/comments

digg.com:
    http://digg.com/programming/Smalltalk_Getting_The_Message