News for hackers. Stuff that matters.
Re:Best aspects of C by flohofwoe on Tuesday November 17, 2020 @11:11AM (#25125407)
I love C but I think most of the C standard library is useless and outdated rubbish (pretty much everything above the mem...() and math functions). The entire IO and memory-management areas should have been either thrown out of the standard library, or updated 20 years ago to keep up with low-level operating system features.

But one of the best features of C is that you can mostly ignore the standard library and still enjoy "C the language", e.g. nobody ever choose C for its standard library ;)

(also re UB etc...: use the mighty trio UBSAN, ASAN and TSAN!)

Re:Best aspects of C by bhaak on Tuesday November 17, 2020 @02:01PM (#25128083)
What do you use then if you don't use the standard library?

What is the standard library for the C which ends all the other standards libs?

Re:Best aspects of C by flohofwoe on Tuesday November 17, 2020 @03:02PM (#25128933)
For IO, memory management and similar "low-level services" it's often fine to call the underlying operating system functions directly and with this also make use of more powerful features than the standard library can provide, such as async IO, virtual memory etc (or wrap those OS calls into your own cross-platform wrapper functions). There's also plenty of libraries which do this for you, like libuv (but integrating such big libs is often not trivial).

Same for string handling/processing, there are specialized libraries out there which do a specific job better than the rather generic standard library functions (this is also true for the C++ stdlib), one just has to find those libraries.

PS: I don't think that a "batteries included" standard library (like python has) would even make sense for C, such a library would need to be opinionated by definition, better to keep (too many) opinions out of the standard, as this road just leads to another C++ ;)

Re:Best aspects of C by arcticbull on Tuesday November 17, 2020 @04:09PM (#25129868)
C++ is IMO defined by a complete lack of opinion. They just standardized every opinion. For everything. C++ would be a much better language if it showed some opinion, even if I disagreed with it.
Re:Best aspects of C by anfilt on Wednesday November 18, 2020 @04:38AM (#25134873)
That's honestly how I also feel about C++ in when I look at how often they are adding new things.
Re:Best aspects of C by WalterBright on Tuesday November 17, 2020 @10:44PM (#25132964)
In my long C career, I invented string library after string library. They all turned out to be garbage. The common cause of their failures is their inability to interact with any other C code.
Re:Best aspects of C by flohofwoe on Wednesday November 18, 2020 @04:56AM (#25134984)
Agreed, but that's an issue for all "interface types" on API boundaries (another similar issue is vector and matrix types in math libraries). IMHO a C string library must still be able to efficiently consume and produce vanilla zero-terminated "const char*" string data (and at a stable address, unlike for instance std::string) even if they mostly work with {pointer,length} ranges internally.
Re:Best aspects of C by WalterBright on Wednesday November 18, 2020 @07:06AM (#25135868)
C strings are so ubiquitous that the ABI impedance mismatch is just too annoying.
Re:Best aspects of C by asveikau on Tuesday November 17, 2020 @04:54PM (#25130441)
> Same for string handling/processing, there are specialized libraries out there which do a specific job better

I actually can't think of a lot of these that are super common across projects.

ICU is probably the most notable one, with its particular focus on unicode correctness.

A lot of large projects end up writing their own string library of sorts.

Re:Best aspects of C by bigbubba on Tuesday November 17, 2020 @06:10PM (#25131153)
There's bstr, I've come across that a few times.
Re:Best aspects of C by einpoklum on Tuesday November 17, 2020 @03:09PM (#25129048)
You can use something like GitHub or Conan to find specific useful C libraries.

There isn't a universally recognized "standard library replacement" (and people argue about what parts of the standard library they don't like), but here:

https://stackoverflow.com/questions/486383/safer-alternative...

are a few options:

* Glib (the basis for Gtk): https://developer.gnome.org/glib/stable/glib.html

* The Apache Portable Runtime (APR): http://apr.apache.org/

Caveat: I haven't used them.

Re:Best aspects of C by 1vuio0pswjnm7 on Tuesday November 17, 2020 @06:26PM (#25131271)
djb's libraries (answer to first question)
Re:Best aspects of C by adrift on Tuesday November 17, 2020 @02:12PM (#25128230)
Your own.
Re:Best aspects of C by lmm on Tuesday November 17, 2020 @10:19PM (#25132821)
> But one of the best features of C is that you can mostly ignore the standard library and still enjoy "C the language", e.g. nobody ever choose C for its standard library ;)

C is one of the hardest languages to do this with given its anaemic dependency management.

> (also re UB etc...: use the mighty trio UBSAN, ASAN and TSAN!)

All of which will miss some cases, even in combination.