News for hackers. Stuff that matters.
Re:Elixir Is Erlang, not Ruby by phreack on Sunday September 06, 2020 @10:37PM (#24396201)
I find this quite funny because it's my first time hearing I was supposed to be thinking of Elixir as a Ruby thing. I actually learnt about it from a concurrent computing class and it was always an Erlang thing, and now I know it as the magic sauce behind Discord that I always want to try and never find a good reason to.
Re:Elixir Is Erlang, not Ruby by TylerE on Sunday September 06, 2020 @11:38PM (#24396428)
It's not really a weird thing because basically all of the Elixir/Phoenix core teams were big RoR contributors.
Re:Elixir Is Erlang, not Ruby by linux2647 on Sunday September 06, 2020 @11:00PM (#24396277)
> I always want to try and never find a good reason to

As someone who learns best by doing, what are some practical projects that someone could do to learn Elixir? I know that Elixir is quite capable of solving certain kinds of problems very elegantly, but maybe my experience hasn’t presented these kinds of problems yet. Outside of building a Discord-like server or a Phoenix web app, what other good practical projects/applications are there for Elixir?

Re:Elixir Is Erlang, not Ruby by dnautics on Sunday September 06, 2020 @11:24PM (#24396370)
I'm probably the crazy one in the community who is using Elixir for the most super-strange things. For example:

- as a custom DHCP server to do multiple concurrent PXE booting (among other things)

- as a system for provisioning on-metal deployments (like ansible but less inscrutable).

- as a system for provisioning virtual machines over distributed datacenters.

I'll probably also wind up doing DNS and HTTP+websocket layer-7 load balancing too by the end of the year. Probably large-size (~> 1TB) broadband file transfer and maybe even object storage gateway by next year. I've rolled most of these things out to prod in just about year. I honestly can't imagine doing all of these things in Go, without a team of like 20.

Elixir sucks at:

- platform-dependent, like IOS, android, or like SDL games or something,

- number-crunchy, like a shoot em up, or HPC.

- something which requires mutable bitmaps (someone this past weekend brought up "minecraft server").

Actually even desktop might be okay, especially if you pair it up with electron.

Re:Elixir Is Erlang, not Ruby by grantjpowell on Monday September 07, 2020 @03:20AM (#24397322)
> Elixir sucks at:

> number-crunchy, like a shoot em up, or HPC.

> something which requires mutable bitmaps (someone this past weekend brought up "minecraft server")

One thing I'd like to see for the BEAM communities long term are well maintained libraries of NIFs[0] for high performance and possibly mutable data structures. Projects like rusterl[1] and the advances made on dirty schedulers make this more feasible than it used to be.

It would be cool to write all the high level components of a minecraft-esque game in Elixir, and drop down to rust when you need raw performance. Similar to the relationship between lua/c++ in some modern game engines

[0] http://erlang.org/doc/man/erl_nif.html

[1] https://github.com/rusterlium/rustler

Re:Elixir Is Erlang, not Ruby by dnautics on Monday September 07, 2020 @11:02AM (#24399877)
I'm in agreement; though I don't like rust (can't read it) and am the author of https://hexdocs.pm/zigler/Zigler.html
Re:Elixir Is Erlang, not Ruby by linux2647 on Sunday September 06, 2020 @11:34PM (#24396412)
These are some good examples, and I highly appreciate you pointing out Elixir’s downsides.

What are you using to store state? The distributed system itself? An external database? Hybrid approach?

Re:Elixir Is Erlang, not Ruby by dnautics on Sunday September 06, 2020 @11:39PM (#24396429)
currently my main system in prod is a (very smart) stateless caching system, I don't have a database, but I will eventually spin up a (probably amazon) database, for the web gateway, when the keys to that are handed over to me. One of the nice things is that using elixir really puts you in the mindset of thinking hard about who should have responsibility for "the truth". No hiding behind objects backed by ORMs. State is pushed out as far as possible to the edge and I don't trust my server to keep state correctly. As soon as it's at risk of being inconsistent (netsplit, e.g.) the state-holders in the server are slaughtered, rebooted, and told to reconnect to the edge machines, which are trusted with the truth. The nice thing about elixir is that restart logic costs the the price of like 5-6 lines of code across the entire codebase (no worrying about cleaning up resources like tcp connections or anything).

Not in prod (personal project), I have a websocket-scraper on an aws free tier that's dropping data into a sqlite file, that I can transfer to my laptop for offline processing, so there are lots of interesting options.

Re:Elixir Is Erlang, not Ruby by exdsq on Monday September 07, 2020 @01:43AM (#24396892)
This is really interesting to read, I’ve primarily thought about the DB as something which keeps your objects warm. Any recommended sources to read more about this way of treating state?
Re:Elixir Is Erlang, not Ruby by dnautics on Monday September 07, 2020 @02:21AM (#24397038)
Haha I dunno, I just came up with it because that seemed like the sensible thing to do. And the virtualization library I use (libvirt) is basically a database anyways. Whenever I've talked with people who know better than I about distributed state (and iot) everyone seems to agree that pushing state management to the edge is the correct strategy in this case. For some things (like tracking customer intent and business logic) where consistency is important, like for you're responsible for someone's $$$, then you want to centralize and really be 100% certain your state is safe, and - I learned this analogy from stephen nunez, who got it from Toyota principles - you want a 'stop the world' lever when things go wrong. To prevent compounding inconsistency.

In crude and probably wrong terms, AP concerns can be more easily pushed to the edge and CP concerns like to be centralized.

Re:Elixir Is Erlang, not Ruby by exdsq on Monday September 07, 2020 @02:34AM (#24397088)
When you say push state to the edge, would this be similar to how with the onion architecture you have the domain model in the center but repo access to get data on the outside?

Edit: So as not to have the DB be the ‘core’ of the app?

Re:Elixir Is Erlang, not Ruby by anko on Sunday September 06, 2020 @11:06PM (#24396300)
if you need to do some batching operations such as read from a queue, do some processing and publish to s3, I can recommend Broadway https://github.com/dashbitco/broadway

I have seen lots of codebases in lots of languages do this type of task, but aside from maybe spark on the high end, i haven't see it done better.

The beauty of erlang is your code reads like synchronous code so it's easy to read/maintain, but it has all the power of the parallelism of async code.

Re:Elixir Is Erlang, not Ruby by smabie on Monday September 07, 2020 @05:13AM (#24397953)
A BitTorrent client would be cool.

I wrote one in Scala+Akka and the actor model is great. It's even better when the runtime supports preemption, like Elixer.

Re:Elixir Is Erlang, not Ruby by mulander on Monday September 07, 2020 @06:27AM (#24398346)
An erlang BitTorrent client exists: https://github.com/jlouis/etorrent
Re:Elixir Is Erlang, not Ruby by searchableguy on Sunday September 06, 2020 @11:12PM (#24396323)
Robotics/iot applications.
Re:Elixir Is Erlang, not Ruby by AlchemistCamp on Monday September 07, 2020 @01:36AM (#24396849)
> I know it as the magic sauce behind Discord that I always want to try and never find a good reason to

Don't ever want to build a web app? That's pretty much Elixir's sweet spot, IMO. You'll get great productivity, great scalability, performance that's better than popular interpreted languages and a code base that's easy to reason about.

You'll also be able to do a lot from within the VM instead of relying on external services.

Re:Elixir Is Erlang, not Ruby by conradfr on Monday September 07, 2020 @03:40AM (#24397425)
In my mind, in a web context, Elixir is a better Nodejs.

It will never be as popular though.

And it's not like other languages stay stagnant. JS and TS, Java with green threads, C# with actor and LiveView like libraries.

Re:Elixir Is Erlang, not Ruby by AlchemistCamp on Monday September 07, 2020 @12:14PM (#24400402)
Aside from getting rid of decades of language cruft, mutability, etc, one thing I doubt Node will ever have is a fairly unified ecosystem with a dominant framework like Phoenix.

I migrated the code base for my last startup from Node to Rails at the end of 2015, then from Rails to Phoenix at the beginning of 2016. Pretty much all of that Elixir + Phoenix 1.1 code is still fine today. There haven't been any breaking language changes and the most arduous part of upgrading Phoenix to the current version would be the front-end—replacing Brunch with Webpack and removing Bootstrap. Other than that it's just a few lines of code.

The Rails app is slightly more dated but still fairly trivial to update. Most of the gems still do things in the same way and there's generally a clear way to go. The JS app on the other hand, is a pretty depressing mess of broken dependencies and multiple libraries I was using have dramatically changed their APIs.

For me, productivity and ease of maintenance matter much more than popularity does when picking a tech stack.

Re:Elixir Is Erlang, not Ruby by RandoHolmes on Monday September 07, 2020 @02:15PM (#24401311)
This strikes me as someone chasing the shiny.

Why migrate working code to a new language?

And to do it twice?

Re:Elixir Is Erlang, not Ruby by AlchemistCamp on Monday September 07, 2020 @04:00PM (#24402258)
The first time was early on while still at an exploratory stage. I made the change for productivity reasons. Rails did pay off on that axis, even though I was much less experienced with it than the original stack.

The second time was because I'd gotten it to where it was getting users but I couldn't afford the server costs (given that it was free to use and my users were largely in Vietnam and Thailand). I needed something that could scale much more cheaply.

If I'd had millions of dollars in the bank, I'd have just stuck with what I knew and added people and servers as necessary.

Re:Elixir Is Erlang, not Ruby by alkonaut on Monday September 07, 2020 @06:02AM (#24398217)
Same. I have never even heard there is a relation to ruby, I always just thought it was just a functional language for the Erlang runtime. I had no idea the syntax was "Ruby like".
[dead]
Re:Elixir Is Erlang, not Ruby by deallocator on Monday September 07, 2020 @02:49AM (#24397148)
You are being outright negative about Elixir throughout the entire thread, generally without providing good reasons why outside what seems to be your personal bias. No one is forcing you to drop Erlang for Elixir
[dead]
Re:Elixir Is Erlang, not Ruby by dqv on Monday September 07, 2020 @11:57AM (#24400265)
>These are literal measurable facts.

I guess it's worth literally showing your measurements. The Elixir macro system is a vast improvement over merl. When people try to make re-usable gen_servers in Erlang it often becomes a mess. gen_listener in the Kazoo project is a mess and very hard to understand. I'm confident that if Elixir had been around when it was first written and they had opted to use Elixir, it would be way more approachable for developers. Another example from the Kazoo project where Elixir would help would be the ability to provide default arguments in the argument body.

Elixir itself has been the genesis of several improvements and optimizations to the BEAM. These contributions came from core Elixir developers.

I don't think your comparison to coffeescript is fair at all.

Re:Elixir Is Erlang, not Ruby by dynamite-ready on Monday September 07, 2020 @03:54AM (#24397496)
Actually, I'd argue that Elixir is to Erlang, as C++ is to C. Before I'd found Elixir, I had never touched Ruby, but had written some Erlang.

Joe Armstrong himself was quoted as saying Elixir was some "good shit" (may he rest in peace. Super smart and super funny is a rare combination).

Re:Elixir Is Erlang, not Ruby by JohnHaugeland on Monday September 07, 2020 @11:09AM (#24399922)
c++ was not created for the specific purpose of making a language feel like ruby

c++ added extensive new tools that the base language did not have

c++ did not get its engineering team hired off to work on something unrelated

c++ did not create problems by misunderstanding c designs and trying to change them

in these four ways, elixir and coffeescript are alike

.

> Joe Armstrong himself was quoted as saying Elixir was some "good shit"

Yeah, Joe also said that object orientation was a terrible mistake, and if you read his design principles, Elixir was swimming upstream of most of them

When Joe got asked about this, his answer was simple: "I just like to support other peoples' programming languages. You can tell my personal preferences by what languages I use."

.

> may he rest in peace.

I also miss Joe :(

Re:Elixir Is Erlang, not Ruby by josevalim on Monday September 07, 2020 @12:24PM (#24400467)
> c++ was not created for the specific purpose of making a language feel like ruby

> Yeah, Joe also said that object orientation was a terrible mistake, and if you read his design principles, Elixir was swimming upstream of most of them

Did you, by any chance, use Elixir in 2011 and never really re-approached it?

Back in 2011, Elixir was an attempt to bring Ruby and object-orientation to the Erlang VM. It had a prototype-based model, it had eval-based meta-programming, it had loops, and, as you may guess, it failed pretty spectacularly.

But at the end of 2011 and beginning of 2012, I started from scratch. Object-orientation has been removed, a Lisp-based meta-programming model was introduced, most Ruby influences were removed except for minor syntax constructs.

Saying that the design principles were "swimming upstream" of OO principles are inaccurate since 2012 - as most of your other comments in this thread. Our main additions at the language level, compared to Erlang, are macros and protocols, where one is Lisp-based and the other is taken after Clojure/Haskell. From 2012, putting the Erlang VM front and center has literally been one of our main design goals.

Re:Elixir Is Erlang, not Ruby by dynamite-ready on Wednesday September 09, 2020 @12:46PM (#24422888)
Suggesting that Elixir has done little to improve on what Erlang offers seems very untrue. If you write as much Erlang as you claim to, the fixes to string/binary handling and structs/records alone, represent a huge productivity gain.

But everyone's entitled to their own opinion. I occasionally read opinions from polyglots who prefer Erlang's syntax to many other languages. But I personally much prefer Elixir's syntax to Erlang's. For one, the issues in dealing with strings and binaries as mentioned above, for another, I find the punctuation rules in Erlang to be a complete PITA ("." and ",", anyone?).

I suppose it's all opinion, but the points you make about Elixir, when it really is very similar to Erlang 'semantically' (not syntactically), are interesting for how at odds they seem with any of the expert Erlang and Elixir developers I've spoken to, or any of the better researched opinions I've read.

Which is why I find your posts interesting, if not a little misguided.

Re:Elixir Is Erlang, not Ruby by dgellow on Monday September 07, 2020 @12:55AM (#24396708)
Discord switched to Rust some time ago: https://blog.discord.com/using-rust-to-scale-elixir-for-11-m...

Still a very impressive use of elixir IMHO.

Re:Elixir Is Erlang, not Ruby by blixtsnabb on Monday September 07, 2020 @01:05AM (#24396738)
The article says nothing about them switching to rust. They implemented a specific data structure in rust using elixir NIFs (native interface). This is equivalent of calling a C library from other languages.
Re:Elixir Is Erlang, not Ruby by nesarkvechnep on Monday September 07, 2020 @01:06AM (#24396742)
"Our core services aren’t written in Rust, they are Elixir-based."

They haven't switched, just use Rust at some places for performance improvements.

Re:Elixir Is Erlang, not Ruby by dgellow on Monday September 07, 2020 @03:00AM (#24397212)
My bad, I visibly remembered the article incorrectly and didn’t take the time to read again when sharing.

Thanks for the correction. Unfortunately I cannot edit my original comment.

Re:Elixir Is Erlang, not Ruby by sodapopcan on Monday September 07, 2020 @01:44AM (#24396898)
Others have already repeatedly mentioned this was a performance optimization. Elixir/Erlang is not particularly good for heavily CPU bound tasks--This is by design. For lack of a better source, here is a post on the Elixir forum from Robert Virding (one of the creators of Erlang) on the subject: https://elixirforum.com/t/on-why-elixir/34038/62
Re:Elixir Is Erlang, not Ruby by xlii on Monday September 07, 2020 @01:08AM (#24396748)
Based on article they didn’t switch to Elixir but instead are using Rust within Elixir in order to solve complex performance issues.