top | item 40307108

What I mean when I say that machine learning in Elixir is production-ready

135 points| cigrainger | 1 year ago |cigrainger.com

103 comments

order

ToJans|1 year ago

I'm a big fan of Erlang, Elixir, OTP and the BEAM vm. However, I only have very lightweight server needs for my SaaS, so it just doesn't make sense to switch to it, especially as my code is mostly client-based/typescript.

If my core value prop would be around real-time messaging or streaming data, BEAM/OTP would be my first choice.

Slightly OT: I'm still in dubio about Cloudflare pages, but I'm sure that the platform for the backend reboot that we're starting will be in Typescript. There's so much advantage in having one language for everything.

ajmurmann|1 year ago

I am really intrigued by the distributed systems capabilities that BEAM brings. I built a chat app using it and am also using Mnesia DB to store recent messages. However, my experience coding it has been terrible. I am using IntelliJ with an Elixir plugin and there is essence is no auto-complete. I used to write a ton of Ruby, but there RubyMine was really good at guessing what's available. Not so much here. On top of that more often than not the errors from Mnesia are just terrible. Most of the time I just get "TypeError" and a line number. Unclear what it expected to get and what it got passed instead. What IDE/editor have you found helpful? Are there any tricks to work around this? In Ruby I sometimes would use Pry Byebug to explore live what's actually available and iterate on my code in the REPL. Is there a similar approach you recommend here?

davidw|1 year ago

What do you use instead, out of curiosity?

auraham|1 year ago

Have any of you used elixir-desktop [1]? It is a wxWidgets + LiveView bundle, pretty much like a Electron app.

In [2], Wojtek Mach explains how the team behind Elixir build Livebook Desktop. He explains how the project started, some subtle bugs found when building the app for MacOS, some limitations of wxWidgets in Windows, and many other implementation details.

It would be awesome if the Elixir team release something like elixir-desktop based on Livebook. That is, forking the Livebook repo and release an official template project for generating desktop applications based on LiveView.

[1] https://github.com/elixir-desktop/desktop-example-app

[2] https://www.youtube.com/watch?v=Kiw6eWKcQbg

vvpan|1 year ago

Wanted to add to the usual "why is BEAM not more popular" conversation that there is also Gleam [1], which is an up and coming typed language on top of BEAM. It has the more common C-like syntax and a growing ecosystem of libraries, for example Lustre [2]. Unlike Elixir it has a much tighter syntax without all the macro magic. It also does not wrap around Erlang processes and you have to use those directly. To myself I see it as more of a Go for BEAM, although I am sure people would criticize me for making such generalization.

It sucks that syntax matters but it kind of does. I, for one, am somewhat put off by meta-programming and flexibility of Elixir. The idea of having to learn a syntax per-library I struggle to see the benefits of. I have never programmed Ruby or Lisp so perhaps I have not experienced the joy of what Elixir has to offer...

[1] https://gleam.run/

[2] https://github.com/lustre-labs/lustre

OutOfHere|1 year ago

Gleam is a tooling development language, not a concurrency language. It runs away from Erlang's concurrency ecosystem. Also, its documentation, especially wrt concurrency, is sorely lacking. In its current state it would be a mistake it to use it for any distributed work, but perhaps this can change in time.

sundalia|1 year ago

Quite frankly, I see a lot of text in this post and no numbers.

For something to be production-ready I'd expect you to at least cover major things like "latency to serve x in Elixir instead of lang y is k% better" or "EMFU we got when training x in Elixir was comparable to lang y".

These are two random metrics that are of course biased to my experience but the article just feels empty without numbers.

ambicapter|1 year ago

I see so much breathless adoration for Erlang and Elixir, how come it hasn't taken over the world in all this time?

macintux|1 year ago

Inertia: curly braces rule the world. Imperative/OO programming are ubiquitous, FP not so much.

Corporate sponsorship: even with curly braces and mutability, Go probably wouldn't have gained its mindshare without Google.

Performance: It's getting much better, but the BEAM was never designed for maximum performance. People don't like slow platforms, despite the other advantages.

Scale: much like one of the databases written in Erlang, Riak, you typically don't need a BEAM language until your solution is large enough that you've already written it in something else.

I love Erlang, but I'm a lost cause.

dsff3f3f3f|1 year ago

The reality is that it's not nearly as good as the loud proponents would have you believe. Performance isn't great unless you're comparing it to really naive applications written in extremely slow dynamically typed languages like Ruby or Python and OTP and real supervisor trees are not trivial to use correctly. Almost all of the Elixir systems I've seen have serious problems in their supervisor trees.

I've also repeatedly seen this idea from relative newbies that you can replace things like Redis with a simple Erlang key/value store, possibly using ETS, and the result is always much, much worse in terms of both performance and reliability. A lot of the older Erlang/Elixir proponents will tell you to just use Redis.

Most of the popular statically typed languages also have decent abstractions for concurrency and parallelism now while having far better runtimes, far better performance in almost all cases, far more libraries and much larger communities. Erlang/Elixir will never be more than a small niche.

bluesnowmonkey|1 year ago

Here's one anecdote: I use Elixir professionally, for 8 years now. A few years ago I moved to the suburbs and met a neighbor two houses down who happens to run a software company based on Elixir with about 20 devs. Seems like I wouldn't be running into Elixir people in my daily, non-professional life unless there were a lot of them.

I have a theory about why there's more getting done with Elixir than you perceive. It's very productive, and you can get a lot done alone or with a very small team. You don't need as much devops. You maybe don't need as many frontend devs, because LiveView. And so on. Elixir teams don't need to hire as much, so when you look around, you don't see a ton of Elixir job postings. Fewer jobs discourages people from leaning into it as a career choice, which means fewer devs, strangling the overall growth of the community.

Also, at least in large tech companies, small productive teams are anathema to managers. Headcount is everything, and you have much more political power managing 10 Java devs than 3 Elixir devs. Never mind that the company is spending more on salaries, because that's the company's money, not yours. Anything you can do to have a bigger team is a win.

hosh|1 year ago

> how come it hasn’t taken over the world all this time?

I don’t know why it has not. However, it has such a strong set of advantages that people who know what it can do for them keep describing it as a “secret weapon”.

As others have mentioned, it will scale up on a single machine to make use of all the cores (unlike Nodejs, Python, or Ruby). It can already scale horizontally by clustering. Because of the way it is designed, I never have to define a Kubernetes liveliness probe for an Elixir app, whereas I have seen Dotnet and Nodejs apps freeze without crashing (cooperative async reactor can go into infinite loops; Nodejs is very bad about orphaning async execution, by design).

A lot of AI apps is going to involve connecting with unreliable third party services (for example, agents making calls to other api to get information or initiate actions), and may even be on hardware with unreliable network (IoT and edge) and this is where BEAM / OTP shines ahead of pretty much every other runtime and platform.

HN and elsewhere are riddled with Elixir developers extolling its competitive advantages for years … I have had very smart people argue to me why Typescript makes Nodejs so much better, but at this point, I have very little incentive to persuade them. Hence, “secret weapon”.

el_oni|1 year ago

I think we need to give it time. Python had a slow and steady growth from 1991 until today and it has eaten so much of the data analysis and ML world (backed by C++, C and more recently Rust).

But python doesn't vertically scale very well. A language like Elixir can grow to fit the size of the box it is on, making use of all the cores, and then without too much additional ceremony scale horizontally aswell with distributed elixir/erlang.

Elixir getting a good story around webdev (phoenix and liveview) and more recently the a good story around ML is going to increase it's adoption, but it's not going to happen overnight. But maybe tomorrows CTOs will take the leap.

arter|1 year ago

Just because it hasn't taken over the world it doesn't mean it's proponents adorations are baseless ?

I agree that the article falls flat on providing descriptive reasons how Elixir compliments machine learning. But that shouldn't be an argument against the product, but rather against it's cult following that does not provide sufficiently detailed and advanced examples and explanations. Something extremely common in tech journalism.

Good ideas and technologies do get underappreciated and wide spread adoption I would wager is not at all correlated to quality. Javascript, c++, java and others are good examples. Yes they have taken over the world at one point, but there are better designed languages out there. It just seems that people don't want to relearn a new paradigm and you can write software on anything.

greenavocado|1 year ago

Elixir has a lot of promise on the surface but today I'm going to tell you why I am going to pivot my ten person company away from Elixir to a different language for two of our main customer facing services: typing and staffing. Elixir's typing situation is simply insufficient for complex real world use cases on teams with many developers and disparate services.

Elixir developers are also almost non-existent in the United States. It is far more productive and far less risky from a business perspective to hire someone that knows Python for the backend and is forced to work with mypy and pydanic using a major web framework.

The trope that functional programming leads to better code and is more maintainable is also a lie. Defect rate is just as high if not higher per module because of the typing problems.

fulafel|1 year ago

"Best language wins" is not how programming language popularity at the top works. Java, C/C++, JavaScript all have/had various other reasons for their wide use. And of course there's huge inertia, even if a language has the requisite of other forces behind it for "taking over the world" it still takes decades.

But no need to put too much weight on this, lots of languages have more than enough users to be viable for a long time. The top stack overflow languages tend to have poor S/N in the user communities.

ramy_d|1 year ago

I think WhatsApp is still using Erlang and they are biggest messaging app in the world. Discord is using Elixir but it's more niche. I think if you look at use cases where they excel, you will find them there.

indigo0086|1 year ago

Same reason you don't see <Language people are enthusiastic about> taken over the world. The demands of the world are different to the demand of small passionate communities.

wincy|1 year ago

Because when you try to throw junior developers at it who had OO concepts in Python, Java, or C# drilled into them in college, switching to Elixir/Erlang feels like learning Martian. I had the fun experience of it being the second language I used in my career after PHP, and it definitely took strong mentorship and smart seniors who were really into Elixir for me to get up to speed.

At least when we used Elixir about eight years ago, we had to also learn Erlang as many libraries running on the BEAM VM that Elixir and Erlang share were only written in Erlang. So that made my brain melt further.

Once I got into the flow, I really liked it, and am glad I got the opportunity to learn it as a junior developer, but I've largely dropped it as there aren't many jobs in my area looking for Elixir.

hansonkd|1 year ago

TBH part of the BEAM runtime is actually pretty slow. is the problem.

    * Want something flexible and easy and don't care about performance? Use Python
    * Care about performance? Use Rust, etc.
Just because it is distributed cloud native doesn't mean for single requests or functions it is fast.

Almost all SaaS applications are request based and do not need P2P or real time communication. BEAM is worse here. If a company does need that they can specialize that part of their application.

asa400|1 year ago

As someone who was Elixir hire #1 at a company that eventually ended up with ~25 Elixir developers with a novel product that people actually used, I see people in this thread and elsewhere mentioning the unorthodox nature of the language or the supposedly poor performance, and I can tell you that none of that actually matters one way or another. The stuff that really hampers Elixir/Erlang adoption, in my own personal experience and from talking to friends who could have used it but went with other stuff:

1. From the outside, the benefits appear almost entirely theoretical, and in many cases, they are, and the issue with that is that in order to understand the real, non-theoretical benefits of having everything integrated into Elixir and OTP, you have to go all-in. Elixir has to own your app. Elixir is amazing, but when you start talking about its ability to do async IO, people say, "my language has a framework for async IO". When you start talking about its ability to automatically timeout and restart tasks and be fault tolerant, people say, "my language has a framework for network timeouts and I have systemd/k8s/whatever for application restarts". When you start talking about having ETS tables built in, people go, "I have Redis and it works amazingly well, why do I need it inside my app?" You can't adopt OTP piecemeal like you can with e.g., Tokio, or Redis, or Sidekiq, or whatever other thing. It doesn't really make sense to. Other languages might not be as powerful and not as well integrated, but through sheer force of effort, people make existing languages compose with general purpose tools and this is often "good enough". Of course you can write a single small service in Elixir, and this is fine and works, but this often runs into the issue of "now we have an Nth language beyond our normal languages, and we already have caching/monitoring/supervision figured out, so what is this actually adding?"

2. The library ecosystem is still very weak if you're used to e.g. Ruby, Python, Java, or Go (or even Rust, which already has way broader library coverage that is often significantly higher quality) and being able to find a mature driver/integration for a given API or native library. I don't know if this will ever catch up or reach a critical level where most people will find it acceptable. Stuff like the AWS library languished for, literally, years. Just critical stuff that's totally sorted in other ecosystems. This is purely anecdotal on my part, but it seems that way less people as a percentage of the whole community are working on libraries than applications. I have no idea why this is.

3. The performance - especially around latency and garbage collection - is great, but it's probably not "better enough" to actually matter in the domains where people tend to adopt Elixir. What I mean by this is, if you're already working on a project where the performance profile of Ruby or Python or Java is fine (web stuff, relatively simple network or CLI stuff), Elixir may be better in certain respects, but it's not so much better that it provides enough of a step change to make the other issues worth it. For our application, we had some very CPU intensive math stuff that dominated processing times, but we wrote that in Rust anyway, so the higher-level control layer could have been literally anything and it wouldn't have had any effect on performance at all. We picked Elixir because we liked it, but the product would not have failed for performance reasons if we had picked Ruby.

4. It is still, somehow, relatively difficult to find Elixir developers that understand OTP and the more operational concepts of the ecosystem (releases, deployments, observability etc.) at more than a beginner level. The community is still rather beginner oriented and there are a ton of folks who have done simple Phoenix apps and never gone further. I want to be clear that I mean this simply as an observation and not in a derogatory way at all. There is absolutely nothing wrong with having beginners in your community. Beginners are essential to ensure the community continues to grow and a language community without beginners is dying. But over time you have to build up a significant base of experts that can start and lead teams and companies independently, without having to rely on a class of consultants (of which the Elixir community seems dominated by - which is another conversation entirely that I will not get in to here). In Elixir, it seems like the proportion of experts has stayed small relative to the number of experts in e.g. Python, Ruby, Clojure, Go, or Rust. I can go out today and hire someone who understands the inner workings of Python as well as anyone working on the Django team. Anecdotally, as someone who has hired for Elixir roles, this seems difficult to do in Elixir, and I don't know why this is. I have been trying to understand why I have this perception and whether this perception is correct for literally years now, and I haven't been able to figure it out. (Strangely, Erlang on the other hand almost tilts too far in the other direction, with a ton of senior-level people and very few junior or mid-level.)

I could say more but it's probably better that I just leave it at that. I also want to say that I write all this as someone who really loves Elixir but wants to be honest about the issues that I have seen hamper adoption at the companies I've been at.

cmdrk|1 year ago

take a look at the Who's Hiring threads - despite the love the BEAM gets on this website, it seems very few folks are brave enough (or public enough) to hire Erlang/Elixir/Gleam/etc engineers. I've seen one or two Elixir jobs each posting and zero Erlang jobs in the last 6 months or so of Ctrl-F'ing the posts as I see them.

hello_computer|1 year ago

Elixir is a combinatorics mess (circa 2020: two different string types, three different types of exception, return AND throw versions for almost every func, slow compiler without much in the way of compile-time checking, constant breakages over trivial renamings "just because", having to burrow into erlang errs half the time since many elixir funcs are just wrappers). Half the libraries we used were abandoned. I take every recommendation with a grain of salt. I think people got invested in the hype, and are trying to keep the sinking ship afloat.

Erlang is a different story. If you're interested in the BEAM, it isn't terrible. It has a few of the same problems, but the combinatorics are reduced.

kamma4434|1 year ago

Because it’s an excellent fit for some problems, but not so much for others. The ecosystem is definitely smaller and the flower quality compared to say, JavaScript, go, or Java. The performance of the virtual machine is definitely way off the JVM For general computation.

neonsunset|1 year ago

They are slow, have clunky syntax and soundness issues due to lack of strong type system. Now, swap Elixir and F#, and HN crowd, usually signing praises to the former, could stand to gain a lot by using productive language with performant runtime and much better standard library that does not force you into writing code in the exact specific way (especially when it does not fit the use case).

namaria|1 year ago

I see so much concern and worry about climate change, how come it's not solved after all this time?

Thaxll|1 year ago

FP, average performance, no static typing, finding people etc ...

Personally I don't like FP.

ttymck|1 year ago

Because most developers struggle with functional programming.

peoplefromibiza|1 year ago

has Clojure/Haskell/Ada/Coq(...) took over the World?

is it wrong to love it then?

jan3024|1 year ago

Because embarrassing little in coding is controlled by these imagineers. There’s no much real difference in programming languages anymore, honestly I’ve never met a good programmer that cared about these, it makes your code fringe and inportable.