AstonJ

AstonJ

Elixir In Action Book Club!

Welcome to our Elixir In Action Book Club! :048:

This book was recently released in its third edition so we thought it was about time we had a book club on it! It is being led by @code-shoily and @juhalehtonen and the author of the book, @sasajuric, will also be dropping in from time to time - so if you have any questions it could be a great way to interact with the author!

Here’s the full list of participants:

There’s no strict schedule but we encourage everyone to post at least once per chapter, and please remember that while criticism is fine, please be kind - book authors are our friends and members of the community too :blush:

Everyone else is also welcome to join the book club or to comment on anything you find interesting. For anyone who wants to join or purchase the book we’ve also got a limited-time 45% off coupon - simply use elixclub24 at checkout over at manning.com! :023:

First Post! Switch mode

code-shoily

code-shoily

Super happy to be here. Looking forward to discuss and learn from y’all. Apologies in advance for the upcoming stream of (friendly) reminders :wink:

I will mostly be reading on Fri/Sat and posting on Wednesdays!

Most Liked

bjorng

bjorng

Erlang Core Team

Having the read the first chapter of the book, I don’t have much to say. I think it is a really good introduction to the BEAM, Erlang, and Elixir, with just the right amount of details.

Thanks for that introduction! Now I must try to live up to it. :003:

I will take this opportunity to introduce myself and my experience of programming in Elixir.

I wrote my first Elixir programs in December of 2018. José posted a few screencasts showing the puzzles in Advent of Code. I immediately decided that I wanted to solve the puzzles while learning Elixir. It turned out that the puzzles themselves was the hardest part. Learning Elixir (enough to solve the puzzles) was easy. I read the crash course for Erlang developers to get going and then I learned more by looking at the other solutions in the forum, and especially at @sasajuric’s elegant solutions using Enum, Stream, and the pipe operator.

Here is a little about myself and my work in the OTP team.

I am the Björn in “Bogdan/Björn’s Erlang Abstract Machine (BEAM)” mentioned in the book.

I joined the OTP team at the end of 1996, and the first Erlang/OTP release in which some of my code was included was OTP R1D. A few years later, when the inventor of BEAM, Bogumil “Bogdan” Hausman, left Ericsson, I became the main developer responsible for BEAM.

To put that in context, I’ll need to explain how the meaning of the word “BEAM” has changed. Nowadays, the word “BEAM” (at least in common speech) seems to have evolved to mean the entire runtime system for Erlang. That it is also the sense used in the book.

At that time (OTP R1 through OTP R6 R5), there existed two Erlang implementations side by side: Joe Armstrong’s original JAM (Joe’s Abstract Machine) and BEAM. They shared the source of the runtime system (scheduler, BIFs, garbage collector, ETS, drivers, and so on).

“BEAM” at that time only referred to the part of the runtime system that executed the BEAM instructions. That is the part that I spent many years on improving and maturing so that it could replace JAM completely. My own invention in that area is the loader of BEAM code.

My blog post A Brief History of the BEAM Compiler goes beyond its title, giving more details on the early Erlang implementations in general, and BEAM and my involvement in its development in particular.

Returning to the book, the only thing that I think could have been added and is perhaps worth adding in the fourth edition, is a mention of the JIT (Just-In-Time compiler) in the Speed section. As written in the book, we in the OTP team do try to keep the performance as predictable as possible, but we also try to improve the raw performance with the goal to make it less frequently necessary to use libraries or programs implemented in C/C++/Rust. But my opinion in that matter is hardly unbiased. :slight_smile:

Perhaps another language feature is worth emphasising: the bit syntax/binary syntax. It makes parsing of binary protocols much easier than in most other languages. For example, the PER encoding rules for ASN.1 is a nightmare to implement in other languages, but quite easy to implement in Erlang/Elixir using the bit syntax.

sasajuric

sasajuric

Author of Elixir In Action

Hi everyone :wave:

It’s great seeing so many people here! I’m looking forward to the fun discussions. I’ll try to keep up as much as possible, but obviously I can’t address every comment & question. If you feel I’ve glossed over or skipped some important point or question, hit me a DM.

This was listed as an example of what can be done with macros, but in general, as the author of ExActor, I don’t recommend using it :slight_smile: I shall try to find a better example for the next edition.

People are using Rust together with Erlang/Elixir. I think Rustler is a popular choice (Rustler — Rustler v0.38.0). I didn’t think about explicitly mentioning it, but I’ll reconsider this for the next edition.

Ideally those would be reported at the official book page on manning, so they can be marked as correct, and fixed with the next update. But if it’s too much trouble, you can report it here, and I’ll see about transferring them over there.

Suddenly I’m starting to feel slightly nervous :sweat_smile:

I remember that! It was so much fun comparing solutions!

Great point, this should be mentioned. The 1st edition was written way back when there was no JIT, and I somehow missed this opportunity during the update. I’ll see about fixing it in the 4th.

Fun fact: the first drafts used the term EVM (Erlang Virtual Machine). But after discussing it with a few folks, I’ve changed it, because it wasn’t really used in the community, while BEAM seemed to be more popular than ERTS. I wonder if at this point the ship has sailed (for which I’m probably partially guilty myself)?

This is the correct interpretation. Also, the table tells the true story, not some hypothetical. Having worked on both systems from day 1, I was confident that the 1st one could be vastly simplified with Erlang. But yeah, I’m not suggesting that the Erlang solutions can always replace the mentioned products.

AstonJ

AstonJ

*Reads the rest of your post..

You already have Björn :blush:

Would also like to take this opportunity to thank you and everyone else who has worked or works on Erlang and the BEAM - Elixir and this community only managed to get to where it has because of you and all your hard work spanning decades :heart: :purple_heart:

Last Post!

andreyvolokitin

andreyvolokitin

In section 9.2.3, the way of checking if to-do server process exists is to attempt to start it with registering using via tuple. If registering fails with “already registered” reason we know we can use existing process. Section mentions 2 inefficiencies:

  1. “Every time you want to work with a to-do list, you issue a request to the supervisor, so the supervisor process can become a bottleneck. Even if the to-do server is already running, the supervisor will briefly start a new child, which will immediately stop.”
  2. notion of distributed registration in chapter 12, which itself in section 12.2.2 states that “unconditional registration attempt can become a serious bottleneck. Every time you want to work with a to-do list, even if the server process is already running, you attempt a :global registration, which will in turn grab a cluster-wide lock and will then chat with all other nodes in the system.”

So even in a non-distributed scenario, supervisor bottleneck is possible? E.g. in a chat application with many rooms, where each message in each room will trigger supervisor request and unconditional registration attempt

Does Registry.lookup solves this? We could make a lookup and return existing process, only starting the new one if it doesn’t exist

Where Next?

Trending in Discussions Top

AstonJ
As the title says, please share what you’ve been up to with Elixir. Whether that’s been learning it, looking into it, making stuff with i...
2976 91332 914
New
byu
@chrismccord : I just saw the Extract AGENTS.md from Phoenix.new into phx.new generator commit to the phoenix project. My initial shotgu...
New
arcanemachine
I was working on an Ecto migration and I needed a timestamp. So, for the nth time, I looked up the different data types for timestamps, a...
New
AstonJ
Just a general thread to post chat/news/info relating to AI/ML stuff that may be relevant for Nx now or in the future. Got anything to sh...
New
type1fool
I just stumbled on a newly redesigned elixir-lang.org. :tada: It looks like @Software_Mansion did the work, and I think it is generally a...
New
juhalehtonen
There has been a thread to discuss the Stack Overflow Developer Survey on this forum every year since 2018, so here’s yet another one for...
New
alexslade
Fly’s CEO posted this recently - Turn And Face The Strange · The Fly Blog It says that Fly is going all-in on sprites, which is a worry ...
New

Other Trending Topics Top

JesseHerrick
Hey, I’m Jesse and I’m the main contributor behind Dexter, a full-featured, lightning-fast Elixir LSP optimized for large codebases. It s...
New
jimsynz
Beam Bots (or just BB for short) is a framework for building fault-tolerant robotics applications in Elixir using familiar OTP patterns. ...
New
Damirados
Hello everyone. After busy few months I am happy to announce v0.1.0 of Emerge & Solve. They are GUI (Emerge) and State management (S...
New
ausimian
Emily is an Elixir library that runs Nx computations on Apple’s MLX. Install it as the default Nx backend and Nx, defn, Axon, Nx.Serving,...
New
akoutmos
@hugobarauna and I (Alex Koutmos) have been hard at work on writing a book on Nerves that takes you from simply blinking LEDs to building...
New
zachdaniel
Introducing AshStorage! Attachment and file management that slots directly into your resources :smiling_face_with_sunglasses: I had hope...
New

We're in Beta

About us Mission Statement