My Erlang/OTP 20 Highlights

Brujo Benavides
Erlang Battleground
3 min readMay 30, 2017

--

While I was on vacation, Erlang/OTP 20 RC1 was released. As you can see in that page, these are the highlights according to the OTP team:

The Highlights of OTP20-RC1

There are many great things there, but… being a thorough guy, I didn’t stop there and went for the README. And what a amazing thing! I found several other jewels there that are, at least from my perspective, much more worthy of highlight status than the ones listed above. So, here you have them…

Brujo’s Top 5 Unsung Highlights form OTP20-RC1

Hong Kong City Highlights

5. Compare and Swap for ETS

OTP-14319    Application(s): stdlib
Related Id(s): PR-1076

Add new function ets:select_replace/2 which performs
atomic "compare-and-swap" operations for ETS objects
using match specifications.

This one is something many of us were waiting for and working around in super-nasty ways for a long long time. A nice compare-and-swap for ETS is something I will certainly use in the future.

4. You can use ct_slave with rebar3 now

OTP-13806    Application(s): common_test

The ct_slave modules now handle nodenames in the same
way as nodenames passed to -sname. That means
ct_slave:start('b@127.0.0.1'). will now work.

Another one that we have fought for a long time. As stated in this article (look for The Bad there), ct_slave and rebar3 weren’t friends. There was a workaround, of course, but it was super ugly and it basically involved not using ct_slave at all. That’s why this fix is more than welcomed.

3. Limit the logs backup on CT

OTP-14179    Application(s): common_test

Added the new option, keep_logs. If setting the value
for this option to an integer, N, common_test will
remove all ct_run.* directories in the current log
directory, except the N newest.

Besides making Loïc extra happy, this option will prevent me from starting every test run with rm -rf logs and then hating myself for not keeping track of previous runs 🤦‍♂️.

2. Write Pids and ports in the shell

OTP-14296    Application(s): debugger, stdlib

The Erlang shell, qlc:string_to_handle(), and the
Debugger (the Evaluator area and Edit variable window
of the Bindings area) can parse pids, ports,
references, and external funs
, as long as they can be
created in the running system.

I still have to try it (I use Erlang Solution’s OSX Installer and it doesn’t provide RCs), but if it means what I think it means (i.e. that erlang:is_process_alive(<0.1.0>). will work in the Erlang shell)… That would be the single most amazing feature of this release! I’ve been expecting this (particularly for ports, thanks Fred for recon:port_info/1,2!!! 😱) since my first encounter with an Erlang shell 10 years ago.

1. Drop all the Callback Boilerplate

OTP-13801    Application(s): stdlib

Making code_change, terminate and handle_info callbacks
optional in the OTP behaviours.

I honestly don’t know how this is not a highlight. Check the full conversation started by this tweet below…

So, these are my favorites (besides being able to use the atom ‘💩’, of course). What do you think? Did I miss any other hidden gem? Let me know in the comments below.

Erlang & Elixir Factory Lite Buenos Aires 2017

I want to finish this article with a little self-promotion, I hope you don’t mind…

I’m one of the organizers of the first South American Erlang & Elixir conference ever in Buenos Aires and I would like to invite you all to it.

The programme is already online and the list of talks is impressive. The BEAM community is growing fast and this will be a great place to start connecting all together. So, all my south-american readers: come join us! It will be awesome!

--

--