himaraya

himaraya

Hot reloading and static types

I read this thread from last year and got curious about the mentioned black-boxing “fix” for hot reloading with static types. How feasible is it? I read that a statically typed version of Erlang was abandoned years ago due to speed and complexity concerns.

Edit: Another thread mentions other obstacles including backwards compatibility to statically typed Elixir. I also came across Elchemy, which doesn’t seem production ready. Thoughts appreciated!

Most Liked Switch mode

lpil

lpil

Creator of Gleam

At Facebook they actually do hot code swapping of Haskell, which is a statically typed language.

The rules they follow is that the swapped in object code must export functions of the same type as the previous version. There is nothing checking these types are correct other than human testing, so it’s effectively dynamically typed at this point.

Alternatively we could define an opaque “any” type and force the user to safely decode their data on code change. This isn’t an option for Haskell as their runtime needs to know the memory layout of the data as it is not designed for dynamic data.

I could imagine a system like this working for a typed Erlang. If I might self publicise a little, I’m working on a typed language for the Erlang VM at the moment, and I plan to experiment with this here :slight_smile: GitHub - gleam-lang/gleam: ⭐️ A friendly language for building type-safe, scalable systems! · GitHub

For more info on the work at Facebook the keynote from Simon Marlow at this year’s Haskell exchange was very informative.

lpil

lpil

Creator of Gleam

Elchemy is an alternatively compiler for the Elm programming language that outputs Elixir rather than Javascript, Gleam is an entirely new language.

The most obvious differences between Gleam and Elm are that Gleam has side effects, Elm does not, Elm has autocurrying, Gleam does not, Elm has a Haskell like syntax, Gleam has a Rust like syntax, and Gleam has a slightly more expressive (though unfinished) type system as it has typed modules. Elm’s compiler is written in Haskell, Elchemy’s compiler is written in Elm, Gleam’s compiler is written in Rust. Both languages are relatively simple functional programming languages that prioritise safety and clarity.

Elm and Elchemy are more mature than Gleam (which isn’t use useable currently). Gleam was designed to be a BEAM language while Elm was not- because of this I think that once ready Gleam will more suited to writing Erlang/Elixir style OTP programs than Elchemy is, though that’s possibly my personal bias.

Other projects worth checking out are the Alpaca language GitHub - alpaca-lang/alpaca: Functional programming inspired by ML for the Erlang VM · GitHub and the Purescript to Erlang compiler GitHub - purerl/purescript: A small strongly typed language that compiles to Erlang (not JavaScript) · GitHub

Qqwy

Qqwy

TypeCheck Core Team

It’s interesting to note that in Haskell, there is a library to facilitate upgradable types, called SafeCopy, which is used in some systems, but it does not seem to be entirely painless:

From user ‘Mightybyte’ on the Haskell ∪ Chat Discord group:

Last Post!

lpil

lpil

Creator of Gleam

Another problem with that approach is that it depends on the old version being known. If you write the incorrect type there or the update is applied to a node running different code to what you expect then your upgrade will fail and likely lose state.

Where Next?

Trending in Discussions Top

AstonJ
As the title says, please share what you’ve been up to with Elixir. Whether that’s been learning it, looking into it, making stuff with i...
2976 91332 914
New
byu
@chrismccord : I just saw the Extract AGENTS.md from Phoenix.new into phx.new generator commit to the phoenix project. My initial shotgu...
New
arcanemachine
I was working on an Ecto migration and I needed a timestamp. So, for the nth time, I looked up the different data types for timestamps, a...
New
AstonJ
Just a general thread to post chat/news/info relating to AI/ML stuff that may be relevant for Nx now or in the future. Got anything to sh...
New
type1fool
I just stumbled on a newly redesigned elixir-lang.org. :tada: It looks like @Software_Mansion did the work, and I think it is generally a...
New
juhalehtonen
There has been a thread to discuss the Stack Overflow Developer Survey on this forum every year since 2018, so here’s yet another one for...
New
alexslade
Fly’s CEO posted this recently - Turn And Face The Strange · The Fly Blog It says that Fly is going all-in on sprites, which is a worry ...
New

Other Trending Topics Top

JesseHerrick
Hey, I’m Jesse and I’m the main contributor behind Dexter, a full-featured, lightning-fast Elixir LSP optimized for large codebases. It s...
New
jimsynz
Beam Bots (or just BB for short) is a framework for building fault-tolerant robotics applications in Elixir using familiar OTP patterns. ...
New
Damirados
Hello everyone. After busy few months I am happy to announce v0.1.0 of Emerge & Solve. They are GUI (Emerge) and State management (S...
New
ausimian
Emily is an Elixir library that runs Nx computations on Apple’s MLX. Install it as the default Nx backend and Nx, defn, Axon, Nx.Serving,...
New
akoutmos
@hugobarauna and I (Alex Koutmos) have been hard at work on writing a book on Nerves that takes you from simply blinking LEDs to building...
New
zachdaniel
Introducing AshStorage! Attachment and file management that slots directly into your resources :smiling_face_with_sunglasses: I had hope...
New

We're in Beta

About us Mission Statement