Writing unhealthy code made me twice as productive—but it surely got here with a catch

I am unable to rely what number of aspect tasks I’ve killed to date. Some by no means even noticed the sunshine of day. Others had been deserted on the preliminary stage. There had been many causes, however one frequent cause was my worry of breaking the principles skilled software program engineers comply with.
When I attempted to get all the pieces good from day one, it solely created extra overhead and prompted burnout. Then I made a decision to do one thing many programmers would contemplate disgraceful. I began writing unhealthy code on function. By unhealthy code, I imply code that is rushed, messy, or generally even incorrect.
When I finished worrying about how my code regarded and stopped cleansing it up, it drastically lowered the time it took me to complete writing code. A venture that used to take a month to achieve someplace significant now takes two weeks or fewer. However, it is a double-edged sword, and I discovered it the onerous method.
Breaking code on function teaches you what to not write
Wrong code as we speak saves debugging time tomorrow
This is a behavior I constructed at any time when I resolve to learn something related to programming. Some of you most likely do it too. When I’m studying a brand new programming language, a framework, or perhaps a new idea, I purposefully write incorrect, damaged code to see what occurs.
I do that so the idea clicks into place. It’s a good way to experiment with how a software works and behaves. That method, you may study concerning the frequent traps you would possibly face sooner or later and keep away from them.
This can be backed by analysis. In a 2022 study, learners who intentionally wrote incorrect definitions after which corrected them did higher on later checks than learners who merely copied the appropriate ones. To be truthful, a 2024 replication attempt did not discover the identical impact, and none of this analysis was about code. Still, it matches my expertise.
When I used to be studying some intermediate JavaScript ideas, I did this quite a bit as a result of it may be cranky generally. For instance, this instance of destructuring:
const { identify } = null;
// TypeError: Cannot destructure property 'identify' of 'null' as it's null.
JavaScript stops you instantly. The error message even tells you what went incorrect. Honestly, these are pleasant bugs. You cannot miss them. But this is one which surprises a variety of rookies:
[10, 1, 2, 25].kind();
// [ 1, 10, 2, 25 ]
No errors or warnings. By default, kind() compares values as textual content, so “10” lands earlier than “2.” Once I noticed this, I by no means forgot to go a examine operate like (a, b) => a - b. The tutorial I used to be following handed these, however I nonetheless experimented with it with out passing them to see what occurred.
As you might have seen. Silent errors are troublesome to cope with. So, studying these traps prepares you for any sudden surprises you might face when writing severe code.
Rules matter most when different folks rely in your code
For apply and private tasks, you could have the liberty to interrupt them
When newbie coders take heed to software program engineers on-line, they study many fancy phrases, similar to SOLID rules or the Factory methodology. This is, after all, real recommendation. The factor is, it’s important to perceive who the recommendation is for. These are meant for folks writing manufacturing code and dealing in a crew on giant codebases.
Most new programmers begin their journey with to-do apps or calculators. You need not apply any of these guidelines to your 100 traces of code. In reality, generally clean code can hold you back whenever you comply with it too strictly. If nobody else goes to learn and work together with your code, then a variety of these guidelines abruptly matter a lot much less.
Take prototypes, for instance. In The Pragmatic Programmer, the writer says prototyping generates disposable code. Though it additionally mentions the “tracer code”, which stays within the last venture. So, the actual trick is understanding which one you are writing. If it is going into the precise system, it deserves actual care.
In my case, at any time when I’m engaged on some weird project on a weekend, I completely flip off my engineering mindset and go wild. I’d most likely get kicked from any software program crew in the event that they ever noticed that code.
For higher or for worse
When AI and LLMs had been getting higher at coding duties, I additionally obtained pulled into vibe coding and AI-assisted development. This is when my behavior of writing unhealthy code reached its peak.
On one hand, I generated a variety of code utilizing AI and did not even trouble to scrub it up. When giving the prompts, I saved them minimal and did not ask it to comply with any of the principles or rules. So, naturally, the code those AI tools wrote “worked” but had poor quality.
On the opposite hand, if I wrote any unhealthy code myself, I all the time delegated the cleanup to AI instruments. Knowing they’d my again, I did not trouble following strict guidelines when writing the primary model of the function. Though, as you would possibly count on, this was by no means a foolproof plan.
Writing extra code does not all the time imply being productive
You nonetheless should learn the unhealthy code you write
Now for the half I discovered the onerous method. On a lot of my AI-assisted tasks, I saved producing code blindly till I had a number of recordsdata with 1000’s of traces. Now I develop options one after the other and check every as I’m going. But actuality hit after I ran right into a bug.
The very first thing I did was, like every other vibe coder would do, clarify the bug to the AI software and ask it to repair it. That failed miserably. For the primary time, I needed to open the recordsdata and browse the code myself. Boy, was I in for a shock.
Since I had some programming data, I understood the code snippets. But the entire move of knowledge, how all the pieces was woven collectively, what function every part was taking part in, I had no concept.
So, finally, whereas writing unhealthy code did save me a while, if I ever should learn that code later, I’d somewhat write it nicely from the start.
Finish first, polish solely what survives
“If it really works, do not contact it” is a well known meme within the programming group. I’m glad that it is simply that. A meme. Bad code did not make me a worse developer. It made me quicker, as a result of I discovered when to make use of it. It additionally taught me why it is a habit of elite programmers to jot down organized code.
