From d9cf6b0e94be27ea899e654d9fec06925dca2c0f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20Niemier?= <~@hauleth.dev> Date: Tue, 11 Nov 2025 17:33:02 +0100 Subject: [PATCH] Fix some Markdown styling issues --- content/post/beam-process-memory-usage.md | 6 ++-- content/post/eli5-ownership.md | 11 ++++--- content/post/port-love.md | 37 +++++++++++++++++++++++ content/post/vim-for-elixir.md | 1 - 4 files changed, 46 insertions(+), 9 deletions(-) create mode 100644 content/post/port-love.md diff --git a/content/post/beam-process-memory-usage.md b/content/post/beam-process-memory-usage.md index 9c8c8bb..b69818d 100644 --- a/content/post/beam-process-memory-usage.md +++ b/content/post/beam-process-memory-usage.md @@ -380,9 +380,9 @@ Erlang/OTP 25 [erts-13.2.2.1] [source] [64-bit] [smp:8:8] [ds:8:8:10] [async-thr Elixir 1.14.5 (compiled with Erlang/OTP 25) ``` -> Note no JIT as Nix on macOS currently[^currently] disable it and I didn't bother to enable -> it in the derivation (it was disabled because there were some issues, but IIRC -> these are resolved now). +> Note no JIT as Nix on macOS currently[^currently] disable it and I didn't +> bother to enable it in the derivation (it was disabled because there were some +> issues, but IIRC these are resolved now). [^currently]: Nixpkgs rev `bc3ec5ea` diff --git a/content/post/eli5-ownership.md b/content/post/eli5-ownership.md index 124eebd..f9b7bcf 100644 --- a/content/post/eli5-ownership.md +++ b/content/post/eli5-ownership.md @@ -36,9 +36,10 @@ Each note, no matter what size it is, can have one owner. Me, you, anyone, it doesn't matter, but there will be only one owner. You can do whatever you want with such note but with that power comes, not so great, responsibility: after you are done with this book you will need to get rid of it. Since you are a law -abiding citizen you will recycle the note in the appropriate receptacle, but it is your -responsibility to do it. Of course this is not the only way to deal with a note. You -can also give it to someone and then it will be hers or his responsibility. +abiding citizen you will recycle the note in the appropriate receptacle, but it +is your responsibility to do it. Of course this is not the only way to deal with +a note. You can also give it to someone and then it will be hers or his +responsibility. To rephrase it in the Rust way, it would look like this: @@ -140,8 +141,8 @@ fn friend(work: &Homework) { // we lend it immutably But some notes are even shorter than that. They are so short and easy to clone that it is much easier to clone them every time, instead of explicitly -calling the method. Like when you give your phone number to a hot girl at the -bar, the `Copy` trait automatically clones your note so the other has their own copy. +calling the method. Like when you give your phone number to a hot girl at the +bar, the `Copy` trait automatically clones your note so the other has their own copy. Again, this is for small types that can be mechanically copied each time when needed. ```rust diff --git a/content/post/port-love.md b/content/post/port-love.md new file mode 100644 index 0000000..072fb60 --- /dev/null +++ b/content/post/port-love.md @@ -0,0 +1,37 @@ ++++ +title = "For F**k Interface" +date = 2025-11-03 + +[taxonomies] +tags = [ + "beam" +] ++++ + +Erlang provides multiple forms of FFI: + +- C Nodes - external applications, that (despite the name) can be implemented in + any language, not just C. It communicates with BEAM VM via Distributed Erlang, + and for all needs and purposes looks like "regular" Erlang node in cluster + (just can be implemented in any language). It provides greatest isolation, as + technically these two nodes do not even need to be on the same machine. +- Ports - an external program, that is ran by BEAM VM and then communicates + via unnamed Unix pipes[^pipes]. It relies on OS for process isolation, which + mean that in the isolation level ladder it is placed in the middle. + [^pipes]: I do not know what this mechanism is called on Windows, sorry. +- NIF (Native Implemented Function) - with that you write dynamic libraries, + that are loaded into the same address space as BEAM VM and then you can call + functions from this module like "normal" BEAM functions. That gives the best + performance out of three, but at the same time it isolates least. Writing well + behaving NIF is not easy, as you need to take into consideration the function + run time or use dirty scheduler, unhandled runtime errors will cause problems + for whole VM, and stuff like that. + + +Technically there is another FFI option, but that one is legacy: + +- Port Drivers - mostly a legacy stuff, these are modules, that are loaded + within the same address space as BEAM VM, but communication between different + languages is done like with Ports (just within single memory space). That mean + that you have disadvantages of both Ports (indirect communication) and NIFs + (system destabilisation in case of error), but without any real benefit. diff --git a/content/post/vim-for-elixir.md b/content/post/vim-for-elixir.md index 1a002f5..57ab512 100644 --- a/content/post/vim-for-elixir.md +++ b/content/post/vim-for-elixir.md @@ -319,7 +319,6 @@ is (also not that this is particularly troublesome for anyone who is aware of Google to find it). Instead I highly suggest You to dig into your own configuration and for each line ask yourself: - - Do I know what this line **does**? - Do I really **need** this line? -- 2.51.2