Theoretical Logic

A collection of Trevor Parscal's illustrated theories, some more plausible than others.

Spicy Food

⇠ Direct link

Theory: The closer you get to the Tropic of Cancer the spicier the food gets.

JavaScript

⇠ Direct link

Theory: JavaScript is the best interpreted programming language in the world.

JavaScript is like water; viscous, powerful, ubiquitous and taken for granted. I’m certainly not alone in this feeling, as JavaScript is currently growing in popularity at an amazing pace. I admit that it’s not my favorite language and that it’s got its fair share of quirks, but the more I use JavaScript, the more I love it, and I would love to tell you why.

It’s viscous

JavaScript gives you enough rope to hang yourself, but tie that rope firmly to an orbiting satellite and you’ve got yourself a space elevator. While a programmer’s success with JavaScript is somewhat proportional to their willingness to embrace prototypal inheritance, JavaScript’s multi-paradigm design makes it conducive to creativity. When combined with JSON encoding and decoding, JavaScript becomes especially fluid in its ability to blur the lines between information markup and source code.

It’s powerful

An interpreted language is only as good as its interpreter. Modern browsers and web servers are now using interpreters that aggressively optimize the code they run, even to the extent of compiling JavaScript to native machine code on the fly. This process, called just-in-time compilation (JIT), makes it possible for interpreted languages to run at speeds nearing that of compiled languages like C. One of the most impressive examples of an interpreter that uses JIT is the V8 engine, which is used in Google Chrome and Node.js. This once exotic technique is now in every major browser including Mozilla Firefox (JägerMonkey), Apple Safari (Nitro) and even Internet Explorer (Chakra). The limits of what can be done with JavaScript are constantly expanding with support for technologies like web sockets, 3D rendering, video capture and audio processing already available and in the process of being standardized.

It’s ubiquitous

The number of devices capable of running this language is staggering. What’s more, nearly every one of these devices is connected to the greatest software distribution mechanism every invented, the Internet. “Write once, run everywhere”, the familiar promise behind Java, is actually true of JavaScript. It’s inside every web browser, powering smartphone apps, embedded in object databases, and even powers the Mac OS X dashboard. This diverse array is still growing rapidly, and the capabilities of these deployment targets are also improving at an amazing rate.

It’s taken for granted

While it’s easy to learn, and easily a language worth learning, very few people actually learn it. That is to say: many people use it, but very few people really understand it. As a result many developers only possess a superficial and often inaccurate understanding of if, how and why their program really works. Perhaps JavaScript’s seductively familiar syntax gives new users an early and false sense of mastery. I personally observe that most criticism of the language is a function of ignorance. This is evident when developers complain more about what a language is not than about what it is.

It’s worth your time

Whether you program to make a living or just hack for fun, JavaScript is a language that will open doors for you. It’s important to take the time to really learn it, but those who do will find themselves capable of expressing themselves efficiently and effectively. One of the best things about scripting languages is general is that they tend to be open-source friendly since programs are distributed as and executed from source code. In the case of JavaScript this has resulted in an amazing number of open source libraries, engines and utilities. All in all, JavaScript is a great language that everyone should know and know well.

Learn more

I highly recommend watching these videos to learn more about JavaScript:

 

Criminal Profiling

⇠ Direct link

Theory: If Santa Claus were real, he would be in jail.

Xbox 360

⇠ Direct link

Theory: Xbox 360 is the worst game console on the market.

An Xbox 360 is like a pet parakeet; expensive, noisy, fragile and less clever than you’d hoped for. In the tradition of its predecessor, the Xbox 360 is yet another example of Microsoft’s lack of attention to detail, shameful quality control and ignorance in the craft of industrial design. The user interface is clumsy and obnoxious; a literal patchwork of advertisements and poorly conceived menus that warp you to arbitrary locations in a maze-like environment. I reluctantly bought an Xbox 360, despite previous bad experiences with Microsoft hardware and software, because I wanted to play some specific first-person shooter games with my friends online. However, my distrust in Microsoft has only been emboldened by this experience and I’d like to tell you why.

XBox 360 SlimThe hardware sucks

Day 1: My new Xbox 360 Slim arrives at my doorstep. I hook it up to my TV quickly and prepare to be impressed. I touch the power button and am greeted with an abrasive and dissonant chime that makes my ears recoil in defense. The fan spins up and the entire machine begins vibrating such that the table it’s sitting on becomes an amplifier for a low frequency rumble that can be heard in the other room. I grab some foam pieces from the box it came in and construct a platform for it to sit atop hoping to reduce the noise and vibration coming from within the black plastic case that creaks as I pick it up. It seems to help, but I’m starting to feel like I’ve made a bad financial decision. Video appears on the screen, then a complex setup process. After a few hours of slow updates and network problems, it turns out that the built-in WiFi adapter is not compatible with my Airport Extreme. I order a $60 WiFi adapter on Amazon and call it a day.

Day 3: I plug in the WiFi adapter and add some complex configurations to my Apple AirPort Extreme and suddenly Xbox Live begins to function properly. I insert a used copy of Call of Duty: Modern Warfare 3, which I purchased at a local game store earlier that day. The user interface claims it is “Reading” the disc, accompanied by a cacophony of robotic noises. ”Disc Read Error”. After an hour of trying, I call it a night.

Day 4: I return to the game store, return the supposedly damaged used game and purchase a brand new one. Once home, I insert my brand new copy of Call of Duty: Modern Warfare 3. ”Disc Read Error”. I eject the disc, and blow into the disc reader with my mouth as if it were an NES cartage gone bad. Finally, it works, but it’s not clear why. Every game I have still gets these errors every few times I play them.

The software sucks

Complaints about Windows 8′s user interface apply equally, if not more so, to the Xbox. The design dispenses with any logical organization or prioritization of controls in favor of making everything a square tile. Some tiles are larger, but it’s not clear why. Some tiles are advertisements, and assault your ears with unwanted noise when you select them. You can not control the arrangement of the tiles. The tiles are everywhere. The only other user interface layout is the dashboard, which is essentially just a bunch of vertically stacked lists, sometimes with an information panel to the right. This layout is vastly overused, to the point where all the screens look nearly identical. Tasks that should be simple and direct are instead complex and exhausting having been crammed into a series of list screens that inexplicably take a few seconds for each to load. It would appear that a combination of laziness and ignorance in user interface design is the culprit. Why I expected anything else out of Microsoft escapes me.

Did I mention the hardware sucks?

The Xbox 360 Slim is far from slim. While it is smaller than the original Xbox 360, that’s really not saying much. For such a large case you might expect it to contain an integrated power supply. Instead there is an enormous power brick with an inconveniently short cable connecting it to the Xbox using a proprietary connector. While the eject button on the original Xbox 360 was a common point of failure, breaking easily and making it impossible to press, the pendulum has clearly swung too far in the other direction. The new eject button is so sensitive that it’s easy to trip on accident. The front facing USB ports are cleverly hidden behind a spring-loaded door, but the width of the door dictates that they be so far inset that getting a USB plug into one of them correctly involves two hands, a head-mounted flashlight and needle-nose pliers. I of course have to use these ports often because the Microsoft brand rechargeable batteries only last a few hours between charges before the controller begins randomly flashing at me and eventually disconnecting despite the battery gauge in the dashboard claiming it’s 50% full. Using a play-and-charge cable resolves the issue, but then I’m back to a wired controller.

It’s almost worth it

Games like Call of Duty: Modern Warfare 3 are amazing, which takes some of the sting out of the miserable experience of owning an Xbox 360. I’m pretty disappointed with Halo 4 so far, but that’s probably a topic that deserves its own post. The bottom line is that Xbox Live is the redeeming value of the Xbox. It’s the one thing they’ve done mostly right, and I give them respect for that. It’s easy to gripe that it’s too expensive, but its success would suggest that it’s priced appropriately for the market.

If you are considering buying an Xbox 360, I strongly suggest you accept that it will be more expensive and less impressive than you would expect. You should prepare yourself to be disappointed, frustrated and even angry. The lower you set your expectations the happier you will be. Microsoft has failed me, once again, and they will fail you too if you give them the chance. Should you dare to venture down this treacherous path, good luck to you. You will need it.

Motorcycle Engine Size Restrictions

⇠ Direct link

Theory: The only thing more dangerous than letting a 15-1/2 year old American kid ride a powerful motorcycle is to let a 14 year old Italian kid ride any motorcycle.

Walking Distance to Food

⇠ Direct link

Theory: People are more likely to compromise on the quality of food when obtaining it was either virtually effortless or extremely difficult.

SublimeText

⇠ Direct link

Theory: SublimeText is the best GUI text editor in existence.

Using SublimeText is like waking up on Christmas morning. There’s this feeling of constantly being impressed with new toys you never had before, but suddenly feel like you don’t want to live without. I spent ages looking for something that would suit my needs better than Eclipse, only to end up back where I started. But the instant I started using SublimeText, I knew I’d found what I was looking for, and I would love to tell you why.

It’s fast

Why do text editors take so much time to load, switch between and scroll through large files? Aside from editing actual text, these are the key functional aspects of a GUI text editor. By these measures, and a few others as well, SublimeText is stupid fast.

The first thing anyone will notice about full-on IDEs like Eclipse or Netbeans is that they are sluggish and clunky. Most other editors are fairly quick, but not impressively so. True, a few milliseconds here and there don’t appear to add up to much at the end of the day. However, once you get used to the feel of an editor that’s as responsive as an F1 car everything else feels like driving a yacht.

SublimeText ScreenshotIt has features you need

When measured against other editors, it’s sufficiently feature rich. For navigating it’s got folder views, panes and tabs. There’s support for syntax highlighting just about any language you’ve heard of and plenty of good color schemes. The find and replace tools are addictive and unobtrusive. Indentation style is accurately detected and applied on a per-file basis. Print margins, line numbers and indentation guides are rendered in a lightweight way. Finally, SublimeText has a plug-in system and even a package manager, so most of what isn’t supported out of the box can be supported with plug-ins. It’s even compatible with TextMate bundles.

It doesn’t have features you don’t need

There’s a couple of things missing here and there, but they all seem to be features nobody really needs. Features like code outlines are typically failed attempts to solve problems like navigation anyways. It doesn’t integrate a version control system, or use icons in the folder view. Some people may debate the values of integrating these and other features, but I find that life without poor implementations of debatably useful features is better, and I’m confident that you will too.

It has features you didn’t know you needed (but do)

You can place more than one cursor, select more than one contiguous region of text, select vertically, and then combine those multiple selections into a single one, or split a multi-line selection into multiple single line selections. I have found this is especially useful for adding commas to the end of many lines of text at a time. Tasks you would typically employ regular expressions to accomplish are now achievable using an intuitive graphical user interface.

While navigating around a file, you see a zoomed out view of your syntax highlighted code on the right. It’s a mini-map of the entire file, which can be scrolled through by clicking and dragging. This mini-map gives you a feel for where you are in a file like nothing else I’ve ever seen. Interestingly, syntax coloring combined with indentation creates visual patterns in code that make functions and statements easy to identify from a bird’s eye view.

You edit your preferences as JSON files. Press save and they are instantly applied. Maybe this is especially suited to front-end web developers like myself, but any programmer can appreciate that there’s no hood for anything to be under.

It’s fast

Seriously, it feels like this editor is implemented in hardware or something. But speed isn’t just about how fast the program runs on my computer. It’s how fast I can work when I am using it. I personally use a plugin called SublimeLinter, which adds static code analysis hints to code as you type it. This alone has sold many of my colleagues on it enough to give the editor a shot. The speed at which you can accurately write code is something that any editor should aim to increase, and SublimeText does so with ease.

It’s not open source?

Yeah, I know – this sucks doesn’t it. This kept me away for ages, but let us not forget that Linux used to use BitKeeper until the great Git was invented. The deal is, the open source community benefits when awesome open source code is produced quickly. If an editor that costs $60 is the guilty pleasure that helps you be more productive and happy, I suggest you indulge yourself and move on with your life. Furthermore, as a software engineer, I can appreciate what’s been built here, and feel my $60 is well spent on supporting an application that inhales code and exhales awesome.

Give it a try, see for yourself.

For the record, I was not compensated or encouraged in any way to write this by anyone. I use this tool every day and have come to love it. I just want to share the love.

JavaScript Array Iteration

⇠ Direct link

Theory: In JavaScript, execution time and file size are mutually exclusive optimization techniques.

Occupy Wall Street

⇠ Direct link

Theory: OWS protesters are only as hard-core as their camping gear.

Unit Test

⇠ Direct link

Theory: The dream of the 90s is only alive in Portland[1].