‹ BackHN Continuity

Thread

C's Flexible Integer Sizes Were Not a Design Mistake

113 points · 166 comments · ibobev

  1. quelsolaar · · focus · HN ↗
    Good article.

    C would probably not have survived unless it had this flexibility.

    But its not justa historical thing. Today there are modern platforms like DSPs that have 32bit sized char, because that is the smallest addressable type. These platforms depend on C for tool chains, even if most "portable" C wont run correctly on them. The fact that you can build hardware like that, and not have to invent a new language / dialect to program them is a huge win for the world.

    <edit> I didnt see the footnote about DSPs at first read </edit>

    1. pjmlp · · focus · HN ↗
      C survived because UNIX carried it.
      1. flohofwoe · · focus · HN ↗
        I don't agree. UNIX was an extremely niche operating system until Linux won the data center, at that time both C and C++ were already extremely popular outside the UNIX world. C won because it was so easy to adapt to new hardware architectures (even GPU shading languages are just minimally extended flavours of C and C++).
        1. pjmlp · · focus · HN ↗
          Most people only cared about C, because they needed to work on UNIX, and UNIX was taking over the server room and all 1980's graphical workstations.

          C was pretty much ignored on 8 bit home computers, outside some toy compilers for CP/M.

          In the 16 bit days, it was yet another language alongside BASIC compilers, Pascal, Modula-2, Assembly.

          C is so tied to UNIX, that POSIX had to be created so that any non-UNIX operating system could provide a cozy home for their C compilers.

          UNIX/POSIX is for all practical purposes the runtime most C applications rely on, there are naturally some exceptions like free-standing or Windows (which eventually gave up and add to start improving its support).

          It is only due to historical accident that Microsoft gave up on Xenix, instead of replacing their MS-DOS efforts.

          1. jstimpfle · · focus · HN ↗
            I don't know about you but I need zero POSIX to write C on Windows. Not even much of the (mostly bad) C standard library. I use snprintf for convenience (but I don't have to), and memcpy, that's about it.

            And many projects properly abstract their OS layer so they aren't tied to POSIX.

            Maybe Unix is tied to C, but C isn't tied to Unix.

            1. pjmlp · · focus · HN ↗
              You failed to read this sentence until the end,

              > UNIX/POSIX is for all practical purposes the runtime most C applications rely on, there are naturally some exceptions like free-standing or Windows (which eventually gave up and add to start improving its support).

              1. jstimpfle · · focus · HN ↗
                Point is that C isn't tied to POSIX. It's just not. Of course there are apps created on e.g. Linux, those sometimes get ported by relying on standardized "POSIX" platform. But that's not how you have to program, and it isn't a great way to program. And it isn't a sufficient platform to do anything useful.
Open on Hacker News to reply ↗

Unofficial Hacker News client; not affiliated with Y Combinator.