Learn Io - 10 Code Examples & CST Typing Practice Test
Io is a small, prototype-based, object-oriented programming language designed for simplicity, concurrency, and rapid development of distributed applications. It emphasizes minimal syntax, message-passing, and highly dynamic objects.
Learn IO with Real Code Examples
Updated Nov 20, 2025
Code Sample Descriptions
Io Counter and Theme Toggle
count := 0
isDark := false
updateUI := method(
write("Counter: " .. count .. "\n")
write("Theme: " .. (if(isDark, "Dark", "Light")) .. "\n")
)
increment := method(
count = count + 1
updateUI()
)
decrement := method(
count = count - 1
updateUI()
)
reset := method(
count = 0
updateUI()
)
toggleTheme := method(
isDark = !isDark
updateUI()
)
# Simulate actions
updateUI()
increment()
increment()
toggleTheme()
decrement()
reset()
Demonstrates a simple counter with theme toggling using Io objects and message passing.
Io Fibonacci Sequence
a := 0
b := 1
write(a .. "\n")
write(b .. "\n")
for(i, 1, 8, do(
c := a + b
write(c .. "\n")
a := b
b := c
))
Generates the first 10 Fibonacci numbers.
Io Factorial Calculator
fact := method(n, if(n <= 0, 1, n * fact(n-1)))
write(fact(5) .. "\n")
Calculates factorial of a number recursively.
Io Prime Checker
isPrime := method(n, do(
if(n <= 1, return(false))
for(i, 2, n-1, if(n % i == 0, return(false)))
return(true)
))
write(if(isPrime(13), "Prime\n", "Not Prime\n"))
Checks if a number is prime.
Io Sum of List
lst := list(1,2,3,4,5)
sum := 0
foreach(x, lst, sum = sum + x)
write(sum .. "\n")
Calculates sum of a list of numbers.
Io Multiplication Table
n := 5
for(i, 1, 10, write(n .. " x " .. i .. " = " .. (n*i) .. "\n"))
Prints multiplication table of a number.
Io Celsius to Fahrenheit
c := 25
f := (c * 9 / 5) + 32
write(f .. "\n")
Converts Celsius to Fahrenheit.
Io Simple Alarm Simulation
temp := 80
thresh := 75
write(if(temp > thresh, "Alarm: Temperature Too High!", "Temperature Normal") .. "\n")
Simulates an alarm if a threshold is exceeded.
Io Random Walk Simulation
steps := 10
pos := 0
for(i,1,steps, do(
if(rand() < 0.5, pos = pos + 1, pos = pos - 1)
write(pos .. "\n")
))
Simulates a 1D random walk.
Frequently Asked Questions about Io
What is Io?
Io is a small, prototype-based, object-oriented programming language designed for simplicity, concurrency, and rapid development of distributed applications. It emphasizes minimal syntax, message-passing, and highly dynamic objects.
What are the primary use cases for Io?
Scripting and automation. Embedded system programming. Prototyping distributed applications. Rapid development of domain-specific languages. Concurrent and asynchronous programming
What are the strengths of Io?
Extremely lightweight and portable. Highly dynamic and flexible. Excellent for prototyping and experimentation. Concurrency support via coroutines. Easy to embed in other applications
What are the limitations of Io?
Small community and ecosystem. Limited libraries compared to mainstream languages. Not commonly used in enterprise production systems. Performance may lag for heavy computation. Steep learning curve for developers unfamiliar with prototype-based design
How can I practice Io typing speed?
CodeSpeedTest offers 10+ real Io code examples for typing practice. You can measure your WPM, track accuracy, and improve your coding speed with guided exercises.