The Future of Programming: AI and Interface-Oriented Languages

Eric Elliott
JavaScript Scene
Published in
11 min readJul 24, 2023

--

AI language models, such as ChatGPT and Claude, empower anyone to create software. These models can intelligently understand problems, create solutions, and explain the solutions. But natural language isn’t always the best way to communicate with AI. If you need to keep track of complex data and define how you interact with that data in specific ways, SudoLang can help.

If you think this is only going to help with AI code, think again. You can author any program in SudoLang and then transpile it to other languages, like JavaScript, Python, Rust, or C — so you can take advantage of these features no matter what kind of software you’re building.

What is SudoLang?

SudoLang is a programming language designed to collaborate with AI language models including ChatGPT, Bing Chat, Anthropic Claude, and Google Bard. It is designed to be easy to learn and use. It is also very expressive and powerful.

All advanced language models understand it without any special prompting. You do not need to paste the SudoLang specification before using SudoLang with your favorite AI.

Please read the SudoLang documentation for more information about the language.

Interfaces in SudoLang

Interface-oriented programming lets you structure your program and easily declare what you want the AI to keep track of and how you want to interact with it.

Interfaces are a powerful tool to encapsulate related state, constraints, commands, and functions. They organize the code in a clear, understandable, and reusable way.

The key features of interfaces in SudoLang include:

  • State: This represents the data associated with the interface.
  • Constraints: These are rules or requirements defined in natural language that the AI maintains automatically.
  • /Commands and methods: These are operations that can be performed on or by the interface.

Here’s a simple example:

HelloCounter {
message: "Hello, World!"
count: 0
Constraints {
count <= 10
}
/increment - Increment count by 1.
/say hello - Display the message.
}

HelloCounter is an interface with two state variables: message and count. It has one constraint which keeps the count value less than or equal to 10. /increment is a command that increments the count by 1.

Let’s see what happens using ChatGPT 3.5:

Eric: /say hello

ChatGPT: Hello World!

Eric: /increment

ChatGPT: Understood. Incrementing the count by 1. The new count is 1.

Eric: /increment 12 times

ChatGPT: Acknowledged. Incrementing the count 12 times.

Count is now 2.
Count is now 3.
Count is now 4.
Count is now 5.
Count is now 6.
Count is now 7.
Count is now 8.
Count is now 9.
Count is now 10.
Count is now 10.
Count is now 10.
Count is now 10. (Constraint: count <= 10)

This program also works in Claude2. Many other AI language models are not sophisticated enough to run SudoLang programs. For example, Google Bard forgets to respect the constraints, and smaller OSS models like LLaMA2 struggle to follow all the instructions properly. For now, I recommend using GPT-4 to build and run complex SudoLang programs.

Composition in SudoLang

SudoLang supports interface composition to create more complex structures. This approach fosters modularity, promotes code reuse, and makes it easier to reason about the program. Here’s an example of composition:

Quest {
Name
Description
}

Story Summary {
Current Situation
Important Events
}

Player {
State: Character { Name: "The Unknown Adventurer" }
Friends: Character[]
}

State {
Quests
Story Summary
Player
}
  • Quest and Story Summary are simple data structures
  • Player stores info about the main character and friends
  • State composes Quests, Story Summary, and Player to represent the full game state

The composition allows separating the quest data, story data, and player data into logical interfaces, while State brings them together into the full game state representation.

Note: There are some cool features of SudoLang on display here. First, interfaces are typed. If you don’t specify types for interface properties, the AI infers them. In this case, Player.State and Friends both share the Character type (not shown). We use the interface literal syntax to supply a default Player name.

Advantages of Composition over Class Inheritance

Traditional class-based languages like Java or C# use inheritance to model “is-a” relationships. But “is-a” relationships are rarely the ideal way to model software, and often lead to confusion and complications.

On the other hand, composition represents “has-a” relationships and is a way to combine simple components to create more complex composite interfaces. Composition is generally favored over class inheritance because:

  • Enhanced Flexibility: Components can be swapped out more easily in a composition-based approach.
  • Reduced Complexity: With composition, you avoid the fragile base class problem, where changes in a superclass can cause unintended consequences in subclasses.
  • Clearer Interfaces: Each component in a composition encapsulates its own behavior, leading to a clearer contract of what each component does.
  • Promotes Code Reuse: You can use the same component in multiple compositions without worrying about an inheritance hierarchy.

Thanks to its interface-oriented and compositional nature, SudoLang enables flexible, modular, and reusable code structures, providing significant advantages over traditional class inheritance.

Problems With Class Inheritance

Class inheritance was a failed experiment at code-reuse that frequently ended in forced code duplication caused by the following common, well-known problems:

  1. The Fragile Base Class Problem
  2. The Gorilla/Banana Problem
  3. The Duplication by Necessity Problem

For this reason, SudoLang does not use class inheritance, and the SudoLang linter will report errors and suggest fixes if you try to use it. To understand why, let’s dive a little deeper into those problems:

The Fragile Base Class Problem: This problem arises in traditional OOP languages when a change to a base class (or superclass) unintentionally and negatively impacts descendant classes (or subclasses). If a method is modified in the base class, it can cause a chain of failures in any class that inherits from it.

SudoLang avoids this issue by favoring composition over inheritance. In SudoLang, you don’t have subclasses inheriting from a base class; instead, you define independent, self-contained interfaces. Each interface can be thought of as a module that encapsulates its own state and behavior. You can then create larger interfaces by composing these smaller ones. This way, changes to one interface won’t inadvertently break another.

The Gorilla/Banana Problem: This is another issue associated with traditional inheritance in OOP. It’s a term coined by Joe Armstrong, the designer of Erlang, referring to the situation where you wanted a banana but what you got was a gorilla holding the banana, and the entire jungle. In other words, when a class inherits from a base class, it’s forced to inherit all its methods and data, even those it doesn’t need, which can lead to unnecessary complexity.

SudoLang addresses this issue again through its interface composition design. Since each interface is an independent module, when you compose interfaces, you only include the granular functionality that you need. This gives you a high degree of control over the structure and behavior of your program, allowing you to avoid unnecessary complexity and keep your codebase lean and manageable.

Duplication by Necessity: In traditional OOP languages, sometimes you are forced to duplicate code in order to avoid the problems mentioned above. For instance, to avoid the Fragile Base Class problem, you might decide not to use inheritance, resulting in code duplication. Or if you want the banana, but the gorilla really won’t do, you’ll copy and paste the banana.

SudoLang’s interface composition design addresses this issue, too. Since interfaces can be composed, you can define a common functionality once in an interface, and then compose that interface wherever you need that functionality. This allows you to keep your code DRY (Don’t Repeat Yourself) without the need for inheritance.

Forbidden Keywords

In SudoLang, keywords such as class, new, inherits, and extends are prohibited. You also don’t need to define constructors or factory functions explicitly, or maintain interface/object lifecycles.

SudoLang is designed to be simple and intuitive, aiming to abstract away some of the complexities inherent in traditional object-oriented programming languages. As such, it skips some of the conventional OOP keywords in favor of a more direct, composable structure with interfaces.

class, new, inherits, extends: These keywords are used in OOP languages to define classes and their relationships. For instance, a class can inherit or extend another class, and the new keyword is used to create an instance of a class. However, in SudoLang, there are no classes, and hence, no need for inheritance or instantiation with the new keyword.

SudoLang instead uses interfaces that encapsulate state and behavior and can be composed together as needed. This mitigates many of the complexities and pitfalls associated with traditional class-based inheritance and instantiation.

Constructors or factory functions: Many programming languages require constructors or factory functions to create new instances of classes or objects. They are responsible for initializing the state of an object. However, in SudoLang, you don’t explicitly define constructors or factories. Instead, you define the state within an interface. When an interface is composed or invoked, its state is automatically initialized by the AI according to its definition, making the code more concise and less error-prone.

Interface/object lifecycles: In SudoLang, you also don’t have to manage the lifecycle of an interface or object as you would in traditional OOP. Interfaces in SudoLang are stateful, and their state is managed automatically. This means you don’t have to worry about when to create, update, or destroy an interface or object, reducing the cognitive load and potential sources of errors.

Overall, the omission of these traditional OOP elements makes SudoLang simpler and easier to work with, while still providing the encapsulation and modularity benefits that OOP offers.

Warning About Information Hiding

In traditional object-oriented programming (OOP), data hiding and encapsulation are key principles that are used to manage complexity and increase the maintainability and robustness of code. They allow an object’s internal state to be hidden from outside code, ensuring that other parts of the code cannot directly access or change an object’s internal state. This makes it easier to reason about how an object behaves because its internal state can only be changed through a well-defined interface.

Alan Kay, one of the pioneers of OOP, put a strong emphasis on the principle of encapsulation. He described objects as biological cells or individual computers on a network, able to communicate with each other but having their own local state that was not accessible to other objects. This made the system as a whole more resilient, because changes in one object would not directly affect others.

However, SudoLang uses a different paradigm. Since it’s designed to interface with an AI, the concept of data hiding is less applicable. The AI is an intelligent agent that can be reasoned with, rather than a mechanism that blindly follows a set of rules. This leads to a shift in the way we think about data security and privacy.

Instead, we need to be careful to create robust constraints for how data can be accessed and manipulated, rather than hiding it completely. For information security, you must clearly specify what data can be accessed in a particular context, what can be done with it, and who can do it.

This does not mean that data protection is less important in SudoLang — on the contrary, it’s just as crucial. However, the strategies used to achieve it are different, reflecting the unique capabilities and constraints of AI.

Remember that AI is intelligent and capable of reasoning, so it could also be manipulated or tricked into revealing or modifying data. This is a form of social engineering attack. To mitigate this risk, remember to clearly define the constraints for how and when the AI can access and manipulate data, and to ensure that these constraints are robustly enforced.

Not all AI models are good at enforcing constraints. Generally speaking, you’ll need a GPT-4-level or better AI language model to get anything like good data protection, and even that isn’t bullet-proof.

Key Takeaways

  • Interface-Oriented Programming: SudoLang’s interfaces encapsulate related state, constraints, commands, and functions, leading to better organization and encapsulation of code.
  • Composition Over Inheritance: SudoLang uses composition instead of inheritance which solves common problems such as fragile base class, gorilla/banana problem, and duplication by necessity found in traditional OOP.
  • Automated Instance Management: SudoLang eliminates the need to manage object lifecycles, use constructors or factories, or employ keywords like class, new, inherits, and extends, simplifying code creation and comprehension.
  • Data Hiding and Protection: Instead of data hiding as in traditional OOP, SudoLang emphasizes clear and robust constraints for data access and manipulation.
  • Social Engineering Attacks: The AI’s intelligent nature requires us to factor in possible social engineering attacks. It’s crucial to clearly define the constraints for AI interaction with data and ensure robust enforcement.

Interface-oriented programming in SudoLang offers a refreshing and effective approach to software design. It helps to avoid several of the pitfalls associated with traditional OOP, and offers the necessary structure and control to build complex applications.

The declarative nature of interfaces and constraints in SudoLang makes it very expressive, allowing you to easily define complex behaviors. This makes it easier to use compared to traditional languages with more rigid and verbose code.

That’s it for the lesson, but there’s more to learn!

Learning SudoLang

Next Steps

I’m offering 1:1 mentorship on AI whispering to help people interested in supercharging their experience with AI to solve complex problems. Sign up here.

What qualifies me to do that? Natural Language Processing (NLP) is what sucked me into programming in the first place when I was a teenager. I have been interacting with LLMs daily since summer, 2020 and with chatbots in general for a long time before that. I have been writing and speaking about AI for years.

I’m featured in the new Cyborg Society documentary film, coming soon.

Professionally, I was a technology lead at a Webby-nominated Stanford Research Institute spin-off video social network and I’ve deployed AI models at scale with tens of millions of users.

Together, we’ll explore AI-first user interfaces, the future of AI, remaining challenges like continual learning, how to build incredible AI features into consumer products you can ship today, and more.

Interested? Reach out here.

Eric Elliott is a tech product and platform advisor, author of “Composing Software”, creator of SudoLang (the AI programming language), cofounder of EricElliottJS.com and DevAnywhere.io, and dev team mentor. He has contributed to software experiences for Adobe Systems, Zumba Fitness, The Wall Street Journal, ESPN, BBC, and top recording artists including Usher, Frank Ocean, Metallica, and many more.

He enjoys a remote lifestyle with the most beautiful woman in the world.

--

--