Skip to content

Latest commit

 

History

4 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 

Repository files navigation

nardjay.github.oi

🥔 SpudLang

A tiny joke programming language with its own editor, terminal, and interpreter — running entirely in your browser.

Made by DS & Jay

🔗 Try it live: nardjay.github.io


What is SpudLang?

SpudLang is a small, playful programming language inspired by Python, but with a potato-themed twist. It has its own syntax, its own interpreter, its own error messages, and a slick editor + terminal interface — all packed into a single HTML file with zero dependencies, zero build steps, and zero backend.

You write code in the left pane. You see output in the right pane. You press Ctrl + Enter and the potato does its thing.

It's not meant to replace Python. It's meant to make you smile while you learn how a programming language actually works under the hood.


✨ Features

  • Custom language — variables, conditionals, loops, functions, and a built-in standard library
  • In-browser interpreter — lexer, parser, and evaluator written from scratch in vanilla JavaScript
  • Live syntax highlighting — keywords, strings, numbers, comments, and built-ins get colored in real time
  • VS Code-style terminal — inline prompts, scrollback, colored output, and friendly errors
  • Auto-save — your code persists in the browser via localStorage, even after closing the tab
  • Zero dependencies — no npm, no build step, no framework. Just one HTML file.
  • Fully offline — once loaded, it works without an internet connection

🚀 How to Use

  1. Open the app in your browser
  2. Write some SpudLang code in the left pane
  3. Press Ctrl + Enter (or Cmd + Enter on Mac) to run it
  4. Watch the terminal respond in real time

Every program must end with the magic line:

run spud

That's the ignition switch. Without it, nothing cooks.


📖 Language Basics

Variables

Plant a variable with spud. Once planted, you can reassign it with just the name.

spud age = 25
age = 26
mash age

Variables declared inside a block { } stay inside that block. They don't leak out.

Printing & Input

mash prints. ask waits for the user to type something.

mash "Hello, potato!"
spud name = ask "What's your name? "
mash "Nice to meet you, " + name + "!"

ask always returns text, even if the user typed a number. Convert with num() when you need a real number.

Conditionals

ish age >= 18 {
    mash "You can vote."
} nope ish age >= 13 {
    mash "Teenager."
} nope {
    mash "Still a kid."
}

Loops

Two kinds of loops:

loop i from 1 to 5 {
    mash i
}

keep count < 10 {
    count = count + 1
}

Use peel to break out, and sprout to skip to the next iteration.

Recipes (Functions)

recipe add(a, b) {
    serve a + b
}

mash add(2, 3)

Recipes without serve return nada.


🥔 Values & Types

SpudLang is strict about types. You can't add a number to text without converting first.

Type Example
Number 42, 3.14, -7
Text "hello", 'hi'
Truth yep, nah
Nothing nada

Falsy values: nah, nada, 0, and "". Everything else is truthy.

Logic & Comparison

  • and, or, not
  • ==, !=, <, >, <=, >=

Important: 1 == "1" is false. Numbers and text are never equal.


🧰 Built-in Spuds

The standard library gives you a handful of handy functions out of the box:

Function What it does
len(text) Length of a string
scream(text) UPPERCASE
whisper(text) lowercase
abs(n) Absolute value
floor/ceil/round Rounding
sqrt(n) Square root
random(lo, hi) Random integer, inclusive
str(x) Convert to text
num(x) Convert to number
type(x) Description of a value
max / min Largest / smallest
repeat(text, n) Repeat text n times
potato() 🥔

🗂️ Cheat Sheet

The app has a built-in cheat sheet accessible via the 📖 Cheat sheet button. It covers every keyword, every rule, and every built-in function — perfect for when you forget the syntax.


🧪 Example: SpudBot

Here's a mini chatbot written entirely in SpudLang:

mash "🥔 SpudBot v0.1"

spud alive = yep
spud count = 0

recipe reply(user) {
    spud u = whisper(user)

    ish u == "hi" or u == "hello" {
        serve "Hey there! I'm SpudBot 🥔"
    }

    ish u == "joke" {
        serve "Why did the potato cross the road? It saw a fork!"
    }

    ish u == "count" {
        serve "You've sent me " + str(count) + " message(s)."
    }

    serve "I don't know that one. Try 'help'."
}

keep alive == yep {
    spud user = ask "you: "
    count = count + 1
    mash "SpudBot: " + reply(user)

    ish whisper(user) == "bye" {
        alive = nah
    }
}

run spud

Copy that into the editor, hit Ctrl + Enter, and chat with a potato.


🛠️ How It Works

SpudLang runs entirely in your browser using three classic interpreter stages:

  1. Tokenizer — scans the source text and turns it into a stream of tokens (keywords, numbers, strings, operators)
  2. Parser — reads those tokens and builds a syntax tree, checking grammar and structure
  3. Interpreter — walks the tree and executes each node, managing scopes and values as it goes

Everything is written in plain JavaScript inside a single HTML file. No frameworks, no bundlers, no dependencies. Just a script tag and a lot of enthusiasm.

Errors are displayed with line numbers, column markers, and a source snippet, so you can see exactly where things went wrong — like a real language.


📁 Project Structure

spudlang/
  index.html    <- the whole thing
  README.md     <- you're reading it

That's it. One file to run them all.


🌐 Hosting

SpudLang is hosted for free on GitHub Pages. Because it's a static HTML file, it works on any static host:

  • GitHub Pages
  • Cloudflare Pages
  • Netlify
  • Vercel
  • Or literally any web server

No backend required. No database. No monthly bill.


🚧 Roadmap

Things that would be fun to add:

  • Arrays and indexing (spud nums = [1, 2, 3])
  • A for each loop (loop x in nums { })
  • String methods (split, trim, contains)
  • A share-link button that encodes your code into the URL
  • Multiple files / tabs in the editor
  • More potato jokes in the error messages

🤝 Credits

Made with 🥔 by DS & Jay.

Built as a fun side project to explore how programming languages actually work — from tokenizing raw text to executing a syntax tree, all inside a single browser tab.

If you enjoyed it, tell a friend. If you broke it, open an issue. If you loved it, send us a potato.


📜 License

MIT — do whatever you want with it. Just don't blame us if your potato overheats. 🥔💨

Releases

Packages

Contributors

Languages