Search

Posts Tagged ‘programming’

So, I just put my blog’s RSS into this FeedBurner thing. Apparently all the cool kids are doing it. It looks like it could provide some useful tracking stats, possibly way more effective than my current homebrew logging/tracking system. We’ll see how it goes.

So, if you please, could you update your RSS reader of choice to http://feeds.feedburner.com/mgroves. Thank you.

How fast is your favorite browser in terms of interpreting JavaScript? This page will test Try/Catch, Layer movement, Random numbers, math, DOM, arrays, strings, and AJAX.

The winner? If you’ve read MD Groves for any amount of time, you know that this answer is going to satisfy my confirmation bias:

Opera!

Opera is about 3 times as fast as IE and about 4 times as fast as Firefox. Yowza. I even tried it for myself (I have all 3 installed):

  • Firefox: 1142 ms
  • IE: 1062ms
  • Opera: 461ms

Obviously, this won’t make a lot of difference, unless, you know, a lot of popular sites start using this crazy “AJAX” thing.

Maybe the Internet really is a series of pipes. Just not in the figurative sense.

I found this Mac commercial a little more accurate, and certainly funnier, though maybe that’s because I’m not a Mac user. Just for the record, I’m certainly not anti-Mac. Mac makes fantastic software that’s pretty, usable, and less error prone. What I take issue with is the dishonest PC-bashing that the real version of these commercials takes part in, though anyone who knows they are dishonest is probably not the target market.

In summary: good, but very dishonest, marketing.

To summarize the summary:

The Monty Hall problem seems very unintuitive–like a paradox.

There are 3 doors–behind two of them are goats, and behind one is a brand new car. You choose 1 door. Monty Hall then opens one of the other doors and shows you one of the two goats. You can now switch to the other door or stay with the current one. Which one do you choose?

Intuitively, you might think it doesn’t matter. There’s two doors left, one has a goat. 50/50 chance, right?

Wrong. Monty has revealed some information to you, so if you make the switch, you will have a better chance of winning the car. Think about it as if there were 3 initial choices, and 1 secondary choice. Consider the case where the car is behind door 1, goat 1 is behind door 2, and goat 2 is behind door 3:

  • You pick door 1 and stay with door 1: You win a car.
  • You pick door 2 and stay with door 2: Goat.
  • You pick door 3 and stay with door 3: Goat.

Now, if you switch:

  • You pick door 1, switch to door 3: Goat.
  • You pick door 2, switch to door 1: You win a car.
  • You pick door 3, switch to door 1: You win a car.

So, if you don’t switch, you have a 1 in 3 chance of the winning the car. If you do switch, you now have a 2 in 3 chance of winning the car. Crazy, isn’t it?

Need more proof? Here is a simulation of the Monty Hall game. As of this writing, it has been played 6109 times. Those who switched have won 66% of the time and lost 33% of the time exactly. Those who didn’t switch have won 34% of the time.

Now, here’s where it gets a little weird. Suppose the game was simply 2 doors–one a goat, one a car. Then you would have 50/50 odds no matter what. This shows that the additional probability of winning comes from Monty giving us extra information about what was behind door 3.

This doesn’t mean that you will win the car every time. What it does mean is that on average, you will win the car every 2 out of 3 times you play the game as long as you make the switch every time.

If you are a FireFox user who wants to try Opera, but is afraid of losing all your precious extensions, then go here. It’s a list of many many popular Firefox extensions and the Opera equivalents (if any).

In terms of boolean expressions, (FALSE and TRUE) evaluates to (FALSE). Suppose we had an expression (FALSE and X), where X could be either true or false. It doesn’t matter, though, what X is, because we know the first value is FALSE, therefore, both values can’t be TRUE, making the whole expression FALSE. Similarly, (TRUE or X) always evaluates to TRUE. This is called minimal evaluation or more commonly, “short circuiting.”

Consider the following table of partial “if” statements, and mentally fill in TRUE or FALSE that you would expect for each value of “a”. (Assume IsNull returns TRUE if a is NULL and FALSE if a is not).

  a=0 a=NULL a<>0
if IsNull(a) or a=0      
if not IsNull(a) and a<>0      

Some programming languages automatically short circuit boolean expressions, some do not. Visual BASIC (at least VB 6.0, VBScript, and VB.NET) do not use short circuiting with and/or boolean statements. Therefore, if you were using Visual Basic to evaluate the above statements, this is the table you would end up with:

  a=0 a=NULL a<>0
if IsNull(a) or a=0 TRUE [runtime error] FALSE
if not IsNull(a) and a<>0 FALSE [runtime error] TRUE

Why are there runtime errors? Because in VB, there is no short circuting. If a=NULL, then IsNull(a) will be TRUE. VB does not stop there, however, even though it logically could. It will try to also evaluate the expression “NULL=0″ and throw a runtime error.

Up until VB.NET, there was no way around this in VB except for annoying nested “if” statements, or even more annoying nested “iif” statements. VB.NET, however, introduced the OrElse and AndAlso operators, which are the short circuiting counterparts to Or and And. Behold:

  a=0 a=NULL a<>0
if IsNull(a) OrElse a=0 TRUE TRUE FALSE
if not IsNull(a) AndAlso a<>0 FALSE FALSE TRUE

If you’re the type of person who wants short circuiting built and doesn’t see many practical reasons for it not to be (like I am), then this could look very ugly to you. However, OrElse/AndAlso is certainly much more elegant than nested if’s.

Opera 9 is officially released. I’m having some bizarre problems with it right away, but I thought I would go over some of the new features that I think I will really enjoy:

  • New content blocker — “Block content” option is available from the page context menu.
  • Added support for peer-assisted file distribution using BitTorrent.
  • Web page thumbnails are now shown when hovering tabs.
  • ‘Find in page’ feature now highlights all matches when searching for text on the page.
  • Major improvements to pop-up blocker.
  • Multiple rendering fixes. Opera now passes the Acid2 test.
  • CSS 3: Added support for attribute and UI selectors and for opacity. Added support for -o-text-overflow:ellipsis, synonymous to text-overflow:ellipsis.
  • CSS 2.1: Multiple fixes for selectors and pseudo elements. Updated display:inline handling on tables according to upcoming specification update.
  • Changed default user agent string to identify as Opera.

I love RSS. I love it. It saves me time. No more surfing around to see what’s updated and what’s not. The updated content comes right to me right when it’s updated. I also avoid using my email address to subscribe to various lists. I can change my email address without interrupting the flow of information, and no one that I subscribe to knows my email address or whatever personal information.

RSS has two weaknesses: low awareness, and an unfriendly name. Most people on the web use Internet Explorer, and aren’t even capable of reading RSS feeds by default (unless they use Google homepage or what not). Firefox & Opera have “RSS” buttons that appear, but IE doesn’t. The name “RSS” isn’t very useful either. It doesn’t tell a new user what it is, what it’s supposed to do, and how it does it. It’s just a cloudy acronym. I think “webscription” is a much friendlier name, in the same vein as “podcasting”, which by some accounts, is a friendly and much more ubiquitous term than RSS at this point.

That being said, based on 35 Ways You Can Use RSS Today, I’ve come up with my own list of 11 things I’m using RSS for right now and you should be too:

  1. Comics: Just about every comic, web-based or newspaper based, has an RSS feed. For instance, Dinosaur Comics and Dilbert.
  2. Sports team: Every pro sports team has huge amounts of RSS content just ripe for the picking. Blogs, official sites, newspapers. For the case of the Cincinnati Reds: Official MLB News, Topix.net Reds news, “Red Reporter” blog
  3. Livejournal: Every LiveJournal site has an RSS feed built in. Just tack “/data/rss” on the end of the LiveJournal URL. For instance, http://joeferg.livejournal.com/data/rss
  4. Free stuff: Slickdeals freebies, Absurdly Cool Freebies, Craig’s List. I’ve been getting a steady flow and samples and junk in the mail for weeks now. Instead of wasting time searching around on free sites and Google for samples that may or may not be current, the newest samples come right to me.
  5. Daily Bible verse: I prefer the NIV, myself, but I’m sure there are RSS feeds for every popular translation out there. At this rate, I think I’ll read the Bible all the way through every 2-3 years or so. There’s probably even one for just the Torah, one for the Koran, etc etc.
  6. Torrents: Is last night’s 24 episode in a torrent yet? I have a feed set up to fetch new torrents of Perfect Hair Forever so that the latest torrents come to me. Seeing a pattern here?
  7. The Daily WTF: This is technically a blog, I guess, but The Daily WTF is a must-read for programmers. It showcases the absurdity and humor found in real live programming code. You’ll laugh, you’ll cry, and maybe, just maybe, you’ll learn something.
  8. Urban Legends: The legendary Snopes has a “What’s New” feed where all the latest articles go. Rumors and inaccuracies will always exist as long as email does–be the first to know if that crazy e-mail forward is accurate or not.
  9. Technorati: Instead of subscribing to a bunch of blogs that might talk about something that interests you, you can use Technorati as a “TiVo” for blogs. Search for a topic that interests you, say, the GBPVR software package. Put the search on your watchlist, and you can get an RSS feed of that blog search.
  10. What’s Popular: To see what’s poppin right now on the web, one of the best gauges (I think) is the “popular” page at del.icio.us. It lists the pages that have been bookmarked by the most people. Digg and Slashdot have similar feeds, but I’ve found that del.icio.us provides the best overlap and the least chaff of the three. YMMV.
  11. Convert it to RSS: Have an e-mail subscription or web page that just isn’t available as an RSS? Simply change your email subscription to a DodgeIt address, then subscribe to the DodgeIt RSS feed. Keep in mind that this will make it public. If you want a feed from a webpage that doesn’t offer an email subscription or an RSS feed, then make your own RSS feed with Feed43 (feed for free). It’s not easy to do, but it is an option.

In a recent ruling, the PS2 was found not to be a “computer”, but a “gaming machine” and therefore subject to certain duties that a computer would not be. While I know it is unpopular to argue in favor of a large corporation making more money, I must take issue with this ruling.

First, let’s examine the technical definition of a computer. Any technical definition of a computer should mention the Church-Turing thesis. Basically, any device capable of simulating a Turing machine is a computer. Without going into detail, the PS2 certainly can do this. Your calculator can do this, and probably even your microwave.

So, obviously, there must be a legal definition of “computer” that seperates the PS2. What would this be? Let’s check the language of the ruling:

[46] The justification for classifying the PS2 under Heading 9504 in the draft regulation was given as:

‘Classification is determined by the provisions of General Rules 1, 3(b) and 6 for the interpretation of the Combined Nomenclature, Note 6 to Chapter 85 and the wording of CN Codes 8524, 8524 39, 8524 39 90 as well as 9504 and 9504 10 00. Of the various functions (including playing video games, playback of CD audio, DVD video, automatic data processing etc.) playing video games gives the apparatus its essential character and determines classification under heading 9504 as a games console’”

So, the primary, essential character of the machine must be gaming. If that is the case, would Alienware Gaming PCs be considered gaming consoles? Sure, it can do other stuff, but it’s primarily for gaming.

Maybe the determining characteristic is that it hooks up to a TV? Then what about the TRS-80 or the Commodore 64? Maybe a “computer” requires a keyboard and has web browsing capabilities. Then what about the Sega Dreamcast?