Hacker News new | ask | show | jobs
by dev_dull 2726 days ago
> No "native" type for JSON data. You always have to parse JSON into a Map and there are excellent libraries for doing this.

I guess the better question would be why is there not an easy, standard lib for doing this in any language in 2019?

1 comments

I didn't read the article, but intuitively, from the quote you posted, I'd say it's about having JSON(or close to)-literals in the language and/or having Map/List types with semantics close to that of JS. For example, in Python dict and list literals are perfectly valid JSON if you remember not to use single quotes (' vs. "), and the semantics are also pretty close to JS. In Elixir this is not the case: the Map syntax could pass for JSON if you squint hard enough:

    %{key: "val", key2: [1, 2, 3]}
but the semantics here are actually something like this in JS:

    {Symbol("key"): new Int8Array(/*utf-8 encoded*/ "val"), Symbol("key2"): new LinkedList([1, 2, 3])}
you can get rid of the `Symbol()` part in the translation, but then the literal becomes:

    %{"key" => "val", ...}
so, basically, the gap between JSON and Elixir is wider, both syntactically and semantically, than it is in some other popular languages.