links to this page:    
View this PageEdit this PageUploads to this PageHistory of this PageTop of the SwikiRecent ChangesSearch the SwikiHelp Guide
Hello World programs
Last updated at 8:10 pm UTC on 23 October 2019
This page gives several variants of how to write a 'hello world' program in Squeak. On a more general level one could think of different ways of informing the user. If you have additional ideas please post it here. – Ned Konz, Tue, 29 Jan 2002

How to write a hello world program in Squeak?

Take a look at Hello World program with StringHolder - details for useful code.

Scott Wallace some time later:
(StringMorph contents: 'hello world') openInHand

 (TextMorph new contents: 'hello world') openInHand

How about a button for it:

b := SimpleButtonMorph new.
b color: Color red. b label: 'Click Me'. b position: Display center.
b addMouseUpActionWith: 'self label: ''Hello World! Click me again!''. self addMouseUpActionWith: ''self delete'''.
b openInWorld.

Now to something fancier:

Text attribute stuff:

SoundPlayer stopReverb

Speaker manWithHead say: 'hello world'

Speaker woman say: 'hello world'

Diego Gomez Deck:

Ted Wright:
OSProcess thisOSProcess stdOut nextPutAll: 'Hello World'

Some code copied from the page "Workspace".
 Workspace new textContents: ('Hello World!!
 This is a test.
 ') withSqueakLineEndings; openLabel: 'Workspace test'

The above in a version which creates HTML output:
(StringHolder new textContents: (HtmlParser parse: '<html>hello <b>World!</b></html>') formattedText) openLabel: 'HTML output'.

Emilio Oca:

Alexandre Bergel, code put here by Hannes Hirzel

s := ServerDirectory new.
s type: #ftp.
s server: 'myServerId'.
s user: 'myUserName'.
s password: 'myPassWord'.
s directory: '/theFullPathOfMyHomeDirectory'.
s openFTP.
stream:=s fileNamed: 'helloWorld.txt'.
stream nextPutAll: 'hello world!'.
stream close.

s quit.

A variant which makes intensive use of TextMorphs and shows How to lay out submorphs:

 r := PasteUpMorph new.
 r color: Color blue twiceLighter twiceLighter twiceLighter.
 r position: 10@10.
 r extent: 170@100.
 r openInWorld.
 r layoutPolicy: TableLayout new. "lay out contents as a table"
 r listDirection: #leftToRight. "how we want to place the contents"
 r listCentering: #topLeft. "start list at the top"
 r wrapDirection: #topToBottom.
 r wrapCentering: #topLeft. 
 "r changeDragAndDrop."

 'Hello world! How are you doing?' do: [ :ch | 
 charTM := TextMorph new.
 charTM beAllFont: ((TextStyle default fontOfSize: 36) emphasized: 1).
 charTM contentsAsIs: ch asString.
 charTM color: Color random.
 r addMorphBack: charTM]. 

Markus Gaelli:

Scamper openOnUrl: 'http://www2.latech.edu/~acm/HelloWorld.shtml' asUrl

Alexandre Jasmin:
self inform: 'Hello, World!'.

Will display a PopUp with the text "Hello, World!". Click OK to dismiss it.