Evergreen: A Provably Safe Systems Language
evergreenlang.net117 points by jordan_bonecut 3 days ago
117 points by jordan_bonecut 3 days ago
It sounds like you know what you’re doing but the documentation seems rather shallow and I don’t quite get it. I think you’re going to need a real language specification. I like how Go does it.
There is some apparently AI-generated prose that needs rewriting for clarity. For example, in the tutorial:
> The caller proves where; the implementation proves ensures. A precondition failure stops compilation before any program runs.
Fron the readme:
> I think you get it now.
Nope, I skimmed, because the syntax is unfamiliar.
> Memory model is in a tree of "planes". The stack is a tree. Each function is a node. Each variable is another node. If it's a struct then it's also a node. Down to the most atomic types, which are just the integers.
Meaning what? This needs to be explained better.
Yeah the repo/documentation is pretty rough right now. TBH I am not quite ready to spend a ton of time on docs yet as some of these things are changing on the fly. But the core concept/syntax should remain the same. The code is not super interesting yet, though
> TBH I am not quite ready to spend a ton of time on docs yet as some of these things are changing on the fly.
I'd assume, what you do is based on some research, with articles and other projects like yours - these references are what's missing from your project, you don't have to write them yourself.
The most important missing explanation, that only you can provide, is this: Why a new language? There are projects that attach proof obligations to standard Rust in order to reuse its vast ecosystem and existing LLM skills. That would be a far easier and more productive approach to take.
For me part of the fun of such a side project is complete control. I’m willing to risk this over starting from something existing, which may be the wrong call!
congrats & just fyi, you should put a "Show HN" if you are posting and presenting your own handiwork. Better optics.
Yeah, if I were motivated I’m sure I could figure it out from the tutorial.
And, to be clear, the README was mostly an initial prompt for the AI. I’ll prioritize making a much clearer and legible README soon
If you want to have an LLM write your README (and other docs), I've found it useful to add a DOCS-GUIDE.md to your project and write your conventions and expectations there.
Google has a two-part technical writing crash course:
- https://developers.google.com/tech-writing/one
- https://developers.google.com/tech-writing/two
I've had good success with adding a directive to the guide that points to those two URLs and tells the agent to adhere to them in all of its documentation.A good tip is to actually polish your README before sharing it with everyone.
I considered waiting longer to share more but felt feedback early was better than waiting for more polish. Will focus on this with high priority though, good feedback
I think you might want to more deeply consider the impact it has on people when you ask them to read a bunch of LLM-generated code and documentation that you haven't even taken the time to "polish" yet. Some (myself included) might consider it a violation of an implicit social contract to expect such disproportionate effort from your audience than you are willing to spend yourself upfront.
Maybe, to put it another way: Why should people want to spend time developing feedback for you when you were not willing to spend commensurate time on the things you want to show them first? You're putting the cart before the horse.
I agree with you, if I were asking for a code review. I'm mostly interested in what people think of the language features. A code review in its current state is not interesting, but I believe the site has some ideas that can be food-for-thought
Just want to say that you did a great job giving critique. Felt encouraging even though it's not even my project
This language has been something I've wanted to build for years. For a while I thought I'd get my PhD and build it there. But now it's very possible to have Claude build it while I'm at work and give it intense code review every day. It's still not in a "useful" place yet, but I'm curious what fellow programmers think of a language like this. If I continue work is this something anyone thinks they'd enjoy using? Would love some feedback, thanks!
It's a really great concept. What guarantees are made by the prover?
Success in programming languages is not simply if-you-build-it-they-will-come. Bootstrapping a community that loves programming in it is the hard part. You'll either need a killer interop story with an already built ecosystem, or you'll need your own HTTP server, JSON parser, etc. etc. etc.
Best of luck! I'll watch this space.
Thanks! The guarantee is that, without the use of trustme (which can prove any fact), you cannot address memory as the wrong type. The compiler also ensures that a pointer/reference to a value is live at compile time, so it’s not possible to create an invalid pointer (without the use of trustme). You can also claim any fact which the compiler must prove in order to continue compilation.
That is good advice, I’m definitely planning on including some batteries soon, once I’m very happy with where the compiler is at.
> You'll either need a killer interop story with an already built ecosystem
On that note: allow me to "import" or "use" a C header without writing any FFI code.
This isn't so much directed at you, as other people that get inspired by this. I have been working on my own Rust like language with claude for a few months and there are a _lot_ of projects like that out there.
Mine has a formally proven borrow checker built on linear types, along with algebraic effects, with an LLVM compiler written in lean -- the type checker uses exactly the proven calculus.
If you are going to build a language with claude, I highly, highly recommend writing it in Lean or Coq and starting by formalizing a pre-existing paper or system that has the properties you want.
Claude gets confused and takes shortcuts constantly, and if you don't have a proven base, you are really going ot struggle. I had to throw away months of work as i got bogged down trying to resolve special cases and bugs that just evaporated when i switched to a proven calculus.
Is your language available anywhere? I'd be curious to check it out. I strongly believe that there will eventually be a new language created with agents in mind as the primary consumers, and making the foundations provable / safe are key cornerstones in my mind. The other property that I think is very important is fast tooling / compilation. Compilation speed is not generally the bottleneck right now in agent loops, but models can get faster, and as software scales up and is written by swarms of agents in concert, making the tools run really fast will be an important way to decrease cycle time and increase speed.
I was thinking about this problem and found a while ago that Unison lang has a cool concept, I recommend you give it a read [0].
> I strongly believe that there will eventually be a new language created with agents in mind as the primary consumers
That is exactly my motivation. The purpose of adding effects to my language, for example, was at least partially so you can track changes to things like IO usage in PRs. I also plan on adding a simple proof DSL that surfaces some lean functionality directly into the surface, so you can prove invariants about code as in this language, or surface exactly what is being trusted when writing the equivalent of unsafe code.
The main thing I am trying to solve is the LLM code review problem, really.
This is cool! Thanks for sharing. I've been wanting something like this for a while
1. I'm curious how this handles I/O? Proving stuff is often really useful for distributed systems where we would like to prove our system behaves correctly under any ordering of I/O operations.
2. How does this compare to just using Rust and some proof tool like Kani or Verus?
Why optimize for old fashioned manual programming, especially since you are vibe coding the language to begin with? Unless you think Claude and friends will “enjoy” using it more.
It's so strange how much effort goes into producing a language that people don't even intend to write.
To me it’s about determinism and feedback. Agents will make mistakes but if they get clear feedback from the tools they use, they will produce a good result.
There are a shrinking number of reasons to geenfield projects with non-strict or unsafe languages now.
What's strange is only seeing value in manually writing code when clearly AI is very useful to produce quality code here.
you can ask ai to write code in existing languages with large training sets, and it'll do better because of the large volume of training data.
if you're all-in on ai, you want to prioritize familiarity for agents.
The objective of this project isn't to make a language fit for AI to write but to make a "probably safe system language" regardless of who's doing the coding.
That would imply the AI should write every program in Python from now until the end of time; but just because the AI is most familiar with Python doesn’t mean we have to throw everything we know about system design and using the right tools for the job out of the window.
Yes, Python or Rust would make sense to use as long as you're planning on sticking with LLMs.
Not in every situation for all time, that's my point. Which language the AI should use will evolve over time as use cases and computing hardware evolve. It isn't the case that language design is now ossified at whatever existed in 2023.
Also, what you're saying implies Python and Rust should stop evolving as languages, as changing the language would invalidate the vast quantity of work the AI has been trained on.
> Not in every situation for all time, that's my point.
I disagree. It's not worth changing languages for new ones if you want to use AI, unless you can manage to create so much training data that it ends up baked into the models.
> Also, what you're saying implies Python and Rust should stop evolving as languages
Yes, much the way x86 assembly has stopped evolving for the user, outside of smallish additions like wider vector ops. Adding small, high value extensions extensions can be worth paying the token cost and increased failure rates if they add strong new capabilities.
If it's just ergonomic, it's a mistake, unless you want to target hand coders.
Just remember models are constantly evolving and being updated, so a language like python shouldn't stop evolving, models should keep updating themselves, for new languages too, it's only a matter of them getting traction and popularity, training data can be synthesized a posteriory using frontier models with extremely large contexts so you can always have the language spec and function reference.
That's basically SPARK (the Ada subset) but with c-like syntax (more or less).
I see minor differences; however, the author does nothing to highlight them. That's the number one thing that any new language should show when it's trying to fit into a niche that a language already exists for: What makes this language different?
I took a skim and I like the ideas, but you should go further with proving elements of real systems. For example, drivers for Linux, if your whole goal is to prove these things while being a systems language. Although I confess that I don't understand its output, are you using a compiler backend like LLVM? Should be in README.
Is this just "Rust with dependent types"? Not saying that as a criticism, I think this is genuinely useful.
Dependent types are part of it, yeah! There are definitely some things I dislike about Rust which I am not planning on including, mainly lifetimes and some ways they handle pointer mutability. One thing I particularly dislike about Rust is:
let x = vec![1,2,3]; let a = &mut x[0]; let b = &mut x[1]; swap(a, b);
This is not allowed. And actually in the compiler’s mind it’s for the same reason as this:
let x = vec![1,2]; let a = &mut x[0]; x.push(3); a = a + 1;
Which is definitely not safe and should be rejected. But the compiler cannot reason that the above case is actually safe, because they both fail to compile for lifetime reasons.
Another thing I’m working on are “patterns” which are like enums on steroids. In Rust you cannot define how an enum is laid out, thus requiring optimizations for types like Option<&T> to be in the compiler. In evergreen this will be in the language via a similar process to trait implementation.
> not planning on including, mainly lifetimes and some ways they handle pointer mutability
How are you going to solve the problem with other means? Lifetimes basically guarantee, that there are no use-after-free bugs.
The compiler statically tracks “where” everything lives. It also knows “when” the “where” is valid.
Each “where” is called a plane, which is a tree. The stack plane contains all your function calls memory, a structure allocated on the stack has a child plane for each field. The compiler tags which plane something is from at compile time and tracks when it dies.
Things do get complicated in scenarios like:
fn max(a: &usize, b: &usize) -> &usize {
if *a > *b { a } else { b }
}In such a scenario the compiler tags the result with both of the input planes. However, you cannot define add a postcondition ensures clause to make it more precise
Sounds a lot like group borrowing from Valen, but that one still has annotations like `entity in world.entities[] mut`. Are you tracking the same things implicitly with post conditions?
And what about allocations and threads?
Allocations live in their own plane, the root allocated typed being the root node of that plane. For threads, I’m still working on that, don’t have a super cool answer yet
how does that prevent use after free? pretty sure your algorithm is either very poorly explained or doesnt' actually work.
Another thing - when a value is moved or dropped the plane’s type changes from T to shape(T). shape(T) contains unspecified data but has the size and alignment of a T. So you couldn’t safely prove that a moved out/dropped shape(T) is a T
This only works if you make every allocation its own plane, and scope all borrows to the lifetime of the plane, with a move terminating all borrows, at which point this is equivalent to rust, just with confusing jargon.