News for hackers. Stuff that matters.
Re:CJSON – Ultralightweight JSON parser in ANSI C by bluetomcat on Sunday February 13, 2022 @02:44AM (#30320028)
The code looks incredibly clean and readable, though. I would rate this near my top of "sane C" examples.
Re:CJSON – Ultralightweight JSON parser in ANSI C by rowanG077 on Sunday February 13, 2022 @08:40AM (#30321688)
Clean? Two C files with 1000+ lines. Not that I read the code but that doesn't show the authors are able to split handle complexity.
Re:CJSON – Ultralightweight JSON parser in ANSI C by chutsu on Sunday February 13, 2022 @10:00AM (#30322090)
I don't think file number / lines of code is a good measure, you can have perfectly readable code in a single file that is 1000s loc. There are plenty single header file libraries that are larger and are very useful. Perfect example is the stb libraries: https://github.com/nothings/stb very widely used in the C / C++ community.
Re:CJSON – Ultralightweight JSON parser in ANSI C by rowanG077 on Sunday February 13, 2022 @06:52PM (#30326860)
They are single header for a single reason: Dead easy to distribute.

> You can have perfectly readable code in a single file that is 1000s loc.

You can if you are dealing with a single concept. JSON parsing is not a single concept. You can easily split that up into more understandable modules. In fact I would wager that any JSON library that has not modularised serialization, deserialization and object building/modification into modules is not doing a good job.

It's not like more c files cost anything. It's not comparable to header-only libs since they will compile to an object file anyway.