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

zachdaniel
Hey folks! AshEvents Release We’ve just released the first version of AshEvents, an Event Sourcing tool for Ash Framework apps. Check o...
New
moxley
An Elixir implementation of the popular PostCSS library, providing CSS parsing, AST manipulation, and stringification capabilities. Feat...
New
hauleth
PhoenixBakery is library for Phoenix 1.6 (and later) that provides modules implementing Phoenix.Digester.Compressor. There are currently ...
New
fuelen
Ecto.DevLogger is an alternative logger of SQL queries in development It inlines bindings into the query, so it is easy to copy-paste lo...
New
pcharbon
This is a new extension for the Ash framework that lets you use the Commanded library in a more declarative manner and removes most of th...
New
type1fool
WebAuthnLiveComponent WebAuthnComponents See this post about renaming the package. Passwordless authentication for Phoenix LiveView app...
New
LostKobrakai
I’ve recently created a small library phoenix_vite integrating the vite build tooling with phoenix. It provides an igniter.installer t...
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
brainlid
LangChain is short for Language Chain. An LLM, or Large Language Model, is the “Language” part. This library makes it easier for Elixir a...
New
billylanchantin
The Explorer library has been out for some time. But we just released the latest version (see below), and we thought we’d start posting u...
New

Other popular topics Top

belgoros
I’m not a pro in using Regex and can’t figure out why the following behaviour happens, especially if we take into account the difference ...
New
peerreynders
Manning 2016 Halloween weekend sale via Deal of the Day Friday, October 28 - Half off all MEAPs - code WM102816LT Saturday, October 29 ...
326 29600 154
New
lessless
I believe there are people here who are dealing with CSV files import on the daily basis, and since Excel is a really popular tool there ...
New
itssasanka
Hi all, Trying to get some more clarity over utc_datetime and naive_datetime for Ecto: https://hexdocs.pm/ecto/Ecto.Schema.html#module-...
New
sergio
I couldn’t find any guides that worked well with Phoenix 1.6.0 and esbuild. I hope this helps people test the waters and eases you into t...
New
quazar
How to set Jason to encode all fields in ecto schema, I don’t care about security and implementing only is taking long list of attributes...
New
lk-geimfari
What is most correct way to open, read and parse JSON file with poison? For example if we have example.json file in root of some projec...
New
myronmarston
The Elixir Typespec docs show the following syntax for keyword lists in typespecs: # ... | [key: type] # keyword lis...
New
fireproofsocks
Forgive me if this is obvious, but how does one delete a database record WITHOUT selecting it first? https://hexdocs.pm/ecto/Ecto.Repo.h...
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