3 ms·
Sometimes I wish the popular programming languages had been invented by people who's written language had no concept of UPPER and lower case. There's so much cr
by gfxgirl 5y ago
Sometimes I wish the popular programming languages had been invented by people who's written language had no concept of UPPER and lower case. There's so much cruft in code bases because of it. A conventions include kUPPERCASE for constants, CapitalizedCamelCase for classes and or functions, sometimes snake_case for variables or whatever. So then you have millions of wasted person hours of things that could have been automated if they matched, but they don't
Example
enum Commands {
kCOPY,
kCUT,
kPASTE,
}
class CopyCmd : Public Cmd { ... }
class CutCmd : Public Cmd { ... }
class PasteCmd : Public Cmd { ... }
Cmd* MakeCommand(Command cmd) {
switch (cmd) {
case kCut: return new CutCmd();
case kCopy: return new CopyCmd();
case kPaste: return new PasteCmd();
...
The fact that in some places it's COPY, in others Copy, and in probably others copy means work that would disappear if it was just always COPY. All of it superfluous work that someone from a language that doesn't have the concept of upper and lower case would never had even considered when come up with coding standards. Hey, I could just copy and paste this.... oh, the cases need to be fixed. Oh, I could code generate this with a macro.... oh, well, I've got to put every case form of the name in the macro so I can use the correct one, etc...
- BoorishBears 5y agoI don't get this... a) Is your tooling not identifier aware? That removes the hassle from remembering the case correctly. And for the matter so does having a consistent standard... b) When is capitalization ever the thing stopping you from copying and pasting some code? Capitalization only differs if the semantic meaning differs. Like what's a specific example in your code where this is avoided: > Hey, I could just copy and paste this.... oh, the cases need to be fixed. Oh, I could code generate this with a macro.... oh, well, I've got to put every case form of the name in the macro so I can use the correct one, etc... when all the capitalization matches?
- gfxgirl 5y agoI'm not sure what your point was. My point is because these languages were invented in English and because English language has a concept UPPER and lower case, English programmers made up naming conventions using different case variations of the same id. The most common convention I've run into I listed above. So I type out some enum using kUPPER for 50 things, I then copy and paste that somewhere to generate 50 functions, but according to naming conventions, I now have to fix the case of all of those functions. That "fix the case" is wasted work. Then we also end up with kUPPER except if it's a compound word so kPASTEANDGO becomes kPASTE_AND_GO which then has to be translated to some `class PasteAndGo` because of naming conventions. Again, wasted work. There are lots of cases where this conversion ends up causing all kinds of headaches, major and minor, just to keep everything matching the naming convention. Sure, you could choose to ignore the convention in this case but I've rarely seen a code base that does. Whereas, if the languages had come from a culture with the language that doesn't have the concept of UPPER and lower case then these conventions might never have happened. You'd have maybe something like K_COPY_AND_GO, CLASS C_COPY_AND_GO, etc and copying and pasting ids around or code generating there'd be no hoops to jump through to match the case conventions for different uses of the same id. > Capitalization only differs if the semantic meaning differs Yes, and I'm positing that prefixes or suffixes would be better than case differences