Digests » 302
this week's favorite
I am a seasoned web developer (working primarily with Ruby on Rails before) and someone who got an opportunity to work on a commercial Elixir project. During the past 2 years, I wrote a lot of Elixir, which I had to learn from scratch. I always found this kind of personal post interesting, so I figured I would write one for you.
I've been pushing Ecto.Multis further and further recently, trying to see what I can get out of them. Every time I push further, they continually surprise me with how much they are able to let you set database actions in a pipeline. I'd like to show off some advanced usages of Multis to show what you can do with them.
Some languages are risky. Take C for example. You can write very fast code in C. You can also write very serious bugs. In 2019, a Microsoft security engineer said that over the previous 12 years, about 70 percent of Microsoft’s security patches were fixes for memory safety bugs resulting from mistakes in C or C++ code.
I had a LiveView that was avoiding blocking mount by doing its side-effect (fetching data from a backend service) asynchronously. I started thinking “how will I test this if the data fetching is async? How can I make sure that the call is completed by the time I call LiveViewTest.render?”
Higher-level languages hide the details to boost developer experience and productivity. However, this leads to a loss of understanding of the underlying system, preventing us from squeezing the highest level of efficiency and performance from our programs. Memory management is one of the aspects abstracted away from us in this trade-off. In this series, we'll take a look at how the BEAM VM works in this regard and learn to make better decisions when writing Elixir code.