
Smalltalk is an object-oriented language and environment, created for educational use.
In a Workspace, you can evaluate a selection and get the result with mouse2, and print it:
"Comment between double-quotes." | x y sum | x _ 4. y _ 16rF. sum _ x + y. 19 "Strings are within single-quotes" |pokemon| pokemon _ 'Drifloon' Drifloon "To print the time" Time now 6:49:44 pm
If you'd like to know more about a specific class:
Pen inspect.
Smalltalk uses the left-arrow notation to assign, which is inserted with _, the vertical-arrow is inserted with ^.
Conditional
| x | x _ 15. ( x > 10) ifTrue: ['True'] ifFalse: ['False'].
Loops
Open a new window to show the System Transcript.
| x | x _ 1. 10 timesRepeat: [ Transcript show: (x\\3) printString; cr. x _ x + 1. ]
Drawing
Fill the screen
Display white Display gray Display black
FizzBuzz
| i fizz buzz | i _ 1. 100 timesRepeat: [ fizz _ i\\3=0. buzz _ i\\5=0. (fizz) ifTrue: [Transcript show: 'Fizz']. (buzz) ifTrue: [Transcript show: 'Buzz']. (fizz | buzz) ifFalse: [Transcript show: i printString]. Transcript cr. i _ i + 1. ]
Emulation
To change the resolution of the window of the Smalltalk-80 emulator:
DisplayScreen displayExtent: 800@480.
The emulator below uses alt+left click for mouse3.
incoming: imperative uxn devlog 2023