3 ms·
This is the sprinkles on the icing of the five teir cake why C scares me. Thanks for sharing this, I'm sure it will help someone but I sincerely hope the never
by thumbuddy 3y ago
This is the sprinkles on the icing of the five teir cake why C scares me. Thanks for sharing this, I'm sure it will help someone but I sincerely hope the never write C again.
- lelanthran 3y ago> This is the sprinkles on the icing of the five teir cake why C scares me. Thanks for sharing this, I'm sure it will help someone but I sincerely hope the never write C again. I looked through this list, and I gotta ask, which items exactly do you find scary? Most other popular languages have similar, if not worse, quirks than the ones in this particular list.
- xigoi 3y agoNot the OP, but: * the comma operator (why not just allow blocks to be used as expressions?) * multi-character constants (yay implementation-defined behavier) * interlacing syntactic constructs (why?????) * the fact that the --> operator works * the idx[arr] thing * the fact that you need a dirty hack with enums to check something at compile time * flat initializer lists (why?) * void pointers (instead of a proper type system) * the syntax for function types * the fact that X-Macros are needed
- lelanthran 3y ago> * multi-character constants (yay implementation-defined behavier) Isn't all of reference-implementation language like Rust and Python all implementation-defined? > * the fact that the --> operator works I pointed out elsewhere (with a link) that that specific construct works in most popular languages, like Java. > * the fact that you need a dirty hack with enums to check something at compile time It's not a check, its an assert. The alternative, for languages like Java and C#, is not having compile-time asserts at all. > * the fact that X-Macros are needed They are not needed, and indeed, equivalent functionality isn't in most popular languages (or anything but, Go, I think). Since many of your complaints are applicable to other languages, it seems, to me anyway, that what you know of C is what you've read online in popular forums.
- xigoi 3y agoImplementation-defined is not a problem if there is only one implementation, since your code is going to work the same everywhere. Languages like Java literally copied most of their syntax from C, so obviously they have the same problem and I hate them too. Ditto for other languages that don't have compile-time asserts. X-macros are a poor substitute for… well, actual macros. Or just metaprogramming in general.
- thumbuddy 3y agoI'm not here to bash C, okay maybe a smidge, but yes other languages do have gotchas and weird ugly creepies. Some of the ones that scare me... The '-->' nonoperator. Defining structs in a function declaration gives me the creeps. Same goes for the nested struct definition interpretation like come on. Void pointers in general stress me out. That's one I knew about before reading this. Makes bookkeeping hard. I get that C is basically sugar around ASM. I have respect for it. At the same time, it feels so hazardous to write. Everytime I think I know enough I stumble on some weird UB landmine, or find some bizarre library that despite understanding 99% of the code the remaining 1% conceals everything I care about. The quirks in many other languages can be rough, but I feel like Cs leave developers in a scarier place given the risk factors
- lelanthran 3y ago> The '-->' nonoperator. it's the same in most languages. Works identically in Java, for example: https://www.jdoodle.com/iembed/v0/JL5 https://www.jdoodle.com/iembed/v0/JL5 See? > Defining structs in a function declaration gives me the creeps. Both Kotlin and Go allow defining classes anywhere - they're anonymous. > Same goes for the nested struct definition interpretation like come on. Come on ... what? That's not a footgun. Because C is strongly typed, anytime you do a nested definition and expect it to be in the scope of the parent struct, you'll get an error if you try to create a new struct with the same name. > Void pointers in general stress me out. Fair enough, casting to and from void pointers explicitly throws away the type information. > The quirks in many other languages can be rough, but I feel like Cs leave developers in a scarier place given the risk factors The two quirks you complained about here are in other languages. While C has problems, there is not much in this list that is problematic.