Live data from Hacker News

I let LLMs write an Elixir NIF in C; it mostly worked

overbring.com

71–73 of 73 posts

Re: I let LLMs write an Elixir NIF in C; it mostly worked

#71

built my startup in elixir. love it but nifs are one of the few ways you can crash the VM. I don't trust myseld to write a nif in production. no way I'd do it with AI in c. Thank god theres projects like rustler which can catch panics before it crashes the main VM.

You could always use ports, or the external port drivers.

Re: I let LLMs write an Elixir NIF in C; it mostly worked

#72

built my startup in elixir. love it but nifs are one of the few ways you can crash the VM. I don't trust myseld to write a nif in production. no way I'd do it with AI in c. Thank god theres projects like rustler which can catch panics before it crashes the main VM.

You could always use ports, or the external port drivers.

I'd say for 90% of times you'd want this, spin it off to a microservice over grpc or rabbitmq.

Re: I let LLMs write an Elixir NIF in C; it mostly worked

#73

Earlier quoted context omitted.

because the author self admitted they don't know C! One of the reason why people use the Beam VM is because its robust and fault tolerant. a lot of the choice here are made at the expense of VM's health. also why wouldn't anyone just use :disksup.get_disk_info/1. (Thats immediate) calling :disksup.get_disk_info/1 won’t mess with the scheduler in the way a custom NIF or a big blocking port might. I see the above code/…

The post explains why I don't want to use disksup. You have to start an extra application (os_mon) and configure disksup to update the starts more frequently than the default of every 30 minutes. Do we really need to do all that instead of the equivalent of a df? Agree about the C code, which is why the latest version (on GitHub, the HEAD, not yet released in Hex.pm) is now using Rust and Rustler.

:disksup.get_disk_info/1 (from :os_mon) just calls into the underlying OS once, grabs the info, and returns it. It’s not a blocking “long-running monitor” the way a NIF doing I/O in a scheduler thread would be. https://www.erlang.org/docs/26/man/disksup#get_disk_info-1

^ just use this.

:disksup.get_disk_data/0, which caches results in the :disksup server that updates every N seconds (configurable) which is what you are referring to.. https://www.erlang.org/docs/26/man/disksup#get_disk_data-0

Post reply on HN