arcadian

arcadian

I wrote a simple C++ NIF that gets the unix time. It’s nothing groundbreaking, but it was great to see all of the pieces fit together pretty easily. My questions:

  1. Where is the best place to ask questions about NIFs? (Just making sure I’m not in the wrong place.)

  2. At one point, it looks like there was a package called elixir_make, but I couldn’t get it to work - it kept telling me to install gmake, which was already installed on my system. However looking at elixir_make, it looks like it was created to solve the portability problem of Linux using make and FreeBSD using gmake. Is that a problem that I can solve another way? Since in the end I just hardcoded gmake into the mix.deps file. Some code here:


defmodule Mix.Tasks.Compile.HorizonNifs do
  def run(_) do
      File.mkdir_p("priv")
      {result, _error_code} = System.cmd("gmake", ["priv/horizon.so"], stderr_to_stdout: true)
      IO.binwrite result
    end
    :ok
  end
end
  1. Assuming that I build something worth building, what is the best way to package it so that others can use it? I don’t really understand how normal libraries are packaged (the ones that appear in the deps section of mix.exs), and I read that libraries with nifs have some extra steps due to the makefile and c src. Any tips would be great.

  2. What would you like to see in a NIF-based library? My interest is mostly in data structures, which IMHO seems like an area elixir is lacking in. I also have some ideas related to security and authentication, since those can be computationally expensive.

  3. Not really a question, but I noticed that dirty_nifs have a much higher overhead - in a tight loop I was able to execute far fewer of them. Suggests that the best way to get performance could be by combining normal nif functions with dirty nif functions as needed, so you don’t take the performance hit unnecessarily.

Bonus: Is it okay to enjoy programming both C++ and Elixir? They seem like a great match since they are both good at completely different things. Just gotta make sure my .ex files aren’t full of accidental semicolons LOL …

Appreciate the community and the help!

Where Next? Top

Trending in Questions Top

stjefim
Hello! Suppose you are building workflow (order / task / payment) processing system with the following requirements: Each workflow con...
New
jonnycharles
I’m in search of an Elixir library that offers PDF generation capabilities similar to Ruby’s Prawn. While there have been discussions abo...
New
spammy
I’m looking to build a personal workflow to quickly deploy web applications written in elixir/phoenix, for local consumption (ie not on t...
New
dli
Before I dive in myself, did anyone successfully sprinkle Hologram into their existing LiveView app? Looking for hints regarding: Addi...
New
roeland
Kia ora, We have been using elixir-google-api to connect to Google Drive. However, with the updates to Tesla due to CVEs this is now bro...
New
bottlenecked
Hi all, I wanted to ask how the community is dealing with post-release steps. Today we have Ecto migrations, which make sure that the db...
New
rahultumpala
Hello, I have an Elixir backend that implements a custom protocol over TCP. I want to load test the backend and assess the performance o...
New

Other Trending Topics Top

JesseHerrick
Hey, I’m Jesse and I’m the main contributor behind Dexter, a full-featured, lightning-fast Elixir LSP optimized for large codebases. It s...
New
jimsynz
Beam Bots (or just BB for short) is a framework for building fault-tolerant robotics applications in Elixir using familiar OTP patterns. ...
New
mcass19
ExRatatui lets you cook up rich terminal UIs in Elixir, powered by Rust’s ratatui via Rustler NIFs. Build interactive terminal applicatio...
New
Damirados
Hello everyone. After busy few months I am happy to announce v0.1.0 of Emerge & Solve. They are GUI (Emerge) and State management (S...
New
netoum
Corex is an accessible, unstyled UI component library for Phoenix that integrates Zag.js state machines using Vanilla JavaScript and Live...
New
ausimian
Emily is an Elixir library that runs Nx computations on Apple’s MLX. Install it as the default Nx backend and Nx, defn, Axon, Nx.Serving,...
New

We're in Beta

About us Mission Statement

Options

Thread Display Mode




Thread Preview

Skip Thread Previews