Latest articles

The TwitFace Network

"The Social Network": A vaguely-but-not-really true moviedrama-fest about a useless ivy league twerp who made a far more useless website, the popularity of which conclusively proves society's epidemic brain damage. (Seriously, how much of a hopeless loser do you have to be to blow time on any of that social networking drivel? Get a goddamn life.)

And yes, I'm writing about a movie I have not and will never see. Deal with it.

Even if I had a shred of interest in TwitFace, compared to this sort of uber-drama, I'd be less bored staring at a wall for two hours. That's not an exaggeration. I'd sooner watch more Stargate Universe or rewatch JJ's vaguely-Star Trek movie (which I did eventually see the rest of the way through - it never got any better.) Yea, that bad. Hell, just the trailers for The Social Network were painful enough.

I do respect Trent Reznor and Atticus Ross's work on the soundtrack. But couldn't they have lent their talents to a movie that would have actually been deserving?

Speaking of Trent Reznor, and getting more offtopic, I recently come across this (rather old) bit. Note the comments. Obviously I wasn't paying attention when it was decided that celebrities aren't allowed to have opinions. 'Cause that's news to me. And yes, in complaining about that, I am somewhat contradicting myself. Go twit yourselfabout it.

Read more


Only an Idiot Would Misrepresent Opinions on Validation

I recently came across Raymond Chen's nearly-two-year-old article "Only an idiot would have parameter validation, and only an idiot would not have it". It was interesting, and so were the comments, but I think Chen's account of the situation is flat-out wrong.

After mentioning that people's reaction to Win3.1's new feature of parameter validation was "It's about damn time", he says:

"But nowadays, parameter validation is out of fashion again. If you detect an invalid parameter and return an error code, then all you're doing is masking a latent bug in the application. It should crash and burn with a big red fat'n'ugly blinking exception. "

Unless there's some real doofuses that I haven't come across, parameter validation is not out of fashion (and wasn't two years ago, either). What's out of fashion is responding to those failure conditions with a mere return code instead of something like an exception.

Getting rid of parameter validation does not amount to "crash and burn with a big red fat'n'ugly blinking exception". It can, but not reliably so - only if you happen to be lucky. And maybe it's just that I don't get out enough, but I'm not aware of anyone who does consider ignoring error conditions to be a reliable way of making an app shout "Failure, failure!" from the rooftops. Maybe it really was back in Win3 as Chen suggests, I don't know, but it's not the case now.

Although, what possibly has flip-flopped (and perhaps this is where Chen got mixed up) is the idea that returning a "bad params" return code is better than forging on and letting shit hit the fan (FWIW, I'm not sure which way I lean on that). I don't think that change in popular opinion happened for entirely unreasonable...umm, reasons. It sounded good at the time, and then we learned it doesn't work out as well as we had hoped in actual practice. So some people are on the other side of the fence now. Live and learn.

BTW, In the title of this, I'm not calling Raymond Chen an idiot. I'm making a play on words with his article's title. So there. Idiot.

Read more


The Internet Attracts Jackasses...And That's Probably Good

I started this "not-a-blog" for two main reasons: To practice and hopefully improve my writing ability, and to act as a pressure release valve. I hate shit. I hate tons of shit. That's no secret, just look through the archives here - I'm a serious virulent fucking ass when I choose to be. What do you think happens when that shit doesn't have an outlet? Certainly nothing good.

But, contrary to what the hippie, feminazi, PC-brigade would have everyone believe - that's normal. Unless you're a spineless doormat, of course, but I'd rather be an ass than have such a disgraceful lack of self-respect. YMMV. That's a blatant lie, of course: Spineless doormats are no exception at all - they're a classic example of an internally destructive consequence.

Whether productive or destructive, internal or external, pressure gets out one way or another. Always. Unless you use a really good sealant...No, always. Pretending it doesn't exist, willing it away...Not gonna work, you're flirting with disaster.

So I write venomous shit. Write. I write shit that no one really even has to read anyway. Shit that nobody has any legitimate reason to even give a crap about. And even if nobody reads it, which is likely anyway, merely writing it and putting it out there makes dealing with that crap manageable.

But as a notably wise man once observed: "I look and see it's not only me..."

The fact of the matter is, our society breeds stress. That's a terrible thing, and it needs to change, but that's modern society's dirty little truth.

So everyone's stressed halfway to the breaking point, if not more, (especially high school students - fuck, I wouldn't go through that hell again for anything in the world) and all the resulting excrement gets sucked up into the Internet by the metric fuckton.

A bleak, unfortunate result, right? I don't think so. Pressure gets out one way or another, right? How did we relax and get by without the internet? Uhhh...alchohol, some other fun substances, domestic beatings (family fun for all ages!), school violence (yes, it has been decreasing - try turning off CNN, "Action" News, and Fox News sometime, your brain might heal) and a fine selection of various other misdemeanors and felonies. Oh, yea, and drum circles...Hmm...Yea, umm, so tell me more about that "felony" thing...

But now we've got a bunch of asinine keyboard-diarrhea filling up the internet. Really not so bad, all things considered. Of course, that's still no reason to feed the trolls...

So basically, the internet is one big collective mega-fart. Ahh. Much better.

Read more


Don't Use Arrays As Stacks

EDIT 2011.10.27: I'll cut to the chase: You can do it in D, it'll work, but it will be slow because whenever you pop and then push, it will reallocate and copy. And stacks do that frequently. For more details and a solution, read on:

The D programming language has fantastic array features. The ease of using D's arrays makes it very tempting to use them as stacks:

int[] stack = [1, 2, 3]; stack ~= 7; // Push auto x = stack[$-1]; // Peek stack = stack[0..$-1]; // Pop (Uses slicing, so it *doesn't* copy any data)

Brilliant! Right? It is, as long as you want an array. But if what you really want is a stack (that is, whenever you'll be doing a lot of pushing and popping), then this is unnecessarily slow. Why? Because of excess allocations.

"Poppycock! Arrays have a reserve capacity which prevents excess allocations."

Yes, but slicing can get in the way of that. Consider this example of using an array as a stack:

import std.stdio; void info(ref int[] stack) { writefln("length %s, capacity %s", stack.length, stack.capacity); } void push(ref int[] stack) { stack ~= 7; write("Push: "); stack.info(); } void pop(ref int[] stack) { stack = stack[0..$-1]; write("Pop: "); stack.info(); } void main() { int[] stack = [1, 2, 3]; stack.info(); stack.push(); stack.push(); stack.pop(); stack.push(); stack.pop(); stack.pop(); stack.push(); }

That produces the following output with DMD 2.055 Windows:

length 3, capacity 3 Push: length 4, capacity 7 Push: length 5, capacity 7 Pop: length 4, capacity 0 Push: length 5, capacity 7 Pop: length 4, capacity 0 Pop: length 3, capacity 0 Push: length 4, capacity 7

The first three lines look ok: The stack starts with three elements and no extra reserve space. A fourth element is added, but there isn't enough room, so it bumps the capacity up to 7. So there's four elements, with room for three more. Then, when a fifth element is added (sans Bruce Willis, unfortunately), there's already enough space for it, so we get that fifth element without another allocation. Joy!

Then we pop an element off...and the capacity plummets to zero?! WTF?! The reason for this is aliasing. For all the array knows, we might still have a reference somewhere to the full original array, including that fifth element:

int[] stack = [1, 2, 3, 7, 7]; auto stackOriginal = stack; stack = stack[0..$-1]; // Pop assert(stack == [1, 2, 3, 7]); assert(stackOriginal == [1, 2, 3, 7, 7]);

Suppose we now append another value to the stack:

stack ~= 20; assert(stack == [1, 2, 3, 7, 20]); assert(stackOriginal == [1, 2, 3, 7, 7]);

In this case, the append must allocate new memory and copy the old data into it. Otherwise, it would clobber the last value of stackOriginal with 20. In other words: After being popped, the stack can no longer guarantee it will still be able to accommodate up to 7 elements without allocating, so its capacity is set to zero [1].

The end result is: Slicing an array is fast, and appending is usually fast [2], but slicing the end off and then appending is slow. But since that's how a stack is normally used, arrays make for slow stacks.

How can you have a fast stack? By handling an array's length and capacity manually. The basic principle works like this:

int[] stack = new int[100]; stack[0..3] = [1, 2, 3]; size_t stackLength = 3; // Push stackLength++; stack[stackLength-1] = 7; // Peek auto x = stack[stackLength-1]; // Pop stackLength--;

That's not as nice, but fortunately those details can be hidden in a templated struct that provides the same syntax as arrays. I've already written such a struct, available in my SemiTwist D Tools project. It's perhaps not as fully-featured as it could be, but it should work in most cases as a drop-in replacement for an array. When I dropped it into the parsing engine for my Goldie Parsing System I got an instant 5x-6x boost in parsing speed [3].

So don't use a plain old array when you want a stack. A proper stack will give you far better performance and memory usage.

One caveat about this method: If you save a slice of the stack, pop elements off the stack, and then push new values back on, the old slice you took will likely [4] reflect the new values, not the original ones.

Note that Phobos's development has been accelerating for the past year or so, so I wouldn't be surprised to see a superior stack implementation in std.container sometime in the not-so-distant future.

For more information about D's arrays and slicing, see Steven Schveighoffer's award-winning article, D Slices.


[1] Why is the capacity set to zero instead of the actual length of four? I'm not certain, but my guess is that zeroing the value is slightly faster than copying the length. Either that, or perhaps it has to do with the fact that the slice doesn't actually "own" the data. Update 2011.09.26: Steven has explained why it's zero.

[2] If you're doing a lot of appending, you may be better off using D's Appender.

[3] This figure is parsing speed alone, not lexing and parsing combined. Your mileage may vary.

[4] I say "likely" instead of "definitely" because of an unfortunate indeterminism inherent in D's array/slice system. This quirk is explained in the "Determinism" section of Steven Schveighoffer's article mentioned above.

Read more


Pushing "Cloud" Proves You're an Idiot Trend Whore

Initially, I had a hard time wrapping my head around the concept of "Cloud" computing. Until one thing occurred to me: It's exactly the same as two concepts we already had, and with names that were already in widespread use: "Hosted" and "Web App".

Gee, I guess it's not web hosting they do after all, it's "Cloud" servers. I guess that must mean it's better. Oh, I see, Microsoft's new DBMS isn't a hosted database, it's a "Cloud" database. Wow, that's so progressive and high tech. And Google Docs isn't a web app, it's "Cloud" computing. Well, fuck me.

It's like the idiotic word "tween". A group of people were too dumb to know the word "preteen" already existed, so they contrived and spread a moronic alternative. And they weren't even as original or clever about it as they thought: Animators had already been tweening for years. Which, of course, just sounds like pedophilia now.

To those pushing and marketing this "Cloud" nonsense: You're like the fashion industry except worse, because being in technology, you of all people should know better than to be a bunch of mindless trend whores.

Suck my cloudsack.

Read more


Back up again...

The "Newer TangoCMS version available" banner in the control panel finally started annoying me enough that I made the mistake of upgrading my TangoCMS installation. A bunch of stuff broke. Then my webhost switched me to another server and that particular version of PHP broke things even more. And my attempts to fix it nearly nuked the DB.

So for months, this site went through various forms of brokenness.

Now, after some DB micro-surgery, a few months, yet another server change, and some blind dumb luck, it's basically working again. Except the side-bar navigation. That's still thoroughly hosed. But I ain't touching it.

I am working on a completely home-spun system, written in D (no more PHP bullshit, I've had enough of that piece of shit excuse for a language), which will fix all the things I hate about this and every other off-the-shelf CMS I've ever come across. Not to mention a new webhost (VPS or bust!). But it's not ready yet, and I don't know when it will be (as a pet project, it's unfortunately on a pet project timeframe). At least this incarnation is more-or-less hobbling along in the meantime, though.

EDIT (2011.09.24): Comments are still here. I know there's no link that says "Comment" anymore, but just click an article's title or "Read more" link. The comments will be there.

Read more