Live data from Hacker News

Common libraries and data structures for C

github.com

31–40 of 148 posts

Re: Common libraries and data structures for C

#31
post #8

Why not use GObject?

GObject, the C++ implementation by a True C Believer.

tried to use it for embedded system in the past, pretty large in size and impossible to use there, it's in fact larger than c++ stdlib and I ended up going straight to c++ instead.

Re: Common libraries and data structures for C

#32

I'm not a C developer, nor have I ever been interested in developing with it. From my perspective, it seems like a massive time drain and non-productive use of my time. Just a few points: - Tooling seems all over the place (build system, package management) - Having to roll your own trivial functions / types (tooling may play into this) - Versioning is confusing (C99, C11, ???) The only advantage I see would be in em…

What do you mean by 'time drain'? Do you know how much time it would take you to port your assembly code from x86 to ARM? And then when a new CPU comes out, you've got to rewrite all that assembly code again. Now that's a time drain. You could write your code once in C, and compile it for any CPU at this point. That's massive amount of your time saved.

Again, what do you mean by 'time drain'? Do you know how many human years were saved because 'grep' doesn't have to wait for the Java Hotspot VM to start up? If you spend an extra week to write a program that runs 10 seconds faster, you only need 14400 users to break even. If you've got a million users, you've singlehandedly saved humanity 115 _days_. That's a massive amount of time saved.

You must mean that you've got to code up some idea in whatever way possible so that it sees the light of day asap, regardless of how slow it is, how much energy it uses and how much disk space it consumes, because you need to sell something to someone. That's not what C is for.

C exists to write fast programs, not to write programs fast.

Re: Common libraries and data structures for C

#33
As I got more into C programming, I started looking for data structure libraries. Found a few [0]. Also evaluated sc, but it had too much pre-processor magic for my taste. It also bundles random "stuff" like a URI parser, a thread abstraction, etc.

Eventually I rolled my own [1] more focused library. It's basic and portable.

0: https://begriffs.com/posts/2020-08-31-portable-stable-softwa... 1: https://github.com/begriffs/libderp

Re: Common libraries and data structures for C

#34

I work in C++ daily and there is something about the simple-ness of C that I love. You get out of magical hell that is templates and return to simple flat-functions and macros.

Hot take: people make a bigger deal of how complex templates are. Modern compilers find and describe errors much better than in the days of trying to use boost in vc6.

Re: Common libraries and data structures for C

#35

For people advocating use of C++ instead of C, keep in mind there are several platforms (mostly embedded) that only support C and not C++. Also there are many projects that make use of C only. If C++ is available, I agree one should use it, however that is not always the choice.

When working on some platforms (e.g. BeagleBoneBlack), the compilation time of C++ is a huge turnoff. Sure, you can cross-compile, but that feels like even more friction.

Re: Common libraries and data structures for C

#36

I work in C++ daily and there is something about the simple-ness of C that I love. You get out of magical hell that is templates and return to simple flat-functions and macros.

Templates suck because they're the wrong abstraction. Or rather, they pretend to be an abstraction when in reality they're leaky as hell.

Rust's traits are generics done right. I haven't looked at Concepts too much, I hope that they'll be better than templates.

Re: Common libraries and data structures for C

#37
What I find frustrating when I use C instead of C# is that I have to hunt for libraries and include them in the project or write my own implementation, even for most popular things like data structures, search algorithms, sorting algorithms, serialization, http calls. Whereas in C# the framework will provide them for me. If something is not in the standard library, I can use a directive or just reference a method from a package and the IDE will help to install the package and reference it in the project.

Go and Rust are similar in that aspect.

Re: Common libraries and data structures for C

#40

For people advocating use of C++ instead of C, keep in mind there are several platforms (mostly embedded) that only support C and not C++. Also there are many projects that make use of C only. If C++ is available, I agree one should use it, however that is not always the choice.

> If C++ is available, I agree one should use it,

C is very simple, while C++ is a monster with 100 heads, each speaking in another language.

If all members of a project use the same subset of C++, then yes, it would be preferable over C. But if anyone or any team in a large project uses whatever he wants, things can get pretty complicated, pretty fast.

Post reply on HN