Hacker News new | past | comments | ask | show | jobs | submit login

> I wonder how your programs do I/O if not with strings.

There's this one weird trick we call binary. Let me give you an example of how I did I/O yesterday:

    static void usb_tx(struct usb_ep *ep, const void *data, uint len) {
      if (len) memcpy(ep->buf, data, len);
      *ep->bufctl = BC_FULL | ep->datax << BC_DATAX_S | BC_AVAIL | len;
      ep->datax ^= 1;
    }
Usage example:

    struct kb_report r = {.m={.id=KB_ID_M, .x=-a[1], .y=-a[0]}};
    usb_tx(KB_IN, &r.m, sizeof r.m);
stdin does not exist in this program.

> As another comment pointed out, C has many flaws unrelated to its standard library.

Yes it does, but this thread has already become a tangent of a tangent. Let's not turn it into a general diatribe against C, as opposed to a discussion about the library interface that TFA takes issue with.

> You know what's the main cause of dependency hell? Needing a library for every basic thing. Notice that mountains of dependencies are much less common in “batteries-included” languages.

In theory, yes. Like I said, libc sucks, and I would love to have a better standard (or de-facto standard) library. But anecdotally C programs are not very prone dependency bloat, perhaps precisely thanks to the fact that C doesn't have a de-facto package manager that allows you to just install a bunch of crap.

Anecdotally, "batteries included" languages are still prone to dependency bloat if there's a package manager. This includes recent experience with Python (I can't remember the last time I had to lay my hands on a python project that didn't need a bunch of things to be installed with pip) and somewhat less recently with Perl (isn't cpan pretty much the grandfather of "oh there's a library for that"?).

Hilariously, my recent experience has people using Python and depending on Python libraries which then depend on C and C++ libraries in order to implement the same things that I'm doing in plain C with no dependencies.

But I'll conclude my participation in this subthread with this message because it's gone too far off the rails into a pointless language flame war.




> isn't cpan pretty much the grandfather of "oh there's a library for that"?

The TeX CTAN in 1992 [1] was clearly the inspiration for CPAN a year or three later [2] (in both name & thing). So, maybe CTAN is the great grandfather? :-) { My intent is only to inform, not be disputatious. I know you said "pretty much". }

To be fair, C has an ecosystem. OS package managers/installers are a thing. There is surely a list of much >1 "core libs/programs" (terminfo/curses/some text editor/compilers/etc.) that would be in most "bare bones" OS installs upon which you could develop. One certainly depends upon OS kernels and device drivers. IMO, at least one mistake "language" package managers make is poor integration with OS package managers. Anyway you cut it, it is hard to write a program without depending upon a lot of code. Yes, some of that is more audited.

As the "lump" gets giant, dark corners also proliferate. There was a recent article [3] and HN discussion [4] about trying to have the "optimal chunkiness/granularity" in various ecosystems. I agree that it is doubtful we will solve any of that in an HN sub-to-the-Nth thread. I think that article/discussion only scratched the surface.

I will close by saying I think it's relatively uncontentious (but maybe not unanimous) that packaging has gone awry when a simple program requires a transitive closure of many hundreds of packages. FWIW, I also often write my own stuff rather than relying on 3rd parties and have done so in many languages. Nim [5] is a nice one for it. It's not perfect - what is? - but it sucks the least in my experience.

[1] https://en.wikipedia.org/wiki/CTAN

[2] https://en.wikipedia.org/wiki/CPAN

[3] https://raku-advent.blog/2021/12/06/unix_philosophy_without_...

[4] https://news.ycombinator.com/item?id=29520182

[5] https://nim-lang.org/




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: