Mind blowing Elixir

I can’t even begin to say how much it opened my mind to FPs in general. Particularly, for me, as I do full time OOP every day ( aka, from jvm world).

There isn’t just one thing that I’ve come across and I’d say shut the f* up.. this can be done? apart from what others have said, the absolute one thing that still astonishes me is the simple, yet most powerful concept of Erlang/Elixir is the pattern matching.

There’s this simple, argument pattern matching for argument – which is ok I believe, but slicing & dicing the input, simply blew my socks off!

Below is something I’m currently on

  defmodule Decoder do
    # 10 byte metadata
    # 5 bytes
    @redis_signature <<"REDIS"::utf8>>
    # 4 bytes - big endian
    @version <<3::big-size(24)>>
    # 1 byte
    @db_selector <<254::size(8)>>

    def read_metadata(
          <<@redis_signature, version::big-size(24), @db_selector,
            actual_data::bitstring>>
        ) do
    end
3 Likes