News for hackers. Stuff that matters.
Re:José Valim Reveals “Project Nx” (Numerical Elixir) [audio] by toast0 on Tuesday February 09, 2021 @12:07PM (#26079888)
I'm an Erlang enthusiast, but find myself writing C for (small) things where I need to interface with struct heavy library calls, and nobody else has built up an BEAMy interface. I could build it, but it would take about the same work to just build my project in C.

Of course, maybe there's a generalized BEAM to C call library I'm not aware of? (I didn't think to search for one until now)

Also, honestly, it's a little easier to have a C daemon than an erlang daemon. Just call daemon() before the service loop vs setting up an app file. Of course, you have to build hotload yourself from dlopen and friends, and you lose out on a lot of features.

Re:José Valim Reveals “Project Nx” (Numerical Elixir) [audio] by rkangel on Thursday February 11, 2021 @05:35AM (#26100099)
Two ideas that might help:

Elixir releases are built in and easy to use. You don't have to write an app file directly for instance.

I usually use ports for C interface (rather than NIFs). I have a little boilerplate C and Elixir that I recycle to do the ground work and then it's just your specific implementation detail.

Re:José Valim Reveals “Project Nx” (Numerical Elixir) [audio] by toast0 on Thursday February 11, 2021 @05:19PM (#26108175)
Yeah, so I'd write just as much (or likely more) C code to interface with the library and BEAM as just writing the implementation in C.
Re:José Valim Reveals “Project Nx” (Numerical Elixir) [audio] by dnautics on Tuesday February 09, 2021 @04:00PM (#26082333)
Probably the best you're going to get for a generalized c call library is rustler or zigler (I maintain zigler)
Re:José Valim Reveals “Project Nx” (Numerical Elixir) [audio] by toast0 on Tuesday February 09, 2021 @04:46PM (#26082771)
Yeah, so those look like nicer ways to call C than writing a NIF, but they don't look like point to a C include and get the constants and a way to call the functions in the include (and use the types in the include. If I'm reading correctly.

I'm looking for the equivalent of Perl's h2xs, or something like that. (which incidentally, maybe I should be writing these things in perl ;)

Re:José Valim Reveals “Project Nx” (Numerical Elixir) [audio] by dnautics on Tuesday February 09, 2021 @05:35PM (#26083363)