Go Native: JSON Vs eval is evil

In the world of browser performance you can find yourself looking for the little things to make big differences, or even a lot of little things to make a bigger difference together.  I’ve been researching one particular change that is coming down the pike: native JSON handling.  John Resig wrote about the need for native JSON support in the browser in 2007 and its finally come.  The difference it makes between Firefox 3.0 and 3.5 is major, the difference between Internet Explorer 7 and 8 is important, and the safety that native support brings for prevention of cross site scripting (XSS) is critical.

I’ve created two tests that you can try for yourself: the eval test and the JSON test.  The tests loop 20 times to give you a broader test range and reveal the average time.  There are notes in the test pages to clarify a few observations, but I’ll put them here just for the sake of a single source.  The test pulls in 1600 JSON objects and either evaluates them using the JavaScript eval function (eval(/*JSON String*/);), or it parses them with the native JSON parser (JSON.parse(/*JSON String*/)).  For consistency’s sake I used the data from John Resig’s test which I have copied onto my server to reduce the load on his server and not steal bandwidth.  My tests were run locally to reduce bandwidth latency influencing results, but you can see that over the Internet, even on a broadband connection, the performance only gets worse.

Firefox 3.5 has javascript tracing enabled and the typical test results will show a much slower first pass with subsequent results being much, much faster. It should never be assumed that the user will be getting the exact same data back like this test shows, so the slower performance should be expected.

Internet Explorer 8’s Eval test appears to be almost as fast as the JSON test and their eval code’s execution is pretty fast already. However, the JSON.parse() code appears to be much safer to use and is thus preferable.

The final results are based on the averages (which are much more consistent than comparing the ‘best’ numbers): eval is roughly 500 milliseconds (or 500%) slower in Firefox 3.5 the first time and nearly the same speed in Internet Explorer 8 with an average of 10 seconds slower in 20 passes.  So for either identical or much faster performance and greater safety against XSS it is a no-brainer to switch to including native JSON support as a preferred method of dealing with JSON data over eval.

I do want to note that I was impressed by Internet Explorer 8’s eval speed, it was much greater than I had expected, and generally disappointed with Firefox’s, but since it is an evil function to use, that’s not all bad.

King Corn: A Movie You Should Watch

Uncle Ben, in the first of the 2000’s Spiderman franchise, tells a young Peter Parker, “With great power comes great responsibility.”  Watching King Corn (website) tonight over Netflix’s instant watching service was sobering.  It isn’t the most entertaining movie you will ever watch.  Comparing it to Spiderman might be cruel because one is for fantasy and fun and the other is for education and presenting reality in a film format.  Despite my stating that it isn’t ‘fun’ to watch, you should watch it because the contents of the film are disturbing.

If you think that government spending is out of hand: watch this film.

If you think that Americans are nutritionally screwed up and need to eat better: watch this film.

If you think that you’ve got everything together and your life is all roses: watch this film.

I am allergic to corn grain and corn syrup, though corn oil does seem to be OK in moderation, and so for me corn is just not a great item to eat.  After watching how corn syrup is made, I’m pretty sure I wouldn’t want to eat corn syrup even if I were able to eat it.  I’m convicted, once again, that I should be careful what I put into this body, but don’t take my word for it.  Watch this film, read Michael Pollard’s book “In Defense of Food” – and see where you land.  I bet it isn’t in a field of corn, or in line at McDonalds.

Coffee with Jeremy

I should have taken a picture.  It would have lasted longer.  However, I had a great time with a brother in the Lord, Jeremy, this morning.  We talked about a lot of stuff, but I can’t tell you about it because what happens in Starbucks, stays in Starbucks.  More blogging will be coming soon.  I’m stoked about that.

Substitutionary Atonement: One for All

This year I’ve really gotten into watching baseball.  I think its in part because of my brother-in-law Kurt’s excitement for sports and my grandpa’s love for baseball.  Baseball is a pastime in this country and I am a fan.  I live near the Colorado Rockies’ stadium in Denver (20 minutes or so away) and I keep track of their activities with some regularity.  This last Friday their head coach, Clint Hurdles, was released from his position and was replaced by their bench coach as the interim coach.  This change is one I don’t agree with as a fan, but they didn’t ask me.  Here’s where the theology comes in: the first basement Todd Helton, a believer, was interviewed and had this to say:

“We should be held just as accountable as anybody. Obviously, he takes the sword for us.  He didn’t have any bad at-bats, he didn’t throw any bad pitches. He’s the same manager he was two years ago [editor: when the Rockies went to the World Series]. We realize that. We realize that ultimately we are the reason he got fired because we played bad baseball. We definitely feel responsible.”

There are times when one person takes the fall for a group.  Christ, being the only acceptable sacrifice for the sins of mankind made the sacrifice.  We all deserved the penalty for our not ‘playing well’ – there is no minor leagues for real life where you get to figure out this being a human thing and then bring it to the big game.  Instead you get to screw up in front of everyone, blow it miserably in front of anyone, and ultimately stand before God as having failed to live up to His glory (Romans 3:23) – accept if Christ took your place in judgment on the cross.  Then you were identified with His crucifixion, death, burial, resurrection, ascension and seating.  The Rockies players know that they were saved from being dropped into the minor leagues because of their coaches sacrifice.

We know that without the sacrifice of Christ we would have nothing to stand before God with that would give us any confidence.  Instead of the worry of judgment for punishment, we look forward to a judgment for rewards.  One where heaven will become a place for a bride and the bride groom.  It will be a perfect game, one with no outs, endless innings, and no injuries.  Oh, and I think that there will be no stealing of bases 😉

This Last Weekend I Had A First

This last weekend I had a first.  I don’t have a lot of firsts in my life any more because of my age, though last September I had a thirty-first.  Sunday I taught on my dad’s behalf as he was in California looking after things there with his family.  I have taught adult Sunday School many times, but its the first time I’ve ever taught in front of my brothers and sisters in Christ in the main service.  I taught on the passage and some possible applications of Titus 2:2-8.  Since that’s not a commonly taught passage I’ll post the text here:

Tts 2:2 Older men are to be temperate, dignified, sensible, sound in faith, in love, in perseverance.
Tts 2:3 Older women likewise are to be reverent in their behavior, not malicious gossips nor enslaved to much wine, teaching what is good,
Tts 2:4 so that they may encourage the young women to love their husbands, to love their children,
Tts 2:5 {to be} sensible, pure, workers at home, kind, being subject to their own husbands, so that the word of God will not be dishonored.
Tts 2:6 Likewise urge the young men to be sensible;
Tts 2:7 in all things show yourself to be an example of good deeds, {with} purity in doctrine, dignified,
Tts 2:8 sound {in} speech which is beyond reproach, so that the opponent will be put to shame, having nothing bad to say about us.

I have put a lot of time into thinking about that passage and I hope you find it edifying on its surface.  Further it is a great passage to use for looking into how we can grow together as a body.  Who has God put into your life for you to grow and have as an example?

Check out the recording of the lesson here.  And the handout that is referenced here.  Feel free to post any questions or comments below in the comments section and I’ll get back to you with answers (assuming I have them).

There is a Special Place in Hell for Virus Coderz

I just wanted to let you know that I’m not dead.  This weekend, aside from celebrating with the family the resurrection of Jesus the Christ, I helped some friends with their computer.  After about 10 hours of funk, trying this, trying that and generally hating malicious people who write viruses I was able to remove it from the machine and then set it up to be more secure, a wee faster, and hopefully useful for them in the months to come.

Hell has a special place for virus coderz and I’m pretty sure they only serve caffeine free diet soda there.