Live data from Hacker News

Elixir and Rust is a good mix

fly.io

21–30 of 165 posts

Re: Elixir and Rust is a good mix

#21

I used to use Elixir, but the lack of static types got to me (especially since I prefer the type-driven development methodology). Using Rust afterwards was great, plus it was faster than the BEAM. I guess, why not use Rust entirely instead of as a FFI into Elixir or other backend language? I've been using Axum and it works pretty well. The only time I had to do FFI with Rust was with Flutter via flutter_rust_bridge,…

I pretty much agree with this. As much as I liked the core language, I absolutely hated using anything else in the ecosystem, and in my opinion a lot of that was due to lack of static types. Using Ecto as the main way of interacting with the database was a miserable experience. Part of that was due to skill issue I'm sure.

> As much as I liked the core language, I absolutely hated using anything else in the ecosystem, and in my opinion a lot of that was due to lack of static types.

You might be interested in Gleam[1].

[1] https://gleam.run/

Re: Elixir and Rust is a good mix

#22

I used to use Elixir, but the lack of static types got to me (especially since I prefer the type-driven development methodology). Using Rust afterwards was great, plus it was faster than the BEAM. I guess, why not use Rust entirely instead of as a FFI into Elixir or other backend language? I've been using Axum and it works pretty well. The only time I had to do FFI with Rust was with Flutter via flutter_rust_bridge,…

Rust is faster, but that's like saying writing to memory is faster than writing to a database - sure, it is - but the BEAM is designed with something completely different in mind and is still 'quick enough' for handling those cases. That said dealing with elixir syntax is like rubbing sandpaper in your eyes for 8 hours a day.

Re: Elixir and Rust is a good mix

#23

I used to use Elixir, but the lack of static types got to me (especially since I prefer the type-driven development methodology). Using Rust afterwards was great, plus it was faster than the BEAM. I guess, why not use Rust entirely instead of as a FFI into Elixir or other backend language? I've been using Axum and it works pretty well. The only time I had to do FFI with Rust was with Flutter via flutter_rust_bridge,…

> I used to use Elixir, but the lack of static types got to me (especially since I prefer the type-driven development methodology). You might be interested in Gleam[1]. [1] https://gleam.run/

I used to use some Gleam back before the syntax change, when it looked more like Haskell. I found that rather than using a language with a comparatively smaller community, I'd rather just use something that's well supported, so I settled on Rust instead.

Re: Elixir and Rust is a good mix

#24
post #19

Doesn't the use of Rust have to be extremely minimal because ErlangVM has hard time limits on their preemptive scheduler and if your Rust code hasn't finished when preempted, that causes lots of problems. EDIT: thanks for pointing out where in the article this is talked about.

I go into this in the article :) the rustler team has a made a DirtyNif that can work around that, or you can manually yield if you'd like.

Re: Elixir and Rust is a good mix

#25

I used to use Elixir, but the lack of static types got to me (especially since I prefer the type-driven development methodology). Using Rust afterwards was great, plus it was faster than the BEAM. I guess, why not use Rust entirely instead of as a FFI into Elixir or other backend language? I've been using Axum and it works pretty well. The only time I had to do FFI with Rust was with Flutter via flutter_rust_bridge,…

Rust doesn't have a lot of good runtime introspection tools (or they're very not obvious). If you're running a system with a lot of concurrency, it's nice to be able to attach a debugger and find out exactly what's going on with each of your tasks.

I haven't seen hot loading for Rust (but a quick search shows there's some out there), and I'm not sure how amenable Rust is to dlopen and friends to force the issue.

Erlang (and Elixir) have a constrained language that allows for BEAM to be effectively premptive in a way that a Rust concurrent runtime can't be. At every function call, BEAM checks if the process should be preempted, and because the only way to loop is recursion, a process must call a function in a finite amount of time. A Rust runtime cannot preempt, if you need preemption, you've got to use OS threads, which limits capacity, or you need to accept cooperative task switching.

Also, some of us are as anti-typing as you are pro-typing. :)

Re: Elixir and Rust is a good mix

#26

I used to use Elixir, but the lack of static types got to me (especially since I prefer the type-driven development methodology). Using Rust afterwards was great, plus it was faster than the BEAM. I guess, why not use Rust entirely instead of as a FFI into Elixir or other backend language? I've been using Axum and it works pretty well. The only time I had to do FFI with Rust was with Flutter via flutter_rust_bridge,…

Rust is faster, but that's like saying writing to memory is faster than writing to a database - sure, it is - but the BEAM is designed with something completely different in mind and is still 'quick enough' for handling those cases. That said dealing with elixir syntax is like rubbing sandpaper in your eyes for 8 hours a day.

[deleted]

Re: Elixir and Rust is a good mix

#27

I used to use Elixir, but the lack of static types got to me (especially since I prefer the type-driven development methodology). Using Rust afterwards was great, plus it was faster than the BEAM. I guess, why not use Rust entirely instead of as a FFI into Elixir or other backend language? I've been using Axum and it works pretty well. The only time I had to do FFI with Rust was with Flutter via flutter_rust_bridge,…

I pretty much agree with this. As much as I liked the core language, I absolutely hated using anything else in the ecosystem, and in my opinion a lot of that was due to lack of static types. Using Ecto as the main way of interacting with the database was a miserable experience. Part of that was due to skill issue I'm sure.

> Using Ecto as the main way of interacting with the database was a miserable experience.

Ecto is prolly one of the best ways to interact with db. Genuinely curious, what other ORMs have you used?

Re: Elixir and Rust is a good mix

#28

I used to use Elixir, but the lack of static types got to me (especially since I prefer the type-driven development methodology). Using Rust afterwards was great, plus it was faster than the BEAM. I guess, why not use Rust entirely instead of as a FFI into Elixir or other backend language? I've been using Axum and it works pretty well. The only time I had to do FFI with Rust was with Flutter via flutter_rust_bridge,…

> why not use Rust entirely instead of as a FFI into Elixir Because many times you value fault-tolerance and distribution more than performance.

There's a couple of Rust libs and frameworks inspired on Erlang/OTP in 'best of both worlds' attempts, such as https://lunatic.solutions

I found others like Lunatic before, but cannot remember right now.

Re: Elixir and Rust is a good mix

#29

I used to use Elixir, but the lack of static types got to me (especially since I prefer the type-driven development methodology). Using Rust afterwards was great, plus it was faster than the BEAM. I guess, why not use Rust entirely instead of as a FFI into Elixir or other backend language? I've been using Axum and it works pretty well. The only time I had to do FFI with Rust was with Flutter via flutter_rust_bridge,…

I think the most attractive part of the Elixir / Erlang ecosystem is BEAM and its ability to manage code, processes and resources in an extremely parallel environment. Rust operates at a lower level and it feels deceptive to just compare the languages.

That said - if you don't benefit from what BEAM has to offer - I agree Rust is a really attractive alternative.

Re: Elixir and Rust is a good mix

#30
post #28

Earlier quoted context omitted.

> why not use Rust entirely instead of as a FFI into Elixir Because many times you value fault-tolerance and distribution more than performance.

There's a couple of Rust libs and frameworks inspired on Erlang/OTP in 'best of both worlds' attempts, such as https://lunatic.solutions I found others like Lunatic before, but cannot remember right now.

I guarantee your life will be simpler with Erlang.
Post reply on HN