top | item 36784698

(no title)

clone1018 | 2 years ago

Really enjoy working with bits & bytes in Elixir. The syntax looks weird at first but pattern matching against an incoming message via individual bytes is very nice. I've found the gen_tcp / gen_udp stuff's documentation to be a little hard to grok as most of it only gives deep in the Erlang modules but once you "get it" you really get it. It plays very nicely with GenServer's too for super reliable, fault tolerant, tcp/udp acceptor clients. Thanks for the article, this will be a good resource for everyone to learn more about gen_tcp/udp directly!

discuss

order

whalesalad|2 years ago

My "learn elixir" project was writing a full API/client for communication with a NEO-M8 GPS chip via i2c bus. I have never done any i2c hardware programming in my life. Suffice to say I bit off way more than I can chew and it barely works - but it's definitely been incredibly rewarding to use such a high level language to do such low level things with relative ease.

giraffe_lady|2 years ago

Completely agreed, I had to reverse engineer and communicate with an undocumented telnet interface last year at work. It was a brutal pain until I decided to do it in elixir, where it was merely annoying.

The nomenclature around binary/bitstream/charlist/iolist is fairly messy though. But to be fair I think most or maybe all of that shit is just straight from erlang. OTP is a rock solid standard lib but we used to joke that they just took turns naming modules and functions. "Everyone gets to do one!" There's no consistency.