smalltalk primer session

of 22 /22
Smalltalk Primer Session Sudhakar Krishnamachari Cincom Systems Pvt Ltd December 2004

Author: sugar

Post on 05-Feb-2016




1 download

Embed Size (px)


Smalltalk Primer Session. skrishnamachari: LFY article + slides print out Paper + pencil for notes taking Marker Feedback forms Try networking 2 systems. Sudhakar Krishnamachari Cincom Systems Pvt Ltd December 2004. Projects: Software or any other A Typical Scenario…. - PowerPoint PPT Presentation


Page 1: Smalltalk Primer Session

Smalltalk Primer Session

Sudhakar Krishnamachari

Cincom Systems Pvt Ltd

December 2004

Page 2: Smalltalk Primer Session

Projects: Software or any otherA Typical Scenario….

• Changing or undefinedCustomer requirements• Incomplete effort at Design stage• Not so perfect execution• Time overruns• Cost overruns• Customer dissatisfactionAnd so on….

Tools herein are only aids to experience, process and commitmentWhat is Smalltalk….?

Page 3: Smalltalk Primer Session

Introduction to Smalltalk: upto Slide 16 1 hour…

Ease of learning Smalltalk and OOPS through Smalltalk 5 min..

Delivering Value in Smalltalk: Slide 17 15 min…

Live demo with Smalltalk: 30 min

Concluding Note: 10 min..

Q&A 15 – 30 min

Session Contents:

Page 4: Smalltalk Primer Session

A Language


Team Dev environment…version controlled code sharing automatically linked..

ToolSet for comprehensive app analysis: Time/ Space profiling…

Framework for various technologies….name a few..? COM, .Net, CORBA, WebServices etc..

It always comes bundled, not just as a language in its various dialects…

A Whole new ( or the oldest ) paradigm…!!!

Above all the test bed for many of the CS concepts we hear today:

MVC, UI framework, XP Programming, Sunits, Design Patterns, Distributed Computing,

comprehensive uniting of garbage control, bytecode and VM based dev platform etc…

Article on Linux and Smalltalk applicable though for any OS

Smalltalk is a comprehensive tool box for the developers…

Page 5: Smalltalk Primer Session

Why the move into Smalltalk:

Project time comparison: C Project (xdelta) 12 weeks..

Java ( file system) 6 + 6 weeks..

Smalltalk (Pathfinder)

3 weeks…Session Objectives:• Smalltalk as a value proposition for a software development unit

(Learn all other languages/ dev platform and realize why smalltalk…!!)

• This is a two way interactive session…• Put Smalltalk in its right perspective..

Skrish personalPast: Fortran,C,

C++, VC++


Page 6: Smalltalk Primer Session

Introduction cont’d…

Smalltalk Presence: The biggest presence is the acceptance and emergence of Bytecode based, garbage controlled, OS/DBMS transparent, MVC based UI and Virtual Machine based language/ development platforms: Java or .Net…

Corporate: Was 17% of US market in mid 1990’s Academic: Small but significant in its love and ease in teaching OOPS Still strong in lots of co’s in the Insurance, Shipping, banking, manufacturing, trading, scientific sectors of programming..A Renewed interest and thrust this 2002 onwards…..• Telecom: > a billion $ project for British Telecom• Shipping: > 50% of world trade software runs on Smalltalk• Insurance: Many insurance companies have significant code in Smalltalk• Finance: Kapital from JP Morgan trades derivatives that other languages cannot…

Regional interests: Entire Deutsch Bahn, Swiss banks, manufacturing units run on Smalltalk. Significant Japanese interests in VisualWorks usage…

Other dialects/implementationsVisualAge, VisualWorks, Squeak, GNUSmalltalk, Dolphin/SmalltalkMT, Object

Studio, Smalltalk X, OOSVM etc….

Page 7: Smalltalk Primer Session

Show progression to Smalltalk…as realized by Alan Kay

* Starts with on-off gates in electronics to 0-1 in binary: all about raw computing.* Moves on to Assembly language of programming instructions

mov, mul, add, jump, sub, loop, etc...* The wakening of easier grammer: Basic and the predecessors

Read , Print, etc....* Move over to the procedural paradigm

function oriented Fortran and others...• C ....a system language finally... Smalltalk is born from:

• LISP: The string interpreter for languages...views everything as a collection of characters.. entities• Simula: The real world object syntax and as recursion on objects. First OOPS language•Ivan Sutherland’s paper on UI based, mouse controlled computing system

Real life is made of objects... and divisible into objects nearly ad-nauseum so is Smalltalk the language/ IDE modelled with Object hierarchy now adopted across all dev platforms

Binary 0/1 s Assembly Procedural: C / Basic Object OrientedSequential: COBOL

Grammer of Programming Languages

Page 8: Smalltalk Primer Session

The move is steadily to make programming languages as easy as you and me talk...but powerful enough for the computer to cannot be fuzzy as we are in real English and hope the computer to be using that as of now..

In English: as you would say: so would you in Smalltalk…!!..Object move, Ball thrown, aCar isDriven, Train runsOn rails

Smalltalk function call on a class or Object: Aircraft from: ‘BritishAirways’ flysTo:’London’ atTime: ‘230AM’ . simple isnt it…

Others languages Java/ C++:Aircraft.aircraftFlightDetails ( “BritishAriways’ , ‘London’ , ‘2.30AM’ );

Its all about nouns, adjectives, verbs.…a parallel captured in OOPS

Read and write in language you understand, in the manner you speak or write..And above all see it in UI not as passive set of code files…

Smalltalk, the first true OOPS language/environment: 1972-80

Page 9: Smalltalk Primer Session

What are Objects, Classes and Object Oriented Programming

Objects: Real World Entities mapped as programming construct computers can understand.

Classes: Collection of functions and the relevant local data for these functions. Extend from your knowledge of C: all functions declared are global, all data used from more than 2 functions ends being global So if say 4-10 functions are logically doing one unified functionality, and say 10 data variables are used by these functions. Combine these functions and data description: one logical unit in memory now called Class XYZ.: This is Encapsulation…

anObject: Instance of a Class ABC. Create a link to the class structure in memory, Initialize all values of the class local variables in this object’s allocated memory area. Invoke a function call on the object using these variable values. If you have 20 objects of the same class they will have 20 copies of their variable values but point to the same class memory area for execution of functions.






Ptr to Class XYZ



Ptr to Class XYZ



Ptr to Class XYZ

Page 10: Smalltalk Primer Session













Inheritance: Extract the common functions and data to a super class… Thus create a hierarchy of super, sub classes and sub-sub classes etc…There are other features that are simply further simplification or in a way optimizing the functionality of the language which are:

Polymorphism: Literal: “Multiple shapes visible of one entity” . In programming it implies a function name that is common within a class or in two class but has differrent code section to execute, but similar meaning in execution.Data Hiding: This is an automatic feature as variables are now within a class memory structure and only that class or its sub class can access it

One step further you can talk of Abstraction too.. Think further on:

Object Aggregation or Composition and Object Inheritance creating a pool of interacting Objects in memory to create a program….!!...

Page 11: Smalltalk Primer Session

1. Smalltalk Conceptualization from Simula, LISP and Ivan Sutherland’s paper 1968: Alan Kay at Xerox2. Smalltalk 72: Conceptual 3. Smalltalk 76: Bytecode, VM, LISP features incl garbage collection etc..4. Smalltalk 80: First formalized release of the Smalltalk specs, incl the PS VM, virtually all known core features of the language + basic IDE to program in

Philosophy of the Smalltalk Design:Dan Ingalls: “Keep it simple, keep it stupid”

5. Carry over to Macintosh of window/GUI and then into “M$oft Windows”..6. HP for distributed Smalltalk7. IBM for VisualAge8. Xerox hives of to Parcplace Smalltalk or VisualWorks9. Digitalk Smalltalk that later merges with VisualWorks10. Squeak in Disney still maintained by Dan Ingalls and others..11. 1999: Cincom takes over VisualWorks12. 2005: VisualWorks 7.3 is the new workhorse… potentially competing with Java Websphere

History of Smalltalk Development

Page 12: Smalltalk Primer Session

Everything is an object: No primitive data types or primitive operations exposed to user

1. It is a dynamically typed language: No instantiation of variable types at declaration Runtime assignment of type, thus variables can be of any type right through the program. [The future of all languages that exist “Stiffly Typed” …]2. Language Syntax: A different syntax to code with, no curly braces, no function params in closed brackets, plain camel case instead of Hungarian notation…3. IDE based live coding: The program is coded within the running application environment. That is no passive, file based coding to compile and then run cycle. “Develop an application while the application is running”. Code while Smalltalk is

running inside an IDE that has all user/framework classes visible. This in turn means: a. Incremental Compilation: Write 1 or n lines of code select and execute, the code code compiles , interprets the byte code and executes during this cycle automatically b. Visible Classes and Methods: No docs and MSDN to search for, all classes and methods are visible in browser. c. Persistence: All classes, methods, objects created persist in the image. Objects remain for interaction till they go out of scope/ released. So simply save the dev image in the state it is and come back later to continue thereof.. d. Executable: Strip the image of all dev classes and tools and the image now can run

of the OS specific engine in all platforms supported.

Support XP maxim of: “Make it run, make it fast and then make it right”Code first, refactor later to get the design right in iterations and not in one “Waterfall” go…

Language/IDE Features of Smalltalk

Page 13: Smalltalk Primer Session

1. Enforces OOPS concept in programming2. Rapid application development (RAD) in team environment.3. Total extensibility of the environment 4. Supports most of the new and old technologies including .Net,WebServices, Sockets BSD.. etc5. Dynamic compilation and debugging..6. Completely secure memory subsystem with a GC ( garbage collector) that is highly optimized7. Smallest footprint amongst any development platform of VC++, VB, etc.. as good as a C code once byte code is loaded and running.( This is true for Smalltalk X but nonetheless better than any other memory managed code )8. Special interfaces for web based programming, DBMS supports, networking protocols of TCP/IP, SMTP, SOAP, WML, XML

etc.9. Built in version control system Call it Store in VW and Envy in VA, it is far more stable and powerful than the VSS.10. The SUnits Testing Suite.11. The MVC paradigm originated in Smalltalk in 1980..!!..11. The new development model of Extreme Programming is rooted in Smalltalk, though adopted by others also now.13. The design patterns concept recommended for a highly extensible application development is propounded by the top guns in

Smalltalk.14. Eclipse is developed by developers from Smalltalk background OTI and VisualAge.15. Develop embedded code for any processor chip, as is done for Mercedes cars.16. Use Pocket Smalltalk to create the quickest and easiest programs for your palm and test it on its simulation test bed.And again lots more… that can be listed endlessly..

Features of Smalltalk Framework as extended now:…

Page 14: Smalltalk Primer Session

Syntax Basics: Start from a function or method inside a Class created…sample01

“Comment: This is just to show some basic Smalltalk syntax"| sum aVar1 aVar2 aVar3 aSet |sum := 12 + 12.

aVar1 := ‘ This StringNum 1234 ‘ , ‘ concatenate it to‘, ‘ another Number: ‘.aVar2 := aVar1 , sum printString.aVar3 := sum + aVar1 asNumber.aSet := Set new.aSet add: sum; add: aVar1; add: aVar2; add: aVar3.^aSet

Class creation: Is on the IDE directly by executing the stmt in its given area or even inside any user method too.. So dynamic Class creation for you if you wish..

AnyNamespace perform: #defineClass:superclass:indexedType:private:instanceVariableNames: classInstanceVariableNames:imports:category: withArguments: (argArray)

Now add methods to Class created in the same IDE browser…as quick as any fancy meta modelling tool with UML would help you do…

Smalltalk Primer 01:

Page 15: Smalltalk Primer Session

An application’s development platform: An application’s development platform:

Virtual ImageVirtual Image

Virtual EngineVirtual Engine

Operating SystemOperating System


Objects: Objects ( class) descriptionObjects: Objects ( class) description Object header and dataObject header and data Object stateObject state (includes contexts as objects) (includes contexts as objects)

•CompilerCompiler•InterpreterInterpreter•Memory handling aka memory reclamationMemory handling aka memory reclamation•PrimitivesPrimitives

•NumberedNumbered <primitive: 123> <primitive: 123>For user extensions use:For user extensions use:•DLLCC DLLCC <c: void func( int …)> <c: void func( int …)> new new •Named Named <primitive: ‘a’ module: ‘b’> <primitive: ‘a’ module: ‘b’>


VisualWorks Smalltalk

Page 16: Smalltalk Primer Session

Multiple Windows IDE:

Each window for each specific purpose:System Transcript: The top or main window for accessing all functionalityWorkspace: A scratch text window to try snippets of code or execute or launch your programBrowsers: A whole host of browsers for Code: creating class and methods; locating implementers senders, references of methods/varsInspector: A powerful tool to inspect Classes, Objects : their object composition and values recursivelyDebugger: The most powerful debugger with the complete Smalltalk Stack for interactive edit and continueAnd lots more as you dig deeper…

Basic Terms to remember:

Parcels: Binary module stored as files ( collection of classes ) in VisualWorksPackages: Collection of classes stored in STORE in VisualWorksApplication: Collection of classes stored in ENVY repository in VisualageConfiguration Maps: Collection of Applications in VisualAgeENVY: The version controlled source repository in VisualAge ( STORE in VisualWorks)Image File: The file copy containing the classes and objects in the runtime memory. Gives OS independence running over an OS executable

Smalltalk IDE Primer 02:

Page 17: Smalltalk Primer Session

Language Primer: * Read and interactively run through Ivan Tomek’s “introduction” workspace in VisualWorks Non Commercial * Read through ReadingSmalltalk.pdf * To refresh everything once more read through AppDevGuide.pdf (VW) Chapter on “Syntax” and if need be “Object Orientation”Learn Basic Framework: Online guides in VW or VisualAge… * Boolean: True and False class

* Magnitude: Numbers, Characters, Date, Time * Collections: Sets, OrderedCollections, Dictionaries etc… * Streams: Internal and External ( files)( Object Class, Behaviour and concepts of Metaclass is basic but can be touched upon much later…) * Processes and process management * Basic of GUI development * Vector/ Raster Graphics/ Fonts etc… * MVC and the inherent Controller framework… * Packaging and delivery..

External Frameworks : Source Code Control, DBMS access, web application server, web services, COM, CORBA, .Net access, Sunits, MQSeries, C dll access etc Advanced: * Reflective programming or Meta programming…. VM and the works..

Smalltalk Learning: How to Proceed ?:

Page 18: Smalltalk Primer Session

Modified Unified VisualWorks IDEDemo:

Basic Hello World UI Painter based GUI screen Vector Graphics/ Raster Graphics TCP-IP example Process fork/ control.. DBMS transparency COM connect DLLCC connect Web Application Web Services .Net DST Animation Graphics

Many others not touched upon…

A Demo of Smalltalk..

Basic VisualWorks Demo:

The IDE and the various windows…

Creating window and manipulating the same

Example factorial, collection operations…

Debugger and inspector… Refactoring Browser

Page 19: Smalltalk Primer Session

Keyed up are you..?

Do you comprehend what Smalltalk is all about…. Are you open to change.. A change for the better, more efficient, and easier computing paradigm…? You are enthusiastic, “no-compromise in my work” developer / team lead or project manager… Wish to concentrate on application logic and flow and not on language semantics…a la pointers…

in C..!! Curly braces, bracketed in a time warp of compile-run-debug cycle.. Wish to take up a technology which lets you ride productively right from day one … and lets you

take the learning curve at your pace…fast to kick off…

Then lets move ahead….

If not have a look at the products based on Smalltalk and mull over it…. As you work on other paradigms, it will make you do better in them for Smalltalk points to the future they are headed for anyways..


Learning to time taken: curve for Smalltalk to others..�Basic �Conceptual � Advanced Expertise � Expert… (more absolute terms )

Page 20: Smalltalk Primer Session

Next Steps Step through VisualWorks or VisualAge Smalltalk and its various components… Prototype one very real project ( mid sized ) important but not critical in Smalltalk Staff the project with keen and true Smalltalker’s trained with atleast one skilled mentor At the end of the project analyze its complete cycle to understand where the organization

benefits… Go ahead and use it from here onwards…benefit from the true RAD tool..

Page 21: Smalltalk Primer Session

Smalltalk: the right choice……..Smalltalk: the right choice……..

So just do it…!!!So just do it…!!!

Page 22: Smalltalk Primer Session

• Thanks for the patient hearing of the presentation..