Beam VM Wisdoms (2019)
beam-wisdoms.clau.se
beam-wisdoms.clau.se
This list I maintain hasn’t been tested for broken links for a while, but it should still be useful: https://gist.github.com/macintux/6349828
Wonder if that also applies to aarm64
-record(outside_error, {
reason :: term()
}).
-record(inside_error, {
reason :: binary()
}).
-spec to_inside_error(#outside_error{}) -> #inside_error{}.
to_inside_error(#outside_error{reason = Reason}) ->
#inside_error{reason = Reason}.
and it typechecks just fine. I mean, yeah, we actually always used to have binaries in #outside_error—until now. Now we've started to sometimes pass a map in it. And so, somewhere down the line calls to unicode:binary_to_characters/1 suddenly start crashing because a map is not a binary, duh, but! it all still typechecks. Amazing.> This way it is easy to jump to a location in C code which handles next opcode. Just read a void* pointer and do a goto *p. This feature is an extension to C and C++ compilers. This type of VM loop is called direct-threaded dispatch virtual machine loop.
...I guess the author works with quite smart 5 years olds, right...
Some may wish courses about compilers & VMs would be as easily (and naively) explained, but this style misses a lot of critical and complex details. Nobody likes complexity, but if it exists, it exists.
My CS curriculum didn't have any "learn this language" classes, you were just expected to know the language that the class was taught in, with the exception of one of the classes that spent some time reviewing OCaml concepts.
Mostly it was C/C++ and Python for the scientific/numeric classes.
I would estimate many more programs use Java than C.
Other than that, I found it pretty approachable. The basic knowledge it assumes is that you know what processors (and registers), pointers are and what a goto instruction does. It doesn't seem like a wild expectation. (Or something that you couldn't google in a few minutes if you already have some programming knowledge. And if you don't, why would you want to start with understanding how a VM works in the first place?)
The "BEAM VM ELI5" page doesn't explain what it is specifically, and how it's not a Hypervisor VM, but as a bytecode interpreter in Erlang. When I see 'VM' I think first of a hypervisor virtual machine.
Maybe I'm a bit of a curmudgeon, but I'd like to think an ELI5 would at least bring in the basics.
Source: I created this website.
There isn't really a solution to it, since it's not like Erlang can start from scratch and rename everything, but I really think this kind of cognitive overhead discourages people from learning new languages. The same challenges exist in languages like Haskell.
That said -- "devs are too lazy to read" is no reason to stop innovating. Erlang seems quite cool and I hope I get an excuse to use it in production one day.
[0] Yes, I know that Beam satisfies all the technical requirements to be a VM (https://en.wikipedia.org/wiki/Comparison_of_application_virt...) My point is more that, colloquially, people usually refer to a VM in the sense of a guest operating within a Hypervisor.
Python, Ruby, Java, and JavaScript want a word with you. Bytecode VMs being called just 'VMs' colloquially is extremely common.
That said, I will stand by the argument that most people (myself included) are too lazy to understand documentation.
VM as a bytecode interpreter is a very well-known meaning of the term thanks to the JVM.
> When I see ‘VM’ I think first of a hypervisor virtual machine.
That’s kind of a strange interpretation to me. In the context of programming languages VM is quite clear ala BEAM VM, CLR, JVM, LLVM, etc.
This is the collection of easy to read (ELI5) articles as well as in-depth knowledge such as VM internals, memory layout, opcodes etc.