Comment by tialaramex

1 day ago

> I’ve been working on fixing C by giving it a high quality, ultra portable standard library

If the only problem with C was that the stdlib is terrible that would be a very different situation.

There are much more fundamental problems with the language. Problems that are entirely understandable in K&R C but aren't acceptable half a century later. A "high quality" standard library can't fix these problems. In some cases it can paper over them though not others, and even then the actual problem wasn't fixed it's just not obvious with superficial examination any more.

First, the type system is crap. The array types don't work across function boundaries, there's no Empty type at all, you are provided with a user defined product type with names, but not one without names etc. There is no fat pointer type, slice reference, nothing like that.

Second, naming is also crap. There's no namespacing feature provided so you're left with the convention of picking a few letters as a prefix and hoping it doesn't overlap and yet is succinct enough to not be annoying.

Third, everything coerces, all the coercions you could want if you like coercions, and then ten times that many on top. Some people really like coercions, C will see them learn that actually they don't like them that much.

These are all just your personal preferences. Just use another language instead which better matches your taste, nobody forces you to use C and there are plenty of more opinionated alternatives.

FWIW, the standard library being stuck in the K&R era is an actual problem since it doesn't make use of more modern language features and some functions are downright footgun magnets, but nobody quite agrees what a modern stdlib should look like, so a stdlib2 probably will never happen.

  • > Just use another language instead

    That isn't really an option if you are working on an existing project written in c.

  • Just today some friends sent me this: https://stefansf.de/c-quiz

    Yesterday I would have agreed that C is a nice and simple language, today I believe it is a cursed one that we just happen to make work somehow.

  • HN is for technical discussions. Even if the parent were only judging by his own personal preferences that would be relevant here.

    Note: I've written a lot of C by profession and passion, yet I find parent's criticisms mostly valid. At least he did not mention rust ;)

  • Nah, I spent many years writing C for a living. That library isn't from the K&R era, it's from C89, the problems I'm talking about are much more fundamental.

    Of course nobody forces me to use C, which is why I stopped writing C a few years ago.

>There's no namespacing feature provided so you're left with the convention of picking a few letters as a prefix and hoping it doesn't overlap and yet is succinct enough to not be annoying.

I've been using C on a daily basis for 30+ years and name collisions has just never been a problem.

Granted, it might be due to lack of a package manager so micro dependencies ala import is_even is not a thing here, but still, in practice, no name collions occurs.

I've spent enough time wondering where a given short name was pulled from that i came to see lack of namespace as a quasi feature.

Sure but it's definitely true that a significant part of the problem with C is that it's standard library is crap. So if you are forced to use C for some reason this could help.