Autolang
Show HN: A lightweight compiler for untrusted AI Agent scripts
Last verified:
What is Autolang?
Autolang is a scripting language and virtual machine designed specifically for AI agents to write code safely, quickly, and at low cost while reusing existing functions. It acts as an orchestration layer that sits on top of or alongside general-purpose languages like Python, JavaScript, and C++, allowing developers to wrap existing functions into a unified, safe, and controlled execution environment. The AI writes high-level logic in Autolang, which is then verified, restricted, and validated by a static compiler before execution through registered bindings.
Key features include a static compiler that validates types and scope, strict opcode execution limits to prevent infinite loops, explicit per-library control over nullable types, Kotlin-inspired syntax with TypeScript-like data structures, and the ability to wrap functions from npm, C++, or any other ecosystem as bindings. Autolang executes roughly 900 lines of code in ~25ms on Windows 11 with a 12th-gen i5, with RAM usage of approximately 5.1MB per compiler instance and cold start of ~18ms on a warm system.
Autolang is for developers building systems where LLMs generate and execute code at runtime and need to control what the AI can access. It is ideal for running many concurrent AI agents where RAM overhead of full runtime isolation becomes a cost problem, for exposing existing JS or C++ functions to AI in a controlled way without rewriting them, and for AI-generated scripts that are short (under ~100 lines) and run frequently. It is not meant to replace Python or JavaScript but to serve as a management layer between AI and the execution environment.
Autolang pricing
Pricing model: Freemium
Autolang is available as an open-source tool with npm install autolang-compiler. The GitHub repository is publicly accessible at github.com/hoansdz/Autolang. There is no mention of paid plans or subscription tiers on the website - it appears to be freely available for use.
Autolang pros
- Safe execution environment where AI can only call explicitly registered functions
- Static compiler validates types and scope before execution
- Strict maximum opcode execution limit prevents infinite loops
- Ultra-low latency with ~25ms execution for 900 lines of code
- Minimal RAM usage at approximately 5.1MB per compiler instance
- Fast cold start of ~18ms on warm systems
- Reuses existing functions from Python, JavaScript, C++ without rewriting
- Explicit nullable type handling prevents null pointer crashes
- Kotlin-inspired syntax that AI models already recognize
- Type-safe code enforced through static analysis
- Tight control over which libraries AI-generated code can access
- Optimized for short AI code snippets under 100 lines
- Total time optimization balancing compile time and runtime
- Language-level sandbox without heavy virtualization overhead
- Clear separation: AI dictates what, system handles how
Autolang cons
- Python bindings not available yet
- Not designed for long, complex programs or large applications
- Does not replace OS-level process isolation for security
- Only suitable when running 5+ concurrent agents for tradeoff to make sense
- First-run times on Windows may be higher due to OS-level file scanning
- Limited to short scripts under approximately 100 lines
- Does not compete with Python or JavaScript on every front
- Requires wrapping existing functions as bindings before AI can use them
Frequently asked questions about Autolang
What is Autolang and what problem does it solve?
Autolang is a scripting language designed for AI to write code safely, quickly, and at low cost while reusing existing functions. It solves the problem that general-purpose languages like Python and JavaScript are too broad and risky for AI agents, allowing them to read, write, delete files, make network calls, and perform unintended actions. Autolang acts as a management layer where AI can only call functions you explicitly registered, with nothing else accessible.
How does Autolang ensure safety for AI-generated code?
Autolang ensures safety through multiple mechanisms: a static compiler that validates types and scope, a strict maximum opcode execution limit that immediately terminates scripts exceeding the threshold without crashing the host process, explicit per-library control over nullable types forcing AI-generated code to adhere to stricter constraints, and static analysis that forces type-safe code from the start. The AI is only permitted to operate within the scope defined by Autolang.
What performance can I expect from Autolang?
According to internal benchmarks in the GitHub src/tests folder, Autolang executes roughly 900 lines of code in approximately 25ms on Windows 11 with a 12th-gen i5 processor and 16GB RAM. RAM usage for a single compiler instance is approximately 5.1MB with peak around 7MB. Cold start is approximately 18ms on a warm system, though first-run times on Windows may be higher due to OS-level file scanning.
Can I use existing Python, JavaScript, or C++ functions with Autolang?
Yes, Autolang does not require rewriting tools that already work. You wrap existing functions from npm, C++, or any other ecosystem as bindings and expose them to the AI through Autolang bindings. The AI calls only what you register and nothing else is accessible. However, Python bindings are not available yet according to the website.
When should I use Autolang and when should I avoid it?
Use Autolang if you are building a system where an LLM generates and executes code at runtime and need to control what it can access, running 5+ concurrent AI agents where RAM overhead becomes a cost problem, want to expose existing JS or C++ functions to AI in a controlled way without rewriting them, or your AI-generated scripts are short under approximately 100 lines and run frequently. Avoid it if you only have a small number of agents, your AI needs to write long complex programs, you need OS-level security guarantees, or you need Python bindings which are not available yet.
How does Autolang handle infinite loops and faulty code?
Autolang mitigates infinite loops and faulty code by allowing users to set a strict maximum opcode execution limit. If a script exceeds that threshold, it is immediately terminated without crashing the host process. Since AI-generated code is rarely compute-intensive, limiting opcodes is highly effective at preventing endlessly running code, faulty loop logic, or an agent getting stuck in an infinite cycle.
What syntax does Autolang use and why?
Autolang uses Kotlin-inspired syntax with data structures that carry the spirit of TypeScript. This leverages prior knowledge AI models already have from these popular languages rather than forcing them to learn an entirely alien syntax. During declaration, the AI is forced to explicitly declare the type preventing mismatched data types later, but once type can be clearly inferred, concise syntax is sufficient saving tokens and reducing unnecessary complexity.
How does Autolang handle nullable types and null pointers?
Autolang provides explicit per-library control over which libraries are permitted to use lateinit and nullable types. System libraries can maintain flexibility while AI-generated code must adhere to stricter constraints. Nullable values are forced to be handled explicitly with the ?? operator, making it exceedingly difficult to crash the VM via null pointers. This solves the problem where a single misaccessed null value is enough to crash a program.
What is Autolang's philosophy on performance?
Autolang prioritizes total time which is compile time plus runtime, rather than solely focusing on runtime. AI scripts rarely need to run so fast that it justifies a heavy compile-time penalty. If compiling takes a whole second just to deeply optimize a short script, the overall user experience degrades. Autolang is designed to strike a balance between compilation speed, compiler intelligence, and execution cost, optimizing just enough without unnecessary deep optimizations that add compile cost but benefit long-running programs Autolang is not designed for.
How does Autolang compare to Wasm for sandboxing?
Wasm is a highly effective solution for modern sandboxing but to use Wasm properly you still have to manage the build process, function invocations, data passing, runtime error handling, and environment orchestration. Wasm solves part of the problem but does not automatically serve as a coordination layer for AI. Autolang aims to fill that role by allowing the AI to express its intent solely through Autolang syntax while coordination and control are handled by the system, instead of forcing you to manage multiple config files, JSONs, and distinct runtimes.