Skip to content

Instantly share code, notes, and snippets.

@wmerfalen
Last active September 9, 2021 22:45
Show Gist options
  • Save wmerfalen/d958e85e4e7c75277f147629581f24cd to your computer and use it in GitHub Desktop.
Save wmerfalen/d958e85e4e7c75277f147629581f24cd to your computer and use it in GitHub Desktop.
Lesson learned
Hindsight is 20/20. The errors of our past and our inabilities to fix them are truly the stuff of nightmares.
The existential dread of imposter syndrome... the effects of knowing that you're incapable of fixing something because you
lack the experience or proper guidance. These issues affect us everyday. Even if you're a grizzled vet. I think every coder
has reached a point where they didn't know how to solve an issue. How many are willing to admit it? How many people let it
affect their sleeping habits? Do you lay awake beating yourself up for not knowing how to fix a specific issue? Even worse:
did you fail in every way to address it? Did it cause you grief?
The good news is that if you've let a problem affect you to the point of losing sleep, you're probably one of the better
programmers among your peers, in a way. If you care enough about a problem to let it negatively affect you, not only does it
mean you care, it also means you're growing. It means you're a human. It means that it might have stumped you this time, but
the next time it happens, you're ready for it. You've re-run the situation over and over in your head to the point that it's
not even a problem anymore.. it's merely a minor inconvenience compared to bigger problems you're tackling.
What separates a senior developer from a junior developer? A senior developer has seen the correct solution to a problem a
junior dev is currently stuck on.
In no way am I advocating that a problem should take a physical toll on your health and well-being. You should do everything
in your power to live a healthy and grounded life full of joy and happiness. You owe it to yourself for working in a
profession that habitually and consistently gas-lights you into thinking that you surely have lost your last bit of sanity.
So when it comes to problems in the digital world, it's not uncommon to feel a bit overwhelmed. I think it's normal to
acknowledge these things and to address it healthily. I'd like to personally share a problem from my past which I had no idea
how to solve.
It was about a year into my professional career as a PHP developer. I was working on a script that had to consume an
abnormally large XML feed. This feed was about 900 megabytes in length.. and the way we were consuming it was as one long
HTTP GET request. For the first month or so, the size of this feed never exceeded 900 megabytes. All was well. Until, out of
nowhere, our script would die unexpectedly.. and it wasn't like it was dying out of nowhere, it was dying consistently
starting at a specific date. The good news was that we were able to see the reason for the script dying... and every PHP
coder has reached this point too: the script was running out of memory. The dreaded memory limit problem that every PHP
developer has to address at some point in their career.
Now, the most common "fix" that even a fledgling Linux administrator can deploy without a shred of PHP knowledge is to bump
up the memory limits of the script. Bumping the memory limit is often times a temporary fix to a bigger problem. Since we
were consuming this XML feed by chucking into a DOMDocument object, we could technically handle this issue by inflating the
memory limit. But this would not suffice. This was far from the ideal situation, but the real solution to this issue would be
to do something that a systems development coder could probably do in his or her sleep: write a streaming XML parser.
Having written a templating engine of my own (and albeit a rather simplistic one), I feel like I could confidently solve this
issue were it to come up again. The true reason why a newbie PHP developer is stumped by this issue is partly because of the
nature of Web Development in general. It is not uncommon for a PHP developer to have zero systems development experience. It
is not uncommon for a web developer to not have a solid computer science degree. I didn't, and I've met lots of very
successful PHP devs who never had the necessary schooling that, say, an embedded developer might require. My career was
essentially me coding PHP and using all my free time to learn computer science concepts. This was me making up for my
deficiencies in computer information science by supporting myself with a scripting language. The problem is that web
development simply does not require you to know these concepts initially. You don't have to worry about manually allocating
memory, or (god forbid) freeing it. PHP handles that.. and if you're using a framework, you're a bit more disconnected from
those horrors. I think that's been my main gripe with using an MVC framework like the massively popular Laravel framework. I
think Laravel is great, and it's massively fun to program in, but I feel like it creates an even bigger rift between real
world problems and developers in general.
If you've worked with me for any amount of time, I've harped about these issues endlessly and this is surely not new content.
In fact, I probably bring it up too much. If you hear me suggesting anything related to this post, you're likely someone that
I see as possessing massive potential. Everyone can benefit from knowing how to solve these issues.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment