Lovely Week with Elixir

Lovely Week with Elixir

It’s now not normally I glean livid about programming languages
since meeting Ruby in 2015.

Process earlier than that, drowning in distress of writing college path works in Java,
has pushed me far off from vogue. Ruby’s freedom and expressiveness
was as quickly as what pulled me inspire, and it’s vogue has saved me in.

I was as quickly as in the hunt for one different language to enlarge my tooling, and discovered
a couple of, harking back to Crystal, Pyhton, Elixir. However what’s the extent with right one different
Object Oriented language I understanding.

So, choosing Elixir was as quickly as a no brainer, and I will ultimately style a couple of of that
juicy concurrent skills with purposeful code imperfect.

I’ll utter that per week in, I’m already satisfied with my dedication. Nonetheless, the explanation
is not going to be any longer largely related to my figuring out of prospects, however extra on fantasy of how
welcoming the language is alongside following most difficult practices.

Beginning with Ruby, all I cared was as quickly as to glean one factor carried out in rapidly and stylish machine.

Beginning with Elixir, I took a diversified potential, now not on fantasy of I selected, however
on fantasy of I bask in been recommended.

Let’s breeze through a couple of facets on how Elixir welcomes learners to the language.

Estimable language documentation and sources

Being a fairly authentic language, I did not search recordsdata from that there was as quickly as such extensive amount of
high quality sources for Elixir. Professional documentation itself is
gold. This, alongside with
Elixir College was as quickly as all I obligatory to glean going with the language.

Documentation as a first-class citizen

I’ll now not stress the significance of documenting code imperfect ample. Nonetheless, in most
languages you glean a sense of it being an optionally available factor, thus largely omitted, or
now not adopted persistently.

Writing and producing documentation is a proceed in Elixir as a consequence of in-built tooling. You
can even write medical doctors which might be routinely added to your test suite

Inbuilt code formatter

Now not all code bases put in energy static analyzers on time, after which it right
turns into a ache to assign up. (I wrote a little post concerning the vogue you’ll additionally elevate
static code prognosis at a later stage to your Ruby tasks.)

There are lots of code bases that don’t even uncover out concerning the existence of constant formatting.

As trivial because it goes to additionally merely seem, it absolutely isn’t. Constant styling is not going to be any longer optionally available, and
Elixir helps us to assign far off from that by providing us with in-built code formatter from supply.

Variety specs, if you want them

Hahaha, I didn’t think about that in some unspecified time sooner or later that I may effectively love to write down typespecs once more. Nonetheless,
working with largely financial instruments/cash, I may effectively considerably accumulate additional readability
after I would like it.

For this we will train kind specs over attribute definitions once we want it.

  @doc """
    Authenticates the utilization of OAuth.

    If succesful, returns {:okay, %Consumer{}}, else {:error, %ApiError{}}.
  @spec authenticate(String.t(), String.t()) ::  ApiError.t()
  def authenticate(grant_type  "password", scope  "forintegration") construct
    params = %{
      grant_type: grant_type,
      scope: scope,
      username: Software program program.get_env(:banco_bs2, :fantasy).consumer,
      password: Software program program.get_env(:banco_bs2, :fantasy).breeze

    case HTTPoison.submit("#{@base_url <> @auth_endpoint}", url_encoded(params), headers()) construct
      {:okay, %Response{status_code: 200, physique: physique}} ->

      {:okay, response} ->

      {:error, %Error{motive: motive}} ->
        {:error, %ApiError{message: "Connection error occured: #{motive}"}}

Your code will quiet deliver alongside facet kind problems as Elixir is not going to be any longer a statically typed language,
then once more, it’ll allow you to indulge in additional readability when writing code.

That you just simply can also merely train Dialyzer or diversified instruments to bask in it statically checked as neatly.

Erlang interoperability

It’s extensive to bask in entry to earlier skool Erlang ecosystem libraries inside Elixir, even
even if it’s train is depressed.

Lengthy machine ahead |>

I’m amazed how after a single week, at the same time as a newbie, I’ll supply to write down maintainable and
readable code in a authentic language and paradigm.

Let’s mediate concerning the hold this all goes. In no potential, I will be writing much less Ruby, however extra Elixir

Scrutinize you spherical on Slack channel!


Please enter your comment!
Please enter your name here