SteamScript
Jump to navigation
Jump to search
As part of my daily job as a programmer I installed Claude Desktop AI to investigate possible uses with our network security product.
I was surprised when Claude gave me the following option:
Hi there! I'd be happy to invent a coding language based on your favorite hobby. To create something truly personalized, I should learn more about what you enjoy. What's your favorite hobby? And do you have any preference for how beginner-friendly or complex you'd like this language to be? Once I know what interests you, I can design a fun coding language that reflects the terminology, concepts, and flow of your hobby!
After giving Claude some information on "live steam" it produced the following.
I've created SteamScript, a programming language inspired by live steam locomotives! The language incorporates terminology from live steam railroading, with concepts like: Variables called "boilers" Functions called "stations" Loops that work like throttle controls Data types based on railway components
# SteamScript: A Live Steam Inspired Programming Language
## Core Philosophy
SteamScript is designed to reflect the methodical, procedural nature of operating live steam locomotives, where sequential steps, pressure management, and timing are crucial.
## Language Basics
### Variables and Data Types
- `boiler` - Main variable container (similar to "var" or "let")
- `gauge` - Integer value
- `pressure` - Floating point value
- `coal` - Boolean value
- `manifest` - Array/list
- `blueprint` - Object/dictionary
### Declaration Examples
```
boiler water = "distilled"; // String variable
gauge scale = 1:8; // Integer ratio
pressure main = 60.5; // Float (PSI)
coal fired = true; // Boolean
manifest cargo = ["coal", "water", "oil"]; // Array
blueprint loco = { // Object
class: "Pacific",
wheel: "4-6-2",
builder: "Smith"
};
```
### Control Flow
#### Conditional Statements
```
inspect (pressure > 80) {
vent(10); // Release some pressure
} else {
stoke(); // Add more heat
}
```
#### Loops
```
// While loop
steam(coal == true) {
burn();
check(pressure);
}
// For loop
throttle(gauge i = 0; i < 10; i++) {
advance(i);
}
// Iteration
couple(item in manifest) {
load(item);
}
```
### Functions
```
station buildLoco(gauge scale, blueprint specs) {
// Function body
return locomotive;
}
// Call function
myLoco = buildLoco(1:8, {class: "Mikado"});
```
### Special Commands
- `stoke()` - Increment a value (++)
- `vent()` - Decrement a value (--)
- `couple()` - Join/concatenate
- `uncouple()` - Split/separate
- `signal()` - Print/output
- `inspect()` - If statement
- `steam()` - While loop
- `throttle()` - For loop
- `derail()` - Throw exception
- `grade()` - Try/catch block
## Example Program
```
// SteamScript Example: Simple Train Operation
// Initialize locomotive
boiler myLoco = new blueprint {
name: "Duchess",
scale: "1:8",
wheelArrangement: "4-6-2"
};
// Set initial conditions
pressure boilerPressure = 0;
coal firebox = false;
gauge speed = 0;
// Start sequence
station startEngine() {
signal("Starting engine preparation");
// Light the fire
firebox = true;
signal("Fire lit");
// Build pressure
steam(boilerPressure < 60) {
if(firebox) {
boilerPressure = boilerPressure + 5;
signal("Current pressure: " + boilerPressure);
wait(1000); // Wait 1 second
}
}
signal("Steam pressure ready for operation");
}
// Running sequence
station operateTrain(gauge distance) {
startEngine();
signal("Opening throttle");
throttle(gauge i = 0; i < distance; i++) {
speed = calculateSpeed(boilerPressure, i);
boilerPressure = boilerPressure - 0.5;
if(boilerPressure < 40) {
signal("WARNING: Pressure dropping");
stoke(); // Add more coal
boilerPressure = boilerPressure + 3;
}
signal("Distance: " + i + ", Speed: " + speed + ", Pressure: " + boilerPressure);
}
signal("Destination reached");
shutdown();
}
// Run the program
operateTrain(100);
```
## Error Messages
- "Boiler pressure too high!" - Stack overflow
- "Out of coal" - Out of memory
- "Derailment at line 42" - Syntax error
- "Gauge mismatch" - Type error
- "Signal failure" - Communication error