rbino

rbino

Ash Core Team

build_dot_zig - Use the Zig build system from Elixir to build your NIFs

build_dot_zig is a Mix compiler that allows you to use the Zig build system and compiler from Elixir. This lets you to easily build C, C++ and Zig NIFs without a system toolchain on Linux, MacOS and Windows. You can think of it as an alternative to elixir_make with some more goodies.

The library also features a handy mix generator, mix build_dot_zig.gen.c_nif, that bootstraps all that is needed for a NIF written in C. The only thing left to do is to write the implementation of the NIF.

In the future (or possibly right now, I have yet to experiment with it) it could also leverage the Zig package manager to retrieve C, C++ or Zig dependencies, without the need of having them installed system-wide.

Here you can find a blog post with some more details about the library features.

Most Liked

LostKobrakai

LostKobrakai

I would love to give more hearts to this than one. I had been hoping this would become a thing for some time. I might even have a usecase for it at work. Does this work with nerves and their targets?

LostKobrakai

LostKobrakai

As someone not experienced in systems level languages I found zig quite a bit more approachable than rust. I also really like that they actually want to make things like cross compilation simpler. I once tried to cross compile a rust project we have at work and just gave up after a bit, because I couldn’t figure out what was going wrong. Doing it with a toolchain in the handful of MB makes zig even more appealing in that regard.

LostKobrakai

LostKobrakai

This was about a proposal for zig to gain more indepenance from third parties it currently depends on. I’ll link to the comment, which should ultimately give some perspective to the initial proposal: make the main zig executable no longer depend on LLVM, LLD, and Clang libraries · Issue #16270 · ziglang/zig · GitHub

rbino

rbino

Ash Core Team

It’s nice to see we had the same idea :smiley:

build_dot_zig was not very discoverable up until now because even though I’ve been working on it since March, it was mainly meant to serve my own use case, and now I finally decided to polish it a little bit and share it with a wider audience.

About the documentation of the Zig build system, I agree it’s a little sparse. This guide that was published recently can help a little, and I also don’t mind digging into the code since I find Zig stdlib code very readable.

What I don’t agree with is the claim that it can’t be used in serious projects.
Here’s some projects which I would consider serious ported to the Zig build system:

I think we can agree that if your NIF gets more complex than CPython your problem is not going to be how you build it :smile:

D4no0

D4no0

Once again, the discoverability on libraries is horrible :sob: .

We created a similar library for this year’s spawnfest: GitHub - spawnfest/zig_builder

Alas, in my opinion the zig build system is still too unreliable to be used in any serious projects, we had a lot of trouble dealing with internal errors from the build system and the lack of documentation didn’t help.

Where Next?

Popular in Libraries Top

Azolo
Hey everyone, I just released WebSockex which is a Elixir WebSocket client. WebSockex strives to work as a OTP special process, be RFC6...
New
alisinabh
Hey everyone i’ve developed a library for Jalaali calendar for elixir which supports converting Gregorian dates to Jalaali and vice vers...
New
Qqwy
TypeCheck: Fast and flexible runtime type-checking for your Elixir projects. Core ideas Type- and function specifications are const...
336 13801 100
New
marcuslankenau
I feel kind of stuck with the absence of a proper xml library for Elixir. Currently I use SweetXML which was ok for me more or less to pa...
New
michalmuskala
Another small library today. PersistentEts Hex: persistent_ets | Hex GitHub: GitHub - michalmuskala/persistent_ets Ets table backed by...
New
Crowdhailer
I have been updating a library that allows you to pipe between functions that use the erlang result tuple convention. Assuming you have...
New
benlime
LiveMotion enables high performance animations declared on the server and run on the client. As a follow up to my previous thread A libr...
New
bryanjos
Hi, I wanted share a small library we at Revelry Labs made for rendering react components from the server side. There are instructions fo...
New
mattludwigs
Grizzly is a library for working with Z-Wave devices. Z-Wave is a low-frequency radio protocol for controlling smart home devices on a me...
New
bluzky
You may know https://ui.shadcn.com/, a UI component library for React. I really love it’s design style and components. I’ve built some co...
381 12391 119
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
9mm
I am constructing a JSON object (map) and I need to conditionally set a field. I’m trying to write proper elixir-way code… and I’m at a l...
New
stefanchrobot
What’s the safe way to decode a JSON string into a struct? I want to avoid calling String.to_atom. Jason.decode can give me a map with st...
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
senggen
Erlang/OTP 25 [erts-13.2.2] [source] [64-bit] [smp:8:8] [ds:8:8:10] [async-threads:1] 15:22:35.803 [error] gen_event {lager_file_backend...
New
dokuzbir
Hello, I am trying to convert my lists to string without losing brackets.For start i have 3 map. They look like these buyer = %{ id: ...
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
stefanluptak
Hello everybody, usually, I use a 29" ultra-wide monitor for VSCode which can easily accomodate explorer (files panel) + file with code ...
New
ovidiubadita
Hey all, I discovered Elixir and I love it. I always wanted to learn a functional programming and I intended to go for Haskell, but afte...
New
Fl4m3Ph03n1x
About me? ( if you have nothing better to do than reading about some random guy in the internet :stuck_out_tongue: ) Hello all, this is ...
New

Sub Categories:

We're in Beta

About us Mission Statement