Skip navigation.

Notes to self

Whatever I feel like writing

Posts tagged with "humor"

The jQuery JavaScript Implementation Quality Metric

,

The jQJSIQM is, besides a horrible acronym, something that I've invented in the honor of the just recently released jQuery 1.2.2 library.

It is a metric for the quality of a JavaScript implementation, and works on three assumptions:
  • jQuery is a sizable and representative body of cross-browser JavaScript.
  • It is documented in the jQuery source, when ever something will trip up, or surprise a JavaScript developer - quirks of the particular implementation.
  • These quirks are bad, and therefor, the fewer the better.


In short: the fewer times a particular browsers name is mentioned in the jQuery source code, the better its JavaScript implementation is expected to be.

Bold claim? perhaps. Like all metrics, it should be taken with a grain of salt, and two grains of pepper.

Onwards! To the Numbers!

First contender is my favorite browser of them all: Opera. Let's see how it fares:
$ grep "Opera" jquery-1.2.2.js -c
7

Seven remarks. Well, eh. I suppose it could be worse. Let's keep an open mind for now, and remember that the upcoming version 9.5 has a completely revamped JavaScript engine that is rumored to be quite good.

Looking at market share, I'd say that Safari is probably Opera's closest contender. Safari also had its JavaScript engine revised in its version 3. Let's see if the boat floats.
$ grep "Safari" jquery-1.2.2.js -c
6

Woops! Looks like Safari is one-upping Opera on this test. Let's just hope that the Mac fanboys at work don't get hold of this data - I'd be havoc on my browser pride.

Scaling up on market share yet again, I think the Gekko browsers comes next. Mozilla and Firefox both have the same Spidermonkey JavaScript engine, so I'll consider them as one.
$ grep "Mozilla\|Firefox" jquery-1.2.2.js -c
8

Considering that Mozilla and namely Firefox has several truckloads more market share than Opera and Safari combined, I'd say that this result is quite encouraging.

Last on our list is the king of market share: Internet Explorer. It's been lambasted for almost a decade as the number one perpetrator in strangling innovation and holding the Internet back, but do these harsh claims stand a beatin'?
$ grep "IE" jquery-1.2.2.js -c
40

Woops. I suppose market share isn't the only area where IE is in the lead, it's pretty far ahead of the other browsers in quirk-count as well.

Since Opera, Safari and Mozilla/Firefox are so close to each other in this test, I don't think I'll declare a winner - if one of these browsers are your favorite, then feel free to think of it as a winner.

So now that we don't have any outstanding winners, it's time to ridicule the loser... by changing the "-c" to a "-n" in the grep command. Notice there's a couple of memory leaks mentioned in the output as well:
$ grep "IE" jquery-1.2.2.js -n|perl -p -e "s/\\s+/ /"
65: // Handle the case where IE and Opera return items
298: // IE copies events bound via attachEvent when
303: // attributes in IE that are actually only stored 
317: // removeData doesn't work here, IE removes it from the original as well
318: // this is primarily for IE but the data expando shouldn't be copied over in any browser
697: // IE has trouble directly removing the expando
823: // We need to handle opacity special in IE
924: // !context.createElement fails in IE with an error but returns typeof 'object'
968: // IE can't serialize <link> and <script> tags normally
981: // Remove IE's autoinserted <tbody> from table fragments
997: // IE completely kills leading whitespace when innerHTML is used
1047: // IE elem.getAttribute passes even for style
1051: // We can't allow the type property to be changed (since it causes problems in IE)
1055: // convert the value to a string (all browsers do this but IE) see #1070
1066: // IE actually uses filters for opacity
1069: // IE has trouble with opacity if it does not have layout
1120: // We have to loop this way because IE & Opera overwrite the length
1124: // (IE returns comment nodes in a '*' query)
1566: // to avoid selecting by the name attribute in IE
1580: // Handle IE7 being really dumb about <object>s
1808: // For whatever reason, IE has trouble passing the window object
1852: // event in IE.
1889: // Nullify elem to prevent memory leaks in IE
2015: // prevent IE from throwing an error for some hidden elements
2060: // Clean up added properties in IE to prevent memory leak
2080: // otherwise set the returnValue property of the original event to false (IE)
2087: // otherwise set the cancelBubble property of the original event to true (IE)
2293: // If IE is used and is not in a frame
2298: // If IE is used, use the trick by Diego Perini
2299: // http://javascript.nwbox.com/IEContentLoaded/
2365:// Prevent memory leaks in IE
2417: // to avoid any 'Permission Denied' errors in IE
2595: // IE likes to send both get and post data, prevent this
2637: // implement the XMLHttpRequest in IE7, so we use the ActiveXObject when it is available
2795: // IE error sometimes returns 1223 when it should be 204 so treat it as success, see #1450
3307: // IE adds the HTML element's border, by default it is medium which is 2px
3308: // IE 6 and 7 quirks mode the border width is overwritable by the following css html { border: 0; }
3309: // IE 7 standards mode, the border is always 2px
3311: // However, in IE6 and 7 quirks mode the clientLeft and clientTop properties are not updated when overwriting it via CSS
3312: // Therefore this method will be off by 2px in IE while in quirksmode

Official: Haskell is the Best Language

, , ,

When having few lines of code is more important than runtime and memory performance, and when the rage is all about binary trees, nsieve-bits, charmeneos, recursion and regex-dna, then Haskell is the language for you.

The proof is right here in the computer language shootout - completely objective, and undestorted linguistic statistics!

The SQL "You Know It's Wrong When"...

,

You know that something is wrong with your SQL when...

  • EXPLAIN takes over 10 minutes to complete.
  • Your query has passed the 150'ieth line.
  • It's starting to look like LISP code.
  • You're considering the third nested SELECT.
  • Your JOIN conditions contain nested ORs.
  • You're starting your 20'ieth JOIN.

Spambot Talk

Today, I got an e-mail. This, in and off itself, is usually not a source of great excitement, but something about this particular e-mail caught my eye.

Let me first note, that the e-mail, on arrival within my domain of privacy, found itself installed in my spam folder. I normally truncate my spam folder without paying much of a glance to the items in it, and without thinking twice, so it was nothing short of a small miracle that this mail managed to catch my attension before being discarded as yet another pity attempt at robbing me of my precious attension!

I will start with the subject line:

The spite of man prevaileth against me.


Oh dear. This sounds serious.

Apparently, all human beings, including those covered by the Juristiction of Mankind, have waighed a campaign of biblic proportions (the 'eth' rather than 'ed' ending of 'prevaileth') in order to thrust a torrent of spite in Mr. Rajab Lares (the apparent originator of the mail) general direction, and this campaign has apparently been successful!

Contemplating this, I can only repeat; Oh dear.

On follows the actual contents of the mail. Mr. Rajab starts out the conversation with this lovely observation on the drawback of the GNU C library:

The GNU C library only supports one character of pushback--in other words, it does not work to call ungetc twice without doing input in between.


What an odd quirk. I had no idear this was the case. I think I can see how it must be frustrating to work under such inhumane constraints, and I am sure that Richard Stallman himself has ordered this one limitation in place, just to spite you, my dear friend, Mr. Rajab (or whoever sent me this mail).

Oh, how I understand.


You must have done something pretty bad in order to rightfully derserve punishment like that.

The next day they gave another piece of Beethoven, Die Schlacht bei Vittoria.


What torture! First Metallica and now Beethoven? I must admit that I am thoroughly shocked to learn that Mr. Stallman has the power to install his enemies on Guantanamo. Or perhaps your felony covers a much broader scope and trotted on the Holy Toes of one not-to-be-named Republican politician in the God All Mighty's own Homeland?
I shiver with fear for learning what crime could possibly justify all this!

An containing the given value as the new type.


New type of prisoner, new type of war, new type of everything. Don't give in to their propaganda! Every prisoner have rights and you need to stand up for them! Shout it out loud: We have rights! We have rights!

Even Perrin could barely hear.


Then you just need to shout it even louder; We have rights!

An object-oriented language for knowledge representation.


What? Mixing the good pure C with the filth of object-orientation? What would you call that abomination, C++? Oh, now I can see how that would be a crime against humanity. Woe unto thee! (points finger)

Dynamic Markov modelling - A prediction technique.


Will the agony never end? Embodying DMMs in C++ is surely the works of the Devil!
What were you going to do with such a monstrocity? Predict the future to evaluate the chances of successful execution in your plans for world domination?

Protection You can't predict the future.


So much you've learned. And if you've missed something, you will have plenty of time to catch up on it in the place your going after all this!

During the day, the sky never shut up.


Mr. Rajab, the good doctor has already told you many times not to stay off you medication for extended periods of time. Now, please, let these two nice men in white suits take you back to your room.

JavaScript, the missing girl.

I'm not sure who wrote this: Comparing Programming Languages in Real Life (which means, as girls), but whoever he is, he missed out JavaScript, so here goes:

JavaScript:

She's the confused girl that kind of had a rough start. To begin with, many men thought she was just easy, and didn't think very highly of her, but recently, tides have been changing in her favor as they have started to discover her true qualities; she's not a fast cook and can't cary heavy load, but she's free spirited and can flex her nimble body in the most exsotic ways.

Table Soccer to the people.

Every working man, and woman, should have access to table soccer doring his or her breaks.

When you feel tired at some point in the day, try taking a break playing some table soccer. I've found it to be a great way to revitalize my brain-cells.

If you don't have table soccer at your place, try telling your boss that "table soccer allows for socialized breaks between the complexities at work, and revitalizes the mental energies of the workers by introducing a competitive yet playful atmosphere during these breaks. This will ultimately result in more productive, and happier, employees with fewer sickdays and more developed inter-colegial social networks..."

He will either be dazzled by the brilliance of your suggestion, of baffled by your use of long words and articulations of complex sentences. However, if he seem somewhat unconvinced, try refering some arbitry Gartner report - that should convince most suits.