Git Product home page Git Product logo

node-zig-fs's Introduction

Node.js Native Module written in Zig

Node.js Native Modules are typically written in C++, but you can write them also in other languages like Rust (1, 2), too. Zig is a new low-level programming language that competes with C, integrating seemlessly with C libraries without FFI or bindings.

This project is an example Hello World for making a Node.js native module in Zig.

The entry point is src/lib.zig.

Test this project like this:

  1. Git clone it
  2. npm install (will download Node.js header files)
  3. npm run build (will compile the Zig project and produce dist/lib.node)
  4. npm run test (will call the greet() function from Zig)

Why Zig?

Writing C/C++ in 2021 is difficult, confusing, verbose, antiquated. (Disclaimer: I have written many thousands lines of code of C/C++ in my lifetime, I know what I'm talking about) But writing native Node.js modules is a superpower for achieving better performance. I've been hyped about using Rust for Node.js native modules, but my experience in practice has been full of obstacles. Now, I'm giving Zig a try. It can produce small binaries with great performance, it builds for all targets I can imagine (out of the box), and is overall a simple and approachable language built for the year 2021. It certainly feels like a young language, but let's test it out, I guess.

License and acknowledgements

Code here is licensed Unlicense, except for src/translate.zig which was copied from Tigerbeetle-node and is licensed Apache-2.0 by Coil Technologies, Inc.

Overall I don't think I would have been able to figure out this example project alone so quickly, so huge thanks to Coil Technologies, Inc. for making an open source node.js native module written in Zig.

node-zig-fs's People

Contributors

shmuelhizmi avatar staltz avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.