XCODX |

Smalltalk Online Compiler & Interpreter

Select Language
Online Code Compiler
Full HTML IDE
Py main.py
Program Output Ready
  Welcome to XCODX Online Compiler

  Quick Start:
  Ctrl+Enter  Run code
  Ctrl+S      Save / Download
  Ctrl+L      Clear output

  Select a language and start coding.
Success
Operation completed

About Smalltalk

Smalltalk is the language that gave the world the term "object-oriented programming." It was created at Xerox PARC in the 1970s by Alan Kay's Learning Research Group, with Dan Ingalls and Adele Goldberg, and matured into the hugely influential Smalltalk-80. Its defining idea is radical uniformity: everything is an object, and every action is a message sent to an object, from arithmetic to control flow. The same research also pioneered the modern GUI, the mouse-driven desktop, and live programming, ideas that later shaped Objective-C, Ruby, and Java. On XCODX, Smalltalk runs as GNU Smalltalk (gst), a free, script-oriented implementation from the GNU project, rather than the live "image" you would use in Pharo or Squeak.

Hello World in Smalltalk

"Everything is an object; every action is a message send."
| name |
Transcript showCr: 'Your name?'.
name := stdin nextLine.
Transcript showCr: 'Hello, ', name, '!'.
(5 factorial) printNl.

When to use Smalltalk

Smalltalk is best understood as a way to learn and think in pure objects: because there are no primitive statements outside the object model, the message-passing style becomes unusually clear. It has also seen serious industrial use, notably in financial trading, insurance, and manufacturing systems, where live-image implementations such as VisualWorks and Pharo remain in production. In this sandbox it is a good place to try class definitions, blocks, and cascades on small exercises. It is not the live graphical environment Smalltalk is famous for, though; here it runs as a non-interactive script with a short time limit.

Common questions

Is Smalltalk still used today?

Yes, though it is niche. The open-source implementations Pharo and Squeak are actively developed, and commercial Smalltalks like VisualWorks and VA Smalltalk still run production systems in finance and logistics. This sandbox uses GNU Smalltalk, which is lighter and script-oriented rather than image-based.

How do I read input in GNU Smalltalk?

Send messages to the stdin stream object: 'stdin nextLine' returns the next line as a String, and 'stdin next' reads a single character. Type into the live terminal / Stdin Box. Because the program runs once and then exits, read what you need near the start.

Can I install Smalltalk packages or save an image?

No. The sandbox has no package manager, no network, and a fresh filesystem each run, so you cannot load external Squeak or Pharo packages or persist a running image. Everything must live in the single script you run, using the classes GNU Smalltalk ships with.

Why is everything written as 'object message'?

Smalltalk has almost no operators or keywords in the usual sense. '3 + 4' is the message '+ 4' sent to the object 3, and 'ifTrue:' is a message sent to a Boolean. This uniform message-send model is the core of the language and why the syntax looks unusual at first.

What is the difference between GNU Smalltalk and Pharo or Squeak?

Pharo and Squeak are live, image-based environments where your code and objects persist in a running world with a GUI. GNU Smalltalk is a more conventional command-line implementation that executes a source file, which is exactly what runs in this sandbox.

How do I print output?

Send display or print messages: 'Transcript showCr:' prints a string followed by a newline, while 'anObject printNl' prints an object's representation. Both write to standard output, which appears in the sandbox console.

How Smalltalk runs on XCODX

Sandbox filename
main.st
Entry point
single main source file
Editor grammar
text/x-stsrc
Reading stdin
stdin
Input delivery
live WebSocket stream
Prompt flushing
flush manually before reading input
Compile limit
10 s
Run limit
3 s batch · up to 3 min live
Memory
256 MB per stage
Max source
50,000 characters

Default program on this page

"Smalltalk Program"
Transcript show: 'Hello from Smalltalk!'; cr.
Transcript show: 'Welcome to XCODX Online Compiler!'; cr.

| numbers sum |
numbers := #(1 2 3 4 5).
sum := numbers inject: 0 into: [:a :b | a + b].
Transcript show: 'Sum of 1-5: ', sum printString; cr.