4 ms·
Memory safety. I don't need the return after a memcpy to be Turing complete. Your C is not your choice because it affects me if your machine gets hacked and i
by PaulHoule 2y ago
Memory safety. I don't need the return after a memcpy to be Turing complete. Your C is not your choice because it affects me if your machine gets hacked and is used as a platform to attack me.
Garbage collection. Code reuse is difficult in C because of differing systems for memory allocations. Basically an application doesn't really know if a library is done with a buffer and the library doesn't know... but a garbage collector does!
The ideal reusable library in C would be able to use a buffer from the application if the application had one ready. In cases where it had to build up a complex linked data structure you'd like it to pass it custom malloc and free so it can use your arena allocator, etc. In Java (Lisp, Python, etc.) libraries automatically compose with the application without having to think about any of that -- I'd say Java was a revolution for code reuse not because of OO but because of GC.
All the brain melting stuff Rustifarians have to deal with get exponentially harder when you mesh systems together which puts a break on what people can accomplish with it. (Though I guess you can interconnect islands with RC)
Poor conceptualization. C is transitional from ancient language specs like PL/I that were often unimplementable and modern specifications that succeed consistently like Common Lisp, Java and Python. There's a strange circularity in the K&R book that made me struggle with the book in high school and if you look at books like Imperfect C++ that circularity remains with the symptom that there are always important words that are used long before they are defined (RAII is chanted over and over as if it was some magic spell!) Modern language specs show you can start from primitive data types and build everything up in a logical order but I've never seen it done with C.
In normal programming languages you can parse first and deal with the symbol table later but the definition of typedef means the grammar depends on whether or not a symbol has been used, so weirdly the parser has to have access to the symbol table. All adds up to C being the language that puts the C in Cthulhu.
(For all it's faults though, C succeeded where PL/I failed as a portable systems language you could write an OS in)
I write C for the AVR8 Arduino even though it burns me up that C is moving the stack pointer around and doing other meaningless activities to support calling conventions for small programs I write that have no recursive functions and don't need it. I have something that's basically a display controller for persistence of vision displays that composites sprites that are stored in program memory following linked lists. A program like this could use entirely global variables and it would be simple, clear and efficient. Sure it doesn't scale but the thing has just 2K of RAM and I am not writing big programs for it. I'd be happier with the code in assembly, the only reason I haven't rewritten it is that I might want to run it on an ARM or ESP32 board and the C would be portable modulo just a little Harvard architecture weirdness.
- ActorNightly 2y ago>The ideal reusable library in C would be able to use a buffer from the application if the application had one ready. So....mempool?