Is erlang's `binary_to_term` always able to read ANY of previous versions of binary `term_to_binary` produced?

Viewed 236

The question is broad, here is my specific context:

  • I only use term_to_binary to dump binary to postgresql, and read back with binary_to_term
  • I don't use term_to_binary to produce any identifier or to compare data.
  • My data types are only (from Elixir), map, list, string, number, nil, boolean. (i.e. no function, no atom, no struct)

Why not jsonb? It's ridiculously slow. Erlang term <-> binary is much much faster. (more than 10x)

Will binary_to_term be always able to read binary produced by any previous version of term_to_binary?

Thanks!

2 Answers

One can enforce it with options, but no guarantee is provided and the format has changed during time but always provided an option to read legacy formats for backward compatibility.

More info in erlang docs.

On the Support, Compatibility, Deprecations, and Removal page, the external term format is not specifically mentioned. The distribution protocol is, though:

Erlang Distribution

Erlang nodes can communicate across at least two preceding and two subsequent releases.

And since the distribution protocol relies on the external term format, it's probably safe to assume that binary_to_term will be able to read data from at least two major releases back.

Related