3 ms·
I fail to see TFA's concerns or take them very seriously. > time() unnecessarily takes a pointer argument to write to Minor cosmetic issue. > strftime() has
by asveikau 2y ago
I fail to see TFA's concerns or take them very seriously.
> time() unnecessarily takes a pointer argument to write to
Minor cosmetic issue.
> strftime() has to write to a string of a fixed length it can not dynamically allocate (This is less legacy than it is bad design)
This is often a good way to structure string functions in C. The fact that TFA repeated the constant 40 instead of using sizeof() immediately signals that they are unfamiliar with the idioms. A "you problem".
Doing heap allocation where it is not required could be a problem for some use cases.
> localtime() needs the pointer to a time_t value even though it does not change it because of register size concerns on PDP-11’s
Also minor and cosmetic.
> sleep() cannot sleep for sub-second amounts of time, usleep() is deprecated and it’s alternative nanosleep() requires you to define variables
sleep(3) is not really a "time function" in the sense of the others mentioned, it is a thread scheduler function. As such it kind of exists in a different universe. This is also shown by the fact that it's part of POSIX and not the C standard, like time(2) is.
- ctoshiningc 2y agoAnother classic case of "if everyone does something differently than you do, it might be worth investigating why". The hubris to think that basic C time functions have been "broken" all this time, and that nobody noticed or cared. What a joke.
- oliverkwebb 2y agoFor a definition of "nobody" that includes Eric S Raymond, one of the most prominent figures in the linux world who's article (https://www.catb.org/esr/time-programming/index.html https://www.catb.org/esr/time-programming/index.html) I reference multiple times. [plonk](https://www.catb.org/jargon/html/P/plonk.html https://www.catb.org/jargon/html/P/plonk.html)
- 1718627440 2y ago> Eric S Raymond [...] prominent figure[...] in the linux world Doesn't he work for Microsoft?
- oliverkwebb 2y agoHe was the publisher of the Halloween documents (from my understanding leaked by a whistleblower to him) and has always been a firm opponent to Windows in all his works. Are you thinking of Poettering?
- 1718627440 2y ago<del> Isn't this his blog: https://devblogs.microsoft.com/oldnewthing/ https://devblogs.microsoft.com/oldnewthing/ ? It is hosted by Microsoft and talks about implementation details of Windows. So I always assumed, that he works there.</del> My bad, that's Raymond Chen.
- asveikau 2y agoThat looks like a decent article, but for the general case, ESR is not credible on name alone. Go look up criticism of that guy.
- MortyWaves 2y agoIs this really the type of discourse on HN now?
- asveikau 2y agoI don't have time to get into it every time that guy's name comes up. Basically he's best known for: * Jargon file * Parading himself around as "Mr open source" in the late 90s * Working on what by all accounts was a not very good mail client a long time ago That's the "good" side that's supposed to give him credibility as an expert, and it's not very much. The negative stuff is pretty bad.
- forrestthewoods 2y agoMany functions in the C API are quite badly designed. The hidden global state in locale for example. HN regularly has articles about nasty bugs that boil down to “C API has several major deficiencies that cause great pain and suffering.