How many times can you call
a recursive function in JavaScript?

Hmm, that’s a question you probably have NEVER thought about, amirite? Well, after doing a bit of random JavaScript programming yesterday to help out a co-worker, he expressed concern that the solution I implemented (which used recursion) might have problems if the number of iterations was very large. To be honest, I’d never thought about it before; my ignorance stemmed from the fact that I’ve never had to deal with a data set large enough to cause a stack overflow from using recursion.

So, is this a valid concern? Should you stop writing recursive functions? After a quick search on Stack Overflow (oh, the irony), I found this answer, which, while old, gives you a general idea of what to expect with modern browsers.

I threw together a quick jsFiddle that you can run in your favorite browser to find out the limits today. The answer’s author also put together a test which displays results for multiple browsers, so you can see some more up-to-date numbers.

The end result? Unless you’re operating on a data set numbering in the tens of thousands, you don’t have to worry about your recursive algorithm crashing. And the sad part is that my co-worker still wanted me to re-write my code.

No comments · Written by Nathan at 2:20 pm · Tags


Get Sassy!

Wow, has it really been five months since I last posted here? Somehow, it’s not hard for me to believe. I’m breaking the blog silence proseletize the newest tech frippery I’ve become enamored with: Sass.

Sass is compiled CSS. It fits in with the current (kind of stupid, in my opinion) trend of taking a language or syntax that doesn’t need compilation, then adding a compilation step in order to get some syntactic sugar. Coffeescript is another example. Sass is a Ruby program that will sit in your CSS directory, scan your .scss or .sass files, then spit out .css results. With these sorts of things, you have to decide if learning new syntax will save you time later on.

I’m doing some CSS work for the first time in about a year, so figured I’d give Sass a shot, because I’m bored out of my mind, and need to do something to keep myself entertained. After working with it for about an hour, I was pretty much converted.

The main benefits I see to Sass are the nested syntax, mixins, and variables. With it, you can write CSS in a “nested” fashion, similar to how your HTML document is arranged. It makes it much easier to scan a block of Sass to see what style corresponds to what HTML element. An additional benefit is that copy/pasting large blocks of CSS is now possible, without having to remove or change the top level selectors for a rule. I’ve been able to create whole new page layouts extremely quickly using this technique.

Mixins and variables are just extra bonuses. Instead of having to write a bunch of vendor prefixes for box shadows or gradients, I can create a box-shadow mixin that can then be included in every rule that requires that style. Variables are great, too: you can just define a $text-color variable, then refer to it easily later without having to memorize an arcane hex value.

If you work in web development, I’d recommend giving Sass a try. Check out this article at 37signals.com for more info, then read the Sass tutorial. Next stop: productivity!

1 comment · Written by Nathan at 2:58 pm · Tags , , , ,


A defense for motion control in games

Last night I read a screed on The Verge forums from a guy who lamented the fact that games have become too accessible. He remembers fondly the time spent as a youth when he played difficult games, and calls out the new Zelda game (Skyward Sword) as example of a “soft, hit-detection-free experience.”

Even though I’ve just started playing the game, I don’t feel this way about Skyward Sword at all. In fact, I’m finding it more difficult than other Zelda games I’ve played. There are a few reasons for this: mostly because of the precision motion control required, but also due to other changes, such as a shield that wears down over time, and fewer randomly found hearts. Playing this morning, I actually died to the first dungeon boss. While it could have been that my sleep-deprived mind couldn’t recognize patterns effectively, it’s also true that I played through Ocarina of Time and Majora’s Mask without ever coming close to dying.

Some Wii games certainly do have “floaty” controls, but these are games that have a broad audience (such as Wii Sports). However, most of the other games I’ve played on the Wii use the remote/nunchuck combo for a more traditional control scheme; perhaps they use the remote for pointing a cursor on the screen as well. While the Wii made broad strokes into a “blue ocean” of non-gamers, it still has a lot to offer to those who were raised on the original NES.

No comments · Written by Nathan at 4:41 pm · Tags ,


Sam Loutzenheiser

By watching television one should be able to guess that no matter how old you get, the same bullshit is always waiting to haunt you… but for whatever reason I reasoned that problems, no matter how complex, are in someway bound and finite. And in that reasoning, I came to the subconscience conclusion that if I work all of the existing ones out, I could actually live in peace… Sadly, this assumption was clearly wrong.

No comments · Written by Nathan at 12:38 pm · Tags


Review: Hario Skerton Coffee Mill

I’m becoming more and more of a coffee enthusiast in my old age. Probably because, unlike other hobbies that require a lot of time, enjoying coffee can be done every day in just a few minutes. The caffeine boost is also a big plus, especially when dealing with a daughter who likes to wake up screaming multiple times during the night.

I’ve gone through phases in my modes of coffee preparation. Of course, my first experience was simply making drip coffee with a traditional coffee maker. My first upgrade was using a French press. After that I started buying whole beans and grinding them myself with a blade grinder. Using a French press and grinding your own beans are regarded as the most important first steps you can take to make your coffee taste better: using a French press means you have to heat the water yourself, and can get it closer to the optimal 200 degrees Fahrenheit, while grinding at home means less time for coffee beans to go stale.

The next coffee upgrade I wanted to make was to switch from a blade mill to a burr mill. The difference is that a blade mill cuts your coffee, while a burr mill crushes it. In addition, blade mills have a hard time grinding coffee beans evenly — you have to grind your beans down to a fine powder before you’ll get a consistent particle size. Blade mills can also make the ground coffee slightly more bitter, due to heat from the friction of the blades.

Unfortunately, blade mills are also way cheaper than burr mills. An electric blade mill might set you back $50, while the burr equivalent might be more in the $200 range. I wasn’t sure I wanted to pay that much for an electric burr mill, so I set my sights on a hand-operated (!) mill from a company named Hario, the “Skerton.” It was priced at a much more reasonable $40. Luckily for me, I got one for my birthday last month, so thought I’d share my experience of using a hand-operated coffee mill for the past two months.

It’s not as annoying as you might think to have to grind coffee by hand. I kind of enjoy using the mill while waiting for my kettle to boil… it adds to the preparation ritual. That being said, I only have to grind enough coffee for a two-cup French press. If I needed to brew a pot of drip coffee, I would definitely be using the electric mill.

The Skerton produces a pretty even grind… basically it’ll look like what you get buying pre-ground coffee. You can adjust the coarseness of the end result, but the mill doesn’t handle very coarse grinds very well; you’ll get some large chunks of coffee bean here and there.

The construction of the device is pretty good. The top of the mill consists of a plastic hopper with a metal crank and ceramic burr. You can adjust the coarseness of the grind by unscrewing the crank and adjusting a metal washer that controls the height of the burr. The top screws into a heavy glass container, used for catching the ground coffee. As a nice touch, Hario includes a rubber bottom for the glass jar, which makes it easier to use the mill: it sticks to flat surfaces, making it less likely to slide around.

All told, I’m happy with the Skerton so far. My electric mill has been put out of sight, and I’ve even gotten the wife to use the Skerton a few times. It’s helped me elevate my coffee snobbery to the next level.

1 comment · Written by Nathan at 9:27 am · Tags , ,


Older Posts →