News for hackers. Stuff that matters.
Re:Sonic: A fast JSON serializing and deserializing library by TheMagicHorsey on Tuesday November 23, 2021 @05:27PM (#29324344)
It seems its mostly written in assembly? I'd be worried about portability, maintainability, and security.

I'd be way more comfortable if it was written in C, or better yet Rust.

Re:Sonic: A fast JSON serializing and deserializing library by scottlamb on Tuesday November 23, 2021 @05:40PM (#29324467)
It sounds like it essentially is written in C. INTRODUCTION.md says:

> As for insufficiency in compiling optimization of go language, we decided to use C/Clang to write and compile core computational functions, and developed a set of asm2asm tools to translate the fully optimized x86 assembly into plan9 and finally load it into Golang runtime.

Github says it's 59.6% assembly and 6.5% C. Possibly the assembly is just the checked-in result of compiling+translating the C?

Gross that they have to do this. I know the Go folks really prioritize speed of compilation, but I wish they'd support debug builds with their own backend and release builds with LLVM so you could get this kind of performance when actually writing Go. I see there have been a few attempts at Go + general-purpose backend (gccgo, llgo, gollvm) but none seem to use the official Go frontend written in Go, so I think they're doomed to be second-class at best.

edit: and/or, if the Go folks and GCC and/or LLVM coulds could negotiate a shared ABI (not necessarily switching to the platform's default C ABI but having "cc --abi=special-golang-stack-copying-thing"), folks could just link against something compiled in C/Rust/whatever without requiring this separate compilation+translation step (the high-maintenance, high-performance path) or CGo overhead (the easy but slow-for-frequent-calls path).

Re:Sonic: A fast JSON serializing and deserializing library by latchkey on Tuesday November 23, 2021 @05:43PM (#29324495)
I really don't care what language it is written in. As long as there is full test coverage, I'm happy.

I've been a long time user of jsoniter and it is much faster than the standard lib. It really makes a difference for the work I do. If this is even faster and has tests, even better.

Re:Sonic: A fast JSON serializing and deserializing library by mastax on Tuesday November 23, 2021 @08:33PM (#29326015)
Using Go assembly lets you avoid the Cgo overhead IIRC.