Show HN: I made an esoteric programming language that's read like a spellbook
github.com122 points by sirbread 16 hours ago
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/...
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. I recommend replacing "hi chat" in the test spell with "Mortal plane, I greet thee". If you really wanna scramble the language grammar, incorporate Enochian tables somehow: https://archive.org/details/JohnDeesFiveBooksOfMysterJosephH... 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... Put it in all caps and drop the definite articles, and you could almost convince people that it's COBOL. 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) “From the depths of the WEB in Castle Evans, I summon thee, oh car, oh cdr; may thine parentheses ever match!” 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… 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. 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. Reminds of Rockstar[1] and The Art of Code[2], a great talk by its creator. > essence 0 of through ritual amplify with power Should this not be "(essence of (0 through (ritual amplify with power)))? 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. 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". How do you call a library function from a spell? Like something from numpy. very silly indeed … to max out the silliness, you could implement this as a Raku grammar 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/... 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. > and you've got something potentially as big as Pokemon. Huh? Granted, anything is "potentially as big as Pokemon" but care to share why this project in particular makes you feel that way? It's a fun project, I'll give you that, but "programming as magic incantations" feels like a niche within a niche within a niche, which would make me believe it cannot ever be "as big as Pokemon". It doesn't need to be either, nothing wrong with fun projects made for fun. Before Cyberpunk became the darling that is has become, there was another sci-fi future with a few authors that imagined a virtual world with magic and sorcery being software, and software developers writing programs that read like incantations. That alternative view of a future chose to construct VR worlds in a medieval style simply because it all fit a theme of fantasy with magic (software.) That version, or school of sci-fi was active in the 70's; which is when I read some of it. It's rich, it's engaging; with good marketing that could all be reimagined. 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… > summon the result with essence of through ritual amplify with power This is not natural language. there may be some parts that read like really, really broken English like the one you just said, but for the most part I feel like it's okayishly readable. and again, this was just an end-of-the-week side project that I made because a random person in school gave me the idea to do so, so it won't be too polished :P 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. Can you please make your substantive comments without putting down others? If you know more than someone else does, that's great! Please do share some of what you know so the rest of us can learn. But don't put down the other person. That never helps, and it tarnishes your positive contribution in a way that is bad for the community. https://hn.algolia.com/?dateRange=all&page=0&prefix=true&sor... Abstraction is at the core of programming. I get your point — but obsessive adherence to baroque complexity has rarely been the M.O. of computer science in rational circles. More often, an elegant simplification that captures the essence has sufficed. That said, perhaps something like this would be more thematically appropriate: 'O Master of sublime name and great power, O Saturn: Cold, Sterile, Mournful, Pernicious; Sage and Solitary, Impenetrable and Sure; Thou who knowest no joy, bringest prosperity or ruin, deceivest wisely, judgest truly—
I conjure thee, Supreme Father, by thy bounty and ancient cunning, to do as I ask: print("hello world")' Absolutely incredible to see a snarky nit on a project like this. Hackernews never fails haha. I appreciate your intention, of course, but please don't respond by breaking the site guidelines yourself. It only makes things worse. Besides "Please don't sneer, including at the rest of the community." (https://news.ycombinator.com/newsguidelines.html), this guideline is relevant: "Please respond to the strongest plausible interpretation of what someone says, not a weaker one that's easier to criticize. Assume good faith." I doubt that egypturnash intended a "snarky nit". More likely this is someone who's passionate about the underlying topic (grimoires!), naturally got excited when seeing the OP, and then was disappointed when it didn't go as deep as someone with their level of knowledge would expect. It's bad, of course, to express that by putting down the OP or their work; much better to respond by sharing some of what one knows, as I explained at https://news.ycombinator.com/item?id=45561740. The project is a carricature of real world religions that are still active today. Where is the surprise that it raises ire? I was expecting to see Haskell.
titanomachy - 3 hours ago
diegoperini - 5 hours ago
CapricornNoble - 2 hours ago
rnhmjoj - 7 hours ago
pavlov - 4 hours ago
jedberg - 5 hours ago
amacbride - 3 hours ago
lokimedes - 8 hours ago
vunderba - 4 hours ago
nunobrito - 6 hours ago
fpsvogel - 10 hours ago
gavmor - 4 hours ago
reactordev - 7 hours ago
INTPenis - 2 hours ago
DarkContinent - 7 hours ago
librasteve - 8 hours ago
simpaticoder - 7 hours ago
bsenftner - 8 hours ago
CaptainOfCoit - 6 hours ago
bsenftner - 4 hours ago
sjclemmy - 8 hours ago
thaumasiotes - 9 hours ago
sirbread - 5 hours ago
egypturnash - 6 hours ago
dang - 34 minutes ago
poolhead45 - 2 hours ago
b_e_n_t_o_n - an hour ago
dang - 30 minutes ago
shakna - an hour ago
christophilus - 8 hours ago