rbino

rbino

Ash Core Team

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.

https://github.com/rbino/build_dot_zig

Showing Posts 1 to 10

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?

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 · GitHub

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.

dimitarvp

dimitarvp

Also they announced they are moving away from integrating well with C compiler(s) and will be doing their own thing, so to speak, which I think alienated a lot of people because they relied on Zig’s toolchain to help them gradually migrate their C projects to Zig, while allowing both to coexist peacefully and seamlessly in the same project. Wrong, see below.

I am not hating on the language – I watched a few demos and I think it’s really simple and to the point and gets things done – but in light of several such recent news I question its fit and place, especially in a world where Rust exists.

Though Rust’s stdlib is quite big so I heard that many people try to code for micro-controllers with Zig (successfully).

So it’s likely not going anywhere but I wonder how widespread it could get.

trnasistor

trnasistor

As far as I remember that was a big misunderstanding.

dimitarvp

dimitarvp

Oh? Would be glad if I am wrong on this. It was one of Zig’s big draws.

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.

dimitarvp

dimitarvp

Same here, and that would be my reason to go use Zig and not Rust – if I had the time or was paid to do so, that is.

Problem is, Rust offers much more guarantees out of the box, and that’s crucially important in systems programming. But really, I am no expert in Zig and I make no claims about if it’s more useful than Rust in these contexts.

D4no0

D4no0

Not really, I never heard about that. Their zig build system however doesn’t plan to be compatible with make, because that eventually breaks cross-compilation, as there are usually flags for targeting a platform.

Indeed, however this is done by constraining the ways you can write code. There are situations, for example MCUs firmware, where you end up circumventing those safety guarantees as they might not make sense. Then you will end up with rust code using unsafe blocks all over the place, hence using zig is more sane in such a situation.

There is also the benefit of easy refactor of c code, just replace c compiler with zig and you end up with a codebase that can be gradually refactored to zig at virtually zero cost.

dimitarvp

dimitarvp

Though not sure what happened to that. I heard on HN some months ago that this will be… I don’t know what. Not a first class citizen though. But I should stop talking because I don’t keep current there. So you would likely know better.

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

Where Next? Top

Trending in Announcing Top

wojtekmach
Hey everyone! Req is an HTTP client for Elixir that I’ve been working on for quite some time. There is already a lot of HTTP clients out...
New
handnot2
Samly can be used to enable SAML 2.0 Single Sign On in a Plug/Phoenix application. This library uses Erlang esaml to provide plug enabl...
New
woylie
Flop is an Elixir library that applies filtering, ordering and pagination parameters to your Ecto queries. offset-based pagination with...
New
MRdotB
I needed to reuse React components from my Chrome extension in my Phoenix/LiveView backend. I noticed that for Svelte/Vue, there are live...
New
garrison
Hobbes is a low-level distributed database for the Elixir programming language. Hobbes provides a simple, safe, and scalable storage lay...
New
marciok
Hi there! We created Gust: A task orchestrator inspired by Airflow. For those who have never heard about Aiflow, it’s a Python-based wor...
New
fuelen
Hi all! I want to present a small library which provides a mix task for generating an Entity-Relationship Diagram for Ecto schemas. You...
New

Other Trending Topics Top

mudasobwa
I am happy to introduce the very α version of the new programming language compiled to BEAM. Welcome Cure. It has literally three kille...
New
AstonJ
This showed up on my feed.. anyone heard of it? Just hype? Ox Alpha is a reasoning model designed for coding, sustained ag...
New
sergio
It’s not that it’s vocabulary is too advanced. It’s something worse. I get lost trying to follow even a paragraph written by Claude. It’...
New
sorenone
Today we’re releasing Oban for Python. Not an Oban client in Python. Not a pythonx wrapper embedded in Elixir. Nope, it’s a fully operati...
New
akoutmos
@hugobarauna, Dr. Dimitrios Koutmos (my brother) and I (Alex Koutmos) have been hard at work on writing a book on how you can use Elixir ...
New
pferriby
Introductory paragraph I’ll be looking for a keen junior or someone that has a couple of years experience in the real world (so you’ve be...
New

We're in Beta

About us Mission Statement

Options

Thread Display Mode




Thread Preview

Skip Thread Previews