Live data from Hacker News

Elixir at PagerDuty

pagerduty.com

101–110 of 190 posts

Re: Elixir at PagerDuty

#101
post #83

Earlier quoted context omitted.

Entirely agreed. Elixir's Macro's are awesome, and Erlang could definitely use an Elixir-Macro-Like Parse Transform library (could definitely exist), Erlang's syntax I find far more readable, consistent, and logical as well. Elixirs syntax has a lot needless, hard-to-read, noise, but it's not hard to overcome the noise to get the benefits of the overall ecosystem and macros.

This topic is quite subjective, but could you provide some example? Overall Elixir seems to me a bit easier to read, for instance: Elixir : "Hello,How,Are,You,Today" |> String.split(",") |> Enum.join(".") |> IO.puts Erlang : -module(tok). -export([start/0]). start() -> Lst = string:tokens("Hello,How,Are,You,Today",","), io:fwrite("~s~n", [string:join(Lst,".")]), ok.

Even better:

    "Hello,How,Are,You,Today" |> String.replace(",", ".") |> IO.puts()

Re: Elixir at PagerDuty

#102

Earlier quoted context omitted.

You sure about that? I've been using bindgen for ages on stable and just grabbed the latest version on an empty project and it still works for me.

I'm sitting next to bindgen's author in meatspace right now and he says yes, it has been on stable for a long time.

Ah sorry, was thinking of rustfmt-nightly, not the toolchain.

Re: Elixir at PagerDuty

#103
post #96
post #83

Earlier quoted context omitted.

This topic is quite subjective, but could you provide some example? Overall Elixir seems to me a bit easier to read, for instance: Elixir : "Hello,How,Are,You,Today" |> String.split(",") |> Enum.join(".") |> IO.puts Erlang : -module(tok). -export([start/0]). start() -> Lst = string:tokens("Hello,How,Are,You,Today",","), io:fwrite("~s~n", [string:join(Lst,".")]), ok.

> This topic is quite subjective, but could you provide some example? Elixir's pin operator is a good example of unnecessary complexity.

Why is it unnecessary?

Re: Elixir at PagerDuty

#104

Earlier quoted context omitted.

Calling `std::process:exit(1)` at the end of main is identical to `return 1`. I'm not sure what your point is with `env_logger::init`. It sounds like you think destructors are run on static items? They aren't. In fact, until very recently you weren't even allowed to have destructors on consts/statics

> I'm not sure what your point is with `env_logger::init` That most of my programs have some global (i.e. "for the runtime of the program") stuff that is setup at the beginning of main. And that some of that might want to Drop when the program exits, for example to delete a temporary directory. Now, if I want to return a non-zero exit code I can not do so while still getting all this global stuff destructed correctly…

Ah, I see. You're wanting to have destructors run on local variables assigned in `main`.

Re: Elixir at PagerDuty

#105

As an Erlang developer for the past couple years now, I love seeing the adoption and excitement around Elixir and the BEAM. I will admit I always shudder when people very quickly call out on Erlang's syntax as a reason not to use it. Feels like a pretty lame excuse... All that said however, it kind of bugs me when I see posts like this (no matter the language) that go somewhere along the lines of "I managed to introd…

> As an Erlang developer for the past couple years now, I love seeing the adoption and excitement around Elixir and the BEAM. I will admit I always shudder when people very quickly call out on Erlang's syntax as a reason not to use it. Feels like a pretty lame excuse...

I have mixed feelings here. From a purely implementation standpoint I totally agree - I don't particularly enjoy using certain tools at work but that is not a valid excuse for me to not get work done. At the same time, as a psych grad turned developer, I'm intimately aware of the effect that dreading a journey can have on attaining a goal and this is no less true of mapping developer experience to productivity - thus we should always be striving to make sure that the goals of the team are not undermined by the requirements to get there. If I had an objective that couldn't be solved in Elixir I would invest time in groking Erlang but its syntax does deter me from wanting to make that investment until I need to.

> All that said however, it kind of bugs me when I see posts like this (no matter the language) that go somewhere along the lines of "I managed to introduce language X and it was all rainbows and unicorns! Everybody loves it and work is fun again".

Totally agree, especially with your points on the gen_* family which are all vastly useful once you understand them but took me some time to bridge that gap. I feel that it's just as important to understand the pain points such that others reading this post and wanting to be the catalyst for similar change can prepare for these issues themselves should they ever want to take the leap.

Re: Elixir at PagerDuty

#106

Earlier quoted context omitted.

I'm sitting next to bindgen's author in meatspace right now and he says yes, it has been on stable for a long time.

Ah sorry, was thinking of rustfmt-nightly, not the toolchain.

No worries!

You shouldn't be using rustfmt-nightly at this point either; install the rustfmt-preview component through rustup. It works on stable!

Re: Elixir at PagerDuty

#108
post #83

Earlier quoted context omitted.

Entirely agreed. Elixir's Macro's are awesome, and Erlang could definitely use an Elixir-Macro-Like Parse Transform library (could definitely exist), Erlang's syntax I find far more readable, consistent, and logical as well. Elixirs syntax has a lot needless, hard-to-read, noise, but it's not hard to overcome the noise to get the benefits of the overall ecosystem and macros.

This topic is quite subjective, but could you provide some example? Overall Elixir seems to me a bit easier to read, for instance: Elixir : "Hello,How,Are,You,Today" |> String.split(",") |> Enum.join(".") |> IO.puts Erlang : -module(tok). -export([start/0]). start() -> Lst = string:tokens("Hello,How,Are,You,Today",","), io:fwrite("~s~n", [string:join(Lst,".")]), ok.

Entirely subjective yes! ^.^

However what you show is not focusing on syntax differences but rather function differences, even `|>` is an (macro) operator. By syntax I'm talking about things like the `do`/`end` and `fn`/`end` and `,do:`/`do...end` mismatches, things like atom key short-form of `someatom: ...` (being short for `:someatom => ...`) only being useful at the end of it's list/map context instead of everywhere (which is not ambiguous nor have any other reason not to do it that I can see), having functions be callable with or without parenthesis (of which thankfully the formatter default puts parenthesis) when functions really should be defined with or without parenthesis and their usage enforced as such, mis-matches in the AST (when creating macro's) by special casing things like 2-tuples among others, and the really weird multi-arity functions of `for` and `with` that really should have been done via body expressions instead of `,` separated expressions (and thus would not need to be special forms but could then just be normal macros, but they seem extremely out of place for the rest of the language syntax), etc.... etc... etc..

It's just a lot of little inconsistencies like that.

Also, if you want pipes for erlang look at the https://github.com/rabbitmq/erlando parse transform (there are others as well, but I like this one), and if you want a shorter erlang form then look at erl2 (just a layer on top of erlang to shorten constructs like module definitions), and of course nothing beats `lfe` on the beam for succinctness and defineability (being a lisp after all).

Also, your Elixir and Erlang codes do not do the same thing. Your Elixir code is being run at compile-time where your Erlang code is not executed at all, only compiled, and thus will only be run if something calls the `tok:start/0` function. The equivalent elixir would be (formatted by the Elixir formatter):

  ```elixir
    defmodule :tok do
        def start() do
            "Hello,How,Are,You,Today"
            |> String.split(",")
            |> Enum.join(".")
            |> IO.puts()
        end
    end
  ```
And you can leave off the final `:ok` on both as both `IO.puts/1` and `io:fwrite/2` both return the atom `ok` in the end. And even then these are not equal as you are working with charlists with one and binaries with the other, so a more direct translation of the Erlang code to Elixir would probably actually be:

  ```elixir
    defmodule :tok do
        def start() do
            'Hello,How,Are,You,Today'
            |> :string.tokens(',')
            |> :string.join('.')
            |> (&:io.fwrite('~s~n', [&1])).()
        end
    end
  ```
That would make the functions equal.

As an aside, a few other bits, Elixir defines if a function is public/private via `def`/`defp`, meaning you have to search through a file to see what is exposed, where in Erlang you can see exactly what is and everything that is exposed by just looking at the top.

And yes, `do`/`end` may be longer by one line than Erlang's sequence operator `,` usage, but I don't mind it to be honest, and you can replicate it in Elixir anyway kind of like:

  ```elixir
    def start(), do: (
        lst = :string.tokens('Hello,How,Are,You,Today', ',');
        :io.fwrite('~s~n', [:string.join(lst,',')]);
        :ok)
  ```
Essentially just replace erlang's `->` with `,do: (`, replace erlang's `,` with `;`, and finally replace erlang's `.` with `)`.

Comparing 'function' differences between them is useless of course, they can call each other functions (though macro's are another issue, erlang cannot 'usefully' call elixir macro's, but then again elixir may not soon be able to use erlang's parse transforms either), the differences are the syntax, and Elixir just has a whole ton of oddities.

Overall I find the Erlang syntax (which is similar to SML/OCaml/etc...) far more uniform, sensible, readable, and that it has far less surprising syntactical cases (like why can't I do something like `%{some_atom: 42, "string key" => 6.28}` in Elixir, blah... you have to do `%{"string key" => 6.28, some_atom: 42}` instead for who knows why reasons...).

I do of course use Elixir for my day job, have for over 2 years now, and these are just a few constant things that bug me on a day-to-day basis. However the tooling, macro's, and community (come join us on the Elixir Forums!!!) are top-notch!

If I had my 'choice' of mythical language though, I'd pick something like OCaml with Rust-style ownership semantics with a full staged macro system (Elixir's is a staged macro system) if it were not otherwise possible to safely add in a full Lisp-style macro system (I really don't think so in a full setup like these though, you need a staged system for various corner-case reasons).

Re: Elixir at PagerDuty

#109

Earlier quoted context omitted.

Part of it is implemented; see https://play.rust-lang.org/?gist=d442c47833587ddeff2158492b0... The rest of it makes it even better; it's a bit limited in ways right now.

Oh nice! Will start using that as soon as we get to 1.26 :) -- currently stuck on 1.24 (upgrading takes a bunch of work since we're building under openembedded/bitbake, so I wait until the new version hits the upstream layer)

Great! :D

Re: Elixir at PagerDuty

#110

Earlier quoted context omitted.

Ah sorry, was thinking of rustfmt-nightly, not the toolchain.

No worries! You shouldn't be using rustfmt-nightly at this point either; install the rustfmt-preview component through rustup. It works on stable!

Does rustfmt-preview work with bindgen though?
Post reply on HN