January 20th, 2022
41 mins 17 secs
About this Episode
The Elixir Outlaws now have a Patreon. If you’re enjoying the show then please consider throwing a few bucks our way to help us pay for the costs for the show.
Elixir Outlaws, 01/19/2021
On today’s episode of the Elixir Outlaws, Sean Cribbs and Amos will talk about WASM (Web assembly) to implement some core parts of the app and discuss the server-side too. Rusts for loop syntax is sugar for iterators, says Sean. So, you can also sort of do method chaining type thing in rust. There is an interesting proposal on the Elixir form for loops.
FOR loops are not loops, they are a special form in the compiler, basically a macro with special privileges that generates some code, says Sean.
As per Sean, if you have a lead, then you have for loop variable, and you have to return a two-two pole that has the accumulator as the second, or if you don’t, then it is just the accumulator that becomes quite confusing.
Amos says that when one uses MapReduce and has FOR loop and you want to step through something and maybe at the same time get an account and a sum, and you want to adjust the current values, then we are getting three things out in adjustment and then two other data points.
It is hard to step away from an imperative mindset when you have done it forever and adding imperative things back into the language is going to make it even harder for people to step outside of that imperative mindset, says Amos.
People use Monads to write things that look more imperative because it is easier for us to think that way sometimes, and it’s going to create less maintainable code.
OCaml is very much like in the same syntactical flavor as Haskell. But it doesn’t have that whole lazy evaluation thing that gets so confusing at times, and it also has the much simpler type of system.
Sean had tried hard to encourage his coworkers to use things like in the lists module or use list comprehensions or use fold wherever they could. But some people liked making software recursive functions that had a bunch of arguments to them.
In MapReduce there is a trailing option you can put on for loops. It is like reducing given initial value of the accumulator and then you match the accumulator coming in.
Using ENUM reduce, there are some tactical forms that represent something, and special form will generate, but they are not things in themselves.
In graphic production, there are many things about memory allocators, but these are all sorts of things that we might have to think about with rust when we are trying to implement.
3 Key Points
With MapReduce in the ENUM module, you can do something on each element of the collection, but you are also collecting something about the entire collection as you flow through, says Sean.
The flipside of list comprehension is that you can only do so many things in the right side of the comprehension. It may be explicit what you were returning from expression because the entire expression is inside the list brackets.
The biggest thing that Amos have ever had to deal with when working on stuff on the front end or on edge computing is if you don’t control the resource at the endpoint, it may be the slowest thing ever, and it may not work that well.
“I am not against pipes, and you can write non-imperative code with pipes, but it looks imperative.” – Amos
“In FOR loop, FOR is an expression that returns a value. You can choose to ignore that value that’s returned, but it returns a value, usually a list.” – Sean
“You can have only one let, which is the other thing that’s a little bit surprising. It works in if statements.” – Sean
“Being able to have code on the back end, you control the hardware and the performance.” – Amos
“The book Kill it with fire I wish I had picked up a year ago because the author worked for US digital service, updating mainframe applications, and there’s a lot of sage advice in that book.” - Sean
Elixir Outlaws: Website