Show HN: Ducklang: Achieving 100x more requests per second than NextJS
duck-lang.dev·2h·
Discuss: Hacker News
Preview
Report Post

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>
<...

Similar Posts

Loading similar posts...