A couple of days ago I finally started properly looking at Erlang for the first time. One aspect I find especially interesting is the bit syntax, so I wrote a small program for parsing ID3v1 tags for practice. There’s definitely room for improvement (I ignored ID3v1.1), but it was a fun little exercise. Here’s the code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
|
Lets see this in action in the Erlang shell (the MP3 comes from a similar exercise in RubyLearning’s core Ruby course):
1 2 3 4 5 6 7 8 9 10 11 12 13 14 |
|
I’m too new to Erlang to judge if this is a proper use of a property list, but it allowed me to write get_tags/2 as a wrapper for proplists:get_value/2 which is rather nice:
1 2 3 4 |
|
Some initial help came from this related blog post, but I think our versions came out quite differently in the end.
All in all Erlang feels quite nice, except for minor syntactic quirks like different statement modifiers depending on context or the need to “extract” a local function with fun for the call in lists:map/2. Any feedback would be much appreciated, I’m sure there’s plenty of things I could have done better.