Why Nomsu Exists

Bruce Hill


I’d like to present an explanation of some of the motivations and backstory behind Nomsu.

There’s a lot of programming languages in the world, including many that you’ve never heard of. You might wonder why someone would bother to make another language. I’m not under any illusions that Nomsu is strictly better than another language like Python, C, Lua, or Lisp. However, it is absolutely possible for a small language like Nomsu to be better than any other language for a specific use case. Nomsu’s specific use case is flexible natural language rule making.

The idea for Nomsu came from playing Nomic, a game that revolves around manipulating its own rules. I played Nomic with some friends in a group chat, and the initial rules were simply written down and voluntarily enforced by the players. As the game’s rules got more complicated, I wrote some simple chat commands to facilitate gameplay. For example, !end turn would end a player’s turn, and !give @person 5 points would give @person 5 points. It was a simple and user-friendly syntax, and it helped keep things running smoothly. However, it was very inflexible (e.g. you couldn’t say !give @person 2+3 points), and I had to manually keep the code in compliance with the rules every time they changed.

I liked the idea of the chat commands, but wanted them to be more sophisticated and include a way to let users modify and make new commands. The commands necessarily had to express complex ideas like “you can only end your turn if it is your turn” or “you need majority approval to make a change to the rules”. The original commands were implemented in Python, but I didn’t want to have user-friendly commands that just forced you to write a bunch of Python code. I needed the user-friendliness to extend to encompass more complex ideas, which meant making a full programming language. Thus, Nomsu came into existence.

With Nomsu, a user could define an action like:

(end my turn) means:
    if (it's your turn):
        (the active player) = (the player after $you)
        say "\(the active player), it's your turn now."

and use it by typing: end my turn. Or propose changes like:

    (spin the wheel) means:
        if (it's your turn):
            when (random from 1 to 3) is:
                    say "Fortune smiles upon you!"
                    give $you 10 points
                    say "Nothing happens."
                    say "Ouch! Bad luck."
                    give $you -10 points

The logic for propose, if it's your turn, and give $person $n points is written in Nomsu code. Because of Nomsu’s natural syntax, however, the meaning of the code should be a lot more obvious than similar code written in other programming languages:

function spin_the_wheel()
    if (ACTIVE_PLAYER == you) then
        local r = math.random(1, 3)
        if r == 1 then
            print("Fortune smiles upon you!")
            give_points(you, 10)
        elseif r == 2 then
            print("Nothing happens.")
            print("Ouch! Bad luck.")
            give_points(you, -10)

This is the heart of Nomsu: making it easy to write extremely readable code and modify the rules of a system.