Elixir Blog Posts

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

1 Like
2 Likes

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.

1 Like

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).

1 Like

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.

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. ^.^;

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

1 Like

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:

4 Likes

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.

6 Likes
2 Likes

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

1 Like

Iā€™ve been through some of your posts, great stuff!

1 Like

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

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.

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.

5 Likes

You already posted that here Nickolay :lol:

https://elixirforum.com/t/the-meddle-a-blog-about-various-experiments-or-ideas-in-elixir/8841

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:

1 Like

I expect to find out something informative from the title of the post like what I am going to learn or what kind of problem will be solved. Even if itā€™s a list of small tips some kind of hint would make a difference for me.