r/ProgrammingLanguages • • Apr 30 '26

Language announcement Doolang – your struct definition is your schema, your validation, and your HTTP contract

Most stacks make you define the same data model four times. Once for the database schema, once for the model class, once for validation, once for the API contract. They drift. They break. You maintain all four.

Doolang collapses them into one:

struct User {
    id: Int @primary @auto,
    email: Str @email,
    password: Str min(8),
}

struct Task {
    id: Int @primary @auto,
    title: Str @min(1) @max(200),
    userId: Int @foreign(User),
}

fn main() {
    let db = Database::Postgres()?;
    let app = Server::new(":3000");

    app.auth("/signup", "/login", User, db);
    app.crud("/tasks", Task, db);

    app.start();
}

doo run. That's a native binary with JWT auth, password hashing, input validation, SQL migration, and full CRUD. Annotations aren't library decorators; they're compiler constructs. The compiler generates the SQL schema and HTTP layer directly from the struct.

Built on Rust + LLVM. Automatic ownership and borrow system with auto clone/copy/move no explicit lifetimes. Structured concurrency, websocket, file, query builder, RBAC, rate limiting, CORS, logger, middleware all in stdlib. Typed error propagation with -> T ! ErrorType.

Alpha. Real bugs. I'm running DooCloud on it in production as the real test.

github.com/nynrathod/doolang
Benchmarks: github.com/nynrathod/doo-benchmark

25 Upvotes

42 comments sorted by

View all comments

Show parent comment

3

u/Resident-Letter3485 May 01 '26

Doing something similar in my language, essentially:

sql foo(id: int) {  
"  
   SELECT * FROM ... WHERE id = {id}  
"  
}  

What is neat is when you make a language like this that handles your DB schema, you can validate all SQL against the schema during compile time. Eventually, I really want to explore something like this:

sql foo(id: int) -> Option<string> {  
"  
   SELECT name FROM ... WHERE id = {id}  
"  
}  

where we can actually determine at compile time if the query results are the correct type.

2

u/SearchFair3888 May 01 '26

Good examples. Thanks for sharing, though this is not align with doo syntax, but still I align complely with your suggestion.

Would you mind to share you language please?

1

u/Inconstant_Moo 🧿 Pipefish May 01 '26

Well this is definitely The Way. I've been working on an essay where I explain why this is basically the only sensible way to do SQL integration. Have you ever seen the JVA ORM? It's the dumbest thing I've ever seen.

1

u/SearchFair3888 May 01 '26

Yes, but I'm not expert yet in such design still learning. It seems design sql in language is huge part not just a typical language design.