r/ProgrammingLanguages • u/SearchFair3888 • 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
9
u/SearchFair3888 Apr 30 '26
Per AutoModerator's request I hereby confirm that this project did not use an LLM as part of the development process.
13
u/Inconstant_Moo 🧿 Pipefish Apr 30 '26
This is nice.
A suggestion. Since you're making SQL integration part of the core language, you might take it a step further and supply us with some custom syntax. E.g. instead of writing:
... you could let us do something like:
I've always hated those
$1,$2things because apart from anything else my interactions with a machine that can perform half-a-trillion floating-point instructions per second shouldn't involve me counting on my fingers.3
u/Resident-Letter3485 May 01 '26
This is awesome!!!! I haven't seen anyone else attempt this before. I began tackling the same problem around 9 months ago, with a schema language that transpiles to a backend and client HLLs (currently focusing on TS).
Having a lot of fun comparing our designs! Check mine out (it's my first ever attempt at a compiler, has a lot of room for improvement)
https://github.com/bens-schreiber/cloesce
2
u/SearchFair3888 May 01 '26
I want to add point here that, I'm working on query builder too for upcoming relase
https://github.com/nynrathod/doolang/tree/0.4.1/tests/dev_test/database/query_builder
this was imp part for making stuctured way for writing query not an ORM. As it gave easy for writing clean schmea to APIS design. Any thoughts?
btw im using it in my own live product
2
u/esotologist Apr 30 '26
This looks really cool! I'm trying to work on something similar that allows for builder like composition of such structs myself
1
u/SearchFair3888 May 01 '26
https://github.com/nynrathod/doolang/tree/main/tests/dev_test
Check out all the features supported by doolang. Bugs may still appear in active development.
1
u/david-1-1 May 01 '26
If you create your own tools, you can make your own data language that puts all configuration in one place. And that puts all functions in all languages (PHP, HTML, CSS, js) in one file for each feature. I did it, and it avoids bugs while making extending easy.
1
u/bjarneh May 01 '26
Similar to PostGREST I guess?
https://docs.postgrest.org/en/v14/
1
u/tobega May 02 '26
The API and the database model have different reasons to change, though. But nice that you don't need 4
4
u/[deleted] May 01 '26
[removed] — view removed comment