I can guarantee that if you write a benchmark pitting Erlang’s dictionary type against that of any other language, Erlang is going to lose. Horribly. It doesn’t matter if you use choose the dict module or gb_trees; Erlang will still have an embarrassing time of it, and there will be much snickering and posting of stories on the various programming news aggregation sites.
Is the poor showing because dictionaries in Erlang are purely functional, so the benchmark causes much copying of data? Or perhaps because Erlang is dynamically typed?
Neither. It’s because the standard Erlang dictionary modules are written in Erlang.
In that light, the low benchmark numbers are astoundingly impressive. The code for every dictionary insert, look-up, and deletion is run through the same interpreted virtual machine as any other code. And the functions being interpreted aren’t simply managing a big, mutable hash table, but a high-concept, purely functional tree structure. The Erlang code is right there to look at and examine. It isn’t entangled with the dark magic of the runtime system.
There are still some targets of criticism here. Why are there multiple key/value mappings in the standard library, one with the awkward name of gb_trees, in addition to the hackier, clunkier-to-use “Erlang term storage” tables? Why would I choose one over the others? Why is dict singular and gb_trees plural? Let’s face it: The Erlang standard library is not a monument of consistency.
But performance? I’ve used both dictionary types in programs I’ve written, and everything is so instantaneous that I’ve never taken the time to see if a disproportionate amount of time is being spent in those modules. Even if I’m overstating things, over-generalizing based on the particular cases where I’ve used dictionaries, it’s still high-level Erlang code going up against the written-in-C runtime libraries of most languages. And that it comes across as “instantaneous” in any kind of real-world situation is impressive indeed.
(If you liked this, you might enjoy Tales of a Former Disassembly Addict.)
Categories: Blogs Programming in the 21st Century
Erlang on Twitter
» introspection (Guillaume Dumas): Faster than GPU: Now you can use Quantum Computing with… #Numpy! What about Erlang? :D http://t.co/h8U5HMZWHy #RIPRSA c/@mdu4rt3
Faster than GPU: Now you can use Quantum Computing with… #Numpy! What about Erlang? :D http://t.co/h8U5HMZWHy #RIPRSA c/@mdu4rt3
» TrainByTweet_VO (TrainByTweet_VO): VOIP: #Engineering #Network #VOIP #Erlang #Ethernet #Codec #Voice #Bandwidth #Signaling #Protocol #Firewall #Security #Encryption
VOIP: #Engineering #Network #VOIP #Erlang #Ethernet #Codec #Voice #Bandwidth #Signaling #Protocol #Firewall #Security #Encryption
» merry8943 (merry8943): 【D’ERLANGER】D’ERLANGER、6thアルバム『#Sixx』発売記念ニコニコ生放送で全曲解説 - D’ERLANG… http://t.co/NjqgCjQSGo
【D’ERLANGER】D’ERLANGER、6thアルバム『#Sixx』発売記念ニコニコ生放送で全曲解説 - D’ERLANG… http://t.co/NjqgCjQSGo
Number of aggregated posts: 10650
Most recent article: May 20, 2013
» Moraru on This is Why You Spent All that Time Learning to Program: It is true that computer science was a pain in the back at time that i’ve had to learn it…
» Commercial hand dryers on Couchbase Meetup at new HQ: Buy online from here where you will get so much of variety in Commercial hand dryers for people. If you…
» Fort McMurray Homes on Motivated Reasoning and Erlang vs Python vs Node: I don’t really understand why this post is motivational? I don’t even see a post, just a title. Fort McMurray…