I’m back! Cask removed, arm in recovery :) — Let’s celebrate with some funny bits of Erlang/OTP!
Up to this point, I’ve been sharing a good number of odd and/or confusing bits for and about erlangers out there. I’ll go back to that, probably next week. But, during the same period in which I collected all those battle-stories, I also found several nice bits of code and documentation that are shipped with the Erlang/OTP distribution. They go a long way to show how the language was created and how it evolved. It was programmed with fun! That’s certainly my favourite way to code.
Aliens Among Us
To begin with, let me show you a really nice utility you can find in Erlang/OTP: The erlang tracer. Yeah, erlang_tracer was a really long name back then (see below), so its authors called it et. And, of course, with a module like that who can miss the chance to create this function?
1> et:phone_home(1, from, to, msg, opts).
I actually wrote a module using it a while back, and tweeted about it…
Hardcore Name Jokes
%% The name zf is a joke!
I had the chance to meet him last year and ask him what was the joke about and he told me it’s a joke about Zermelo and Fraenkel. Let’s see what these gentlemen have to say about that joke…
No Objective-C Devs Allowed Here
If you remember from one of my previous articles, you have many types for lists in Erlang. And in that article I only listed the proper ones (i.e. the ones that represent valid lists). Erlang allows you to use improper lists as well, but the developers found an excellent way to prevent devs from doing that. According to the note in that page:
The following built-in list types also exist, but they are expected to be rarely used. Hence, they have long names:
True story, man! Who has time to use such long type names, right?
This one is a classic. In Erlang, both keywords and atoms are written as lowercase words (well… atoms can also be written within single quotes, but let’s forget about that for a bit). Most of the times, that’s not an issue: you know that if is a keyword, case is a keyword, my_function is not, etc.
But there are a few reserved words that are not actually keywords (in the sense that you can’t build expressions with them) but they’re also not atoms. They’re just reserved for the future. A while back (before OTP17) the one that everybody stepped over was query. Since then, you can finally write a function called query, but 2 other magic keywords still remain. Let’s see if you can spot them by comparing the list of reserved words here with the list of valid expressions here ;)
That’s All Folks!
Hope you have enjoyed it. See you next week with more battle stories!