SudoLang is a pseudolanguage designed for interacting with LLMs. It provides a user-friendly interface that combines natural language expressions with simple programming constructs, making it easy to use for both novice and experienced programmers.
SudoLang is designed to be understood by LLMs without requiring the spec prompt, which leaves you with all the tokens available for your SudoLang program.
Why?
Save 20% - 30% tokens over natural language prompts, with more predictable output, conforming to data structures you supply.
Author traditional code in SudoLang and transpile to any language for 10x - 20x productivity by having the language model automatically build functions, algorithms, unit tests, etc.
Main features:
- Literate markdown - freely mix documentation and code.
- Declarative, natural language constraint-based programming.
- Pattern matching with inferred patterns and destructuring
- Pipe operator
|>for function composition. - Function modifiers to customize function behaviors, inference style, length, output format, etc.
- Most operators you use in any popular programming language.
- Interfaces and loops with block scopes.
- Transpile to any language.
- Linter included in spec
- Unit tests with Riteway (see examples folder)
- Teach program in examples folder can teach you basic SudoLang concepts.
Constraint based programming in SudoLang
Simple natural language constraints can represent complex algorithms with little human readable text.
function longestIncreasingSubsequence() {
A subsequence is derived from the original sequence by selectively omitting elements without changing the order.
}
This also works for math axioms:
function pythagoreanTipple() {
if not supplied, generate random seeds
a^2 + b^2 = c^2
return [a, b, c]
}
(Warning: LLMs are not great at math, but it correctly infers the intent).
Define interfaces with the optional interface keyword, or omit it:
Foo {
bar // undefined
baz: "Default value"
Constraints {
// list constraints in natural language
// can be used to dynamically synchronize state, emit events, etc
when baz changes, increment bar and emit({ changed: baz, oldValue, newValue })
}
log() {
{ bar, baz } as json
}
}
Because it's an LLM, many functions can be automagically inferred. Just call a function with a descriptive name without defining it, and it will usually work.
