@AI %{{--
This logic validates order amounts.
Constraints:
1. Do not skip the amount <= 0 check
2. Add matching tests after any change
3. Do not leak business errors as internal exceptions
--}}%
func validate_amount(amount: Int) -> Int, ErrCode {
if amount <= 0 {
return 0, ErrCode::InvalidArgument;
}
return amount, ErrCode::Ok;
}
A Programmer's Intelligent Companion
Egret
A new AI-era programming language for intelligent, efficient software.
Latest Version: 0.1.3
New to Egret? Start with the beginner tutorial.
Read Egret in Twenty MinutesTwo orioles sing amid emerald willows,
A row of egrets rises into the blue sky.
Snow from western peaks fills the window for ages,
Boats from Eastern Wu are moored beyond the gate.
Get Started Today
Install Egret in one command:
curl -fsSL https://egret-lang.org/install.sh | sh
norm Score<T> {
func score(x: T) -> Int;
}
class Article {
var likes: Int;
var comments: Int;
func init(self: Article, likes: Int, comments: Int) -> Void {
self.likes = likes;
self.comments = comments;
}
}
norm impl Score<Article> {
func score(x: Article) -> Int {
return x.likes * 2 + x.comments;
}
}
func rank<T: Score>(item: T) -> Int {
return score(item);
}
func fetch_user_score(user_id: Int) -> Future<Int> {
return lazy {
return user_id * 10;
};
}
func main() -> Int {
let task1: Future<Int> = spawn fetch_user_score(7);
let task2: Future<Int> = spawn fetch_user_score(9);
let score1: Int = join task1;
let score2: Int = join task2;
print(score1 + score2);
return 0;
}
Why Egret?
In the AI era, programming should not belong only to humans. Machines can write well too.
The AI era needs a native programming language better suited to automatic generation, automatic verification, and automatic repair. Egret Lang centers on clear syntax, strong type constraints, modern abstraction, AI-operable diagnostics, and cross-platform native compilation, so AI-generated code is not merely writable, but also stable, maintainable, and ready for confident delivery.
AI-Friendly
Language constructs designed for AI generation and collaboration
Egret Lang includes @AI syntax and other AI-oriented constructs, so code can carry design intent and engineering constraints in a stable way, not just remain readable to humans. AI no longer has to guess the context; it can read the collaboration protocol directly from the source.
"I want Egret to build a bridge between humans and AI, so people can drive AI better and more efficiently."
Engineering-First
A complete engineering experience from development to delivery
Egret Lang is closer to an engineering language system than a pile of syntax features. It cares about packages, modules, the standard library, test metadata, performance testing, cross-platform builds, and clear diagnostics, so code can form a closed loop from writing and compiling to verification and deployment. Its language features serve that goal as well: generics and norm/impl for abstraction, async for servers and IO, and immut plus internal for boundary control.
"The value of Egret Lang does not come from any single syntax feature. It comes from connecting abstraction, verification, diagnostics, and delivery into a maintainable engineering workflow."
Safe-Enough
Pragmatic language constraints for common engineering risks
Egret Lang does not follow Rust's complex ownership model. Instead, it focuses on simple and efficient engineering boundaries: strong typing, GC, deinit, internal, and immut work together to constrain object lifetimes, resource cleanup, module boundaries, and state mutation. The goal is to expose common mistakes at compile time without turning everyday work into a fight with the type system.
"Egret Lang uses semantics that are strong enough without being overcomplicated, reducing accidental state changes, resource leaks, boundary violations, and type errors."
Join the Community
From user to Egretist.
People who take part in Egret are called Egretists. We believe a good programming language community should make problems easier to reproduce, proposals easier to review, and the entry path clearer for contributors at every experience level.
Explore the Community