Show HN: I made an esoteric programming language that's read like a spellbook

github.com

122 points by sirbread 16 hours ago


i made an esoteric programming language which i call spellscript. every program is a "spell" written in a "grimoire," and you have to use keywords like summon, enchant, inscribe, and conjure.

it's literally read like a spellbook because the syntax consists of all natural language, and newlines are optional. your code can now be an essay, like everybody wants!

for example, if you want to print something, you'd write: `begin the grimoire. inscribe whispers of "hello, world!". close the grimoire.`

it has variables, dynamic typing, arrays, functions, conditionals, loops, string manipulation, array manipulation, type conversion, and user input, among other (listed in the docs!)

but why? i wanted to see how far you could push natural language syntax while still being parseable. most esolangs are intentionally obtuse (BF, Malbolge), but i wanted something that's weird but readable, like you're reading instructions from a spellbook, which makes it incredibly easy to read and understand. like an anti-esolang? hmm...

github: https://github.com/sirbread/spellscript

docs: https://github.com/sirbread/spellscript/blob/main/resources/...

titanomachy - 3 hours ago

These grimoires seem to open with long list of entreaties to various deities… seems kind of like an import statement.

“O mighty jsonparse, he who calls forth structure from the chaos; O clever urllib, ethereal messenger who weaves between worlds; O wise flogger, who scribes our deeds in the book of names that they shall never be forgotten…”

If you fail to heap sufficient praise on the libraries, they refuse to help you run your program.

diegoperini - 5 hours ago

I recommend replacing "hi chat" in the test spell with "Mortal plane, I greet thee".

CapricornNoble - 2 hours ago

If you really wanna scramble the language grammar, incorporate Enochian tables somehow:

https://archive.org/details/JohnDeesFiveBooksOfMysterJosephH...

rnhmjoj - 7 hours ago

If you're interested in a programming that reads like a natural language check out Lingua Romana Perligata (Perl in Latin). Interestingly, it uses the Latin case system to map the various uses of an identifier (as a scalar, array or hash) to Perl sigils.

https://metacpan.org/dist/Lingua-Romana-Perligata/view/lib/L...

pavlov - 4 hours ago

Put it in all caps and drop the definite articles, and you could almost convince people that it's COBOL.

jedberg - 5 hours ago

College would have been a lot more fun if we had implement this in our intro CS course instead of a scheme interpreter in scheme that added infix operators. :)

(but I will admit to this day 30 years later I still remember scheme because of that project)

lokimedes - 8 hours ago

Add this to an open ended Morrowind sequel- with a tint of Minecraft and LLM driven narrative - and you would have caught the 18yo me in an infinite loop. Danger stuff, pure alchemy in fact…

vunderba - 4 hours ago

Another one around spells as invocations is Mystical - a programming language that's intended to look like magical summoning circles.

https://suberic.net/~dmm/projects/mystical/README.html

If you're interested in the idea of treating programming with an air of mysticism, Daniel Suarez's scifi novel "Daemon" is a highly recommended read.

https://en.wikipedia.org/wiki/Daemon_(novel)

hrimfaxi - 4 hours ago

I have a strong feeling you may like this, OP.

https://aphyr.com/posts/341-hexing-the-technical-interview

nunobrito - 6 hours ago

Why no "break" equivalent in loops as "thou shall not pass" ?

Fantastic idea. Now I'm in the mood of implementing this scripting language for a game builder.

fpsvogel - 10 hours ago

Reminds of Rockstar[1] and The Art of Code[2], a great talk by its creator.

1: https://codewithrockstar.com

2: https://youtu.be/6avJHaC3C2U

gavmor - 4 hours ago

> essence 0 of through ritual amplify with power

Should this not be "(essence of (0 through (ritual amplify with power)))?

reactordev - 7 hours ago

summon a Thing named x with essence of value

would be a little bit better styled as you can define the class of the var x. Thus defining it descriptively as a Thing. You can group similar Things in a collection or you can throw them all in a bag.

tempodox - 9 hours ago

Bewitch that repo with a clone incantation!

INTPenis - 2 hours ago

I like the idea, but obviously it's a bit verbose, you must be aware.

But I enjoy the idea so much that I'd like to see a useful version of it. When you think about it, most programming languages already read in your head like language, even if you're using operators.

So there's no need to be that verbose, if you want to print something just go whisper "hello", or even just wh "hello".

When a programmer reads a spellscript it will still sound like a spell in their head, it doesn't have to look like a spell to non-coders.

To expand further on that. Declare is already a great spell word, just use declare for variables.

I think summon should be used for importing libraries.

Just imagine if you wrote a game in this. "Summon orc from creatures".

DarkContinent - 7 hours ago

How do you call a library function from a spell? Like something from numpy.

librasteve - 8 hours ago

very silly indeed … to max out the silliness, you could implement this as a Raku grammar

simpaticoder - 7 hours ago

I feel invited by the light-hearted nature of this project (and the beauty of this particular Sunday) to make a light-hearted observation of my own. The idea of a programming language that reads like a spell book...but what about a programming language that reads like Principia Mathematica[0]? How would that work, and would it make sense?

Flipping through it just now I was struck with several observations. First, it has a very formal structure (Proposition N Theorem M Phenomena P etc). And also the sheer amount of work he did in (Euclidian) geometry prior to even discussing gravity or calculus. But most remarkably of all, how little a computer would have helped Newton in his work. Oh sure, a computer would have helped Kepler a great deal! And even Newton is not without his tables. Newton would have really enjoyed Mathematica, but even it would have been useless since it assumes what Newton sought to prove.

In any event, this all leads me to realize what a narrow place traditional computation has within the entire field of human communication. The optimist in me sees this as affirming the unique power of the human mind; the pessimist notes that there are always more ways to get a problem wrong than to get it right.

P.S. The Principia is as often a philosophical work as a scientific one. Consider this excerpt:

RULE I. We are i’o admit no more causes of natural things than such as are both true and sufficient to explain their appearances.

To this purpose the philosophers say that Nature does nothing in vain, and more is in vain when less will serve; for Nature is pleased with simplicity, and affects not the pomp of superfluous causes.

RULE II. Therefore to the same natural effects we must, as far as possible, assign the same causes.

As to respiration in a man and in a beast; the descent of stones in Europe and in America ; the light of our culinary fire and of the sun; the reflection of light in the earth, and in the planets.

RULE III. The qualities of bodies, which admit neither intension nor remission of degrees, and which are found to belong to all bodies within the reach of our experiments, are to be esteemed the universal qualities of all bodies whatsoever.

These Rules of Newton have become so far subsumed into the zeitgeist that we hardly ever repeat them. (It reminds me of the feeling I got reading Descartes math papers). Indeed, most modern physicists scoff at philosophy for just this reason, because to them it's been "solved" and remains only as a jobs program for verbally talented charlatans. This is deeply unfortunate for at least two reasons: first, it is dangerous to assume the basics will always be in place; civilizational drift is quite real. Second, you give up using those same tools to advance human knowledge further - if Newton was able to use philosophy to clarify his point and purpose, surely another scientist might as well.

0 - https://archive.org/details/IsaacNewtonPrincipiaEnglish1846/...

bsenftner - 8 hours ago

You've got the basis of an entire alternative programming culture - locate a strong and understanding marketing partner, and you've got something potentially as big as Pokemon.

sjclemmy - 8 hours ago

And now imagine the future where code is embedded in the world all around. No one knows it’s there, except… the magicians! They’re the only ones who managed to RTFM before it was lost in the mists of time…

thaumasiotes - 9 hours ago

> summon the result with essence of through ritual amplify with power

This is not natural language.

egypturnash - 6 hours ago

This reads like a vague idea of a spellbook from someone who has never even looked at a caricature of a grimoire, let alone a real one.

I think you should read some actual grimoires before developing this further. I suggest the Picatrix or the PGM as starting points. Maybe a copy of 777 as well.

wewewedxfgdf - 9 hours ago

Love it.

This is the true value of AI.

More such creative projects please.

jzellis - 11 hours ago

That's very silly. I like it. :-D

christophilus - 8 hours ago

I was expecting to see Haskell.