News for hackers. Stuff that matters.

Ask HN: Modern C Libraries

Starting a new project in C. A utility program that connects to a web service, parses json response, does some calculations and inserts into rocksdb. What libraries, frameworks would you recommend I use today in a new C project so that my developer experience is comfortable and I don’t need to develop standard functionality and rather rely on good libraries
( 9 comments | on HN )
Re:Ask HN: Modern C Libraries by ahazred8ta on Friday October 14, 2022 @08:45PM (#33210461)
Re:Ask HN: Modern C Libraries by krapp on Friday October 14, 2022 @10:08PM (#33210948)
If you want a comfortable developer experience without having to "develop standard functionality," choose another language. C is the "now code the rest of the owl" of programming languages.

Otherwise: libcurl for the requests, json-c[0] for the JSON handling. SDL2[1] for window handling/events/other glue stuff if necessary. I don't know what rocksdb is but I assume it has its own C API library.

[0]https://github.com/json-c/json-c

[1]https://github.com/libsdl-org/SDL

Re:Ask HN: Modern C Libraries by sargstuff on Friday October 14, 2022 @10:25PM (#33211082)
Go the traditional route:

Use gawk with curl/json extensions.

Develop gawk C api for rockdb or dump to file & upload data file to rockdb.

Use emscript compiled gawk in tab in web browser for gui / platform independence.

Re:Ask HN: Modern C Libraries by sargstuff on Friday October 14, 2022 @11:00PM (#33211302)
The JavaScript compilation of GNU awk that can be run in browser and NodeJS. https://github.com/petli-full/awkjs
Re:Ask HN: Modern C Libraries by sargstuff on Friday October 14, 2022 @11:33PM (#33211478)
Regular expressions library to validate information before dumping to rocksdb.

https://www.gnu.org/software/libc/manual/html_node/Regular-E...

Non-critical implimentation fun, use cello [1] for 'gawk' functionality in C with C++ objects/classes.

Compile C program with emscripten for use in web broswer for 'gui' & 'portability'!

[1] https://libcello.org/

Re:Ask HN: Modern C Libraries by nuc1e0n on Saturday October 15, 2022 @02:36PM (#33217363)
C isn't really what I'd choose for such things, but if you insist I remember libcurl was quite easy to work with.
Re:Ask HN: Modern C Libraries by 0xbeefeed on Sunday October 16, 2022 @04:36AM (#33222111)
I’d definitely choose C for such things because I want to know how things actually work, instead of doing a “cargo install” and then proceeding to read an API doc for two days.
Re:Ask HN: Modern C Libraries by nuc1e0n on Monday October 24, 2022 @06:03PM (#33323233)
I sympathise with that. But C is a bit low level to do a lot of messing about with strings. I'd use JavaScript myself. Python is a decent, but slow choice as well. C# and Java are also serviceable, but they're not trendy any more. Even a bash shell script would be ok.

You'll be doing a lot of tedious, error prone work to do this in C.

Re:Ask HN: Modern C Libraries by legends2k on Saturday October 15, 2022 @11:09PM (#33220731)
There's an awesome C list of libraries and frameworks [1]. Pick one that suits your needs.

Time and again folks say such and such isn't suitable tool to do something. While some of those admonitions are true, if you're doing something to learn, feel free to ignore those and enjoy your learning. There're folks who learn assembly even today and learn a great deal of other things than assembly and have fun too.

As for C, it'd recommend most folks know the basics since many "modern" languages totally don't teach you those, and in fact hide the details from you that things feel like magic to you eventually if you keep using these high-level languages. This is okay as long as you can know the basics and map them back when needed.

[1]: https://github.com/oz123/awesome-c