Fun statistic; I’ve been in three dumb internet fights in the last week or so (one of which wasn’t even with a random stranger)! It must be that time of year again. You know, the one where I decide too many people like me and I need to start doing some alienating. Or something. Hur hur.
Anyway, as some of you know, I occasionally lurk around the CodeGrrl Forums partly because it tickles my helpful streak, and partly because after some initial revulsion I got gradually more and more curious as to the kinds of issues that pop up there. Today’s adventure comes from this thread. It starts off simply enough; kid having trouble with the Build A Blog ‘tutorial’ script. For those of you who read this and have some coding experience, I’m going to sit here and let you read a few segments to kinda get the drift of why this script makes me cringe so much. Firstly from a teaching perspective, since that’s exactly the one thing that it utterly fails to do; instead mostly presents hunks of lines of code to be copypasta’d. And secondly from a coding perspective, since it teaches some absolutely horrible habits that I then see repeated all over the place. The scary thing is that it’s also allegedly been ‘cleaned up’ since it was written. Shudder.
Look, don’t get me wrong; I dig the whole concept of making PHP ‘accessible’ to hip young internet chix0rz, really I do. But this isn’t the way to go about it. CodeGrrl is the official (and unofficial) distribution point for several scripts commonly used on personal domains, including phpFanBase; a script so truly terrible that not only has my domain host issued an official warning to all its subscribers not to use certain versions of the code, but that I completely re-wrote instead of actually using.*
Like most people, I learnt to code in the proverbial School of Hard Hacking Knocks, and I truly, honestly believe this is the only way to learn to code; by getting down and dirty with your own project and grinding out code until it all just works. This is why PHP is the only language I feel I’ve truly mastered (even though technically I’ve had experience in C/++, Java, Perl, Python and even COBOL); because it’s the only language I’ve ever used to program something for me, that I thought of, because I wanted it. Every other person I know who is even vaguely competent at coding has learnt exactly the same way.
I did not learn, and I’d bet money that neither did any single person in the world, by crawling into a forum and begging “lolz it’s broken again fix pls” and waiting with my mouth open for someone to shove some answers down my throat. Proving you’re a Super 1337 Haxx0r who can debug code with nary but a glance is cool for pointless ego stroking, but it’s not helping anyone. Somewhere halfway down the thread I got sick of ego-stroking, and decided it was time to stop playing Rent-a-Coder. I fess up straight away; it’s my fault the code got mangled. I stuck an if-not in by accident where it shouldn’t go. Any first year CompSci student should be able to spot it except, oops, the BAB ‘tutorial’ says exactly nothing on the subject of debugging or, for that matter, the subject of the not operator (or any operator). And because the vast majority of people who use the tutorial seem to solely use that one tutorial (a friend of mine used to suspect that it was primarily so they could claim to have “written their own blog”, as if copy-pasting some code out of a tutorial and whining in a forum when it broke somehow constituted “writing your own blog”), well then the thread was screwed from the start.
Dragging out for a week and three pages, eventually some admins poked their heads in suggesting that it might just be easier to give the solution. Believe me, I’d thought about the pages ago when I realised the error was my fault. But I decided to gt preachy instead:
I’m all for people learning to code, and believe me I’ve been there myself and I know how frustrating it is (the first night I sat down to write my own blog I actually cried in desperation thinking I’d never understand any of it), but the fact that the vast majority of posts in this forum are people handing out answers to already solved problems over and over again isn’t helping anyone. If someone can’t even be bothered searching the forum for the answer to the bloody register_globals problem, should they really be “writing their own blog script”? You want to learn to code? Great, I’m all for that and I’m all for helping people with their code so long as they can give me at least half an answer about what they think is going wrong. But — maybe this is a newsflash — you’re not going to learn to code by reading the BAB ‘tutorial’; you’re going to need to go to some outside sources and get some basics on control structures, expressions, variables and operators.
Harsh? Elitist? Both; but I worked hard to learn what I know (which admittedly isn’t much), and so did every other person I know who codes. I also know, from firsthand experience, that spoonfeeding doesn’t work. I remember one uni assignment we were asked to (and this was the whole assignment spec) “Solve the producer-consumer problem in Nachos”. This is a pretty common CompSci 201 kind of assignment. I had no idea where to even begin; I didn’t even understand what the producer-consumer problem was (the entire lecture notes on it included a diagram of a segmented doughnut with an arrow going in one side and another arrow coming out the other side). So I Googled the question, copied some code, handed it in and passed my assignment. Do I know what the producer-consumer problem is? Vaguely, now. Do I know how to ‘solve’ it? Hell no; I didn’t understand the solution then and I still don’t. But my problems with the producer-consumer problem wasn’t just about the question itself; it was about a fundamental problem suffered by pretty much every student at my uni, and that was lack of a decent grounding in programming basics. Not just the syntax stuff, but fundamental architectural concepts.
And that’s what I’m seeing here. Copying code without understanding the hows and whys of what you’re doing isn’t ‘learning to code’, and won’t help you solve your own producer-consumer problems when you encounter them. And yeah, this kind of attitude is going to turn a lot of people off; good, I’d much rather people turn away and go back to WordPress (which is good logware), than hear another sob story about how someone’s database got hacked or (worse) they got kicked off their host for using dodgy ‘homebrew’ scripts they didn’t really understand.
Quoted From: Dee @ CodeGrrl
I admit it now, it’s not going to be a popular opinion, and yeah, maybe it makes me an egotistical jerk. Or maybe it just makes me arrogant (since the underlying assumption is that I’m ‘saving’ people by turning them off before they get a real chance to hurt themselves).
But you know what? The internet already has more shitty PHP code that it knows what to do with; it doesn’t need another noob churning the stuff out.**
Maybe it’s time to put some code where my mouth is…
________________________________________
* Back In The Day it was the only available fanlisting script, and I’d told myself that I just wanted to experiment with something for once without getting the project lost in a mountain of custom webapp. After taking one look at the guts of the code, however, I knew I was doomed; I spent so long one afternoon ‘cleaning up’ the script that I might as well just have started from scratch.
** You can all totally shut up; I’ve been doing this for years and I totally got here first, k. Oldskool noobs FTW.
1382 days ago
125 comments