ityonemo

ityonemo

Zigler - Zig nifs for Elixir

Currently just starting out on a new mini-project - getting zig NIFs to run in elixir.

https://github.com/ityonemo/zigler

The idea here is to make the zig NIFs be “embedded” in the elixir code, much like an “asm” call in C. It also makes the bridge between the zig function call and the elixir “basically transparent”. Several adapters are provided: i64, f64, string (as a c string or a zig slice), i64 arrays, f64 arrays. Of course it’s not terribly hard to do the unmarshalling of the erlang terms yourself inside the NIF.

Haven’t started documenting yet, but if you want to see how it works, the test/ directory has quite a few instructive examples which are all passing as of zig 0.4.0

Comments and criticism appreciated!

Most Liked

ityonemo

ityonemo

Updated to 0.8.1

Zig version is bumped to 0.8.1

https://hexdocs.pm/zigler/Zig.html

Major highlights:

  • Supports cancellation of threaded and yielding nifs by killing the owning process.
  • When compiled with debug symbols, zig “error return traces” are merged with elixir exception stacktraces.
  • Supports idiomatic "std.testing.*’ zig stdlib functions for running zig tests
ityonemo

ityonemo

Zigler version 0.10.1 is released, with a redone API, fully updated documentation and guides.

Big highlight is “easy_c” which lets you mount a c library (or supplied c code) and allows you to integrate C libraries as nifs in an intuitive fashion without having to write error-prone glue code by hand.

https://hexdocs.pm/zigler/6-c_integration.html

ityonemo

ityonemo

Version 0.9.1 is released!

Zig version updated to 0.9.1:

Major highlights: Support for c and c++ compilation using the sources option:

https://hexdocs.pm/zigler/Zig.html#module-compiling-c-c-files

ityonemo

ityonemo

https://hexdocs.pm/zigler/0.3.0-pre/Zigler.html

Version 0.3.0-pre has landed with support for Zig 0.6.0. Support for “Long Nifs” which are Nifs that run in their own OS thread is currently disabled (pending investigation of most effective use of Zig async methodology). Other major improvements include a completely overhauled Zig Parser and support for Resources. Full, correct documentation and fixing long nifs will be released with the proper 0.3.0 release, but I wanted to spin up a few demos that leverage the Zig 0.6.0 standard library first.

The couple of demos I intend to write are:

  • ICMP ping library for elixir
  • Fast, safe (flushes the JSON binary from the shared binary memory) JSON parser using arena allocation and builtin BEAM allocator.

I would like to compare the performance JSON parser to an equivalent package made with rustler, so if anyone knows of the preferred Rust JSON parser that would be appreciated. Or, if anyone would like an easy demo, I can try my hand at it.

Things to look forward to:

I’m thinking about releasing Nerves support in the v0.3.0 series where the native cross-compilation capabilities of Zig are used to allow you to seamlessly cross-compile NIF modules in to your nerves releases.

ityonemo

ityonemo

Updated to 0.7.1

Zig version is now bumped to 0.7.1

Now supports threaded, yielding, and dirty nifs. Consult the documentation guides on how to use these different long-running nif methods:

Regression: nerves is (temporarily) not supported until the arm32 architecture becomes tier 1. If you would like to use zig with nerves, consider using v0.3.2.

Where Next?

Popular in Announcing Top

ityonemo
Currently just starting out on a new mini-project - getting zig NIFs to run in elixir. https://github.com/ityonemo/zigler The idea here...
New
BartOtten
This powerful library works together with Phoenix Router to provide the ultimate routing solution. It simplifies route manipulation, givi...
New
BartOtten
Phoenix Live Favicon Favicon manipulation for Phoenix Live A lib enabling dynamic favicons in Phoenix Live View applications. To sho...
New
MRdotB
Greetings Elixir community! Today, I’m thrilled to present you with resvg_nif, an open-source project that provides Elixir bindings for ...
New
kasvith
Hello Everyone, I was working with some HTML-to-Markdown libraries and ran into a few issues when converting a complex markup file to Ma...
New
garrison
Hobbes is a scalable, fault-tolerant transactional record store written in Elixir. Hobbes is designed to be: Scalable - Hobbes can sha...
New
mindreframer
ElixirProto: Protobuf-Inspired Serialization for Elixir Events I wanted to have an Elixir-native serialization for events, that also supp...
New
corka149
A JSON patch is a way to define a sequence of manipulating operations on a JavaScript object. The IETF published the RFC 6902 - found he...
New
Asd
Hi, I am happy to release the Repatch library for mocking and patching implementation in tests and anywhere else. It brings new possibili...
New
zoedsoupe
update (since 2025-07-24) the project got forked and rebranded to anubis-mcp, since i not on CloudWalk anymore and can’t ensure they will...
New

Other popular topics Top

JorisKok
I have a server on AWS, and was running a load test using artillery. When looking at the Phoenix dashboard I see the Ports going to 100% ...
New
New
nsuchy
Hi. I’ve noticed that Windows Powershell has it’s own IEX command and you cannot access Elixir’s IEX due to the conflict. This isn’t a cr...
New
vertexbuffer
Hello, can anybody help here..? I have a list of players and I what to delete an element, but every for loop the list is reverting to ori...
New
lastday4you
I wanted to check elixir version in phoenix because i found that my elixir is 1.5 but when i use Enum.chunk_by it said the function is un...
New
myronmarston
The Elixir Typespec docs show the following syntax for keyword lists in typespecs: # ... | [key: type] # keyword lis...
New
ashish173
I am using Ecto timestamps with postgres, I can see the timestamps() use the :naive_dateime but for my use case I wanted to store the ti...
New
josevalim
Hi everyone, One of the features added to Elixir early on to help integration with Erlang code was the idea of overridable function defi...
New
romenigld
I am trying to run a deploy with docker and I successfully runned with this command: docker build -t romenigld/blog-prod . but when I t...
New
Nvim
Elixir appears to be a superior language to Python. I don’t see any advantage of Python over Elixir. Are there any?
New

We're in Beta

About us Mission Statement