C Is Not a Low-Level Language (2018)

(queue.acm.org)

36 points | by tosh 3 hours ago

9 comments

  • bee_rider 11 minutes ago
    “Low level language” is one of those terms like “VLSI” (very large scale integration) where they defined it in the 70’s or something, so the academic definition is out-of-sync with what most people would expect.

    This is fine, it’s a term of art and those don’t need to be immediately obvious.

    I don’t like the title of this article for that reason, though. Really a better title would be something like “a modern x86 processor is not a PDP-11.” The subtitle is perfect basically.

    Edit: also IMO it is not really fair to beat up on C for this, the problem is not really one of low-level-ness. A language that actually exposed the complexity of speculative execution and all that could be pretty high level. It would just be harder to read in a linear text editor, right? We’d be better off drawing the dependency graph or something.

  • legobmw99 39 minutes ago
    I’ve been a fan of this article for years, though it does often make me think that there really aren’t any true low level languages for our super scalar modern CPUs. Does anyone know of any?
    • giancarlostoro 20 minutes ago
      Probably Mojo, it doesnt just talk to your CPU it also will talk to your GPU bypassing the need for CUDA. Its early days, but I see strong potential in Mojo. Currently its primary focus is GPUs for AI inference, but give it a year or two and it will be really interesting for more than just that.
      • poly2it 2 minutes ago
        But Mojo is a high level language?
    • aDyslecticCrow 24 minutes ago
      The article does make an example quite early;

      > GPUs achieve very high performance without any of this logic, at the expense of requiring explicitly parallel programs.

      GPU cores are in some ways closer to "PDP-11", they're either acting as thousands of parallel simple processors, or expose pretty raw instructions for very parallel use-cases.

    • ferguess_k 17 minutes ago
      Wondering can we write microcode? That's definitely closer to the metal.
    • MrBuddyCasino 36 minutes ago
      In what way would exposing the true microcoded out-of-order etc nature of the beast benefit certain tasks?
  • glouwbug 31 minutes ago
    Maybe not then, but we basically have our own poor man's template system now:

        #define array(T, N) struct array##T##N { T value[N]; }
    
        void copy(array(int, 32)* x, array(int, 32)* y) {
            *x = *y;
        }
    
        int main() {
            array(int, 32) x;
            array(int, 32) y = { 1, 2, 3, 4 };
            copy(&x, &y);
        }
    
    With (rumors of) lambdas and defer on the way, C is going the way of classic WoW.

    https://en.wikipedia.org/wiki/C29_(C_standard_revision)

    • leptons 13 minutes ago
      >C is going the way of classic WoW

      What does this mean?

      • omani 11 minutes ago
        it means C is going the way of classic World of Warcraft.
    • warmwaffles 14 minutes ago
      I remember `defer` being up for consideration for the last consortium but it got yanked. Lambdas would definitely be nice to have.
      • glouwbug 6 minutes ago
        Seems like its in C29, but who knows. I've waited since 2009 for just about anything
  • veqq 39 minutes ago
    This is one of my favorite papers; it stole about a year and a half of my time. I still pine for Lisp processors although array languages can now self-host on GPUs, which, APL-pilled, I now feel is better. It'd be so cool (...for compiler writers) to be able to control precisely which kernels stay in which cache levels etc.
  • blastonico 22 minutes ago
    In this sense, not even assembly is a low-level language because an instruction may hide what the microcode is actually doing.

    IMHO, C is the lowest level a procedural programming language can get.

  • fsckboy 26 minutes ago
    >and even the pre- and post-increment operators cleanly lined up with the PDP-11 addressing modes.

    pre- and post- increment operators cleanly lined up with... the programmer's conceptualization and objectives--the index is/was frequently used in other contexts than loop bounds and indexing. if that's not your conceptualization, don't use that operator. whether you are on a PDP-11 makes no difference.

  • actionfromafar 49 minutes ago
    If anyone was thinking, but in practice it is a low level language, behold Fil-C.
  • EGreg 39 minutes ago
    It's just a matter of personal definitions, it seems. Here is an example:

    https://ulanguage.org

    What level would you say this language was? Is it a low-level systems language, or is it also usable for writing web sites?

    • rfgplk 10 minutes ago
      Unique language!

      To me the definition of low-level vs high-level strictly comes from the indirection the language runtime provides for you. If the language compiles down to asm, it's low level. It literally does _not_ matter what it looks like. The only other constraint is possibly whether you can manipulate low-level CPU level constructors like memory, albeit it's not necessary. You can take python and write an LLVM frontend for it and it would instantly become a low-level language.

  • applfanboysbgon 33 minutes ago
    This article is so blatantly fallacious I can't even get past the first couple of paragraphs. Perhaps it makes a stronger case later in the article, but the early claims it makes invoke Meltdown/Spectre, eg. speculative execution, and your CPU being more advanced than a PDP-11, and that C doesn't expose modern CPU features like speculative execution, therefore C is not low-level. But assembly doesn't either. You could attempt to make the claim that assembly is no longer a low-level language, but the article explicitly does not do this, instead listing assembly as the low-level extreme that C is being compared against.

    This is embarrassingly bad.

    • rfgplk 12 minutes ago
      > C doesn't expose modern CPU features like speculative execution, therefore C is not low-level

      This is a 100% skill issue of the author, as is always the case. C does expose it fully, except it's implicitly implied by your code rather than explicitly declared. Same with all of the other arguments that always plague these type of articles.

    • nizmow 20 minutes ago
      I think that’s the point.