Duck Programming Language

Duck is a modern, compiled and batteries included programming language for full-stack web-development, that's built on top of the go ecosystem, it leverages the concepts of duck-typing onto a fast and reliable platform while introducing JSX like server-side templating and client-side react components as first-class citizens.

Speed compared to Alternatives

140.000Duck
40.000Bun
17.000Node
See benchmarks →

Duck in Comparison

Language FeaturesDuckBunNodeJS
Ducktyping
Static Typechecking
Multithreading
Truly native executables
CPU and Memory efficient
Server Side Rendering
Client Side Rendering
node_modules
built-in test runner
Dirt cheap to host
Duck by Example
Typesafe fetching from JSON APIs
fn main() {
    const response_json = match std::web::fetch("https://dummyjson.com/test").send() {
        String @str => str,
        .http_error => return,
    };

    const parsed = match parse_json<{status: String, method: String,}>(response_json) {
        { status: String, method: String } @response => response,
        else => return,
    };

    std::io::println(parsed.status);
}
$ dargo runok
Server Side Rendering
component Counter(props: { initial_value: Int }) jsx {
    const [value, setValue] = useState(props.initial_value);

    return (
    <>
        <div>
            <div>Current value: {value}</div>
            <button onClick={() => setValue((v) => v + 1)}>Increment</button>
        </div>
    </>
    );
}

template Page(props: { param: String }) duckx {
    <html lang="en">
        <body>
            <p>You sent: {props.param}</p>
            <Counter initial_value={10}/>
        </body>
    </html>
}

fn main() {
    std::web::HttpServer::new(.none)
        .handle("GET /{param}", fn(req, res) {
            const param = match req.param("param") { String @s => s, else => return, };
            res.duckx(Page({param: param}));
        })
        .listen(":3000");
}
See more examples in our Tour of Duck