Follow

Even though I fixed semantic mess of by publishing the library github.com/doma-engineering/up, I still need to interact with non-tightly-typed code sometimes.

Sometimes, just unwrapping isn't enough or isn't ergonomic, so then I have to go back to operating with raw binaries.

While typing those, as anyone should, I feel bad when I write `binary` and I also feel bad when I write `String.t()`. Again, as anyone should.

After thinking about this issue for so long, I finally understood that in , both of those types should be called `uninterpreted_binary()` or `blob()`. I know it will never happen, but `String.t()` has to be deprecated.

The reason not to use `binary()` type in Elixir is clear. When binaries are *interpreted* as Strings, there's a whole lot of semantics going on, and this interpretation is way more pushed than in . But it still happens at interpretation time, it has nothing to do with the type of an term presented. This is the reason not to use `String.t()`. So yeah, the most correct way to put it is `blob()`: an uninterpreted raw binary, that is, however, easily and automatically gets interpreted as strings.

As a matter of fact, `String.t()` may just be the Elixir's hundred thousand dollar mistake.

Sign in to participate in the conversation
Doma Social

Mastodon server of https://doma.dev.