C programming old bad practices

So I’ve just started learning C. C is a really, really old language, and with it comes bad practices from the past. Learning C is like traveling in time to decades ago, almost but not really. C is much closer to the architecture, meaning you must consider memory management, pointers and more. There is lots of C code running around just chock full of bad practices.

What kind of bad practices are in C? To be fair these bad practices are in all programming languages. Like naming practices that are stupid and tell you nothing about what a variable or function does. Short names are the dumbest thing you can possibly do in programming, regardless of the language.

Lets look at C’s string conversion function names for example. <stdio.h>

  • atof – OK WTF does this even begin to mean?????
  • atoi – Wow you guys tried hard with this one didn’t you
  • atol – Cryptic much??? FFS. WTF does this even mean?
  • strtod – GTFO with this BS
  • strtol – Woohoo we are on a roll here.
  • strtoul – I want to smack you in the head with a hammer for this.

Seriously NEVER EVER NAME SHIT LIKE THIS. How did these even begin to sound like descriptive names? You might as well have named them as follows

  • boinknod
  • derpsterf
  • plockbang
  • snarflarg
  • hopdinger
  • bertioat

This is a great example of “How NOT to name things.

What do the cryptically named functions actually do???

  • atof – Converts the string to a double. Wow it is all in the name isn’t it FFS Why not stringToDouble? WTF is the a even for?
  • atoi – Converts the string to an int. Yeah I totally get that from the name. What about stringToInt or strToInt Again with the a shit.
  • atol – Converts the string to a long int. This totally says what it does,. What about stringToLong or strToLong???? Yeah that a is really telling me so much about WTF this stuff does.
  • strtod – Converts the string to a double. A little betterish??? How about stringToDouble, or even strToDouble, no confusion with that is there?
  • strtol – Converts the string to a long. Why not stringToLong? I say stringToLong or strToLong
  • strtoul – Converts the string to an unsigned long. str2UnsignedLong or stringToUnsignedLong would be better,
hide the pain meme

This kind of bad practice still appears today, especially with new coders from bootcamps or leetcoder or hackerrank, or those who don’t read books and perform research in general.

The longer you program the more you like longer, more descriptive names. You will prefer stringToDouble instead of atof. You will crave function and class names that tell you WTF they actually do. You will crave single responsibility theory. You will want to kick people that name variables a,b,c,d1 etc. Longer names no longer matter as the IDE’s have advanced so much with code hints etc. that you just start spelling, find the right name and hit enter. Hell some even fill in the parameters for you.

Great code can be written in any language by using descriptive names for everything. When you use descriptive names, the code might be longer, but you can actually read the shit and know what it does from reading it. Other people can read the names of variables, classes, functions, methods etc. and have a good idea of what they actually do.

Short names are good for nothing at all. Short names are preferred mostly by those who think they are some sort of genius programmer. You know the ones, we have all seen them. The ones that boast about only using VIM or Nano or some other silly shit text editor like it makes them superior, while acting like those that use proper IDE’s are just bad at programming or not smart enough to use a text editor to program. No, sorry you text editor loving fools, we like IDE’s because they have been proven over decades now to be much better than some POS text editor, and we write lots of code. These same clowns also feel superior when they crack open a terminal and waste time typing BS cryptic commands; which are much better executed by clicking a single fucking icon in a user interface.

Typing cryptic commands into the Terminal makes stupid people feel smart

Good programmers who take programming serious read books like Clean Code , Coders at work and The Pragmatic Programmer among other great books.

I actually had one young dingleberry of a pretend programmer try to make fun of me and pretend I am stupid and that is why I read books. He was all like “bruh, I am a great programmer and I just use google, I don’t need books”

I said nothing more as I knew it was probably a a newb who only knew node.js, react or Python, all of which SUCK. You don’t become a great programmer or even a good programmer by using Google and doing bootcamps or leetcodes/hackerranks. You actually need to read books on programming and computer science theory. I have learned about 10+ languages over 18 years. I have hundreds of books on most of those languages still. I read books on theory like OOP design patterns, database design, Functional programming, cloud server architecture etc.

Leetcode, hackerrank and googles only teach you minor things and often very bad programming practices, like single letter variable names and cryptic shit function names . Also those who don’t read and research are doomed to do things we have learned are bad practice. Reading books allows you to more quickly find out what doesn’t work, what others have tried and how they failed so that you can have a more direct path to success. Also good luck understanding networking, database design and computer science in general without reading books.







This site uses Akismet to reduce spam. Learn how your comment data is processed.

%d bloggers like this: