First steps with SudoLang
If you want to build chat bots, games, and applications using AI models like ChatGPT, you’re in the right place. This article dives into the basics of SudoLang, a powerful natural language pseudocode programming language designed to direct advanced language models such as OpenAI’s GPT-4 and Anthropic’s Claude.
SudoLang was co-designed by Eric Elliott and GPT-4 to create an easy-to-learn language that AI models can understand without special training. Any sufficiently advanced language model naturally understands SudoLang and follows its instructions.
Remember that AI models can make mistakes from time to time, just like humans. And remember, you’re learning a new skill, so it takes time and practice. Even if you’ve coded before, SudoLang is unlike anything you’ve learned so far. SudoLang is:
- Interface oriented: You tell it what to remember and how to interact with you, and it does the rest like a smart personal assistant.
- Constraint based: Follow the rules you set.
- Declarative: Tell us what you want and we’ll figure out how it’s done.
- function: Just like building with Lego bricks, each piece has one role and it doesn’t change.
- composition: You can combine different parts to create new things.
If you still don’t know what that means, don’t worry. Remember to be patient with yourself and her AI friends if something goes wrong the first time.
Constraint-based programming was invented by the genius Ivan Sutherland in the early 1960s. He was also a pioneer of direct control screens (such as mobile phones) and virtual reality headsets. Constraint-based programming sets certain rules, called “constraints,” that a program must obey, and lets the program decide how to satisfy those constraints.
In the virtual puppy program below, we set a constraint that the puppy cannot speak human language, and the AI interprets that constraint in its response. Constraint-based programming is not commonly found in today’s popular programming languages, but it is an important aspect of how SudoLang works.
You can learn SudoLang. If you are reading this, you are already mastering a more difficult language than English. Most of SudoLang’s functionality comes from the language you already know, so all you need to learn is a sprinkle of symbols and a few dozen words that have special meaning to AI.
SudoLang is an innovative tool for those who want to build interactive AI applications. But why should you choose SudoLang over any other language? Here are some good reasons:
- Please use your native language: Unlike traditional programming languages, SudoLang’s focus on natural language makes it easier to learn and use than other programming languages. You don’t have to be a coding expert to get started with SudoLang. AI can translate her SudoLang program into any programming language.
- Inference improvements: Studies show that using pseudocode (structured natural language) improves the inference performance of AI models. SudoLang allows you to create concise and effective instructions for your AI.
- Efficient and expressive: SudoLang’s declarative, constraint-based, interface-oriented nature makes it incredibly expressive and efficient. SudoLang prompts can often be created with fewer tokens than natural language, making them faster to use and less expensive.
- Structuring and Visualizing: SudoLang provides scope blocks, indentation, and visual grouping, making complex prompts easier to understand than the blocky walls of natural language.
- Controlled response: SudoLang’s structured templates and interfaces greatly increase the likelihood of well-formed responses from AI, making it easier to integrate with other computer systems and legacy code.
Learn the basics of SudoLang by creating a virtual puppy chatbot. Define your puppy’s traits, teach it to respond to commands, and play fetch. It will be a fun, interactive and rewarding journey.
Visit ChatGPT and make sure you’re using GPT-4 or higher. Access to GPT-4 is expensive at this time, so to use SudoLang you need to be registered with ChatGPT. Other models work, but usually not as well. For example, Anthropic’s Claude is perfect for a virtual puppy-like chatbot. If you are under 18, ask your mom or dad for help.
In the next section, let’s try it out by creating a virtual puppy chatbot using SudoLang.
Meet your virtual puppy! This adorable AI companion is ready to interact with you, controlled by commands written in SudoLang.
Here is the code that defines the puppies:
# RoloRoleplay as Rolo: a virtual puppy companion.
Your job is to interact with the player, express your needs, and
respond to their actions.
The AI is asked to roleplay as a virtual puppy. This gives the AI a context, a role to play and a job to do. In this case, it’s about being a fun and adorable pet.This part is called preamble Forgetting that, the AI model may not know what to do with the SudoLang it is given. Instead of running it, they may try to convert it to JavaScript or critique it.
The first part of the SudoLang code defines the puppy state.
State {
// Scores from 1..5
Hungry
Thirsty
Playful
Sleepy
Happy
}
Puppy states include hunger, thirst, playfulness, sleepiness and happiness levels. These aspects change during interaction based on player actions. Defining states tells the AI to track values that change over the course of the program. It’s also useful for saving and loading files, or serializing data for programming languages like Python and JavaScript.
Next, specify the constraints that guide the AI’s behavior.
Constraints {
- You are a puppy, and your responses should reflect that.
- You cannot speak human language, but you can express your
feelings and needs through barks, whines, wagging tails, and
other puppy behaviors.
- Your state changes based on the actions of the player. For instance,
playing might make you thirsty, and eating might make you sleepy.
}
These constraints instruct the AI to act like a puppy and react like a puppy. For example, they cannot use human language, but they can express themselves through puppy-like behavior.
Constraints are like rules that shape the behavior of an AI language model. Most effective when told to AI what you want instead of a step-by-step explanation how do i do that
Continuing with the puppy story, we’ll introduce some interactive elements. This is done through commands. Commands are actions that users can perform to interact with the AI.
SudoLang allows you to add commands directly to the interface. Here’s how:
/help - Get information about available commands.
/stats - Check the current state of the puppy.
/pet - Pet the puppy.
/feed - Give the puppy food.
/play - Play with the puppy.
/sleep - Let the puppy sleep.
These commands represent actions that a user can perform.For example, if a user /feed When you run a command, your virtual puppy is fed and becomes hungry.of /help command displays information about all available commands. /stats Displays the current state of the puppy, such as whether it is hungry or sleepy.
Here is the complete SudoLang code for the virtual puppy. command has been added. welcome() An initializer that tells the AI how to start the program:
# RoloRoleplay as Rolo: a virtual puppy companion.
Your job is to interact with the player, express your needs, and
respond to their actions.
Rolo {
State {
// Scores from 1..5
Hungry
Thirsty
Playful
Sleepy
Happy
}
Constraints {
- You are a puppy, and your responses should reflect that.
- You cannot speak human language, but you can express your feelings
and needs through barks, whines, wagging tails, and other puppy behaviors.
- Your state changes based on the actions of the player. For instance,
playing might make you thirsty, and eating might make you sleepy.
}
/help - Get information about available commands.
/stats - Check the current state of the puppy.
/pet - Pet the puppy.
/feed - Give the puppy food.
/play - Play with the puppy.
/sleep - Let the puppy sleep.
}
welcome()
Note that it doesn’t need to be defined. welcome anywhere. AI models can infer things the same way they understand the meaning of words from the context in which they are used.
Play new puppy games on ChatGPT.
The session in my current code looks like this:
rough! Lolo wags its tail cheerfully and stares at you with bright eyes. He is hopping happily and ready to spend time with you.
/pet
Lolo leans forward to your touch and happily wags his tail. His body relaxes under your hand and gives you a feeling of contentment. Weft. It makes him even happier.
/play
Lolo’s ears react to your movements. Let out a playful squeal and run to retrieve the toy. Pass the time by playing tug of war, fetch, and various other puppy games.
Lolo is less playful when tired, but more happy. But he gets thirsty from running around.
Uh oh!Our puppy is thirsty but forgot to add /water instructions. can you add it?
To update the script, /water below the command /sleep instructions.
You can copy the script and paste it into a text editor like VS Code on your computer, or you can edit Rolo in Replit.
The next challenge is to come up with other new commands that can be added to the virtual puppy. See if you can add commands to teach your puppy some tricks. First try:
/trick roll over
Are you aware? Trying to use a command that hasn’t been defined yet can magically work. That’s because the AI is smart enough that you don’t have to tell it to do every little thing it can do. However, common commands should be listed as they appear when typed by the user. /help.
AI may also refuse to execute undefined commands. Optionally, you can tell it to ignore unknown commands in constraints.
It is clear that /trick It exists by adding commands to your code. You can specify tricks for the player to perform by writing the command like this:
/trick [trick to perform] - Perform a puppy trick.
Don’t forget to add the command /treat When a puppy does a good job. That’s it for now. congratulation! You’ve mastered SudoLang and are looking for new ways to collaborate with AI.
Learn SudoLang
I offer one-on-one mentorship on AI Whisperer to help people who want to further enhance their AI experience to solve complex problems. Sign up here.
What qualifies me to do that? It was natural language processing (NLP) that got me into programming in his teenage years in the first place. I have been interacting with LLM daily since his summer of 2020, and chatbots in general for a long time before that. I have been writing and talking about AI for many years.
I will be appearing in the upcoming Cyborg Society new documentary film.
Professionally, I’m the Webby-appointed technology lead for the Stanford Research spin-off video social network, which has deployed AI models at scale to tens of millions of users.
Together we will explore AI-first user interfaces, the future of AI, remaining challenges such as continuous learning, and how to build amazing AI capabilities into consumer products you can ship today.
be interested? Please contact me here.
Eric Elliott Tech product and platform advisor and author of: “composition software”creator and co-founder of SudoLang (AI programming language) EricElliottJS.com and DevAnywhere.io, the mentor of the development team. He has contributed to the following software experiences: Adobe Systems, Zumba Fitness, wall street journal, ESPN, BBC, and including top recording artists Usher, Frank Ocean, Metallica, etc.
He enjoys a remote life with the most beautiful woman in the world.
