2007-03-01

PHP Arrays

Some day I'm going to come back to these posts and laugh at myself for being such a newb. Those of you who already know all this stuff have the pleasure of laughing at me right now.

I finished the HTML/CSS course, and it was about as easy as I expected. Aside from being pissed off for a few hours during the final assignment before discovering the difference between quirks mode and strict mode (which wasn't addressed in the course), it wasn't difficult at all.

It would be less confusing to the student if they gave more robust example code, though. I had a bit of a time trying to get their code for vertical CSS buttons working right until I tried it in IE. Suddenly it worked. When I found the tiny bug and pointed it out, my instructor's response was, "too bad all browsers don't render the same." Yeah. Thanks. I know you require your students to use IE, but how hard would it be to support other browsers? When your target audience is people who want to learn open source languages, you can assume that a larger than normal percentage of them will be using an open source browser. It's not as though what you're teaching is complex enough to require special CSS hacks, it's all pretty basic stuff.

The only HTML I've used in the last couple of years has been in my blog templates, and while I came away from this course with a handful of new tricks, the main thing I got out of it was a chance to hone some rusty skills.

Still, I was happy with it. It's a well-written course.

Introduction to PHP, on the other hand, is not. It was very obviously written by a (messy) coder, not a teacher. The first five lessons consisted of a collection of little tricks buried in an ever-growing spaghetti bowl of ugly code. Each new concept was shoehorned into the same snowballing mess, regardless of whether it made sense to do so.

Teaching a neophyte this stuff is hard enough without tossing ugly and irrelevant code in front of him. The person who wrote the example code is probably proud of some of the little hacks in it, but when those hacks are extraneous to the lesson they're just distracting. It's a bit like trying to teach a kid about baseball and suddenly interrupting yourself to talk about valence levels. Yes, from the right perspective, it's related. But just offer up the most relevant material before going there.

I managed to simplify the examples enough so they made sense, then figure out the small hacks later, but it took a lot of needless slogging.

They finally dropped the tangled ugly mess of snowballing code and started fresh in lesson six, and it suddenly got easier. Which is good, because lesson six was arrays. Clean examples helped tremendously. I can't imagine if they'd tried to shoehorn arrays into that other crap.

I didn't like this section. I "get" arrays just fine, but one of the assignments involved traversing through a nested array, which is a lot easier if you're not using PHP 4 (the version they teach with), which lacks the array_walk_recursive() function. Of course it's doable, and I have to admit that I learned more figuring out how to work around the lack, but it ticked me off having to write twice the code I would have had to if I'd been using the version of PHP I have installed on my own fucking computer.

I'm not old-school enough. I can just hear the old dogs saying, "Son, in my day iterating through an array meant keeping track of the keys' addresses in memory. So you had to use a few ifs. Get over it."

To that, I say "shut the fuck up, old-timer." If I've got access to a post-hole auger I'm not going to be happy about having to spend three hours sweating with a clam-shell digger. Yes, yes, I know. I learned more by hacking around a missing feature than I would have if it had been handed to me. I appreciate that. I just didn't enjoy it.

And that, I see upon re-reading, is a big fat lie. I hated it when I was doing it, but having done it feels pretty good. You old dogs already knew I'd say that, didn't you? I can hear you chuckling to yourselves.

I'm not quite halfway through this course and I already enough to know that, at the end of it, I won't know anything. It'll be like spending two years in art school having learned nothing more than how to hold a pencil. Hopefully I'll know enough to confidently dig myself out of my own holes. (I didn't plan that last sentence when I wrote the bit up there about clam-shell diggers, but it worked out well, didn't it?)

I'd be extremely interested in hearing stories of what it was like for you to learn programming. What language did you start with? Would you have started with something else? What concepts baffled you, and what "aha" moments got you over the humps? What approach did you take? How long did it take for you to feel proficient? What would you have done differently? What did you do exactly right? What was your frustration:fun ratio back then, and what is it now?

Go ahead, get nostalgic.

Labels: , ,

0 Comments:

Post a Comment

Links to this post:

Create a Link

<< Home