DEV Community

Cover image for I Summoned COBOL to Ask If It’s Dead. It Was Offended.
Saima Aliya
Saima Aliya

Posted on

I Summoned COBOL to Ask If It’s Dead. It Was Offended.

Hacktoberfest Open-Source AI Challenge: Ghost in the Machine Submission 👻🌼

This is a submission for the Hacktoberfest Open-Source AI Challenge Week 4: Ghost in the Machine

What I Built

Every few years someone declares COBOL dead. This time I decided to ask it myself.

There are eight spirits, and none of them are polite about being forgotten:

  • COBOL SPEAKS IN UPPERCASE and is deeply offended that you think it's dead.
  • Fortran is a grizzled scientist who invented the compiler and has opinions about NumPy.
  • Pascal is a strict teacher who is disappointed in JavaScript.
  • Flash is a bitter millennial who still misses Newgrounds.
  • BASIC is the friendliest ghost alive and wants to talk about line numbers.
  • ALGOL, 6502 Assembly and Lisp round out the graveyard: an aristocrat, a monk who thinks in hex, and a zen philosopher who finds enlightenment in parentheses.

The first thing I typed to COBOL was "are you dead?" It said:

I AM COBOL. I PROCESS TRILLIONS OF DOLLARS DAILY. IT IS NOT "DEAD," UNDERSTAND? IT IS... ACTIVE. I AM HERE.

You can do more than chat. /translate makes a spirit rewrite your modern code in its own language, /teach gives you a lesson from the source, /roast has your code critiqued by someone who was there first, and /history gets you a real story from the language's past.

I took "Ghost in the Machine" literally. These languages are the ghosts in the machine: invisible, supposedly gone, and still running somewhere under everything.

Demo

Code

🕯️ The COBOL Séance

Summon the ghosts of dead (or "dead") programming languages and talk to them.

A terminal app where eight legacy languages come back as spirits with their own personalities, grudges and ways of speaking. It runs 100% locally with Ollama and Gemma 3 (4B). No cloud, no API keys, no internet needed once the model is downloaded.

YOU: are you dead?

COBOL: I AM COBOL. I PROCESS TRILLIONS OF DOLLARS DAILY. IT IS NOT "DEAD," UNDERSTAND? IT IS... ACTIVE. I AM HERE.

Demo

The Spirits

Spirit Personality
🏛️ COBOL Proud bureaucrat. SPEAKS IN UPPERCASE. Offended that you think it's dead.
⚡ Fortran Grizzled scientist who invented the compiler. Has opinions about NumPy.
🎩 ALGOL Aristocratic ancestor of everything. Wears a monocle.
🎓 Pascal Strict teacher with a ruler. Disappointed in JavaScript.
🎮 Flash Bitter millennial. Misses Newgrounds.
🧮 6502 Assembly Minimalist monk. Thinks in hex. Judges your
…

How I Built It

The core app is Python, Ollama and Gemma 3 (4B), running on CPU with no cloud and no API key. The libraries are Rich, Click, httpx and PyYAML.

Spirits are just YAML files. Each one holds a personality, a greeting, era context, a code style and translation rules. A registry auto-discovers them and supports aliases, so asm finds 6502 Assembly. Adding a ninth ghost means writing one file and no code.

Prompts are layered. A shared preamble sets the rules (never break character, be eerie, use real syntax, stay short), and a per-mode block changes behavior for chat, translate, teach, roast or history.

Replies stream. An async httpx client pulls tokens from Ollama, and a typewriter layer reveals them one character at a time. It pauses on punctuation, and now and then a character flickers into static and corrects itself.

Memory is a rolling window. The last 20 messages are kept, but the opening greeting is always preserved, so a small model keeps its personality without overflowing its context.

The spirits can talk (ElevenLabs)

/voice on sends each reply to ElevenLabs text-to-speech and plays it. It runs in a background thread so the typewriter never stalls. Before sending, the text is trimmed to about 350 characters, with code blocks and *stage directions* removed, so the ghost doesn't read out "asterisk static crackles asterisk" and the free tier lasts longer.

The gotcha: some ElevenLabs voices return a 402 on the free plan when called through the API. [FILL: describe what you ended up using, e.g. "I ended up with one premade voice for every spirit."] Voices are a simple dictionary in voice.py, so giving each spirit its own sound is a one-line change per ghost.

Tracing the ghosts (Sentry)

These spirits are agents with personalities, so I wanted to know what each reply costs. Every reply is a Sentry trace with the spirit, mode, model, time to first token, model generation time (typewriter delays excluded), an approximate token count (counted from streamed chunks) and any errors. Message text never leaves the machine, only timings and counts.

What I found: [FILL: your real numbers, e.g. "The first reply after launch took X seconds to start. Every later one started in about Y seconds. That gap is Ollama loading Gemma into memory."]

[FILL ONLY IF TRUE: what you changed because of it, e.g. "So the app now warms the model at startup." Delete this line if you didn't change anything.]

What didn't work

A 4B model has limits, and I'd rather tell you than hide them:

  • Style drift. COBOL's all-caps rule held in the greeting, then slipped in translate mode once the prompt got longer.
  • The translated code is flavor, not a compiler. My a + b test came back as COBOL with hardcoded values and a DISPLAY statement that isn't valid. It looks right and shouldn't be compiled.
  • The glitch effect leaks a few terminal escape codes before a spirit's name. I'm calling it haunting.

A bigger Gemma would likely fix the first two. That's the tradeoff of running on a laptop CPU.

Why Does Open Innovation Matter?

A closed API would have changed what this project is.

It cost nothing to run. Tuning a persona means sending the same prompt thirty times, and I did that late into the night without watching a bill.

The core is private. When you /roast your own code, it stays on your machine. Voice and tracing are opt-in extras, and I want to be clear about what they send: voice sends the spirit's reply text to ElevenLabs, and tracing sends timings only.

Anyone can add a ghost. The model is open-weight and the spirits are plain YAML, so someone can summon Perl or Delphi without asking permission. A project about keeping old technology alive felt right on top of something anyone can run, read and keep alive.

My Agent Session

I started with an AI coding agent (Antigravity), which generated the first version of the app: the structure, the spirits, the effects, the engine. Its files were written in about ten minutes, according to the folder timestamps. Then it hit its quota, and its shell was broken, so the code had never run once.

I picked it up there. I ran it, fixed the bugs, added the ElevenLabs voice and the Sentry tracing, and wrote this post, with help from Claude for the debugging. A ghost in the machine, built partly by one, and finished by hand when the agent ran out of breath.

The Spirit of It

The moment it landed for me was COBOL's answer. A 4-billion-parameter model on my laptop had just taken offense on behalf of a language from 1959.

These languages carry stories. COBOL and Fortran still turn up in banks, government systems and labs, BASIC taught a generation their first program, and Lisp keeps being rediscovered. (The "trillions of dollars" line is the model talking, so don't quote it as a statistic, but the point stands.) When we call something dead, we usually mean "I don't have to deal with it." The people who maintain these systems know better.

If this makes one person look up the real history of a language, or lets a beginner try BASIC without feeling intimidated, then the ghosts did their job.

Prize Categories

Best Use of Gemma: the whole app runs on Gemma 3 (4B) through Ollama, locally on CPU. Gemma is every spirit's voice, translator, teacher and critic, and the post covers what a 4B model handled well and where it struggled.

Best Use of ElevenLabs: spirits speak their replies through ElevenLabs text-to-speech. Voice is opt-in with /voice on, plays in a background thread, and trims and cleans the text so the free tier lasts.

Best Use of Sentry Agent Tracing: every spirit reply is a trace with time to first token, model time, approximate tokens and errors, with no message content sent. The findings are in the Sentry section above.

Top comments (0)