10 ms·
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 grea
by satvikpendem 4y ago
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, for running a CRDT library (automerge) that was implemented in Rust, for offline app functionality.
- hosh 4y agoEveryone have different needs. For us, OTP on top of pre-emptive lightweight threads and a REPL in production is a huge winner for troubleshooting, finding performance bottlenecks, and reliability.
- malkosta 4y ago> why not use Rust entirely instead of as a FFI into Elixir Because many times you value fault-tolerance and distribution more than performance.
- rapnie 4y agoThere's a couple of Rust libs and frameworks inspired on Erlang/OTP in 'best of both worlds' attempts, such as https://lunatic.solutions https://lunatic.solutions I found others like Lunatic before, but cannot remember right now.
- malkosta 4y agoI guarantee your life will be simpler with Erlang.
- eikenberry 4y agoCould also be nice as it means the Rust parts are smaller and so its slow compiler speed isn't as much of a bother. You get the safety and runtime speed of Rust with the fast iteration cycle of Elixir. Best of both worlds type of thing.
- satvikpendem 4y agoI often find FFI more annoying than it should be (ie something always breaks somewhere), I try to avoid it where possible.
- zinclozenge 4y agoI 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.
- parthdesai 4y ago> 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?
- zinclozenge 4y agoI usually just write the SQL, honestly. For the last 6ish years of my career I've mainly been in the Golang world, so the closest I've gotten to an ORM is a utility to scan rows into structs.
- freedomben 4y agoInteresting, I usually just write the SQL too in most projects, but in Elixir I love Ecto because it's so close to the SQL but has an elegant and powerful way to handle interpolated values.
- Andys 4y agoHave you tried sqlc? Different to any other SQL library I've used and suits Go really well
- zinclozenge 4y agoYes, I like it very much. I've run into some edge cases with it, and I wish there was a setting to change the names of some of the autogenerated code, but otherwise it works very well.
- shiryel 4y agoAs it usually goes in programming, "it depends on your objectives", there are things that are easier accomplished with the ErlangVM than Rust. Also, if you want a language that uses the ErlangVM and has static types, maybe you should take a look at Glean[1]. In my case I prefer to work with Elixir because of the community, as I find easier to work professionally with Elixir than some other mainstream languages, as mostly projects follows the same good practices, use the same tools and have good documentation. [1] - https://gleam.run/ https://gleam.run/
- kerkeslager 4y ago> 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/ https://gleam.run/
- satvikpendem 4y agoI 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.
- callamdelaney 4y agoRust 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 4y ago[deleted]
- toast0 4y agoRust 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. :)
- RhodesianHunter 4y ago>Also, some of us are as anti-typing as you are pro-typing. Assuming ample experience with both, how does one reach this conclusion? I have yet to see a project of any size that needs to be worked on by multiple teams and is written in an untyped language not descend into dumpster fire.
- throwawaymaths 4y ago>I have yet to see a project of any size that needs to be worked on by multiple teams and is written in an untyped language not descend into dumpster fire. Github? Dropbox? I mean they both eventually went to type hints in their respective languages or migrated to a typed language but for a long time I'm certain it wasn't.
- ollien 4y agoIt's worth noting of course that ~Github~ Dropbox was the driving force behind mypy
- throwawaymaths 4y ago
- aeturnum 4y agoI 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.
- dsiegel2275 4y agoI used to use Elixir. I still do, but I used to too.
- dxhdr 4y ago> 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? Sure, you just need to reimplement light-weight threading with preemptive scheduling prioritizing latency over throughput, extremely robust fault tolerance with a supervision hierarchy, and runtime introspection with code hotloading capabilities. Maybe you could add frictionless distributed system support as well. No big deal, why not right?
- lucasyvas 4y agoIs any of this needed though? For some use cases yes, but for many no. It's possible the parent has no practical use for these capabilities.
- deleted 4y ago[deleted]
- hexo 4y ago[flagged]
- lucasyvas 4y agoThe author gave static types and performance as examples of things that matter to them that they clearly don't feel Elixir does as well. It's probable they weren't the target demographic for Elixir, like many aren't the target demographic for Rust. The initial response made an assumption that all these capabilities matter either way, and that's not true.
- tines 4y agoYou may not realize this, but your comment comes off as being very snide and annoying, which I'm sure you didn't intend. Try rewording things in a way that assumes good faith, and besides making better relationships you'll persuade people more effectively as well.
- tessierashpool 4y ago
- vlunkr 4y agoI'm in the same boat with Elixir. I love many aspects of the language, but it borrows the fast-and-loose type ecosystem of ruby. nil is an especially big problem. Any value could be nil, and this will absolutely bite you over and over. nil even allows you to use square brackets for some reason (some_nil_value[:some_key]) which is a great way to disguise the actual issue. There is optional type checking with Dialyzer, which is good but has some problems. The warning output can be really hard to read, and unless you're diligent in using it across most of your project, it's not very useful, because you'll end up with 'any' values all over.
- OkayPhysicist 4y agoI disagree. Any value could be nil, but any value could be 5, too. In fact, nil is just like any other atom. Elixir shines when you lean on pattern matching as much as possible. Your functions should unpack as much as possible within the function definition, frankly the "if" macro is completely superfluous to case and in rare cases cond. You'll find that you match the data you want, and thus reject anything else. Square bracket dictionary accesses are a code smell, because you should be using %{^key = val} = dict or Map.fetch(map, key) or rarely Map.fetch!(map, key). If you do that, managing typing in Elixir just boils down to defining structs to differentiate cases where dictionary A and dictionary B contain similar keys but strictly are not interchangeable.
- bPspGiJT8Y 4y agoAny errors these techniques could catch would have to happen during runtime, not at compile time, and this is a huge and key difference. In my experience having the type errors being caught at compile time is an incredible boost to productivity. I just write code then hit Ctrl+S and the compiler tells me what I got wrong, instead of all the hassle of having to write functions a line at a time, flip to IEx, run, inspect some intermediary value to make sure it works as intended, while trying to keep so many things in my head at once, which at times can be just overwhelming and highly frustrating.
- throwawaymaths 4y agoElixir is incredibly consistent with how it uses nil. It does take a bit of work -- you have to really pay attention to the convention of fetch! vs fetch vs get -- and often times library maintainers are not... always the best at that... but for all the problems that dynamic languages has, nil in elixir is pretty low on the list. I think I get bitten by maybe one a year, and it causes the sporadic report on sentry, and then I go and fix it, and that's that. That access acts on nil is unfortunate, but it's necessary for things like get_in.
- whalesalad 4y agoThere is a great talk from the creator of the language on why static types are not necessary. Of course there is nothing wrong with wanting them and feeling that they are, but I think he (José) makes really great arguments for why Elixir is the way it is. https://www.youtube.com/watch?v=Jf5Hsa1KOc8 https://www.youtube.com/watch?v=Jf5Hsa1KOc8
- baby 4y agoI’m with you there. I haven’t played with Elixir but did some Erlang. I really liked Erlang. Worked a bit in Whatsapp’s codebase as well. But IMO it’s def. not as nice as Rust + using a single language is better.
- victorbjorklund 4y agoHave you checked out Gleam? It is statically typed running on BEAM
- peoplefromibiza 4y ago> I guess, why not use Rust entirely instead of as a FFI into Elixir or other backend language? Because Rust brings none of the benefits of the BEAM ecosystem to the table. I was an early Elixir adopter, not working currently as an Elixir developer, but I have deployed one of the largest Elixir applications for a private company in my country. I know it has limits, but the language itself is only a small part of the whole. Take ML, Jose Valim and Sean Moriarity have studied the problem, made a plan to tackle it and started solving it piece by piece [1] in a tightly integrated manner, it feels natural, as if Elixir always had those capabilities in a way that no other language does and to put the icing on the cake the community released Livebook [2] to interactively explore code and use the new tools in the simplest way possible, something that Python notebooks only dream of being capable of, after a decade of progress But they do not not stop there, the documentation is always of very high quality, even for stuff not coming from the core developers, and they also regularly release educational material that is worth a hundred times a gain in speed. They've set a very high quality standard and I noticed how much it is important only when I stopped programming daily in Elixir and went back to other more hyped or establish ecosystems. That's not to say that Elixir is superior as a language, but that the ecosystem is flourishing and the community is able to extract the 100% of the benefits from the tools and create new marvellously crafted ones, that push the limits forward every time, in such a simple manner, that it looks like magic. Going back to Rust, you can write Rust if you need speed or for whatever reason you feel it's the right tool for the job, it's totally integrated [3][4], again in a way that many other languages can only dream of, and it's in fact the reason I've learned Rust in the first place. I must also say that the work done by the Rust community looks refreshing as well, if you look at the way rustler works it was very well thought and made writing NIFs, something that seemed arcane and distant, only for the proverbial mad professor to try, a breeze. Kudos to them. But the opposite IMO is not true, if you write Rust, you write Rust, and that's it. You can't take advantage of the many features the BEAM offers, OTP, hot code reloading, full inspection of running systems, distribution, scalability, fault tolerance, soft real time etc. etc. etc. But of course if you don't see any advantage in them, it means you probably don't need them (one other option is that you still don't know you want them :] ). In that case Rust is as good as any other language, but for a backend, even though I gently despise it, Java (or Kotlin) might be a better option. [1] https://github.com/elixir-nx/nx https://github.com/elixir-nx/nx https://github.com/elixir-nx/axon https://github.com/elixir-nx/axon [2] https://livebook.dev/ https://livebook.dev/ [3] https://github.com/rusterlium/rustler https://github.com/rusterlium/rustler [4] https://dashbit.co/blog/rustler-precompiled https://dashbit.co/blog/rustler-precompiled
- Dowwie 4y agoConcurrency: if you used Elixir, then you should understand how different its concurrency offering is from that of std and tokio. Standardized, structured concurrency makes building complex, highly concurrent, stable, low-latency systems achievable by mere mortals. Rust has no such offering, yet, but it may 5-10 years from now. Runtime instrospection: the ability to log into a running application to inspect its state, start and stop processes Compile times: elixir compiles very quickly and has tight feedback loops where as rust compiles slowly and has long feedback loops Elixir also doesn't get in the way that the borrow checker does, allowing a programmer to just get on with work and not become saddled with related debugging. Ecosystem: data pipeline processing via GenStage, Broadway, Flow -- wow. Rust developers should take note of what can be achieved in Elixir. However, Rayon and crossbeam are fantastic. Elixir cannot compete with Rust on performance in the category of pipeline processing, but it has very high marks in other very important categories that need to be considered for professional development. I don't think that fault isolation is as compelling an advantage over Rust as it is other languages. Rust makes defense programming a regular part of development, unwrap used sparingly. Faults hardly happen because the program isn't designed to crash. In the rare event that a well-designed Rust program crashes, it's probably managed by an orchestrator that will restart. Both well-designed Elixir and well-designed Rust applications can enjoy very long uptimes if that is a goal. This is just a starting point of discussion.