Smalltalk Primer Session Sudhakar Krishnamachari Cincom Systems Pvt

  • Slides: 22
Download presentation
Smalltalk Primer Session Sudhakar Krishnamachari Cincom Systems Pvt Ltd December 2004

Smalltalk Primer Session Sudhakar Krishnamachari Cincom Systems Pvt Ltd December 2004

Projects: Software or any other A Typical Scenario…. • Changing or undefined Customer requirements

Projects: Software or any other A Typical Scenario…. • Changing or undefined Customer requirements • Incomplete effort at Design stage • Not so perfect execution • Time overruns • Cost overruns • Customer dissatisfaction And so on…. Tools herein are only aids to experience, process and commitment What is Smalltalk…. ?

Session Contents: q Introduction to Smalltalk: upto Slide 16 q Ease of learning Smalltalk

Session Contents: q Introduction to Smalltalk: upto Slide 16 q Ease of learning Smalltalk and OOPS through Smalltalk q Delivering Value in Smalltalk: Slide 17 q Live demo with Smalltalk: 30 min q Concluding Note: 10 min. . q Q&A 1 hour… 5 min. . 15 min… 15 – 30 min

Smalltalk is a comprehensive tool box for the developers… q A Language q An

Smalltalk is a comprehensive tool box for the developers… q A Language q An IDE q Team Dev environment…version controlled code sharing automatically linked. . q Tool. Set for comprehensive app analysis: Time/ Space profiling… q Framework for various technologies…. name a few. . ? COM, . Net, CORBA, Web. Services 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

Introduction… Why the move into Smalltalk: Project time comparison: Skrish personal Past: Fortran, C,

Introduction… Why the move into Smalltalk: Project time comparison: Skrish personal Past: Fortran, C, C++, VC++ 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. .

Introduction cont’d… Smalltalk Presence: The biggest presence is the acceptance and emergence of Bytecode

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 Visual. Works usage… Other dialects/implementations Visual. Age, Visual. Works, Squeak, GNUSmalltalk, Dolphin/Smalltalk. MT, Object Studio, Smalltalk X, OOSVM etc….

Grammer of Programming Languages Show progression to Smalltalk…as realized by Alan Kay Binary 0/1

Grammer of Programming Languages Show progression to Smalltalk…as realized by Alan Kay Binary 0/1 s Assembly Sequential: COBOL Procedural: C / Basic Object Oriented * 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

Smalltalk, the first true OOPS language/environment: 1972 -80 The move is steadily to make

Smalltalk, the first true OOPS language/environment: 1972 -80 The move is steadily to make programming languages as easy as you and me talk. . . but powerful enough for the computer to understand. . you 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, a. Car is. Driven, Train runs. On rails Smalltalk function call on a class or Object: Aircraft from: ‘British. Airways’ flys. To: ’London’ at. Time: ‘ 230 AM’. simple isnt it… Others languages Java/ C++: Aircraft. aircraft. Flight. Details ( “British. Ariways’ , ‘London’ , ‘ 2. 30 AM’ ); 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…

What are Objects, Classes and Object Oriented Programming Objects: Real World Entities mapped as

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… an. Object: 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. an. Obj. Of. XYZ 01 CLASS XYZ DESCRIPTION OF LOCAL VARS VALUE OF CLASS VARS FUNC 01: ALL INSTRUCTIONS… FUNC 02: FUNC 03: So on…. . VALUES OF LOCAL an. Obj. Of. XYZ 02 VARS VAR 1, VAR 2, VAR 3 …. VALUES OF LOCAL an. Obj. Of. XYZ 03 VARS Ptr to Class XYZVAR 1, VAR 2, VAR 3 …. VALUES OF LOCAL VARS Ptr to Class XYZ VAR 1, VAR 2, VAR 3 …. Ptr to Class XYZ

CLASS XYZSuper DESCRIPTION OF Common LOCAL VARS VALUE OF Common CLASS VARS FUNC 01:

CLASS XYZSuper DESCRIPTION OF Common LOCAL VARS VALUE OF Common CLASS VARS FUNC 01: CLASS XYZSub 01 CLASS XYZSub 02 CLASS XYZSub 03 DESCRIPTION OF LOCAL VARS VALUE OF CLASS VARS FUNC 10: FUNC 11: FUNC 20: FUNC 21: FUNC 30: FUNC 31: 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…. !!. . .

History of Smalltalk Development 1. 2. 2. 3. 4. 5. Smalltalk Conceptualization from Simula,

History of Smalltalk Development 1. 2. 2. 3. 4. 5. Smalltalk Conceptualization from Simula, LISP and Ivan Sutherland’s paper 1968: Alan Kay at Xerox Smalltalk 72: Conceptual Smalltalk 76: Bytecode, VM, LISP features incl garbage collection etc. . 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 6. 7. 8. Philosophy of the Smalltalk Design: Dan Ingalls: “Keep it simple, keep it stupid” 5. 6. 7. 8. 9. 10. 11. 12. 13. 14. Carry over to Macintosh of window/GUI and then into “M$oft Windows”. . HP for distributed Smalltalk IBM for Visual. Age Xerox hives of to Parcplace Smalltalk or Visual. Works Digitalk Smalltalk that later merges with Visual. Works Squeak in Disney still maintained by Dan Ingalls and others. . 1999: Cincom takes over Visual. Works 2005: Visual. Works 7. 3 is the new workhorse… potentially competing with Java Websphere

Language/IDE Features of Smalltalk Everything is an object: No primitive data types or primitive

Language/IDE Features of Smalltalk Everything is an object: No primitive data types or primitive operations exposed to user 1. 2. 3. 3. 4. 5. 6. 7. 8. 9. 10. 11. 12. 13. 14. 15. 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 now. . as “Stiffly Typed” …] Language Syntax: A different syntax to code with, no curly braces, no function params in closed brackets, plain camel case instead of Hungarian notation… 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 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. 16. Support XP maxim of: “Make it run, make it fast and then make it right” 17. Code first, refactor later to get the design right in iterations and not in one “Waterfall” go…

Features of Smalltalk Framework as extended now: … 1. Enforces OOPS concept in programming

Features of Smalltalk Framework as extended now: … 1. Enforces OOPS concept in programming 2. Rapid application development (RAD) in team environment. 3. Total extensibility of the environment 4. Supports most of the new and old technologies including. Net, Web. Services, Sockets BSD. . etc 5. Dynamic compilation and debugging. . 6. Completely secure memory subsystem with a GC ( garbage collector) that is highly optimized 7. 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 Visual. Age. 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. .

Smalltalk Primer 01: Syntax Basics: Start from a function or method inside a Class

Smalltalk Primer 01: Syntax Basics: Start from a function or method inside a Class created… sample 01 “Comment: This is just to show some basic Smalltalk syntax" | sum a. Var 1 a. Var 2 a. Var 3 a. Set | sum : = 12 + 12. a. Var 1 : = ‘ This String. Num 1234 ‘ , ‘ concatenate it to‘, ‘ another Number: ‘. a. Var 2 : = a. Var 1 , sum print. String. a. Var 3 : = sum + a. Var 1 as. Number. a. Set : = Set new. a. Set add: sum; add: a. Var 1; add: a. Var 2; add: a. Var 3. ^a. Set 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. . Any. Namespace perform: #define. Class: superclass: indexed. Type: private: instance. Variable. Names: class. Instance. Variable. Names: imports: category: with. Arguments: (arg. Array) 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…

Visual. Works Smalltalk An application’s development platform: Virtual Image Virtual Engine Operating System Hardware

Visual. Works Smalltalk An application’s development platform: Virtual Image Virtual Engine Operating System Hardware Objects: Objects ( class) description Object header and data Object state (includes contexts as objects) • • Compiler Interpreter Memory handling aka memory reclamation Primitives • Numbered <primitive: 123> For user extensions use: • DLLCC <c: void func( int …)> new • Named <primitive: ‘a’ module: ‘b’> 03

Smalltalk IDE Primer 02: Multiple Windows IDE: Each window for each specific purpose: System

Smalltalk IDE Primer 02: Multiple Windows IDE: Each window for each specific purpose: System Transcript: The top or main window for accessing all functionality Workspace: A scratch text window to try snippets of code or execute or launch your program Browsers: A whole host of browsers for Code: creating class and methods; locating implementers senders, references of methods/vars Inspector: A powerful tool to inspect Classes, Objects : their object composition and values recursively Debugger: The most powerful debugger with the complete Smalltalk Stack for interactive edit and continue And lots more as you dig deeper… Basic Terms to remember: Parcels: Binary module stored as files ( collection of classes ) in Visual. Works Packages: Collection of classes stored in STORE in Visual. Works Application: Collection of classes stored in ENVY repository in Visualage Configuration Maps: Collection of Applications in Visual. Age ENVY: The version controlled source repository in Visual. Age ( STORE in Visual. Works) Image File: The file copy containing the classes and objects in the runtime memory. Gives OS independence running over an OS executable

Smalltalk Learning: How to Proceed ? : Language Primer: * Read and interactively run

Smalltalk Learning: How to Proceed ? : Language Primer: * Read and interactively run through Ivan Tomek’s “introduction” workspace in Visual. Works Non Commercial * Read through Reading. Smalltalk. pdf * To refresh everything once more read through App. Dev. Guide. pdf (VW) Chapter on “Syntax” and if need be “Object Orientation” Learn Basic Framework: Online guides in VW or Visual. Age… * Boolean: True and False class * Magnitude: Numbers, Characters, Date, Time * Collections: Sets, Ordered. Collections, 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. .

A Demo of Smalltalk. . Basic Visual. Works Demo: v The IDE and the

A Demo of Smalltalk. . Basic Visual. Works Demo: v The IDE and the various windows… v Creating window and manipulating the same v Example factorial, collection operations… v Debugger and inspector… v Refactoring Browser Modified Unified Visual. Works IDE Demo: v v v v 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 v Many others not touched upon…

Keyed up are you. . ? v v v Do you comprehend what Smalltalk

Keyed up are you. . ? v v v 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. . Time Learning to time taken: curve for Smalltalk to others. . Basic � Conceptual � � Advanced Expertise � Expert… (more absolute terms )

Next Steps v v v Step through Visual. Works or Visual. Age Smalltalk and

Next Steps v v v Step through Visual. Works or Visual. Age 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. .

Smalltalk: the right choice……. . So just do it…!!!

Smalltalk: the right choice……. . So just do it…!!!

 • Thanks for the patient hearing of the presentation. .

• Thanks for the patient hearing of the presentation. .