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 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!
Trending in Announcing
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...
New
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
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
Flop is an Elixir library that applies filtering, ordering and pagination parameters to your Ecto queries.
offset-based pagination with...
New
The repo is at GitHub - cyberchitta/openai_ex: Community maintained Elixir library for OpenAI API · GitHub.
Docs are at OpenaiEx User Gu...
New
The Chelekom project is a library of Phoenix and LiveView components generated via Mix tasks to fit developer needs seamlessly.
One of i...
New
Hobbes is a low-level distributed database for the Elixir programming language.
Hobbes provides a simple, safe, and scalable storage lay...
New
Other Trending Topics
I am seeing a lot of aplications of Argumentum ad Vericundiam in software discussions. They do link some piece of writing and point us to...
New
Hey folks,
I just published a post about Hologram’s funding and where the project goes next - the short version:
Curiosum as Main Spons...
New
Fly’s CEO posted this recently - Turn And Face The Strange · The Fly Blog
It says that Fly is going all-in on sprites, which is a worry ...
New
We’re evaluating API mocking tools for OpenAPI-based projects and would love to hear what other teams are using.
We’re particularly inte...
New
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
I was thinking since Goatmire Elixir turned out pretty good I should maybe do another one. 30th of Sep - 2nd of Oct this year./
The firs...
New
Categories:
Sub Categories:
Forums
Popular Tags
- #ecto
- #liveview
- #troubleshooting
- #learning-elixir
- #deployment
- #library
- #erlang
- #testing
- #genserver
- #mix
- #absinthe
- #remote-other
- #otp
- #plug
- #how-to-question
- #macros
- #postgres
- #elixirconf
- #channels
- #exunit
- #discussion
- #code-sync
- #javascript
- #podcasts
- #onsite
- #dialyzer
- #docker
- #authentication
- #umbrella
- #full-time-contract
- #podcasts-by-brainlid
- #ecto-query
- #elixir-ls
- #blog-post
- #ai
- #phoenix_html
- #elixirconf-us
- #iex
- #graphql
- #genstage
- #websockets
- #supervisor
- #advent-of-code
- #distillery
- #processes
- #api
- #forms
- #hex
- #security
- #metaprogramming










Showing Posts 1 to 10- Show Best Posts
- Show All (oldest first)
- Show All (newest first)
OvermindDL1
Lol, that’s cool. ^.^
ityonemo
Thanks! That means a lot to me. I think zig is a great fit for elixir. Incidentally, do you know of any good references on refrences? I’m a little bit blocked on my understanding of them.
Edit:. Oops, resources, not references
webuhu
Very cool project…
OvermindDL1
Do you mean OTP resources? Where you can store native code specific data pointers and so forth? Or something in Zig?
ityonemo
Yep, otp resources. I’m trying to get my head around what the right way is to square them with zig’s opinionated (but optional) allocator semantics. One thing I’m unsure about is if otp resources can be realloc’d, since there is no resource realloc function. Probably not hard to try though, once I figure out how to even make one.
OvermindDL1
I would just have you allocate a resource with enough space to hold a zig pointer and store that pointer in it. Have the resource deallocation function deallocate the zig object (if you are done with it of course). That’s generally what I do regardless, I rarely have resource be ‘big’, I treat them as basically just a pointer to my internal object or pointer.
So no, you can’t realloc them, treat them as handles and you are good to go.
ChaseGilliam
When I try this out locally I don’t seem to have the mix task.Then I ranmix do deps.get, deps.compileThenAny clue what I’m doing wrong here?Edit it seems like only Linux is supported atm and I’m running macOS
ityonemo
that’s super strange, it should work though (just tested the mix task myself on a completely fresh system).
In theory there is no reason why most of this stuff shouldn’t work on OSX, but I need to get a few paths correct, but i have no way to test it. If you would like to try getting it to work on OSX, any help would be appreciated! In the meantime I’m going to put a warning about OS at build time.
ChaseGilliam
Yeah, I got it almost working int this test PR WIP/discussion experiment with macOS support by Ch4s3 · Pull Request #16 · E-xyza/zigler · GitHub. It seems like the mix task had a hardcoded check for
:os.system. But you’re right, it seems the only real blocker is a path issue.ityonemo
ok, I will try to generalize the operating system when i get a chance to work on this tonight, will let you know how it goes.