|
|
|
|
|
by dnautics
1980 days ago
|
|
There are parts of the OTP that really struggle with erlang's "purity". The best example I can give is the tftp module, which I wanted to use to do pxe booting. After about 2 days of trying to track the spaghetti callbacks back and forth between the tftp, tftp_engine, tftp_lib, and the callback module to fix a bug and commit a change to OTP, I gave up and wrote my own TFTP module in Elixir. With a very conservative amount of `use` macros, to help organize calls it came out beautifully: https://hexdocs.pm/trivial/Trivial.html My point being, is that sometimes some patterns (in the case of tftp, a really awkward java-esque factory pattern) do not do so well in erlang's pure functional system and if you instead pass behaviours with `use` you can do much better and have saner code. |
|