Smalltalk In A Nutshell

2,366 views
2,282 views

Published on

Published in: Technology, Education
0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total views
2,366
On SlideShare
0
From Embeds
0
Number of Embeds
18
Actions
Shares
0
Downloads
17
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

Smalltalk In A Nutshell

  1. 1. Smalltalk in a Nutshell Oscar Nierstrasz Software Composition Group scg.unibe.ch
  2. 2. Roadmap > Introduction > Demo > Exercises: > Everything happens by sending messages > Everything is an object > Scripting with control constructs > Objects are instances of classes > Creating your own classes > SOI 2008 sample problems > SOI Workshop © Oscar Nierstrasz 2
  3. 3. Programming is Modeling Programs = Algorithms + Data Programs = Objects + Messages © Oscar Nierstrasz 3
  4. 4. The origins of Smalltalk Alan Kay’s Dynabook project (1968) Alto — Xerox PARC (1973) © Oscar Nierstrasz 4
  5. 5. Object-oriented language genealogy © Oscar Nierstrasz 5
  6. 6. Smalltalk-80 and Squeak • Everything is an object • Everything is there, all the time • First windowing system with mouse • First graphical IDE Squeak: a modern, portable, fast, open- source Smalltalk © Oscar Nierstrasz 6
  7. 7. Squeak resources www.squeak.org www.seaside.st Downloads and links One-click image SqueakByExample.org Free download — Print-on-demand © Oscar Nierstrasz 7
  8. 8. Don’t panic! New Smalltalkers often think they need to understand all the details of a thing before they can use it. Try to answer the question “How does this work?” with “I don’t care”. —Alan Knight. Smalltalk Guru © Oscar Nierstrasz 8
  9. 9. Everything is an object Public interface Private data Everything happens by exchanging messages © Oscar Nierstrasz 9
  10. 10. Smalltalk architecture Image Virtual machine + + Changes Sources © Oscar Nierstrasz 10
  11. 11. Three-button mouse Operate Select Window © Oscar Nierstrasz 11
  12. 12. World Menu and Open Menu © Oscar Nierstrasz 12
  13. 13. Three kinds of messages > Unary messages 5 factorial Transcript cr > Binary messages 3 + 4 > Keyword messages 3 raisedTo: 10 modulo: 5 Transcript show: 'hello world' © Oscar Nierstrasz 13
  14. 14. Precedence First unary, then binary, then keyword: 2 raisedTo: 1 + 3 factorial 128 Use parentheses to force order: 1 + 2 * 3 9 (!) 1 + (2 * 3) 7 © Oscar Nierstrasz 14
  15. 15. A typical method in the class Point Method name Argument Comment <= aPoint quot;Answer whether the receiver is neither below nor to the right of aPoint.quot; ^ x <= aPoint x and: [y <= aPoint y] Return Binary message Block Instance variable Keyword message (2@3) <= (5@6) true © Oscar Nierstrasz 15
  16. 16. Statements and cascades Temporary variables Statement | p pen | p := 100@100. pen := Pen new. pen up. pen goto: p; down; goto: p+p Cascade © Oscar Nierstrasz 16
  17. 17. One-click download scg.unibe.ch/Teaching/ICUB © Oscar Nierstrasz 17
  18. 18. License > http://creativecommons.org/licenses/by-sa/3.0/ Attribution-ShareAlike 3.0 Unported You are free: to Share — to copy, distribute and transmit the work to Remix — to adapt the work Under the following conditions: Attribution. You must attribute the work in the manner specified by the author or licensor (but not in any way that suggests that they endorse you or your use of the work). Share Alike. If you alter, transform, or build upon this work, you may distribute the resulting work only under the same, similar or a compatible license. For any reuse or distribution, you must make clear to others the license terms of this work. The best way to do this is with a link to this web page. Any of the above conditions can be waived if you get permission from the copyright holder. Nothing in this license impairs or restricts the author's moral rights. © Oscar Nierstrasz 18

×