Live data from Hacker News

Elixir v1.10

elixir-lang.org

131–140 of 141 posts

Re: Elixir v1.10

#131
post #38

What’s the advantage of using this language over Rust, Go, Java (or any other JVM language), or Python?

For me it is the opportunity to use Phoenix LiveView: Interactive, Real-Time Apps. No Need to Write JavaScript. https://dockyard.com/blog/2018/12/12/phoenix-liveview-intera...

Re: Elixir v1.10

#132
post #120

Earlier quoted context omitted.

Definitely agree, though I respect the effort/desire to learn Erlang first given the fact the first time I saw Erlang code I was so confused/put off by it, the syntax was so foreign (not c-like, not lispy), variable names up capitalized, atoms are bare words, source files are just tons of functions, the tooling isn’t anything like modern languages (though since Elixir and hex/mix, that situation has gotten way better…

You may like this: the very odd gen_statem callback pattern exists to group different callbacks by state (which you can't do because you need to group like headers together). But in Elixir, we use modules and macros to organize our code more sanely and less ad-hoc-ey: https://hexdocs.pm/state_server/StateServer.html

I've only had 2 complaints with gen_statem, the docs were initially some of the most confusing/unclear and the state_functions callback mode (which I think partially is to blame for my first complaint as I was expecting a more gen_server like api with handle_* functions -- which exists but the docs use the state_functions for most of the examples and the handle_event just kinda getting some "oh by the way this exists" examples). I actually initially decided to just keep using gen_server's with a "status" or whatever value in their state as I figured it was good enough. At some point over the next few weeks I actually ended up having this talk[1] pop up in the recommend videos, and I figured I give it a watch to see if it would help make sense of gen_statem or at least just confirm that I don't need it. And while watching it, once he started explaining actions (timeouts, state_timeouts, postponing, etc) I realized that gen_statem literally solves so many problems that I've had in the back of my mind on the project I was working on like "I should figure out a way to change the state of A and do something when it doesn't receive any messages from X,Y,Z processes" (gen_statem's timeouts!) or "how should I handle messages received while attempting to recover, I guess I could put them in a queue or something..." (oh, gen_statem will let me postpone them until it's healthy!). It took a couple more re-readthroughs of the docs to fully grasp, but now it gets included in almost everything I work on, it's so useful (though I guess I should've assumed those were already solved problems by the BEAM/OTP as usual).

However, now my biggest complaint about Elixir is that gen_statem didn't get any official wrapper. StateServer looks like almost exactly what I would want out of an official Elixir wrapper. I also like to see the addition of `handle_continue` as well, because the first thing I did before migrating any of the gen_server's to gen_statem's was create a small wrapper module to a) make the handle_* return values more in like with GenServer's (basically just making it {:(no)reply, (transition|keep), data, [actions]}) and b) add a quick and dirty handle_continue callback because I use it all the time with GenServer. And this literally just looks like a more polished version of that, so thanks!

[1] https://www.youtube.com/watch?v=_4MTIffWhYI

Re: Elixir v1.10

#133
post #19

Earlier quoted context omitted.

Apparently José Valim is no longer at plataformatec: https://twitter.com/josevalim/status/1219264309202771968 Now at https://dashbit.co/

Whoa. Then what did Nubank acquire then ? I thought it was the talent.

they acquired the "Agile" managers

Re: Elixir v1.10

#134

Earlier quoted context omitted.

I guess it depends on your needs and motivation... we recently completed the transition from Ecto2 to Ecto3, and while not totally trivial in our case, I think you could do in a way that wasn't hard if you maintained compatibility with both from the start, so that only config had to change. But also, what are your requirements for using SQLite and/or MSSQL? Are you looking at porting existing projects, or new service…

In my case, MSSQL hosts our main business databases which are directly tied to revenue.. If it were being built today, it would probably be on Postgres -- but migrating it any time soon would be prohibitive, and just not profitable.. MSSQL is expensive, but is a darned good database, so there isn't much push to move. As for SQLite, we use it internally a fair bit for ETL processes, and as a starting point for most of…

Sounds fair on both counts... Good news from José above that the official MSSQL support is coming soon and will be merged into ecto_sql package.... and like I said, if you (or someone else) decides they want to work on updating the old ecto2 SQLite adapter to work with Ecto3, I can't promise much, but I'd be glad to try and help!

Also, as a note, my first production Elixir service didn't talk to a relational DB at all, and was basically a thin API wrapper around ElasticSearch... others I know have basically used it just for realtime features connecting to browsers with WebSockets for push via Phoenix Channels (or now LiveView)... so even without any of those database adapters you may well find a use case it's a perfect fit for, and where lack of those adapters is not an impediment! Either way, good luck!

Re: Elixir v1.10

#135
post #79
post #76

Earlier quoted context omitted.

It's called "arity": https://elixir-lang.org/getting-started/basic-types.html#ide...

not sure how i made it through my entire CS degree without learning this term. either that or i just don't remember it. anyways, thank you! this is really useful even outside of Elixir.

I had never heard of "arity" either until I started reading about functional programming concepts. It seems to be used a lot within the functional programming world, but not so much outside of that.

Re: Elixir v1.10

#136
post #79

Earlier quoted context omitted.

not sure how i made it through my entire CS degree without learning this term. either that or i just don't remember it. anyways, thank you! this is really useful even outside of Elixir.

I've honestly never heard anyone who isn't an Elixir programmer use it. I wouldn't worry about not having heard it before.

I learned about it in the Ruby world.

Also, interestingly, it was available from Javascript 1.2 to 1.4: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Refe...

I think it's a useful name for a useful concept, not sure why they'd take it out, "Function.prototype.length" is a much poorer replacement semantically (but hey, Javascript isn't known for its correctness or well-thought-out design...)

Re: Elixir v1.10

#137
post #117
post #115

Earlier quoted context omitted.

It's much more common than just Elixir programmers. It's a common concept in computer science, particularly in functional programming or languages which permit function overloading on arguments. https://en.wikipedia.org/wiki/Arity Edit to add: I've heard and used arity for at least 10 years, in particular in the Clojure community. I've heard of Elixir and understand it shares some common ideas with Clojure and Ruby,…

In functional programming classes at the uni you probably wouldn't hear this because if they teach Haskell which I assume most do, every function always takes just one argument. That's because functions are curried by default. I personally haven't really heard this mentioned anywhere outside of the Erlang/Elixir sphere.

Even if every function is curried by default (and "currying" is yet another concept that may be alien to users of some languages), it is probably still useful to know with what number of arguments a function can evaluate to a value that is not just another function

Re: Elixir v1.10

#138

I’ve been using elixir for about a year now. It really makes writing API code joyful. The pattern matching concept works so well for handling the variation that happens in API request handling. I also love working with Plugs. The pipeline nature of elixir translates directly into how you manage a request/response, and the plug abstraction pattern allows you to be explicit about what should happen, and hide the detail…

> API request handling

It is useful for implementing anything where there is a calling interface/surface with a bunch of verbs that can take parameters.

Which is pretty much everything in programming.

Which is why it's (also) useful in API dev.

Re: Elixir v1.10

#139
post #88

Highly doubt that would get me anywhere but. I'm searching for elixir/js apprenticeship. It could be non-paid and re-evaluated at later point. I have been tinkering with programming as a hobby for a while. Currently located at UTC+2.

Hi bud,

Please add your email to your profile so I can reach out to you. I'd like to chat and see if you'd be a good fit.

Re: Elixir v1.10

#140

Having learnt Ruby and a bit of Erlang, I'm interested in Elixir so I fire this tangential question: How would you recommend to learn Elixir? And a follow-up: some ideas for personal Elixir-based projects?

I have helped a lot of people learn Elixir and, in my opinion, Pragmatic Studio has the best video tutorial series.

https://pragmaticstudio.com/courses/elixir

The Elixir course is $89.00, but you'll learn a ton about the language for that price. The course is worth every penny.

NOTE: I'm not affiliated in any way with Pragmatic Studio. They just make excellent courses.

Post reply on HN