Programming memes are wrongApril 05, 2020 • #Productivity
I’m on Reddit. A lot. Maybe too much. Like a lot of programmers, I follow /r/ProgrammerHumor and have a good laugh. But there are some memes that just make me facepalm when I see them.
I know what memes are. They are supposed to be jokes. But they just show that programmers are doing things that are wrong. Sometime because they don’t know better (lack of experience), sometime because they just don’t care. And judging by the upvotes, many developers do relate to these situations!
You have seen them already… Here is the kind of meme I’m talking about:
Or this one:
Let’s make this clear: as a developer, your job is NOT to find missing semicolons for hours. I hope someone didn’t hire you basically just to proofread text. The job of a developer is to create a solution to a problem by using coding skills. Your time should be spent thinking of a solution that satisfies requirements. If you spend it fixing static errors in your code, then your tooling sucks.
What you need is a linter. Most IDE/editors and languages have one. You are welcome.
Same goes for this one:
And this one:
If you are coding in English (and you should) you can avoid typos by properly configured IDE or editor. In Jetbrains IDEs, this feature is there by default. If you use VSCode, you can probably use Code Spell Checker. If you use something else, there is probably a plugin as well.
Even if you forget about the spell checker, the linter will probably tell you something like “unused variable”. If you see an unused variable and you are sure that you have declared this variable, then you made a typo.
If you are not using these tools, you are making your life more complicated than it should. It’s not your job to remember the name of every variable/method/class/symbol you defined in your program. You should not have to switch constantly between tabs to check for the correct spelling. Again, you are not a proofreader!
When we started programming we all did this:
Print or console.log to dump the value of a variable:
This has to stop. Debuggers do exist for a reason. Just take the time to learn how to use one.
Look at this thing, it stops where you want, without modifying your code! And you can unfold every property and method of an object!
Now imagine this situation with your classic print debug workflow: your print a variable that’s a Python dictionary. It’s a very large dictionary with lots of lines. You have nested properties and you have to modify your print and restart your app/rerun your test suite every time you want to go deeper in this nested dictionary. That’s daunting. Just use a debugger.
Here is the VSCode one.
There are a lot of debugging options out there. Just pick the one you prefer. There is even one directly in Chrome and Firefox! No excuse.
This one is actually funny:
This one is just sad:
You should not format your code manually. Life is short. There are plenty of cool things to do, like learning how to play guitar or printing stuff with a 3D printer. But formatting your code manually?
You guys seriously spend time typing spaces to align things? Here is a thing: no one should for two reasons:
- Everyone has its preferences. Therefor, there should be a team setting shared by everyone in the project and preferably applied automatically, for example using commit hooks. No one cares what your personal preference is. You are working with a team. Make it easy for everyone to read!
Don’t do the stupid work, let chunks of code do it for you.
This one is hilarious:
This one implies harmful behavior:
Just ask what the team is using, configure your IDE properly and call it a day. I’ve seen a mix of tabs and spaces in some production code and this is depressing. This shows an absence of consideration that code is a social construct. Everyone should be on the same page.
It’s a bit like simple-quote vs double-quotes. This should be decided upfront by your team as a coding style and enforced by tooling. No personal preference here, buddy.
Programming memes are fun but some just show behaviors that create frustration for both the developer and people working with him. Some part of programming are hard but these parts should not be “finding the missing semicolon” or “hitting 12 times space to indent your line”. So get good tooling and start focussing on the things that matter!