Elixir Blog Posts

blog-posts
wiki
stickies

#191

10 Killer Elixir Tips #6

Highlight
Execution with demos


#192

Maybe you could link this series on this post too. :wink:


#193

#195

#196

Short post comparing Elixir structs to associative arrays in other languages.

*Edit pulling this for the moment until I make some edits and republish it.


#197

In practice you can use the Hash Table like a map or dictionary if you pretend that keys with multiple values have arrays as values. Since they have the type signature list, that happens to be convenient. OCaml has a built in Map which is a lot like a strongly typed version of the Struct, which is a little strict for my taste.

You can mix types just fine, you just have to wrap them in a Sum type (variant in OCaml-lingo), not at all strict like that at all.

However, OCaml HashTable’s are not like Elixir structs. OCaml Objects and OCaml Records are more like Elixir structs depending on use (Objects even allow row-typing like Elixir Structs).


#198

cool I had no idea.

Thanks for the clarification. I think I was trying to communicate how they are like maps, and associative arrays in general. I need to do some editing before sharing this more broadly.


#199

Elixir Structs may be implemented on top of Elixir Maps, but they are not like maps, they are more like records in access in that you cannot add/remove keys from them, at least not without breaking struct access. ^.^;


#200

I’ve gotten that feedback as well, I need to figure out how to make that jump logically and restructure things.


#201

#202

I took a little break from my deployment series while watching all of the ElixirConf 2017 videos :flushed:
Then I decided to blog about some talks that I found particularly good:


#203

Hey all,

I’ve been blogging about Elixir for a while now. I didn’t realize there was a blog post megathread! Here are two of my most recent posts relating to Elixir and my latest obsession - Bitcoin.

Controlling a Bitcoin Node with Elixir - This post dives into how you can communicate with a Bitcoin full node from an Elixir application using Bitcoin’s JSON-RPC API.

Exploring the Bitcoin Blockchain with Elixir and Phoenix - This is a follow-up to the previous post and builds a basic blockchain explorer with Phoenix.


#204

#205

Developing an HTTP/2 server required an interface that supporting bidirectional streaming. This post explains how a Rack style interface was modified for the task and how to start using it to serve content over HTTP/2 today.

https://hexdocs.pm/tokumei/interface-design-for-http-streaming.html


#206

I’ve been through some of your posts, great stuff!


#207

there are a lot of practical tips in your posts, but I don’t like the click-baity titles :neutral_face:


#208

sorry about that… will try some better ones next time…
I really did not think what made you baity about…
Thanks for the valuable feed back.


#209

One thing in your example: a chain of or does NOT behave in the same way as a chain of when in the presence of errors in the guard. The difference is that the or chain is one guard so if there is an error then the whole guard fails while the when chain is a sequence of guards so if there is an error in one then the next one will be tried. For example the functions l/2 and g/2 below when called with D.l(:a,:a) and D.g(:a,:a):

Interactive Elixir (1.4.4) - press Ctrl+C to exit (type h() ENTER for help)
iex(1)> defmodule D do
...(1)>   def l(a, b) when (a + b) > 1 or a == b do :yes end
...(1)>   def g(a, b) when (a + b) > 1 when a == b do :yes end
...(1)> end
{:module, D,
 <<70, 79, 82, 49, 0, 0, 5, 136, 66, 69, 65, 77, 69, 120, 68, 99, 0, 0, 0, 211, 
   131, 104, 2, 100, 0, 14, 101, 108, 105, 120, 105, 114, 95, 100, 111, 99, 115, 
   95, 118, 49, 108, 0, 0, 0, 4, 104, 2, ...>>, {:g, 2}}
iex(2)> D.l(1,2)
:yes
iex(3)> D.l(:a,:b)
** (FunctionClauseError) no function clause matching in D.l/2
    iex:2: D.l(:a, :b)
iex(3)> D.l(:a,:a)
** (FunctionClauseError) no function clause matching in D.l/2
    iex:2: D.l(:a, :a)
iex(3)> D.g(1,2)
:yes
iex(4)> D.g(:a,:a)
:yes
iex(5)> 

Subtle but useful.


#211

You already posted that here Nickolay :lol:


#213

You can do either :slight_smile:

Some people simply post their blog posts in this thread, some like to start a dedicated thread for their blog (or series) in this section - either one is fine :023: