Language Features

Pure Smalltalk Semantics

Harding preserves the essence of Smalltalk:

  • Everything is an object - Numbers, strings, blocks, classes
  • Everything happens via message passing - No function calls, only messages
  • Late binding - Method lookup happens at message send time
  • Blocks with non-local returns - True closures with ^ return
Message Passing
3 + 4                    # binary message
obj size                 # unary message
dict at: key put: value  # keyword message

# Blocks with non-local return
findPositive := [:arr |
    arr do: [:n |
        (n > 0) ifTrue: [^ n]
    ].
    ^ nil
]

Modern Syntax

Optional periods, hash comments, double-quoted strings:

  • Newlines separate statements (periods optional)
  • Hash # for comments
  • Double quotes for strings
  • Clean, readable code
Modern Syntax
# This is a comment
x := 1                  # No period needed
y := 2
z := x + y              # But periods work too

"Double quotes for strings"

Class-Based with Multiple Inheritance

Create classes dynamically with slots and methods:

  • Dynamic class creation with derive:
  • Direct slot access for O(1) performance
  • Multiple inheritance with conflict detection
  • Qualified and unqualified super sends
Class Definition
# Create a new class with two instance variables
Point := Object derive: #(x y)

# Add methods
Point extend: [
    self >> x: anX y: aY [
        x := anX
        y := aY
    ]

    self >> moveBy: dx and: dy [
        x := x + dx
        y := y + dy
    ]

    self >> distanceFromOrigin [
        ^ ((x * x) + (y * y)) sqrt
    ]
]

# Use it
p := Point new
p x: 3 y: 4
p distanceFromOrigin println   # 5.0

Runtime Features

Green Threads

Cooperative multitasking with first-class Process objects:

worker := Processor fork: [
    1 to: 10 do: [:i |
        i println
        Processor yield
    ]
]

worker suspend
worker resume
worker terminate

Stackless VM

Each Process runs in its own stackless VM, enabling lightweight processes and a path to true parallelism.

Live REPL

Interactive development with immediate feedback:

$ harding
Harding REPL (:help for commands, :quit to exit)
harding> 3 + 4
7

> Point := Object derive: #(x y)
Point

> p := Point new
Point instance

> p x: 10
10

> p x
10

Collections

Rich Collection Library

Arrays, Tables, and all the classic Smalltalk collection methods:

  • Array - Ordered collection #(1 2 3)
  • Table - Dictionary #{"key" -> "value"}
  • Iteration - do:, collect:, select:
  • Reduction - inject:into:, detect:
Collections
# Array literal
numbers := #(1 2 3 4 5)

# Table literal
scores := #{"Alice" -> 95, "Bob" -> 87}

# Collection methods
numbers do: [:n | n println]
squares := numbers collect: [:n | n * n]
evens := numbers select: [:n | (n \ 2) = 0]
sum := numbers inject: 0 into: [:acc :n | acc + n]