Nov. 15th, 2007

prog: (Default)
They say that every Perl hacker's journeyman project is an HTML templating system. I'm learning about a variant, running into clients who each developed their own SQL abstraction modules before hiring me. Like every other SQL abstraction module, it really has just one purpose: an attempt to avoid having to embed one programming language (SQL) inside another one (Perl).

To this I say: Bleah. I used to agree with this sentiment, and for years used modules like Class::DBI, which treat tables as classes and rows as instances. Clever, and easy to work with! But now try doing a right join. Ha ha, no, I know: show me how do to a subselect with that. Yeah. Either you punt and shove raw SQL into your code anyway, or you insist on doing it "Perlishly" with loops and checks, in which case a query that should have taken a tenth of a second takes several seconds or more.

In fact, I'll wager that your code is already running at horrible efficiency because you're pounding the crap out of your DB with unneccessary loop-based SELECTs instead of carefully doing case-by-case SQL queries that get exactly the rows you need, each holding exactly the columns you care about, every time you call an information-seeking object method. I'll also bet your INSERTs are ass-slow because you're not using bind values in them. Actually, you're not using bind values anywhere, right? Yeah, see.

My friend, if you're going to work with a little raw SQL, I argue you're already blown it, and may as well just let it all hang out, throwing out your half-useful abstraction layer. There is no sin in openly acknowledging that you're using an SQL database by actually writing SQL. If the fastest way to get some particular information out of the DB is to write a crazy-long and baroque query, then you should do so. Let the database do the work it's optimizied for and stop treating it like a set of config files that you'll need to write your own logic around.

Another way to put it: If you're writing nested loops in your SQL-driving Perl, you're probably doing it wrong.
prog: (Default)
I had some questions about the Netbank → ING transition so I called them. A non-robot human answered the call so quickly that I hadn't yet pulled up the page in my notes with my questions on it. This surprised me, and if she hadn't used a corporate slogan in her greeting I would have assumed that I dialed the wrong number. To buy time, I told her this. She laughed.

That's a good first impression, that is.
prog: (Default)
I think this is everything but it wouldn't surprise me to learn that I'm leaving something out.

I am a Strange Loop: Borrowed from Zarf. Quite thought-provoking. I find myself reflecting often on the metaphors of mind that Hofstadter presents (and then tells nigh-innumerable parables about). That said, I stopped reading it after I bought...

Spook Country: Purchased at a signing event at the Brattle. I like it, but like all of Gibson's recent stuff it's not very grabby. On my recent train ride to Jersey I re-read the most recent 50 pages or so to re-contextualize since my last stopping point, and I barely remembered any of it. My reading this actually interleaves with...

Imajica: The first of two novels I bought at the Big Chicken Barn while vacationing in Maine last month. Probably I should have read this when I was 16, but some of my friends had been bringing it up in recent conversation, so what the hell. I was all right with it until about halfway through, when it starts to become clear that the only female character (who, because this is a Clive Barker novel, represents all of womanhood) is actually as much of a weak-willed twit as she seems. Seriously, I assumed that she was under a villainous enchantment, until the writing took turns that suggested otherwise. So I hang it up for a while, and that leads to...

Jhereg: The other Chicken Barn book, and another that I should have read as a teenager. I hadn't even heard of Brust until this decade, actually, and I think it was through [livejournal.com profile] tahnan or [livejournal.com profile] temvald slavering over him at a game night? Does that make sense? Anyway, started this today. Seven pages in. Hooked. We'll see. It's short, so if any other books wanna wedge into this one, they'd better act fast. (I borrowed some crazy Martin Gardner books from [livejournal.com profile] dougo the other day but they're just kinda hangin out right now.)

August 2022

S M T W T F S
 123456
78910111213
14151617181920
21222324252627
28 293031   

Most Popular Tags

Style Credit

Expand Cut Tags

No cut tags
Page generated Jul. 31st, 2025 11:54 pm
Powered by Dreamwidth Studios