DEV Community

Cover image for Build native NodeJS / Bun addons with Nim language, in seconds πŸ‘‘
George Lemon
George Lemon

Posted on

2

Build native NodeJS / Bun addons with Nim language, in seconds πŸ‘‘

This is DENIM! a little CLI monster and library that provides Nim bindings for writing safe and fast native NodeJS/Bun modules.

import denim

init proc(module: Module):
  proc hello(name: string): string {.export_napi} =
    return %*("Hello, " & args[0].getStr)
Enter fullscreen mode Exit fullscreen mode

In JavaScript:

const {hello} = require('./my.node');
console.log(hello("World!")) // Hello, World!
Enter fullscreen mode Exit fullscreen mode

That's it!

Check GitHub:
https://github.com/openpeeps/denim

Top comments (0)

Billboard image

The Next Generation Developer Platform

Coherence is the first Platform-as-a-Service you can control. Unlike "black-box" platforms that are opinionated about the infra you can deploy, Coherence is powered by CNC, the open-source IaC framework, which offers limitless customization.

Learn more

πŸ‘‹ Kindness is contagious

Please leave a ❀️ or a friendly comment on this post if you found it helpful!

Okay