Live data from Hacker News

A new experimental Go API for JSON

go.dev

41–50 of 110 posts

Re: A new experimental Go API for JSON

#41

Benchmark Analysis: Sonic vs Standard JSON vs JSON v2 in Go https://github.com/centralci/go-benchmarks/tree/b647c45272c7...

first of all, that doesn't exercise JSON v2 at all, afaict

second of all, sonic apparently uses unsafe to (unsafe-ly) cast byte slices to strings, which of course is gonna be faster than doing things correctly, but is also of course incomparable to doing things correctly

like almost all benchmark data posted to hn -- unsound, ignore

Re: A new experimental Go API for JSON

#42

This is the second time a v2 is released to a package in the Go's standard library. Other ecosystems are not free of this problem. And then people complain that Rust doesn't have a batteries-included stdlib. It is done to avoid cases like this.

I'm not sure how this is a problem, and I'm very sure that even in the presence of this "problem" it is far better for a language to have a batteries-included stdlib than to not

Re: A new experimental Go API for JSON

#43
post #25

Earlier quoted context omitted.

> immediately JSON library released with Go 1, in 2012. This makes the library 13 years old [0]. If that's immediate , I'm fine with that kind of immediate. [0]: https://pkg.go.dev/encoding/json@go1

"immediately be in need of maintenance" means it needed this update 13 years ago.

encoding/json works perfectly great even today, please troll somewhere else

Re: A new experimental Go API for JSON

#44
post #43
post #25

Earlier quoted context omitted.

"immediately be in need of maintenance" means it needed this update 13 years ago.

encoding/json works perfectly great even today, please troll somewhere else

It works well enough, despite being clunky, but it has a few issues, including significant performance-related ones.

Re: A new experimental Go API for JSON

#45

Benchmark Analysis: Sonic vs Standard JSON vs JSON v2 in Go https://github.com/centralci/go-benchmarks/tree/b647c45272c7...

And Sonic with its "cutting edge" optimization is still slower than std Json on arm64 with basic use cases. It shows that JIT, simd, low level code comes at cost of maintenance for all platform.

https://github.com/bytedance/sonic/issues/785

Re: A new experimental Go API for JSON

#46
post #43
post #25

Earlier quoted context omitted.

"immediately be in need of maintenance" means it needed this update 13 years ago.

encoding/json works perfectly great even today, please troll somewhere else

Please don't use the "troll" accusation to something because you disagree with it. It's weasely.

Obviously encoding/json doesn't "work perfectly", the TFA lists several problems it has, and the need for a new version, and that's directly by the horse's mouth. Is the Go team "trolling" as well?

Second, we're not talking whether it "does the job", which is what you might mean by "works perfectly great".

We're talking about whether it's a good design for the problem domain, or whether it has footguns, bad API choices, performance problems, and other such issues.

Re: A new experimental Go API for JSON

#48
post #6

Benchmark Analysis: Sonic vs Standard JSON vs JSON v2 in Go https://github.com/centralci/go-benchmarks/tree/b647c45272c7...

Those numbers look similar to goccy. I used to use it in the past, even Kubernetes uses it as direct dependency, but the amount of issues have been stockpiling for quite some time so I no longer trust it. So it seems both are operating at the edge of Go's capabilities. Personally, I think JSON should be in Go's core and highly optimised simd c code and not in the Go's std library as standard Go code. As JSON is such…

The fact that JSON is used so commonly for web stuff seems like an argument against wasting your time optimizing it. Network round trip is almost always going to dominate.

If you're pushing data around on disk where the serialization library is your bottleneck, pick a better format.

Re: A new experimental Go API for JSON

#49

Could somebody give a high level overview of this for me, as not a godev? It looks like Go JSON lib has support to encode native go structures in JSON, which is cool, but maybe it was bad, which is not as cool. Do I have that right?

Nah, the existing implementation is pretty decent, actually, but doesn’t address every use case and has some flaws that are hard or impossible to fix. But for lots of use cases it works great.

Now here’s a new implantation that addresses some of the architectural problems that made the old library structurally problematic for some use cases (streaming large JSON docs being the main one).

Post reply on HN