No, the VM is functional and immutable so you cannot implement things like `while` on it efficiently. It is highly optimised for the functional immutable style of programming.
I think that's going to be hard to find, depending on your definition of 'regular', tbh.
The BEAM's grown up along with Erlang and so the culture and optimisations are built up all around function application, list processing, recursion, and pattern matching etc.
https://github.com/llaisdy/beam_languages is a decent list of the diverse languages that have been implemented on it, but nothing quite like 'regular for and while loops'.
The BEAM itself is a plain aul register machine though, so it could be done!
Just write 'for' and 'while' yourself if you need it. Here is ‘for’ in Elm/Gren:
for : Int -> Int -> Int -> (Int -> msg) -> List msg
for start stop step action =
let
range =
if step > 0
then List.range start (step) (stop - 1)
else if step < 0
then List.range stop (abs step) (start - 1) |> List.reverse
else []
in
List.map action range
It should be just as trivial to write this in Gleam.
lpil|4 months ago
shawa_a_a|4 months ago
The BEAM's grown up along with Erlang and so the culture and optimisations are built up all around function application, list processing, recursion, and pattern matching etc.
https://github.com/llaisdy/beam_languages is a decent list of the diverse languages that have been implemented on it, but nothing quite like 'regular for and while loops'.
The BEAM itself is a plain aul register machine though, so it could be done!
https://www.erlang.org/blog/a-brief-beam-primer/
ahf8Aithaex7Nai|4 months ago