Other commenters have already pointed out the safety implications of using NIFs for this. There are, however, other downsides worth considering: - The Erlang VM scheduler can't preempt a NIF, so a long-running Python call risks hanging the VM. This is a non-issue for ports, since Python's running in a separate OS process. A NIF can mitigate this by spawning an OS thread and yielding until it finishes; ain't clear if…
I would have guess the builders of this would have mitigated this problem by running the python in a thread? That won't hang the VM (or cause a segfault at the 1ms boundary). It might cause OS starvation in extreme cases, but you'd have to be really extreme.
Embedding Python in Elixir, it's fine
61–66 of 66 posts
Re: Embedding Python in Elixir, it's fine
#62Earlier quoted context omitted.
I hadn’t heard of gleam. Looks cool! I like working with elixir in a lot of ways but never was a Ruby guy, and I think I’d prefer the C-style syntax.
I'm more of a Python and C# kind of guy, so Elixir never really hit the itch for me, but Gleam definitely does. One of these days I'll take a crack to see how I can use Gleam with Phoenix.
Re: Embedding Python in Elixir, it's fine
#63Earlier quoted context omitted.
I hadn’t heard of gleam. Looks cool! I like working with elixir in a lot of ways but never was a Ruby guy, and I think I’d prefer the C-style syntax.
My current favorite language, just no time to finish my gleam projects.
Re: Embedding Python in Elixir, it's fine
#64Elixir has some features I wish Python had: - atoms - everything (or most things) is a macro, even def, etc. - pipes |>, and no, I don't want to write a "pipe" class in Python to use it like pipe(foo, bar, ...). 90% of the |> power comes from its 'flow' programming style. - true immutability - true parallelism and concurrency thanks to the supervision trees - hot code reloading (you recompile the app WHILE it's runni…
Re: Embedding Python in Elixir, it's fine
#65Earlier quoted context omitted.
I feel like you can write some variant of this comment every few years and just add the previous "best" to the front of the stack of things it's better than.
It’s true - people were saying that Poetry solves these problems for ages. Maybe uv does? I’ll wait and see.
Re: Embedding Python in Elixir, it's fine
#66Earlier quoted context omitted.
uv for Python is a game changer, better than anything else out there and solves a lot of the core problems with pip/venv/poetry/pyenv (the list goes on).
I feel like you can write some variant of this comment every few years and just add the previous "best" to the front of the stack of things it's better than.
That said, in my personal experience with uv, it solves nearly all of the problems I've come across that were created by other python package management tools. It seems to have been very thoughtfully designed and I think there's a strong chance it'll become the standard, and that there won't need to be more standards after this. We'll see!