4 ms·
Two Erlang patterns I love
- lionkor 3y agoMeta but the font size on mobile is MASSIVE. Its around 1.5 times the size of large text in the HN text box. Oof
- jasonjmcghee 3y agoIt's true, which isn't great, but the real issue imo is turning on reader mode, there's just no text. For a workaround for the size, 60-75% zoom works well. If the author notices this thread- a couple of tweaks could make this much more accessible to folks.
- pmontra 3y agoReader mode works well on Android Firefox but the code is not easy to read there. Yes, the mobile font is too large: 15 lines on my screen vs 30 lines in reader mode.
- wryoak 3y agoWhich mostly bothers me because of the text justification
- macintux 3y agoThere’s a minor whitespace glitch in both examples: the first gather() header is unnecessarily indented. AFAIK it doesn’t matter; this isn’t Python. But it does make it a little harder to spot the mechanics at play.
- WJW 3y agoThe ordered one is nice, but I do have to wonder about the efficiency of it. If I read https://blog.ndpar.com/2010/11/10/erlang-selective-receive/ https://blog.ndpar.com/2010/11/10/erlang-selective-receive/ correctly, ALL messages in the save queue are re-delivered after a new message has been matched, so if you are unlucky and happen to hit a poor ordering then you will receive O(N^2) messages when submitting N jobs. Probably fine for 1000 messages like in the example, probably not fine for batches of 1000000 jobs.
- mikhailfranco 3y agoYes, worst case quadratic, but redelivered is not resent. Everything is local to the process. In fact, I think the save queue is just a high water mark index at the head of the mailbox. Processing new messages for an existing receive pattern means matching from the end of the mailbox to the HWM. Redelivering for a new receive pattern means resetting the HWM to 0 and rematching everything. So potentially quadratic in matching, but no overhead of copying.
- parentheses 3y agoThis makes me want to learn erlang. In much of the way that functional programming has a lot of useful ideas to learn, so does erlang. Unlike functional programming which can be learned in many ways with many languages, it's unmatched in what it can teach. No other language (ignoring Elixir here) has OTP and friends.