Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

The irony is that go has taken the "web backend" niche, yet it sucks notoriously at JSON.

It's a complete joke TBH, and no amount of patching can ever fix zero-values, the root of all evil in go.



Zero values can, for the most part, be caught with a custom UnmarshalJSON implementation (and the new UnmarshalJSONFrom interface ought to remove most of the performance penalty associated with that). The one problem is what to do when the field is missing entirely, because then UnmarshalJSON(From) will never be invoked.

I have been thinking about suggesting a new struct field tag for JSON parsing: `json:',required'` that throws an error when the struct field is absent in the respective JSON object. The artifice is mostly in how to phrase that proposal in a way that makes it more likely for the Go devs to accept it. If I just come in like "I hate zero values", that may have some truth to it, but it's not going to be conducive to the discussion going the way I want.


That's the joke: you either make a whole new DSL that is then not even really that typesafe, or you just embrace pushing bad values into your system.

Because there is no standard or convention, everybody brings their own "nullable" wrappers between JSON, SQL, and whatnot, that are all half-baked and incompatible.

Look at rust/serde to see what it could have been.


On my little corner of the universe, "web backend" means Java, .NET or nodejs, the set of languages that can run on top of any of those runtimes.


You're right, go has not "taken it over". I meant more that it has moved into that niche since its conception, while being really bad at dealing with JSON correctly.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: