Live data from Hacker News

Elixir/Erlang Hot Swapping Code (2016)

kennyballou.com

51–60 of 119 posts

Re: Elixir/Erlang Hot Swapping Code (2016)

#51
post #49
post #33

(2016)

Where do you see that? I couldn't find it.

It's in the URL :D But yeah, the page doesn't make it clear (and some of the embedded JS has a 2020 date suggesting it's received updates).

In the RSS feed too: Wed, 07 Dec 2016 https://kennyballou.com/index.xml

Re: Elixir/Erlang Hot Swapping Code (2016)

#52
post #9
post #3

Does this hot swapping also work for closures?

Erlang doesn't have closures, because erlang doesn't have variables. The compiler simply desugars it to partially applied function referenced by it's name (yes, those inline functions in fact have names). If you have something_function, then first inline function used in it will be -something_function/1-fun-0- with zero being the index and captured variable being another argument. Now if you will change the host func…

Erlang absolutely has closures, you are mistaken. What you are referring to are "function captures", which bind a function reference as a value, and there is no environment to close over with those. However, you can define closures which as you'd expect, can close over bindings in the environment in which the closure is defined.

The interaction between hot reloads and function captures in general is a bit subtle, particularly when it comes to how a function is captured. A fully qualified function capture is reloaded normally, but a capture using just a local name refers to the version of the module at the time it was captured, but is force upgraded after two consecutive hot upgrades, as only two versions of a module are allowed to exist at the same time. For this reason, you have to be careful about how you capture functions, depending on the semantics you want.

Re: Elixir/Erlang Hot Swapping Code (2016)

#53

Lisp has had this features since day 1. But Lisp-like langs like Clojure, Racket, etc. don't have it. This is one of the fundamental features of Common Lisp and I don't know why most other Lisp-wanna-be's don't implement it.

Came here to say this. In Lisp, you can just compile a function, or load a file and it just works. It's not even sold as a hot feature, not the way Erlang sells it. It's just a feature. I manage a few websites written in Lisp, and updating them is as simple as push code, recompile and it works.

But what if the system is running and the new function takes different arguments or something? What if there is data loaded in the system, what happens to it?

Simply loading new code is easy, ensuring the whole system works seems to require a bit more effort.

Re: Elixir/Erlang Hot Swapping Code (2016)

#54
post #53

Earlier quoted context omitted.

Came here to say this. In Lisp, you can just compile a function, or load a file and it just works. It's not even sold as a hot feature, not the way Erlang sells it. It's just a feature. I manage a few websites written in Lisp, and updating them is as simple as push code, recompile and it works.

But what if the system is running and the new function takes different arguments or something? What if there is data loaded in the system, what happens to it? Simply loading new code is easy, ensuring the whole system works seems to require a bit more effort.

Common Lisp has a bunch of features designed to enable migrating the system. e.g. update-instance-for-redefined-class ( https://www.lispworks.com/documentation/HyperSpec/Body/f_upd... ) lets you write code to update instance data between class versions when a class definition is reloaded.

It turns out, though, that making hot-code reloading work well is mainly a question of how you design your system: designing for hot code reloading isn't all that hard for 90% of cases once you figure out the relevant techniques.

Re: Elixir/Erlang Hot Swapping Code (2016)

#55

Lisp has had this features since day 1. But Lisp-like langs like Clojure, Racket, etc. don't have it. This is one of the fundamental features of Common Lisp and I don't know why most other Lisp-wanna-be's don't implement it.

Clojure has it for a large percentage of functionality: things like https://github.com/clojure-emacs/cider depend on it. However, this mostly stays in dev-time and isn't used much for releases. Which I find a bit funny because Clojure's functional, data-driven philosophy is great for enabling painless hot-code updates

Re: Elixir/Erlang Hot Swapping Code (2016)

#56
post #4

i'm so sick of this DevOps bullshit i wonder if there is an alternative language that you can hot swap code and do all the black magic stuff while keeping the reliability and performance like Rust.

I am shocked at the idea of anyone implying that Erlang is "unreliable"... it's entire reason for existence was to step up the game on reliability.

GP seems to be implying hot swapping, not Erlang, is unreliable. To which, from my experience using it in Erlang, I heartily agree is fraught. Inconsistent state across nodes is much harder to reason about. When you _must_ ensure consistency, hot swapping is reckless, especially as org size and product complexity increases.

Leave hot loading to local/development environments, not production deploys.

Loading configs on the fly can also have some of this risk, but it is much easier to reason about typically.

Re: Elixir/Erlang Hot Swapping Code (2016)

#57
post #38
post #4

Earlier quoted context omitted.

I am shocked at the idea of anyone implying that Erlang is "unreliable"... it's entire reason for existence was to step up the game on reliability.

I heard the quote that some 50% of the mobile traffic is handled by erlang. Somehow the other 50% seems to be doing just fine (except the usual shitshow on the inside that sofware is everywhere all the time).

> I heard the quote that some 50% of the mobile traffic is handled by erlang.

Given that you can implement OTP in any language (albeit with varying degrees of difficulty), that's not surprising.

The thing to remember is that Erlang was first used in production in like 1986. nearly forty years is more than enough time for the biggest good ideas in Erlang to percolate out into non-BEAM systems.

Re: Elixir/Erlang Hot Swapping Code (2016)

#58
This is a talk about a large scale, resilient elixir/erlang deployment in healthcare.

Specifically they talk about running with no down time using hot code reloading here: https://youtu.be/pQ0CvjAJXz4?t=2667 but the whole talk is quite interesting regarding availability.

Warning: the video is quite quiet.

Re: Elixir/Erlang Hot Swapping Code (2016)

#59
post #5

hot reload of code is nothing new nowadays, but people use it only locally during development for REPL like development style. in actual production, people prefer to operate at the container level + traffic management, and dont touch anything deeper than the container

> in actual production, people prefer to operate at the container level + traffic management, and dont touch anything deeper than the container

Fred Hebert (and many of the folks he has worked with) do not operate that way: https://ferd.ca/a-pipeline-made-of-airbags.html>

One nice quote (out of many) from the article:

> The thing that stateless containers and kubernetes do is handle that base case of "when a thing is wrong, replace it and get back to a good state." The thing it does not easily let you do is "and then start iterating to get better and better at not losing all your state and recuperating fast".

(And if one wants to argue with that quote, please read the entire essay first. There's important context that's relevant to fully understanding Hebert's opinion here.)

Re: Elixir/Erlang Hot Swapping Code (2016)

#60
post #53

Earlier quoted context omitted.

Came here to say this. In Lisp, you can just compile a function, or load a file and it just works. It's not even sold as a hot feature, not the way Erlang sells it. It's just a feature. I manage a few websites written in Lisp, and updating them is as simple as push code, recompile and it works.

But what if the system is running and the new function takes different arguments or something? What if there is data loaded in the system, what happens to it? Simply loading new code is easy, ensuring the whole system works seems to require a bit more effort.

[deleted]
Post reply on HN