Truss: A programming language optimized for agent-written software
69 points by sram1337 3 hours ago | 46 comments

thesecretsquad 51 minutes ago
I'm not half as smart as most of the people on HN and I don't know much about formal verification, so maybe this is a dumb question....

My understanding of this is: You write a "contract" that defines the specification for some functionality, including inputs, outputs, preconditions, post-conditions, etc. and the contract can be formally verified by some proof checker that says it's logically consistent. Then you build the implementation and the implementation can be proven to abide by the contract (or not).

But somebody has to write the contract (either a person or AI). If the contact specifies behavior that is logically consistent as far as a proof checker is concerned, but the behavior is defined incorrectly, you could have a situation where "you built the thing right", but "you didn't build the right thing".

So someone still needs to make sure the contracts are specifying the correct behavior. Once you know you have, then I suppose the formal verification is good because everybody (people and AI) know that it guarantees its behavior.

My question then is: Assuming everything I just said isn't nonsense, aren't we still in the same place as before? Someone needs to know how to specify (and program) the right behavior?

reply
iamwil 15 minutes ago
It is a gap, but the spec is often declarative, on what needs to be true, rather than imperative, about all the exact steps. Hence, less prone to error. You're right that it proves the protocol, but not necessarily the implementation.

A not-quite-there way to close the gap is that you can generate traces from the spec/proof, a sequence of states and events that must hold true. and then you can use that trace to replay back in tests, and if the implementation is correct, then it should mirror the trace.

reply
pratzc07 37 minutes ago
The spec is far smaller than the implementation. For example take the TimSort case whose implementation in Java and Python had a bug that was there for years until someone tried to formally prove it correct. I also think many valuable properties do not need specific domain judgement like never crashes, no out of bounds access, no data races etc. A spec says "what" not the "how" you still need someone who understands the requirement but they don't have to get every single edge case right. If a model writes both the implementation and the proof, the checker doesn't care who wrote them. Human review shrinks from "read all the generated code" to "read the spec".
reply
ahussain 38 minutes ago
I would assume that the contract is much more concise than the implementation to satisfy that contract. Therefore, it's much easier for a human or AI to maintain.

It's a bit like writing and maintaining a declarative SQL query (new-style) vs writing a query planner (old-style programming).

reply
andoando 39 minutes ago
Were already trusting LLMs to write code, which means it has to translate the human language to both system requirements and make sure the implementation fits those requirements. Why not remove half the problem?

There is also something excellent formal code produces: modularity

reply
grahamlee 3 hours ago
Difficulty: no existing model is trained on Truss. They have been trained on examples of design by contract in other languages (Ada, Eiffel, Java etc) and would do a better job with those and with contract-enforcement rules. Or even with grammar-constrained output and those languages.

Source: I also tried writing an agent-optimized language (for concision and adaptability, not correctness), then I measured.

reply
spankalee 2 hours ago
This is not my experience at all. LLMs universal translation abilities let them pick up new languages really easily, especially if they borrow from existing languages and are consistent.

I've been building a new programming language, Zena [1], for a year and modern Claude and Gemini have absolutely no problem generating the code with about a 300-line skill: https://github.com/elematic/zena/blob/main/skills/zena/SKILL...

(I also happen to be adding contracts and formal verification for gen AI, maybe similar to Truss, but that targets Wasm for sandboxing).

[1]: https://zena-lang.dev/

reply
burcsahinoglu 57 minutes ago
[dead]
reply
malloc2048 8 minutes ago
raise hand

Here someone else who tried to write a coding agent optimized programming language, but I asked it to optimize for cost. Using less tokens is an obvious one but while working on it the actual engineer (LLM) decided that saving on tokens would be marginal savings compared to being able to write the same quality code by a cheaper model. But it never found out how.

After a couple of hours seeing benchmarks in which it lost from Python on pretty much everything, it told me to give up. I did.

reply
mikece 3 minutes ago
Maybe the answer isn't to create a new language for AI, but add to Python the things that Claude tells me makes other languages better for some things, like type safety and a try compilation step to find errors way ahead of runtime.

(Or did I just describe something that has been done eleven times already?)

reply
brightball 2 hours ago
I saw a talk this year from one of the Pony Lang folks talking about this exact problem and how they essentially taught Pony to Claude.

https://carolina.codes/speakers/2026/redvers-davies

It was really interesting. Pony is also deeply underrated.

reply
btown 18 minutes ago
That's a great talk, and it has a resonant quote: "If you let your LLM us a general purpose language, your LLM has to solve all those hard problems instead. Good languages make the illegal impossible."

I think there's some truth here: linters and compilers for general purpose languages are only so powerful, and LLMs will always be tempted to use patterns they've seen before when they're knee-deep in a language they think they understand how to use for your problem. Restricting them to think about problems from first principles in languages with clear and enforced guidelines about data sharing, ownership, traceability, etc. can be very powerful.

Direct link to talk: https://www.youtube.com/watch?v=oU5sV1ljTzs

reply
capv 3 hours ago
+1. You cannot teach AI a new programming language with prompts. In order to be efficient the language has to be in its "brain", i.e., AI's neural network has to be trained on large number of samples.
reply
amterp 2 minutes ago
> You cannot teach AI a new programming language with prompts

Incorrect. I built my own programming language [0] and agents just look up the docs and write it with great success. It helps to have static linting/analysis of course, but they always do just fine writing Rad despite it being very small.

[0] https://github.com/amterp/rad

reply
rfgplk 3 hours ago
They already have been trained, on other languages that provide similar-enough constructs to translate over to the new language. Same principle as how a C++ developer can write Rust after looking at a few syntax examples.

For instance:

  contract ReplaceElement {
       function replace(words: &mutable Slice<UInt64>, index: UInt64, value: UInt64) -> UInt64
           requires index < words.len
           ensures result == old(words[index])
               and snapshot(words) == update(old(snapshot(words)), index, value)
           terminates
           effects { read(words), write(words) }
   }
This is _extremely_ similar to JS/Rust/Java style syntax mixed with common forms from general ALGOL descendant languages. LLMs should have no trouble writing this whatsoever.
reply
cyanydeez 3 hours ago
you don't want anything thats extremely close; you want something that is dissimilar and users very cogent keywords.

Similarity shits up context very quickly.

reply
latentsea 2 hours ago
If any such language gets adoption or even seems like a promising direction, I think in this day and age it should be trivial for the labs to RLVR it into the model with synthetic data.

Edit: if you use local models you could probably fine-tune or do a LoRA for it yourself.

reply
rfgplk 3 hours ago
Incorrect. Models can actually adapt to new syntax quite easily, even with zero training material. Of course that does depend on how truly novel your syntax && constructs are, but generally speaking if you don't deviate too-too far from conventional wisdom you should be fine. My language is quite exotic in fact and frontier LLMs have no trouble writing it, as long as you supply a .bnf file.
reply
DonaldPShimoda 3 hours ago
It's funny: if we were talking about programming languages generally, I would pop in to say something about how syntax really doesn't matter and a language having "exotic" syntax is almost entirely irrelevant. But since LLMs only interact with syntax, it's interesting that they are seemingly able to adapt to novel syntax fairly well.
reply
six_seven 2 hours ago
Dumb question maybe (IANAAIPowerUser)- this new teaching will now always occupy some part of the working context right? As a result of that 1) Do you have smaller usable context? 2) Does the model over-use the new teachings?
reply
dom96 3 hours ago
They do fine even with completely novel syntax. I built a programming language designed to be hard for LLMs[1] with syntax that no other programming language uses and most can get the hang of it pretty quickly.

1 - https://killswitch-lang.org

reply
alexanderabakah 2 hours ago
Great idea, but I believe AI you can't make an ML model efficient just through prompts. You must train the model with the language and vast samples of code written in that language. Even with python which is ubiquitous, something models struggle with optimization or smart algorithms it hasn't seen during training.

I guess the best way will be to improve on existing languages by adding the contracts and verification methods on top of them.

reply
sureglymop 2 hours ago
Maybe I am finally getting old but I remember `truss` as a sort of `strace` alternative.
reply
onedognight 2 hours ago
MocOS still ships `dtruss`, but it’s hobbled compared to Linux’s `strace`.
reply
abeppu 2 hours ago
Proofs about program correctness are great but I don't think this even really attempts to argue why a new language is needed or what this does better than other systems in the space. The only other language mentioned in this project page is Rust as "a small step", but doesn't mention F*, Dafny, Idris, Verus, CakeML etc. I think basically all of these have some greater burdens for authors which previously made them realistic for only some projects, but now that we can have agents deal with those headaches, maybe they should expect to see broader use.
reply
miffy900 3 minutes ago
it's interesting you mentioned Dafny, as after taking a look myself, I see the method specification syntax that Truss uses, has keywords like ensures and requires which is straight up from Dafny, which itself is a Microsoft Research language made by a person who worked on SpecSharp (basically contracts for .NET). I couldn't find a connection between Truss's author and Microsoft, so I do wonder if he maybe got an LLM to design the syntax, which then included prior art from Microsoft etc.
reply
wavemode 43 minutes ago
How does this differ from just plain Lean?
reply
irdc 27 minutes ago
Considering LLM performance tends to depend on how well a particular language was represented in its training set[0], is this even going to work?

0. https://esolang-bench.vercel.app/

reply
ModernMech 3 minutes ago
That paper is benchmarking esolangs, which are meant to demonstrate concepts, not to be usable —- some of them try to be as unusable as possible. So it’s the pathological case.
reply
Incipient 59 minutes ago
We've had a few similar formally verifiable, contract based, provable languages appear recently.

Isn't that whole concept covered by a test suite? The language can't know what you want to do, so you have to write a contact/rule/etc for it - in the same way you'd write a test?

reply
qayxc 53 minutes ago
No. Tests can only uncover the presence of errors, never their absence. Ideally, pre conditions, post conditions, and invariants are part of every function. Nothing new really. Languages like Eiffel have been doing this for decades, but everything old is new again, I guess.
reply
Kuyawa 2 hours ago
I've been beating this drum for some time, this is the way forward
reply
mathisfun123 34 minutes ago
This doesn't work without a formal spec for the target ISA.
reply
rahen 2 hours ago
Original commit two days ago with +663,934 lines of Rust. Eight commits. Already reposted six times on HN since then.

I'm not sure I want to bother with something where the only human involvement was generating the hype.

reply
joshheitzman 8 minutes ago
> optimized for agent-written software

Benchmarks or it wasn't optimized.

I followed the link, poked around, and couldn't find any benchmarks results.

reply
pmkary 11 minutes ago
If it ain't gonna formal verify, it ain't gonna rhyme (just as demonstrated)
reply
pwdisswordfishq 3 hours ago
Named for having the lifespan of an iceberg lettuce?
reply
nmstoker 57 minutes ago
Great name for their test suite!
reply
ltrg 43 minutes ago
Had to actually read the comments to find this after Ctrl-F "liz", Ctrl-F "brit" failed me.
reply
louthy 3 hours ago
Each program takes 49 days to run, and then never runs again having destroyed the computer that it was running on.
reply
phoghed 3 hours ago
Named for how you have to respond to people at work questioning wtf you’re doing. “We got this bro. Truss”
reply
meitham 35 minutes ago
Lovely idea, but I reckon the lettuce on my shelf will probably outlast this language!
reply
semiinfinitely 2 hours ago
so the idea is to invent a new programming language that agents have not been trained on for trillions of tokens, and somehow they're supposed to be better at it than all the languages they have been trained on for trillions of tokens??
reply
IshKebab 60 minutes ago
The trouble is: a) if you want formally verified software you can write it in Lean - AI is extremely good at that, and b) why should I use your 3 day old vibe coded language when I can just as easily make one myself?
reply
acedTrex 3 hours ago
Its hard to hate a project more than this to be honest. What an anti human way to think.
reply
nonethewiser 7 minutes ago
Why does that bother you? Its a programming language for an AI, of course it's not for humans.
reply
IKnowMazin 44 minutes ago
Agreed
reply
deathhawk 2 hours ago
[dead]
reply
ordesign 38 minutes ago
[dead]
reply
theturtle 2 hours ago
[dead]
reply