Dustin Diaz: /with Imagination Podcast: Episode 16 Saturday November 11 - 2006 Listen to this podcast at: http://dustindiaz.com/downloads/episode-16-javascript-tale.mp3 Discuss at: http://dustindiaz.com/episode-16 Ads: Podvine: A new media advertising network for creative listeners http://podvine.com Check out Paul Boag too: http://boagworld.com Characters Dustin Diaz : http://dustindiaz.com John Resig : http://jquery.com Dan Webb : http://danwebb.net Peter Paul : http://www.quirksmode.org Justin Palmer : http://encytemedia.com cpb - Copy Paste Boy (Billy) : n/a Libs and stuff Prototype : http://prototype.conio.net YUI : http://yuiblog.com Dojo Toolkit : http://dojotoolkit.org/ jQuery : http://jquery.com PPK : http://quirksmode.org Baseball Cards (Young Boys at the age of 10) - Baseball card set I was very picky about my sets, and somehow managed to have a large collection of small sets. However sometimes I would buy a whole set of baseball cards just to find my favorite player. (Eg $ from Prototype) Buying a set just to get Tony Gywnn. Justin would bring back his set and immediately when he got home he would take each one out and put them in a binder with plastic sleeves. He liked his cards neatly organized and got to know them one by one very well. Dan would light his cards on fire then try and put them back together thus performing the ugliest tricks on the planet. Ultimately, he had a set of cards, but you had to question if they were still in fact worth keeping around. Peter wouldn't buy sets, but he would subscribe to baseball becket magazine and craft together his own cards by wrapping hard plastic shells around them screwed tightly together, effectively making them a one of a kind and bullet proof John would always somehow manage to convince mom that he only bought one set, yet there was two sets...somehow packed in one. And cpb (billy) just never knew how to get his baseball cards out of the box. It would be the equalent of downloading a JavaScript library in a zip file, but not knowing how to extract it. Dieting & Excercise (High School) Dustin was essentially force fed and took all my vitamins. I was a very healthy boy. That includes vitamin A - E, iron calcium, potassium... essentially composed of 10 different vitamins that I had to take throughout the day. In other words my parents had taught me very well. On a great track to success Working out included running 8-10 miles a day to keep up with the varsity cross country team which roughly came out to 60 miles a week, and also hitting up the gym about 2-3 times a week. Justin on the other hand was also very healthy, but instead of taking the 10 separate vitamins that Dustin was taking, he would pop one multivitamin and be on his way. Very effective, and for the most part produced the same effect. Exercising for Justin also meant running, but instead of running so damn far, he would wear sweat clothes to effectively cut the same amount of calories w/o taking up so much time. John was perhaps the strongest of the group... having grown up on snickers bars and chocolate milk, he was now getting into performance enhancing drugs. At that day and age the popular stuff to throw in your water was creatine, and afterall, there is no law say you're not allowed to do it. Excersising for John included sprinting and lifting large barbels. He was even looking into entering a couple of strong man competitions. I mean literally, the guy was about to become the freakin' incredible hulk. So much mass compacted into one human being. Peter had an interesting diet. Yeah. real interesting. His diet consisted of only organic foods. He was a purist. He only ate the essentials and when people thought he was playing with his food, he was actually identifying and filtering the foods that he was going to put in his body. College was a hard time for Peter, especially in these Fast Food / fat infested times. Lucky for Peter though, he is ammune to most of it because he trains his body very well. Peter took tai-kwon-do classes, yoga, and other various martial arts - essentially training to become a ninja. He was to become the Bruce Lee of JavaScript. Dan had the most interesting diet of all though. Nothing he ate was consistent with the last meal he ate. For the most part everything seemed normal. He ate cheese bugers, he drank beer. He'd drink beers you've never heard of. On the outside appearance actually, nothing seemed to make a whole lot of sense from Dan. If you looked at his dinner plate, you'd see a pile of mush, he two minutes before the mush was there, there may have been a decent meal. Excercising isn't something Dan did because he wanted to, but it more or less happened because it was an accident. It truly is Dans curiosity that keeps him moving. Let's say for instance there's a mountain - and, well what's on the other side is a mystery. Dan will climb the mountain not for the sake of climbing and healthiness... but because he wants to know what's on the other side. Billy. Well Billy didn't know good dieting. As an avid copy/paster, he would just copy what he saw other people eating. If the ice cream truck came strolling by, and he saw other kids running toward it - well, he'd do the same... effectively eating ice cream thinking it's healthy. He would drink coffee because it looked mature. and he walked funny because... well he just did. Exercising. Billy didn't exercise. Training program (The wall climb) (College & the like) Now featuring Alex Russell (representing Dojo) The purpose of this training exercise is very simple. Get from one side of a wall, to the other. That is all the details. Here is each one's approach. As all the members sit around and point at each other as to who's going to go first.... someone was already missing. No not billy.... he was missing, but nobody cared. It was in fact, however, Peter. Peter and his nina-like JavaScript skills had already cleared the wall. Before anyone could even come up with a game plan, he was done. First off the line, and before any results could come back, his would ultimately be the fastest approach. His approach was simple. He took five steps back; sized up the wall just by "eyeing it" - took off like an olympic sprinter then hurdled it. If Peter were a shop owner, he'd be the old man at the antique shop that had thousands of nicknacks that were each a one of a kind. As a customer, you could ask from him the most bizarre items, and he would most likely have them. After all, Peter had seen this wall before; so he knew exaclty what to do. Dan on the other hand, decided, "hey, I'll go next, why not?" To him the wall looked kinda familiar, but he wasn't too sure. He most likely didn't have a good breakfast that morning since it involved ketchup and toast. So Dan's approach seemed very, interesting. He first walks over to the wall, and one of the scenarios happen: A) Dustin comes over and joins. They have a good laugh at the wall - then Dustin brings a few beers and Dan's face lights up. Soon they both forget the wall is there while they have now effectively pitched camp right in front of it. They start a fire just to keep warm while hacking away at nearby trees to produce more kindling for the fire. However while they were gone, the fire consequently gets way out of control, subsequently burning down the wall. When they returned to find that the wall was gone, they realized they had achieved their goal. They become heros of the camp and their work will not be forgotten. B) Dan decides to tackle it by himself - and thus with his spare axe, he is effectively able to hack down the wall. Dustin, using his in depth knowledge and training of Yahoo UI zen, would take the following approach. Having always bringing along two of his favorite utilities (DOM collection and Event), whips one out of his back pocket to measure the wall. And just to clear and certain, checks what 'type' of wall it really is. Even checks its fragility... you know, pushes and nudges it a little bit - making sure there's no quirks. After all calculations are correct, Dustin has concluded that he can animate himself up the wall with a little help from drag and drop. He then returns with the full set of proper tools, then stands back at a precise 8.5 feet from the wall. Throws a rope at the top then effectively making himself a swing. He then tugs hard on the rope and makes himself fly. Afterall, Dustin doesn't weigh much at all, and neither do his tools. He clears the wall perfectly and elegantly. Then even after clearing the wall, he makes notes of his success in his diary (logging) - making an entry so that he may remember (caching) later if he needs to do it again. In other words, the next time he sees this wall again, it's all over. Alex then volunteers to go next over the wall. And although he appeared to look the same on the outside as Dustin with all his tool boxes and gadgets and namespaces. Some expected him to take the same approach. However as Alex approached the wall, he found several things wrong with it. Rather than letting it be, he takes the role of a doctor and attempts to fix the wall. After all, it's broken, right? Using his mind-bending vudu magic tools that no one's ever seen before. It's fixed! People applaud with amazement. This wall has been broken for years, and nobody has ever fixed it. What did this guy just do? Rather than explaining the details, he then steps back at the same 8.5 feet from the wall that Dustin did - but instead of pulling out a rope, he pulls out some never seen before Batman dart gun, aims it toward the top of the wall, and flys right over. Justin, as everyone expected, did it just everyone thought he would. It was, after all, just a wall. Rather than over analyzing the situation, he just did what had to be done. He ran up to the wall, jumped, used his arms to pull himself up, then simply whaled on over. Done and done. John was at the back of the line just waiting to show off his stuff. He saw what everyone else was doing, mashed them all up into his game plan, then just started running toward the wall. Noticing the fact that he was running, we might have expected to see him hurdle the wall like Peter. However John's feet never left a few inches from the ground... and before you knew it, he had ran straight through the wall. After all, the shortest distance from A to B is a straight line, right? It was at that point we all knew John was taking steroids. It was like watching the incredible hulk. There was now a whole in the wall that he just bursted right through. Nonetheless you couldn't give him crap for it, because it was amazing to watch. Billy, well, Billy was the uncaught exeception that somehow snuck into the program. He was still learning how to construct functions that said "hello world" - but would be missing an end quote, and his program would be terminated. To say the least, he didn't make over the wall, but the army felt sorry for him, and let him in because he was trying. War Battle time WWW 2.0 (Career age) It is now that point in everyones life where they're living in their career. The following bit takes place at the actual battle field during a war. Not a real war, but it will just explain various scenarios of how each will either come to glory, or die. This also assumes that all JavaScript is gZipped and minified to be prepared for war on the frontline. Some may have even decided to camoflouge themselves (by obfuscation). We'll call this war "World Wide War" 2.0 In order for Yahoo! UI to win, you need to train your soldiers. YUI consists of state of the art fighter jets with very complex controls and allow you to pretty much manuever any way you like. When entering the battle field, they come flying in with Blue Angels with missles attached to the bottom. They will effectively destroy anything and everything. You might be thinking to yourself, "Where is Crockford in all this?" Well, he doesn't fight in wars. Not anymore at least. He served his time during web 1.0 war. However he is a commander. A true leader. In our industry we call them architects. He is very smart and in some ways he is like Albert Einstein. But instead of inventing Energy (E = mc2) - he came up with JSON; fairly equivalent to energy in regards to JavaScript. In one sense, every JavaScript developer uses it and allows us all to comuniate to each other. Getting back to YUI, they are the airforce of JavaScript libraries. It's corporate. The tools are high quality, and when put in the right hands, will conquer. Put it in the wrong hands, and you may crash and burn. Scenario: If John and Dustin were placed together in the battle field (ala extreme programming), what would happen. Let's come up with some possible solutions: HOW THEY LOSE A) John gets in a Blue Angel fighter jet with Dustin then immediately begins bickering about the controls. "What the hell is this YAHOO.util.foo.bar.whateverthehell - I'm trying to drop the bomb!" and essentially involves Dustin turning around and explaining quite a few things.... and before they knew it, they had crashed into the side of a mountain. They die. B) Dustin gets inside of Johns tank and starts tinkering around with things - then effectively short circuting a few wires then really starts to mess things up... The tank falls in a ditch, our tank is raided by the enemy, we get shot. HOW THEY CAN WIN A) John gets in a Blue Angel fighter jet with Dustin - and says nothing. They win. B) Dustin gets in Johns Tank and keeps his hands to himself, and says nothing. They win. John destroys all things living on the ground by either blasting them with his cannon, or running them over. C) They both find an underground bunker with a two ton supply of hand grenades supplied by Prototype and they just chuck them all night long. They win - however their approaches were very interesting in the fact that Dustin kept popping his head out of the whole and when he sees an enemy is near, he would throw his grenade. Meanwhile John is figuring out how he can hold three grenades in the same hand and without ever looking... thus he's bound to always kill the enemy whenever they come close. Peter: Just let him be. He will conquer the field in due time. He has every macGuyver gadget known to man and will effectively win the war with a rubberband, a q-tip, three beeds, and a wash clothe. Picture Peter as a sniper. Nobody sees him, but evidence of his existence is written all over the battle field (aka the web). You'll see empty gun shells spread throughout the land with "PPK" carved into the insides. If you want to win like Peter, be prepared to make your own reciipes. Peter has essentially came up with sandwich pickers, textarea maxlengths, and large charts of browser bugs and incompatibilities that have proven himself to be one of the webs greatest heroes. Dan. Ah Dan! As mentioned before, if Dan and Dustin were ever caught fighting the war together, they'd also be in an underground bunker... but probably caught getting drunk and playing poker. If the enemy snuck in, one of us would probably throw a bottle at him and he would die an unorthodox death. In the meantime we'd be busy trying to come up with an invention similar to the atomic bomb... but essentially wasting so much time, that our bunker has became overcrowded with enemies and we've ran out of bottles to chuck, then... accidently our bomb would light up and effectively destroying the entire continent. We won the war, but died while doing it. Thus dying a very heroic death. Justin: As mentioned previously about having 2 tons of grenades. Justin only brought one ton because he knew exactly how much he needed. Using Ruby on Rails it did that for him... but beyond just having the perfect amount of grenades, he throws them like baseballs. He won the war. Alex enters the field with a very similar approach to YUI. He comes flying in his jet... but it looks like last years model. But oh, wait... what the hell is that? Those aren't missles, those are sharks with freakin' lazers attached to their heads! As he draws closer to the ground he drops the sharks thus eating the enemy alive - and anyone else from a distance is getting shot by the lazers. Very chaotic approach - but totally gets the job done. If for whatever reason his jet runs out of fuel, Alex is able to parashoot himself out and use his jetpack which happens to have built-in tear gas from which only he himself is ammune to. While he is still flying in the air he makes a remote request for backup. Albeit his system radio was offline to make the request, he was fortunate to have a backup dojo.storage for when he landed on the ground and could be reconnected. When Alex lands on ground zero he then gets back online to make his request and yet anyone who comes near is poisoned to death because of the tear gas. The rest of the Dojo army shows up, and cleans house. He wins. Billy. I don't know why Billy was at the war, but he was. He's pumped and excited... but it just isn't looking good for him. Having finally learned how to construct his "hello world" function, he runs to the center of the battle field, and detinates his function. Everyone sees this and he is shot immediately. He dies a horrible death. The end.