30 Day JavaScript Learning Challenge: Day 12

(Sharp eyed readers will note that day 11 is missing. Unfortunately I have many excuses for why that is, but no results to show for it. Mea culpa).

Today's lesson continues the functions chapter of Eloquent JavaScript. I continued working on understanding JavaScript's functions and got a brief taste of JavaScript closures and recursion. Not a whole lot stuck in my craw this time around, as it's pretty straightforward. I did like the following advice:

The basic rule, which has been repeated by many programmers and with which I wholeheartedly agree, is to not worry about efficiency until you know for sure that the program is too slow. If it is, find out which parts are taking up the most time, and start exchanging elegance for efficiency in those parts. Of course, this rule doesn’t mean one should start ignoring performance altogether. In many cases, like the power function, not much simplicity is gained from the “elegant” approach. And sometimes an experienced programmer can see right away that a simple approach is never going to be fast enough.

The reason I’m stressing this is that surprisingly many beginning programmers focus fanatically on efficiency, even in the smallest details. The result is bigger, more complicated, and often less correct programs, that take longer to write than their more straightforward equivalents and that usually run only marginally faster.

All in all I'm finding this book quite pragmatic, which matches my own pragmatism about development. Just because you can doesn't mean you should.