Home
 

Thinking Inside a Different Box

About Recent Entries

Hockey Wuss Jan. 2nd, 2008 @ 01:31 am
At one point during the game, Buffalo defenseman Henrik Tallinder appeared to stumble over a hole in the ice. Luckily, he didn't hurt himself, but what if he had? And with all due respect to Tallinder, what if Crosby had fallen in a hole or been blinded by snow and crashed into Georges Laraque or some other inanimate object?

There was an outdoor hockey game in Buffalo, and this is one of the quotes from Mr. Burnside, an ESPN NHL 'Analyst', arguing against making outdoor hockey games a regular event. I'm pretty well convinced that word 'analyst', to ESPN, means "someone who knows how to sensationalize everyday events". In any case, he wrote that above; and it made me think (which is ironic, seeing how he obviously wasn't when he wrote it).

And this is what I think: What the hell? I mean... seriously. Hockey players are supposed to be touted as the toughest blokes in uniform. They pride themselves on being much tougher than American football players. Proof? Despite moving at near twice the speed of a sprinting human, and having quite solid walls to be rammed into, and having a rock-hard surface to fall onto, hockey players still refuse to wear anything more than basic padding, and only recently started requiring helmets, and still insist on wearing helmets that hardly even cover their head. How many times have I seen a hockey player's helmet fall off as his head is driven into the ice? Oh, a few dozen now. And I only watch the highlights! And Burnside brings up the argument of stumbling as some tragic event that, he implies, might be unforgivable?

Football players play outdoors pretty regularly. Rain, snow, even ice on occasion. The fear of injury only comes up in the worst of conditions. I suspect most of the actual hockey players feel about the same. Oh sure, they might hate the fact that the conditions make them look ordinary (flopping puck, bad passes, etc), but getting hurt? Foolish.

Furthermore, it's a moot concern. This is the first time in the US an outdoor NHL hockey game has been held. According to reports, many of the techniques used to get the stadium ready were new ideas, never before tested. In other words, the admins had little clue what they were doing and had set themselves up a large margin of potential error by trying to go "above and beyond" the methods employed by similar previous outdoor hockey games (only three ever, so far). In all likeliness, future games will be much better in the "quality of ice" dept anyway.

... and for that matter, the three previous outdoor arenas all had better ice conditions than this one. In other words, it's an anomaly of sorts. In fact! It's not exactly uncommon for ice at indoor arenas to get hacked up pretty badly. Especially in some of these not-so-hockey towns, where they turn the heat in the arena way up, to keep from driving away potential dis-interested non-fans from showing up for corporate-sponsored beer-and-chips parties (*cough* Phoenix, AZ), the ice often ends up getting non-repairable divots, and feels like mush by the end of the 3rd Period.

I'll bet a donut players enjoy playing in crappy outdoor conditions in front of an audience that cares more than they enjoy playing in crappy indoor conditions in front of an audience that can't be bothered to with the fact the players exist.

So yeah, Mr. Burnside, what if the guy had been injured? You're the big fancy analyst. You try and answer the (stupid) question. I will! Nothing. Nothing would have changed. Audiences would still love it, players would still like it, and most importantly it still generates massive revenue for the teams and the league (which even the players understand the significance of now, after the strike season and yet another round of threats of teams moving to new markets).

In other news, there is a single simple and good reason not to do regular outdoor hockey games: The whole concept of a unique spectacle will be lost. It's that simple. You do it enough, and it loses its newsworthy effect. Hype is only hype if you didn't hear the exact same thing yesterday. If outdoor hockey games became commonplace, people would no longer scramble to witness it, since in all fairness, many of them only went to the Buffalo game because they perceived it to be a unique event.

That said, I think having one or two outdoor games a year in different cities would balance the threshold between Spectacle Event and Too Much Hype. It would draw big crowds, high revenues, and yes the players might trip over a snow bank or two in the process. God forbid!

Two times the fun from the WTF?! Dept. Dec. 1st, 2007 @ 12:43 am
WTF #1: Casting Picks for the upcoming Dragonball Z Live Action Movie

Firstly... well.. um.. a LIVE-ACTION DBZ movie? WTF?! And as if that alone wasn't enough to totally blow your mind, just look at the guys they've cast for it! These are the types of actors who got turned down for roles in shows like Scrubs and the OC, and now they're going to be cast as Goku and Piccolo? Just how much Dawson's Creek can producers mix into the Dragonball concept? I dunno, but I'm sure we'll find out.

WTF #2: Simple tasks in .NET that people are convinced don't exist.

The most recent culprit I've discovered:

* Capturing the Mouse to a window or control.

Why this surely must be a cinche, so WTF? It's a WTF-case because it is a cinche! Err, what? That's right, it's dead-pan easy. This is a shocker because as far as I can tell there's hardly a blogger or forum answer guy out there who knows how to capture the mouse properly -- or, at least, none who are important enough to score a high rank on relevant Google search terms.

Here's the deal: If Google is your Oracle of Programming Knowledge, you'll most likely be led to believe that the only way to capture the mouse requires the use of Win32 APi functions CaptureMouse and ReleaseMouse -- which of course isn't exactly difficult in its own right, as it only requires setting up some reasonably straight-forward P/Invoke prototypes. But Microsoft couldn't have have overlooked these obvious, necessary, and simple features when implementing the new .NET Framework, right? Not according to this:

Quoting http://www.thescripts.com/forum/thread234697.html:
Actually, .Net did not include all the feature of windows. So it introduces the P/invoke technical to supplement it. Many platform related issue should be completed through P/invoke.(Such as Hook technical, Memory Mapping File, etc)

Jeffrey Tan
Microsoft Online Partner Support

That certainly sounds rather definitive and matter-a-fact-like, coming from Microsoft Online Partner Support. I was still skeptical though (and for good reason, since mouse capturing is required for even most basic Windows UI behaviors), so I paged through the Windows.Forms.Control class... and after about 16 seconds of browsing, found this:

Control.Capture Property

Quick summary of that link:
Control.Capture = true;  // Mouse is captured!
Control.Capture = false; // Mouse is released!
... that's it. That simple. And it's been in there since the first incarnations of C# and NET framework (v1.0+). So much for Microsoft Online Partner Support competence.

Aspergers w/ Cheese. Hold the Onions! Nov. 26th, 2007 @ 05:32 am
Aspergers Syndrome sure isn't what it used to be.

As little as five years ago, Aspergers was widely considered a variant of Autism Spectrum. It still is in text (largely by legacy definitions), but not so much in practice. The criteria for diagnosis five years ago and the criteria today, both as found on the web, are vastly dis-similar. Honestly, I find that the "new modern" criteria for Aspergers has been generalized to the point where it can safely encompass just about every self-proclaimed "computer nerd" that's ever lived. Any sort of asocial behavior combined with analytical thought tendency == Aspergers! It's a bit silly really. This is not unlike the history of Attention Deficit Disorder, which went from being a diagnosis for a severe behavioral problem to something that just about every kid on earth can qualify as on those occasional restless and unfocused days that we all have. (more on why this has happened in a bit)

As I (used to) understand it, in order to be an accurate "official" diagnosis of Aspergers, a number of autistic-like traits must exist or or have existed during early/mid childhood (most Autism Spectrum and even some severely autistic grow out many of these as they get older though). Here's a basic list, with the more pertinent Autistic behaviors first, and more general behaviors afterward.

- Fear of loud noises or bright lights/colors. In particular, a reaction toward noise/light as if it's physically painful.

- Sensitivity to the seams in clothing, like the toe seam on socks or shoulder seams on shirts, and in particular exhibiting a preference toward rather going naked or wearing togas instead of "enduring" the pain of those seams.

- Moderate to extreme clumsiness or lack of coordination. Obvious examples include abnormal difficulty catching or throwing things, handwriting (especially cursive), "two left feet", etc. Less obvious are things like an inability to learn how to tie shoes properly, or open a box of cereal without tearing the whole top of the box into bits.

- Repetitive movements such as rocking or twirling, self-abusive behavior such as head-banging, or destructive behaviors such as carving, whittling, or otherwise dismantling things in rote fashion.

- Difficulty comprehending 3D projection on 2D media. In particular non-photograph material (artwork, games) will appear as the literal flat images, resulting in a failure to comprehend the "true" meaning of otherwise simple 3D->2D projections.

- Seemingly doesn't know how to play with toys. In Aspergers in particular this can manifest itself in the form of very selective toy favoritism (ie, the child gravitates toward the toys he/she "understands"). It is even apparent in video game selection: complex games with character inventories and such will usually be almost impossible to comprehend, while much simpler current-visual-state/reaction games will be effortlessly mastered.

- Lack of eye contact and/or lack of name recognition. In severe cases, a child can act as though they are deaf.

- Regular displays of frustration, unhappiness, and anxiety - which may or may not lead to tantrums or panic attack. This is obviously very common among all children and so it comes last. The notable trait in autism is usually the timing of tantrums: they'll often occur in situations that don't seem to have much rhyme or reason, leading to the adult assessment that the child must be trying to be "difficult" for no reason other than to be difficult. From the autistic child's perspective, there could be any number of things that trigger the attack, such as any of the things listed above (anger/frustration over itchy clothing seams, noises or colors that an adult might not even notice, etc).

These are the traits that link Aspergers to Autism Spectrum disorder, and without at least some of these traits present, the current Wikipedia-listed criteria for Aspergers becomes little more than a chart for identifying children who don't fit that "perfect" cookie-cutter model for social behavior.

So what's up with these children's disorders always getting blown out of proportion? The modern school system! It's a well known fact that the school system is ill-adept at dealing with children who don't fit the mold around which the whole system has been designed. In the case of AD/HD, it was popularized to help protect all the kids out there who can't sit still and learn impractical and useless drivel for 6 hrs at a shot. Aspergers has been popularized thanks to increasing amounts of classroom and campus over-crowding. Classroom over-crowding makes social interaction a critical part of public school survival; and it makes analytical thinkers with asocial tendencies both tease-fodder and a potential classroom distraction.

Children who don't fit the required educational system mold are both disadvantaged and worse are often a distraction to the rest of the classroom; mucking up the finely tuned education system like a misshapen sole on a shoe assembly line. No time to fix! You either sew it together hap-haphazardly, or you toss it aside and focus on the other ones.

In order to get these otherwise normal - but not well-suited to school life - kids some sort of specialized educational environment that's still covered by the government tax dollars, well-intentioned psychologists have to find ways to diagnose them as having some sort of disorder that the government recognizes. Word gets out. Jimmy's aunts find out that he got diagnosed as AD/HD -- he's not, but the psychologist recognized the poor kid needs special care in "school terms" and using the diagnosis was the best way -- but Jimmy's aunt doesn't know that. She just knows that her son had bad grades too and is every bit as obnoxious as her nephew, and off to the doctor she goes so that she too can get her kid whatever it is he deserves.

Years later, not-so-well-intentioned psychologists, doctors, and in particular pharmaceutical corporations, take advantage of the ever-expanding popularity of this new syndrome-turned-hot-topic, and along the way the clinical meaning of the term itself changes to match the children that have been diagnosed with it.

... which happens to be just about anyone who has difficulty coping with school.

Thus, I find that terms like Aspergers and AD/HD today have far less to do with normalcy or behavioral patterning, and have almost everything to do with what's required from a child to be a functional attendant of the modern american school system. I guess in a way, that is a definition of normalicy. It's the brave new world.

Toys of Discovery Nov. 23rd, 2007 @ 07:55 pm
Yay! I have stumbled across a couple free software packages that, in the hands of an unskilled non-atisan as myself, are both fun and entirely non-productive. It's like getting a whole new set of Fisher Price Little People all over again.

First on the List:

Google Sketchup!

Download From: http://sketchup.google.com -- Don't bother with the Pro version. It's $495, or approximately $490 more than someone of my social standing could ever hope to afford.

Benefits: It can draw regular shapes! The Extrusion and Follow Me tools are the funnest things on earth! Although admittedly, I'm not quite sure why they're so fun, nor am I sure they'd be fun for anyone who doesn't exhibit the level of geekiness that I often do.

Drawbacks: All the tutorials are in streaming movie format. Woe is me, who misses the days of text-based documentation. Ah, silence is bliss, and text serach ability is useful! Watching some bloke do junk on the screen is comparatively boring and slow.


Second on the List:
InkScape!

Download From: http://www.inkscape.org

Benefits: If you ever spend more than 5 mins of your life working on website graphics, this has all the benefits in the world. Can even make me look like I know what I'm doing when it comes to art (or otherwise known as "crap" where my abilities are concerned).

Drawbacks: None that I know of!


Inkscape in particular has about a bajillion fan and contribution sites, and another half a bajillion tutorials. There are tutorials for just about every written language too, not that any of my readers here would care too much about that particular caveat. Maybe later tonight I'll post a creation or two spawn forth from these programs, since lately all I've been doing is playing with them.

Nov. 21st, 2007 @ 05:31 pm
Is someone who posts an idea or theory on the internet more than likely to be shot down by hordes of young, egocentric religious kids that wouldn't consider a single idea unless it was they who thought of it first? Phrased other ways: Is information posted on the Internet wasted effort? Does the internet fuel mis-information, deception, and destruction of our society?

... and is that different from material published non-internet?

Answer: There is no good solution to obscurity. To eliminate obscurity in the media channels can lead to its own can of worms.

Mis-information, mis-direction, and falsehood has always existed and has, as far as my studies have concluded, maintained a pretty consistent status quo. I don't think the problem is the ease of transmission so much as the changes in potential for damage. And that potential is related to strength/power -- which stems from technology and population more than anything else. (strength via weapons and strength in numbers)

In this way, I find that the internet is actually beneficial in many ways. The Net turns both the good and the bad of information sharing into obscure endeavors: creating "en masse" trends that lead to the strengh-in-numbers required to form dangerous lynch mobs becomes ever increasingly more difficult.

Let's take a trip through time! (it's like an episode of Mr. Peabody and his Pet Boy Sherman!)

For example, when the Gutenberg Press was invented in the 15th century, it was largely controlled by a few select entities -- countries and large corporations that had the capital to construct and operate them. If you didn't like what they were printing, all you could do was yell out your window in disgust and hope your neighbors cared enough to listen.

In the 1800's things changed as pressing newspapers and books got easier and easier, especially in the United States and Britain. Postal services also saw leaps and bounds in functionality. People were able to communicate between each other, and then publish their thoughts to niche journals and other small-time media outlets. People were able to do more than just yell out their windows, and as a result the whole of media experienced a period of relatively high accountability.

Unfortunately, the TV news media took a step in the wrong direction. It restored a pattern of limited (and controlled) media distribution, where-by the large majority of people can be force-fed select soundbites at the discretion of news media management. The TV news decided what to air and when to air it, and in the process they grew rich and powerful enough to also buy up many of the major newspapers. Changes in the scale of economics - in part thanks to entities like McDonalds, Sears and Wal-mart, which helped to create an economic standard that requires large-scale production in order to turn a profit - the small time papers, journals, and editorials lost their ability to stay in business. The major news machine thusly returned to rule the roost.

But thanks to the internet things have shifted quite a bit the other direction, at least for now. Yes, there's plenty of mis-information on the 'net, but the wills of individuals are not able to dominate the field. They're lost in the obscurity almost as much as everyone else, which of course means that the power is more balanced (as much as we can hope for) than it has been in the past.

That said! Your real enemy to target is usually blind patriotism! Blind patriotism will undo all the benefits of informational integrity. People can have all the right info int he world, but as soon as they think they're doing 'right' by their fellow neighbors, compatriots, comrades, or whoever -- they'll cheerfully and joyfully lynch the heck out of everyone else who isn't one of those people. The worst part? As far as I can tell, that's just human nature. It's possible to clean up the condition of public information, it's possible to apply accountability to the major media channels, and it's even possible to give people a secularist and/or humanist "greater good" focus. But it's impossible to turn off blind patriotism... and that's when otherwise smart people turn into slobbering warmongers; ever-too-eager to prove their moral compass and none-too-eager to adhere to the depressing truth of the unfair needs and desires that comprises existence.

So the conclusion is: Adding to the obscurity of the internet is probably a good thing. Niche markets and niche opinions influence small amounts of people, which helps reduce the strength of the mass media channels that are oft-times controlled by mere individuals. This helps fuel, if nothing else, greater diversity of mis-information, which is still better than unity-in-mis-information. And in most cases, it helps fuel better levels of accurate information since that info is often not available at all in a world dominated by mass media.

So embrace the internet and, once again, embrace the irrelevance. Your obscurity matters!
Other entries
» A Part 2 to the previous entry
I'd like to re-iterate that axe'ing the IM thing hasn't really affected my life in any way except that it's limited my already meager 'exposure to the opposite sex' potential. Other than that, I really haven't noticed a difference... and even there I don't notice much of a difference. It was a lot easier for me to sort out some communicational success when the internet was a much smaller place.

These days I'm just another bland and forgotten shrub in the chaotic grassy field that is existence; lacking the required social competence required to stand out among the crowds, and lacking the unsophisticated nature required to relate to (and not intimidate) the lower common denominators who don't stand out. So I'm right back where I was before I found the (much smaller) internet many years ago. So much for progress and development.
» Ex-Communication Redefined
In another move to improve my life, I have sworn off most forms of real-time technology-based communication. I don't use instant messengers or chat programs, period. I only use phones sparingly; for business and immediate concerns discussions only. As I spent some time reflecting over my life (which I do far more often than I used to, since I have little to look forward to these days) I came to realize that bad things happen to my social condition when I use instant messengers, chat rooms, or telephones. Furthermore, nothing especially good has come from my use of IMs, chatrooms, or telephones. Analytically speaking, I've spent most of my life relying on these things as my primary forms of communication and connection, and likewise my life history is a winding trail of failed projects, failed relationships, and alienated friends.

... which is a clear indicator that I need to change something, because what I've been doing hasn't done me many favors. So I applied cause-and-effect analysis and combined it with psychological education and observation. At the end of it all, I concluded that IMs and chats suck (for me anyway). Most of the worst moments of my adult life have occurred in front of a monitor or at the end of a telephone, and most of the better moments of my adult life occurred nowhere near either of those. So I'm playing the numbers:

Instant Messengers! You are the weakest link!

What does this mean to you? If you're one of the (very few) people who still had me in your instant messenger friends list, then you'll have a better idea why I haven't been online for nearly five months now! More importantly, you'll know that I'm not going to be online anytime soon, and that anything you might have sent me on ICQ or Yahoo or whatever other stupid program will likely never be received. Sorry. Sucks to be the poor little offline message, stranded in the void of IM Server Hell. It's sacrifice may very well be my savior!

... eh, not really. But it's fun to sound like a nutty bloke preaching about manifest destiny, life-after-death-ness, and other desperate attempts at self-relevance. :)

Unfortunately, the most stand-out consequence of this decision is that I'll likely never have another relationship again. Why? Because my three prior relationships all spawned via online communication and phone conversations (and all of them ended the same way), and thus far there is absolutely no evidence to support the theory that I'm capable of attracting a female without the help of communication-by-proxy -- via monitors, keyboards, and/or phone receivers. Then again, I haven't had a meaningful online IM session with a girl in almost five years either. So either way I appear to have drawn the short straw (or maybe I missed drawing any straw at all), and so I might as well simplify my life by removing unnecessary (and potentially distracting or socially destructive) technological clutter.

IMs are out of the question, but I still read emails and journal comments! I have no one in real like to talk to other than my parents. No one, nothing, no how, nowhere. My entire social circle consists of this journal and a nearly-defunct forum (2ddev!). I'm not exaggerating.

I may not reply for some days, weeks, or even months depending on my current (lack of a) daily routine, and I'll probably say something that's seemingly disinterested, cold, depressing, or potentially insulting. The great part is that most of the time I'm trying to be constructive and complimentary, so with that in mind you can be entertained by my befuddlingly incompetent attempts to make myself useful.
» My Irrelevant Status to Date
So some months ago I decreed that - perhaps - I should move on to "the bigger and better" (as far as informative programmer information exposure is concerned) and find myself a real programmer's blogging server for my sudden plethora of verbose C# explorations. Alas, I spoke too soon; and I should have thought better of it right from the beginning if not for the dreaded trap of "hopeful thinking" clouding my judgment.

... I do find that so-called positive thinking is half the time as destructive as it can be constructive the other 50% of the time.

Whatever am I talking about, you ask? I'm talking about the fact that I am, if nothing else, wholly inconsistent. Always. (I hope Wal-mart won't sue me for trademark infringement) I have never done anything with consistency or reliable predictability for more than a few days or a few weeks at a time. If I go on a run of a series of C# essays for a month, I'm likely to fall out of the loop the following month, and am likely not to regain another run for several months.. or even years. I'm like this for everything: running, programming, basketball, cooking, the foods I eat, or even when (or where) I sleep. My (very limited) experience with girls even follows the same retarded (lack of a?) pattern... something that has kept me up long nights in lonely seclusion as I try to puzzle out possible solutions when I'm again in that situation.

... but on the morbidly bright side, there's a good chance I'll probably never be in that situation again anyway. It's been three years since my last (brief) phone conversation and almost five years since the last time I talked to a girl in-person for more than 20 minutes.

Going back to the original topic; there's no place for me on a dedicated programmer's blog. Not to say that there aren't dozens of other dorks with defunct programmers' blogs, but I'd just as soon not add to the pointless idiocy. I find programmer blogging sites to be a wealth of information, and adding belated blogs like the one I would have to the mix would only lessen that value -- and that is not my goal.

In all of my (not so) newly-found angry, insensitive, disattached attitude, I'm still completely and totally selfless when it comes to decision making. Even when I blatantly make decisions to further my own personal cause, my personal cause inevitably ends up being in the best interest of someone else. And fuck you anyone who thinks I need to change that aspect of my personality, because I've learned that to take that away from me is the equivalent to expending all purpose to my existence, and at that point I might as well be dead.

So I'm here to stay on the LiveJournal, right where I (don't really) belong: in line with all the redundant soul searching, teenage angst, school years diaries, gamer bragging, and whatever other emotional irrelevance that begets most human existence. Not that I belong here either. It's just that here I'm less of a distraction to the grander focus and purpose of the site since, well... there isn't one! Oh the joy of existence without structure.
» John Doe
While watching reruns of a canceled TV series "John Doe" on the Sci Fi channel, it occurs to me that if the show had a different name that it would have been no less than 3 times more likely to have been extended into a second season.

John Doe is at the very least as good as shows like Psych, and is unquestionably far superior to other shows like Numbers or any one of the CSI spinoffs. But it has a terrible title. Imagine how much more viewership it could have gandered if it were called The Phoenix instead. Seriously. I bet that would have made all the difference.

It's an unfortunate fact of the human condition. Names matter.
» (No Subject)
I stumbled across this (dated) blog entry and the comments truck me as both amusing and very similar to a recent discussion here:

http://discuss.fogcreek.com/dotnetquestions/default.asp?cmd=show&ixPost=6598

This is a perfect example of how not to hold forum discussions. -_- The first reply to that post pretty much says everything there is to say about the Ternary Operator: It's useful in functional programming for readability and maintenance, and otherwise just a minor variant aesthetic option that's seldom used. An astute reader would of course infer that the operator is not very useful for objective programming (the near-opposite of functional programming), which of course encompasses 95% of your business-related coder shops and offices. Yet there are 25-so more replies, only two of which have any constructive content what-so-ever.

... the rest are just instances of opinionated idiocy stated-as-fact, counter-acted by instances of trying to set the record straight, with a couple mediator-type posts thrown in to try to extinguish the flames. The whole thing is ridiculous because it really doesn't matter. Little in the world changes whether or not the operator is used properly, used in excess, or banned altogether. People have used languages like Perl and Scheme for years, thus I'm convinced that any grown adult can handle a stray Ternary operator or two. Likewise, there's no harm in deciding to ban it from a project of office setting, and finally there's no garuantee that just because you ban things like the Ternary operator that your idiot coders still won't find ways to make totally obtuse code.

For that matter, no one actually made the most obvious and indisputable argument for not banning the stupid thing (and furthermore not arguing pointlessly over whether or not it should be banned). Which is this:

Guidelines exist in all areas of programming, and the idea of eliminating guidelines is ludicrous. Thus I contend that the banning of the Ternary operator in any workplace setting is nothing more than an act of shallow principle and human emotional bias, without any rational basis. I submit the following example:

if( i-NewPos > ( Location+Offset ) * Indexer ) { i++; myObject[Indexer].Tweak(); } else { i+=2; myObject2[Indexer].MoveTo( Location-Offset ); }

OmG! Disgusting! Looks like we have to ban if conditionals.

In other words, the Ternary operator really is no different than an If/Else clause, except it's abbreviated the if and else parts into ? :, respectively. That's it. Otherwise, all the same coder readably & maintenance guidelines apply to both operators, just as they do to every other line of code.

Conclusion: Banning the Ternary (?:) operator does not simply programming guidelines, nor does it improve program readability. Thus the banning has no effect on the productivity of programmers within a project or office setting. It's just something people do for show, to make them feel like they're simplifying their environment

... and so for all those Ternary banners out there? If you really want to ban bad syntax and simply programming guidelines, you're going to have to use a language that forces strict syntax layout. Something like Python, or something even more strict perhaps. Otherwise all you're doing is just fooling yourself into thinking you've somehow improved your environment.
» The "Agree to Disagree" resolution.
Of the many forum-related Logical Fallacies and Argumentative Strategies that get my goat, the "Agree to Disagree" strategy is one of the very worst in my book. It goes something like this:

Person A: The world is round, so it's safe to say that when doing navigational calculations you should probably ... (rest of post)

Person B: [quotes snippet above] Not really! You really shouldn't assume the world is round. Scientists are like finding new dimensions and stuff all the time. Who's to say that they won't find a new theory that changes our concepts of reality, and at which point the physics that apply to flat objects will actually be round objects too?

Person A: Wow! That's nuts and totally unrealistic, and useless too since it doesn't help people navigate their ship at all.

Person B: But let's just assume for a minute that it isn't. What if the laws of physics really do change? In that case, when the laws of physics change these people won't know how to navigate anymore. So don't say the world is round.

Person A: But that's a totally outlandish assumption, and has no bearing in reality. The laws of physics aren't going to change anytime soon, and even if they do, then yeah we won't call the world round. But we do now, and that's what matters.

Person B: Well that's just your opinion and I think we're just going to have to agree to disagree.

That's a bit of a dramatization of course, but actual discussions aren't much less retarded. I see them happen a lot and have been part of many. In almost every case, Person B decides to completely disregard the common sense rules of observable reality and invents his own little irrelevant scenarios where his side of an argument is, in fact, true. When the other person dismisses these cases as ludicrous and/or totally impractical and presents solid analysis proving such, he eventually bites back with the Opinion Dismissal.

What pisses me off is that the Opinion Dismissal is most often used to declare a "fair draw" -- by dismissing both sides of the argument completely. The user of the Dismissal then expects the other side to play the role of a gentleman and accept the declaration of a draw -- even though one side is littered with factual / observable data and the other side consists of nothing but speculative hogwash. This is something akin to a person ramming into your Benz with his 1985 Chevy Cavalier and then appealing to a Gentleman's Draw because both cars got totaled. Any attempts by the other side to set the record straight are then used to villainize that person for being rude and/or egotistical, even though he's the one who's getting shafted.

So it's hardly fair, and far worse yet, in a supposedly information-driven environment - such as any Programming or Technical Help discussion board - it's highly counter-constructive; which means that it hurts everyone, not just the guy who made the otherwise accurate statement. As such I generally refuse to accept these draws; proving both my lack of Gentlemanship and furthering the cause against mis-information! I see no point in being a gentleman if it means I have to reward deceptive behavior and inaccurate information propagation. And so I say unto all those people guilty of using this argument in their posts:

Fuck your ego or weak emotional state. I will not let your inability to handle the truth interfere with the propagation of accurate information for everyone else. I care not if people find me charming or respectful; only that they find me to be a reliable source of useful and constructive information. Villainize me all you like! But I shall never give in to the tyranny of manipulative conversation for as long as I have my wits about me.

.. at such time that my brain cells begin to fail and my mind goes dim, I'll retire to the seclusion of a dark room and babble incoherently about my toenails.
» Comments aren't for redundancy
I should start a real programmers blog. Not that I personally have anything against the predominant livejournal community, but the widely accepted fact is that livejournal is a home for young girls suffering from severe cases of post-pubescent angst. There are more than a few people in this world who abstain from visiting any link that is hosted from livejournal or myspace.

... but more importantly, there are coder-oriented blogs out there that offer up built-in layouts ideal to inserting code examples. Livejournal's is...cumbersome at best. (I'd have an easier time writing my own pure HTML/CSS updates from scratch).

I guess I'll have to shop around for one that doesn't suck.

In the meantime, I'll throw a brief rant on one of my pet peeves. It's a well known fact that most people can't comment their code for shit, and this I accept. But one thing I hate and refuse to tolerate is people who insist on trying to pretend like they comment their code by inserting bullshit like this:

   //free the memory
   Free( MemoryPtr );
.. What the hell is that? Seriously. Who here would ever find that comment useful? If anything, the comment merely adds to the clutter of the code, which is why I won't stand for it. Sometimes I'll find people who comment almost every line of their code in that fashion, creating what can only be described as Pure Retardedness (tm):

   // Check if Left is less than Right
   if( Window.Left < Window.Right )
   {
      // move to the left
      MoveLeft();
   }
   // create the directory
   Directory.Create( "homedir" );
   // open the file
   Stream file = FileStream.Open( "homedir\\hijohn.txt" );
   // close the file
   file.Close();
Disgusting. I'm convinced that culprits of this asinine habit are college grads who still think they're being graded on how many instances of '//' appear in their code. Either that or they seek some form of false security in adhering to the sheer idealistic principle behind an otherwise de-constructive habit. The idealism says that commenting your code is good! Period. The reality is that individual lines of code speak for themselves. You don't comment the code specifically, you comment the grander purpose of the code as a whole, via comment blocks at the head of complete algorithms or procedures.
» .NET / DllImport / Structures -- Why so Slow?
Structure Marshalling Performance via P/Invoke
(C# Platform Invoke Benchmark Guide, episode 3..ish)

As always! Do all your performance testing in C# Outside the IDE. In the world of Managed Code, it's the debugger that gives you all the slowness, not the code generation. The only real code difference between the Release and Debug builds of an application is a few minor optimizations that have virtually no impact on program execution speed and -- more importantly -- the DEBUG define (and that only matters if you use it in your code to enable things like logging or extra strict sanity checks).

Moing along...

Structs By-Reference

Let's say you have a DLL that takes a structure, passed by reference as an input parameter. Here's the recommended P/Invoke syntax:

[Example 1 : By Ref ... the Slow Code]
public struct StructLand
{
    public int val1, val2;
}

public class Woombey
{
    [DllImport( "woombey.dll" )]
    public static extern void DoSomething( ref StructLand woot );
}

public class Invoker
{
    public void Method()
    {
        StructLand woot = new StructLand();
        Woombey.DoSomething( woot );
    }
}
... and, as with marshalled unmanaged function pointers below, this works! But it also comes with a steep performance penalty... granted not nearly as bad as the unmanaged function pointers, but still pretty steep. So steep, in fact, that the following code alternative is significantly faster:

[Example 2 : Avoiding ref via use of IntPtr]
public class Woombey
{
    [DllImport( "woombey.dll" )]
    public static extern void DoSomething( IntPtr woot );
}

public class Invoker
{
    public void Method()
    {
        StructLand woot = new StructLand();
        unsafe fixed( Structland *wootptr = &woot )
		{
        	Woombey.DoSomething( new IntPtr( wootptr ) );
		}
    }
}
I found Example 2 to execute maybe 6-10x faster than Example 1. The performance of Example 1 might be dependent on the structure size as well.. I dunno. I didn't go so far as to test since the structs I was using were pretty small (8-12 bytes)... ie, I had nowhere to go but "worse" in that area.

Of course I wouldn't recommend using the unsafe pointer trick all the time. If it's a call you're only making a few times a second, the measure of syntaxical convenience and -- I assume -- higher level of memory protection out-weights the benefit of the faster call. I reiterate that I have no solid proof that the ref keyword uses a more secure form of marshalling. It's just an assumption I'm making based on the (errant?) theory that the marshaller must be doing something to incur such a high level of overhead.

What about Structs By-Value?

Good question! At eye-level structs by-value would seem a naturally speedy fit into the realm of marshalling. All the marshaler need do, after all, is push the contents of the sruct onto the stack just like any other blittable type! This is so deadpan simple that you can even do nifty forms of overloading, such as this example:

[Example 3 : Overloading Trickery is Cool!]
public class Woombey
{
    [DllImport( "woombey.dll" )]
    public static extern void DoSomething( Point point );

    [DllImport( "woombey.dll" )]
    public static extern void DoSomething( int xloc, int yloc );
}
Yes, this REALLY DOES WORK. The unmanaged function on the DLL side will be able recieve the two values fine. This can be terribly convenient, obviously, if you're doing some heavy levels of unmanaged DLL invocation. But it too comes at a seemingly hefty cost to your app's performance! I noticed that the second overload of my method (the xloc/yloc one) was running considerably faster than the method that used a Point struct. So I did the following test:

[Example 4 : A Faster Struct Overload]
public class Woombey
{
    [DllImport( "woombey.dll" )]
    public static extern void DoSomething( int xloc, int yloc );

    [DllImport( "woombey.dll" )]
    public static void DoSomething( Point point )
    {
        DoSomething( point.X, point.Y );
    }
}
... and discovered that now both method invocations ran the same speed -- which was several times speedier than passing a Point struct into the DllImport directly! It's pretty trivial to create these sort of managed code overrides to substitute blittable types for structures, so I recommend to everyone and anyone - regardless of your preference toward performance - to use this technique. It's just a good habit to be in! :)

That got me thinking... if passing a Point struct is slow, what about passing an IntPtr struct as we did above? Is that too being impacted by this struct marshalling overhead? To test:

[Example 5 : Avoiding IntPtr via Platform Dependency]
public class Woombey
{
    [DllImport( "woombey.dll" )]
    public static extern void DoSomething( ref StructLand woot );

    [DllImport( "woombey.dll" )]
    public static extern void DoSomething( int pointer );
}

public class Invoker
{
    public void Method()
    {
        StructLand woot = new StructLand();
        unsafe fixed( Structland *wootptr = &woot )
		{
        	Woombey.DoSomething( (int)wootptr );
            // ... or you could do this:
        	Woombey.DoSomething( new IntPtr( wootptr ).ToInt32() );
		}
    }
}
Voila! My new struct-by-reference invocation runs a couple magnitudes faster than the original (and recommended) ref method. This is pretty naughty code, of course, since it's completely dependent on 32-bit platforms. But hey, thems are the breaks when you're gunning for top-notch performance. But all is not lost! You could make platform-independet code via this final unsafe example:

[Example 6 : Avoiding IntPtr via Unsafe Code!]
public class Woombey
{
    [DllImport( "woombey.dll" )]
    public static unsafe extern void DoSomething( StructLand* woot );
}

public class Invoker
{
    public void Method()
    {
        StructLand woot = new StructLand();
        unsafe fixed( Structland *wootptr = &woot )
		{
        	Woombey.DoSomething( wootptr );
		}
    }
}
The drawback of this method is that it alienates VB.NET, which -- by my limited understanding -- is incapable of using pointers or instantizing managed classes or invoking managed methods that bear the unsafe keyword in their MSIL signature. However!! Users of VB.NET are still able to use the original IntPtr solution and the platform-dependent IntPtr.ToInt32() solutions. One's not as fast and the other is platform-dependent, but something is still better than nothing. :)
» .NET / DllImport / Function Pointers -- why so slow?
Function Pointer Performance via .NET PInvoke
(C# Platform Invoke Benchmark Guide, episode 2..ish)


Let's say you have a DLL that passes a function pointer (or set of function pointers) back into your .NET code. The proper implementation would look something like this:

public class Joe
{
	[UnmanagedFunctionPointer( CallingConvention.Cdecl )]
	public delegate void UnmanagedPointerThingie( IntPtr handle, int param_a, int param_b );
	
	[DllImport( "woot.dll" )]
	static extern void ManagedEntryPoint( ref UnmanagedDataSet data );
	
	[StructLayout( LayoutKind.Sequential )]
	static struct UnmanagedDataSet
	{
		public IntPtr ActionPtrA;
		public IntPtr ActionPtrB;
	}

	public UnmanagedPointerThingie ActionA;
	public UnmanagedPointerThingie ActionB;
	
	public void InitStuff()
	{
		UnmanagedDataSet data = new UnmanagedDataSet();
		ManagedEntryPoint( ref data );
		
		// Create delegates out of the function pointer here:
		ActionA = (UnmanagedPointerThingie)Marshal.GetDelegateForFunctionPointer(
			data.ActionPtrA, typeof( UnmanagedPointerThingie ) );
		ActionB = (UnmanagedPointerThingie)Marshal.GetDelegateForFunctionPointer(
			data.ActionPtrB, typeof( UnmanagedPointerThingie ) );
			
		// And now we Invoke this bad boy:
		ActionA( handle, param, param );
	}	
}

... and this method certainly works. But sometimes just working isn't enough. Let's consider, we are working with a native unmanaged DLL that returns function pointers. The logical assumption is that we're probably doing something that is performance-critical, since there aren't many other compelling reasons to use functions pointers from unmanaged DLLs. Here's where the problem starts, because invoking unmanaged function pointers, as it turns out, is -- what people like me in the business of performance apps like to refer to as -- God-awful Slow.

How slow? Good question to ask! I didn't take exact measurements (I hate exact benchmarks, but that's a different rant), but by my estimates it's anywhere from a few to several magnitudes slower than calling a DLL EntryPoint. In other words, it takes anywhere from 30x to 100x more processor effort to execute an unmanaged function pointer than it does to execute any other type of method directly, albeit managed method or unmanaged DLL entry point. OuchiE!

Now before we move on, I'll give a quick disclaimer: I have no idea how unmanaged function pointer invocation compares to normal managed delegate invocation and/or managed event invocation since, up to this point, I haven't personally needed to use delegates in performance-critical code. It's entirely possible (but unlikely) that the bottleneck is in C# / .NET delegates in general. Moving on...

The solution! It's an amusing one, really. Create a new EntryPoint in your DLL (or create a new DLL if you're using a 3rd party library) that executes a function pointer passed into it. Explained a different way: Don't bother invoking the function pointer from managed code, instead opting to pass the pointer back into unmanaged code to be invoked. Here's the example:

[C / C++ Unmanaged DLL Code]
__declspec( dllexport ) void _stdcall MyDLL_ActionInvoke( void (_cdecl *action)( void *, int, int ),
	void *handle, int param1, int param2 )
{
	action( handle, param1, param2 );
}
[C# / .NET Managed Code]
public class Joe
{
	[StructLayout( LayoutKind.Sequential )]
	static struct UnmanagedDataSet
	{
		public IntPtr ActionPtrA;
		public IntPtr ActionPtrB;
	}

	[DllImport( "woot.dll" )]
	static extern void ManagedEntryPoint( ref UnmanagedDataSet data );

	[DllImport( "allmine.dll" )]
	static extern void MyDLL_ActionInvoke( IntPtr func, IntPtr handle, int param1, int param2 );
	
	public void InitStuff()
	{
		UnmanagedDataSet data = new UnmanagedDataSet();
		ManagedEntryPoint( ref data );

		// Now to invoke this bad boy, the Fast Way(tm)
		MyDLL_ActionInvoke( data.ActionPtrA, handle, param, param );
	}
}

Wow! Looks like we just made our own unmanaged version of a delegate layer!

Enjoy your new speedy PInvoke function pointer into unmanaged code.
» Pirates 3 : Bitter Spoiler / Review
Pirates of the Caribbean 3 : At World's End.
My Official Review.

Simply put: This movie should start wih Jack Sparrow's Nose. Translation! If the first 30-40 minutes had been removed entirely and that extra time alloted to lengthening the three main scenes of the movie, this movie would have been at least 231% improved over its current incarnation. Futhermore, if Chow Yun-Fat's character were removed along with it, the movie would be a full-on 321% improved.

Rating? C.

From here out is stuff that only makes sense if you've seen the movie. In other words, SPOILER ALERT! MUAHAHA

Here's the deal. The first 30-so minutes are mostly about introducing Chow Yun-Fat's character; a character so mundane and unimportant to the plot that I have no idea what his name was nor do I care. He's a pretty stereo-typical pirate but, unfortunately, we already have one here, thanks. That's what good old Barbossa is for. Adding Yun-fat's character to the mix just produced a level of redundancy that was tiring and far from entertaining or compelling.

Look at it this way: Jack Sparrow is an a-typical pirate. Very quirky, reasonably unpredictable, sports a funny accent, and is of questionable moral stance (sometimes good, sometimes bad). Barbossa is a mean old koot, sides with greed and deceit more often than not, and comes complete with the thick Irish-descended Blackbeard accent. Will Turner is the proverbial white knight, who tries so hard to do the best by everyone and ends up getting caught between shades of gray and having to pick sides -- his character made especially compelling thanks to Sparrow's strong moral ambiguity. Elizabeth Swann is.. well.. she's the girl. Gotta have a pretty girl; and better yet one who's prone to sudden acts of non-lady-like outbursts of aggression! (makes for good comedic spontaneity).

So where does this Sao Feng fellow fit into the equation? He doesn't. He's just another mean old koot pirate who makes it his business to swindle people of valuables before they swindle him. He talks a lot, gets suckered no less than five times (only one of which was particularly amusing), and then he dies. Man, what a waste of screen time. That's time that could have been in the hands of the most excellent non-typical Depp / Bloom characters. That's time that could have been invested into making the Bad Guy (Cutler Beckett) seem a little more human -- more on him in a second.

The final suggestion I make is to remove the whole Cutler Beckett death scene. Yes I know, it was wonderfully fun for you CGI animators to make that scene. But without more development of his character, the audience just didn't care to watch him die in slow motion. Although, in a perfect world, the entire sequence of events leading up to Cutler's death should have been replaced with something that.. doesn't suck? Seriously. Maybe it looked good on paper to drive home Beckett's arrogance by having him sail in against the Black Pearl alone, when he had 150 ships sitting there at his disposal. But in practice it just looked incredibly stupid and embarrassing. It's the sort of bone-headed decision that is so incomprehensibly stupid that it literally detracts from the rest of the movie by de-valuing the efforts of the 'heros' in trying to thwart Beckett's sinister goals thorugh-out the rest of the film. It's like "oh wow, you were getting man-handled by this complete turn-for-brains up until now? Wow you pirates suck!"

So, in conclusion:

Good-bye Asian Pirate scene, and Good-bye Yun-Fat (sorry, nothing personal dude). Good-bye to the Journey through the Arctic and over the cliff. Pick up the movie with Sparrow talking to himself on the Black Pearl (a brilliant scene!), and introduce the rest of the cast/crew when they appear on the coast and rescue him. Now lengthen the Sparrow/Beckett escape scene by 3-5 minutes (also a brilliant scene, except it went by so fast that most people missed it while looking for their soda). Next, lengthen the Shipwreck Cove part by 3-5 minutes. Finally, lengthen the whirlpool battle sequence by 7-12 minutes -- allowing the movie to incorporate a lot more "Wrath of Khan" style battle strategy leading into the whirlpool, etc. When you have fucking cool ideas like that you need to put some emphasis on it in order to pull the audience in milk them for all they're worth! And finally, axe the "me stupid!" Cutler Beckett death scene and replace it with something more compelling and less insulting to both the audience and the characters of the movie.

Plot Inconsistencies?

On Shipwreck Cove, Barbossa is apparently one of the nine pirate captains and thusly carries one of the nine pieces of eight... but wasn't he originally a first-mate to Jack Sparrow on the Black Pearl before he mutinied and left Sparrow on the island? (visit sea turtles story and all that) Maybe I'm wrong. Anyways, the whole resurrection of Calypso was pretty sketchy. Maybe if they had the opportunity to play on it more, it might have been a little more immersive. (citing the removal of said scenes to give more time for other things!) Oh well!

Advertisement

Top of Page Powered by LiveJournal.com