Thread with 16 posts
jump to expanded post“c is portable assembly” hasn't been true since optimising compilers appeared for it. it's an accurate description for those really simple (usually old) c compilers on the other hand… where for (;;) and while (1) are different and local variables aren't free. old c is so cute
i think sizeof(short) == sizeof(int) is cute
it's a portable macro assembler, even. macros are faster than functions, just like in assembly, and c has really powerful macros by assembler standards
so much of c was a good idea, or at least good enough, for its time, but we've been using this poor old language for far too long and i think making optimising compilers for it was really mean to it. society if rust had existed in 1992…
@hikari it's 2087. the last line of linux is rewritten in rust. the tsukumogami spirit of the c programming language is finally set free and retires in comfortable pdp-10 pastures.
@hikari I think I'd still be waiting for the cargo build I started in 1992 in that case though.
The "portable assembly" thing always bugged me. C has functions, data types, and variables that are distinct from registers or memory locations. That's not stuff you find in assemblers.
@suetanvil this is true, but none of them are necessarily particularly sophisticated: the functions might always map to a label, the data types and variables are no more complex than you can define in an assembler macro, etc
@suetanvil it's definitely not an assembly language, but in its simple implementations it's not very far removed from it
@hikari i wish there was a good portable language that has basic programming constructions to allow building a language on top without having to reimplement the wheel every time. Something like wasm could've been nice, but calling native code from wasm is a bit messy
@SRAZKVT yeah!! llvm ir is absurdly complicated (don't let someone tell you it's simple, i wish it were, i worked with it professionally and as a hobby for four years), and wasm is i think reasonably simple, but because it has memory sandboxing it's only good for compiling to… wasm
@hikari yeah llvm ir isn't exactly simple, honestly i almost like jvm instructions, they are reasonably simple to write out, but they are assumed to run in a vm, so that doesn't make it very suitable to be compiled to native. i kinda wish there was something in between wasm and jvm bytecode sometimes
@hikari and that can be compiled to native easily (though if it can also just run in a vm, i'm not against it, that would allow some nice things for debugging it)