Live data from Hacker News

Elixir 1.12

elixir-lang.org

71–80 of 109 posts

Re: Elixir 1.12

#71
post #65

Earlier quoted context omitted.

I was very, very disappointed that the `tap` macro has nothing to do with pattern_tap: https://github.com/mgwidmann/elixir-pattern_tap Basically, in Elixir pipelines are not very friendly to simple destructuring: if a call at the beginning of the pipeline returns a tuple of `{:ok, result}`, you can't use either of shortcut syntaxes for lambdas (&Mod.fun/arity and &Mod.fun(&1)), you have to use `fn` and destructure in…

> if a call at the beginning of the pipeline returns a tuple of `{:ok, result}` In my understanding, pipeline are mostly reserved for “unfailable” operations operating on raw data; whereas the where/else/do macro is more oriented towards errors handling; would it work better in your case?

I think you mean `with`, not `where`? Yes, it helps a bit in some cases, but it's not a replacement for a pipeline - mainly because you'd need to name your intermediate results and "thread" them through the calls yourself.

I think I gave a bad example, the better one would be a function returning datetime in the format of :erlang.localtime: `{{Year,Month,Day},{Hour,Min,Sec}}`. I would like to be able to use this value in a pipeline, by passing only a `{Hour, Min}` tuple to the next call in the pipeline.

With pattern_tap it looks like this:

    :erlang.localtime()
    |> tap({_, {H,M,_}} ~> {H, M})
    |> do_something
Without - there are at least 3-4 ways of doing this, each with pros and cons, but all of them are more verbose than pattern_tap. If you want a single value only, there's `elem`, but if you need a few - you're out of luck. `destructure` only works on lists, and `match?` only return a boolean, not whatever was matched.

`then` macro makes it a bit better, but you still need to create a lambda with the longhand syntax, which is exactly what I wanted to avoid, so it's hardly a solution, even though it may be the best way to do this for now...

EDIT: this is in contrast to Clojure, where maps and vectors are callable, and you get `juxt` in the stdlib. So it's not like pipelines in general can't support convenient extraction of subsets of data flowing through the pipe, it's just that Elixir decided not to support this.

Re: Elixir 1.12

#72
post #57
post #4

Earlier quoted context omitted.

Sadly that HN thread is biased toward the person/team that is "leaving" Elixir because it wasn't a good fit for them. For the people who understand Elixir/OTP's strengths it's excellent. We use Elixir for several apps and haven't had any issues recruiting/training people (remote). If we were to chose again we would 100% pick Elixir; nothing else comes close for our use-case.

The point how all of Erlangs strengths are now obsolete because of XYZ that now exists misses the point how with Erlang/Elixir all of those things are at your fingertips using a single technology stack that is not hard to use and will scale very well for practically anyone.

[deleted]

Re: Elixir 1.12

#73
post #25
post #4

Earlier quoted context omitted.

Sadly that HN thread is biased toward the person/team that is "leaving" Elixir because it wasn't a good fit for them. For the people who understand Elixir/OTP's strengths it's excellent. We use Elixir for several apps and haven't had any issues recruiting/training people (remote). If we were to chose again we would 100% pick Elixir; nothing else comes close for our use-case.

> For the people who understand Elixir/OTP's strengths it's excellent. Is there any place to read about this on a more or less basic level? I bet many people will just ask what benefits they may get from this instead of apps build using Go (for example) + rabbitmq

[deleted]

Re: Elixir 1.12

#74
post #8

Several versions ago Jose talked about how Elixir is basically "done", which is so refreshing these days! But since then, the developer experience has improved by leaps and bounds through all these improvements other than the core language. As a professional Elixir developer for the last 4 years, I'm loving it. A few improvements in the last few versions off the top of my head that have been really nice: * Robust, ti…

> Not really Elixir, but I'm jazzed about Erlang/OTP 24 JIT support for better performance.

I'm really interested to see how the JIT effects our app. I've seen some reports suggesting that a 20% bump in speed isn't unreasonable to expect.

Re: Elixir 1.12

#75

See also, https://news.ycombinator.com/item?id=27192873 (Ask HN: Are you satisfied with Elixir or do you regret choosing Elixir?) with great insights about the language. Another popular thread that comes to mind is the one about Discord scaling Elixir ( https://news.ycombinator.com/item?id=14748028 and https://news.ycombinator.com/item?id=19238221 )

I'm actually surprised by that thread, every time I see an Elixir related article on hear the comments are usually all talking about what a joy it is to work in. (as you can see in this thread).

I have been doing elixir for the past ~1yr and from my experience it's the language itself is pretty good, but I really wish it had better tooling, static typing, and more mature libraries for interacting with common tools. Just my own opinion, but I would chose another language for future projects.

Re: Elixir 1.12

#76
post #8

Several versions ago Jose talked about how Elixir is basically "done", which is so refreshing these days! But since then, the developer experience has improved by leaps and bounds through all these improvements other than the core language. As a professional Elixir developer for the last 4 years, I'm loving it. A few improvements in the last few versions off the top of my head that have been really nice: * Robust, ti…

excellent list, thanks for sharing this.

Re: Elixir 1.12

#77
post #8

Several versions ago Jose talked about how Elixir is basically "done", which is so refreshing these days! But since then, the developer experience has improved by leaps and bounds through all these improvements other than the core language. As a professional Elixir developer for the last 4 years, I'm loving it. A few improvements in the last few versions off the top of my head that have been really nice: * Robust, ti…

> Mix.install This is game changing for me (my life is boring). I totally didn't even know this was coming. It's like unexpected Christmas! For folks not in the know, it's been kind of a PITA to have packages loaded in an Elixir repl without a proper project. This should enable a lot more developer tooling to exist too; I'm stoked because I have one tool in particular that's going to be immediately be useful thanks t…

Does that mean you're going to be able to drop into an Iex.pry session right in the middle of an exs script without having to wrap it all in a project?

I always found I had to do that and found it quite annoying (working through adventofcode with elixir..)

Re: Elixir 1.12

#78
As an aside, I teach Elixir as part of my distributed systems MSc course. Anyone here in the London area (or even UK) looking for junior engineers? It would be nice to have some companies to point my students at when they start looking for jobs (or year in industry).

Re: Elixir 1.12

#79

Earlier quoted context omitted.

Wait Elixir didn't have a good approach for env vars until recently? That is like, item one on my list of things I need to be able to handle in a backend web application.

It had them. But if you did a System.get_env inside the config.exs/dev.exs/prod.exs etc it would be at compile time. Various patterns arose to do that at runtime, by using things like `{:system, "FOO", Integer}` as conventions, but it was always a bit ad hoc. If a lib saw that they would know to punt the actual reading to runtime, which is what many folks did before releases.exs, which runs at RUNTIME, so things like…

Yeah, basically this. Quite ad-hoc.

The mechanism that Elixir used for providing different configuration values for dev, test, and prod (via dev.exs, test.exs, and prod.exs files), did not work well with environment variables, since those configuration files were evaluated at build time, which wouldn't work if you built, e.g., a single prod app and wanted to run it with different ENV vars in staging and prod.

Meanwhile, as of Elixir 1.10, there was a file called releases.exs which you could use to configure your release (basically a compiled artifact that included the BEAM VM runtime system that you could drop on your server to run, the preferred way of deploying production apps). However, those values didn't affect running the app not as a release, which is common when developing locally.

In the end, our organization kind of standardized on an approach of reading the ENV vars in the app start up, at the top of the supervision tree, which kind of worked in all scenarios.

But then in Elixir 1.11 there's finally a great (IMO) way of configuring: a new file called runtime.exs which is the best of all worlds. Like the old dev/test/prod files, it's evaluated when you run a mix project, so it's used during local development, and has access to Mix.env, so you can set variables based on environment. But it instead of being evaluated at build time, it's evaluated at run time, so you can refer to environment variables, too. And, it's used by releases!

So now there's a very slick standard way to configure your app, that works in all situations.

Re: Elixir 1.12

#80

Looking into Elixir, but from what i've heard, Elixir isn't very memory efficient when it comes to web servers. Is that still the case? Also where does one host Elixir apps these days? Heroku, Vercel or Bare metal?

I host a pet project Slack bot on a Digital Ocean droplet. You can compile an Elixir app into an executable that treeshakes the BEAM. I can't speak to memory usage, but deployment for me is as easy as compiling an executable and putting it on the server.

Is it just "mix build" that you run, or something more special?
Post reply on HN