3 ms·
I think I'm over "C but better" as a language design premise. C is really good as a low level language. The control you give up over assembly is well chosen. Th
by JonChesterfield 2y ago
I think I'm over "C but better" as a language design premise. C is really good as a low level language. The control you give up over assembly is well chosen. The syntax is fine. You have to tell the compiler to now screw you which is crazy as a default but doesn't matter much in practice.
I've just spent a week doing ~ nothing other than writing C. It's been great. The language does exactly what you tell it to. Generating C to do things from tables of data is very easy. I especially like the zero context switching that comes from being able to remember the language. Python or C++ involve far too much looking up documentation.
It's the wrong tool for solving most problems but the right tool for telling a computer what to do.
- bxparks 2y agoC may be the best example of "worse is better", but every time I do something non-trivial with it, I wish there was something better: * Undefined behavior, there are apparently over 100 of them. I can probably name about 5, maybe 10. Will the compiler warn me if I accidentally trigger undefined behavior? Of course not, it assumes that I am super-human who never makes a mistake. * Code sharing using '#include', god I hate 'em. * No namespaces, which means a single global namespace for all functions. * Strings: every time I have to manipulate strings in C, I want to shoot myself. * Arrays decaying into pointers, very clever, causing so much misery. * Array length decoupled from the array pointer. No way to pass around both of them together, and checked automatically by the compiler. * The C preprocessor #define magic. Love 'em when they are mine, hate 'em when they are someone else's. Hate 'em even more when they are mine 6 months later. * The #define/#ifdef spaghetti code. There ought to be better ways to support multiple architectures. Those are just off the top of my head. I'm sure I could come up with a few more items.
- JonChesterfield 2y agoThe UB is a lot more manageable if you pass nostrict-aliasing and similar to the compiler, or if you use a compiler that doesn't do that style of trickery. The includes and raw pointers are a build your own abstraction thing. Annoying if the abstraction you're building is the one a different language gives you to work with. For example, a struct with multiple arrays of the same length - in C that's multiple pointers and one size, in other languages that's probably multiple sizes and asserts that they haven't diverged. It's not a perfect language but it's really rather good.
- tobyhinloopen 2y agoYeah writing C is like a little zen garden. It’s so relaxing. It’s simple, and you get a lot of freedom. I love it, wish I could use it more. I also really love Zig but for some reason I still prefer C