Thursday, June 30, 2011

Progress in Programming Languages

Many people recognize one form of progress in programming language design: the addition of new features, usually forming higher levels of abstraction. Less recognized is the dual of this form of progress: the removal of older, usually lower level, features and freedoms. Paradoxically the removal of language freedoms frees the mind to concentrate on more important parts of the problem at hand.

The earliest programming languages, assembly languages, provided unlimited freedom at a micro level. As an example, each developer was able (actually required) to invent their own conventions for calling subroutines. They could pass parameters in (their own choice of) processor registers, or on a stack (ascending or descending), or in memory structures on a heap. Each of these techniques had benefits and drawbacks, but in the end it was more important to standardize so that developers could share libraries of common modules and free up cognitive space for other issues.

At a higher level, the C programming language (plus the operating system binary formats) standardized routine calling conventions, but left freedoms as to where variables are located and how they are passed. C provides primitive types and records, locates them on the stack or heap, and supports direct memory pointers and pointer manipulation. C++ adds slightly safer references, while retaining pointers. Java, safer and at a higher level, takes away pointers and leaves only references. Much of the safety becomes possible (and necessary) once memory garbage collection is added and low-level memory control is taken away.

Other higher-level languages continue this pattern of addition and subtraction. Python and Ruby add lists and dictionaries as built-in types, and take away direct use of native hardware types.

Perl (yes, the topic of this post) is the oddball. It added many beneficial higher-level features later found in Python and Ruby, but did not remove the low-level freedoms of C++ or even assembly. Like assembly, Perl does not have a single built-in way to pass arguments to functions; instead "there's more than one way to do it" (the Perl motto) so users of CPAN libraries need to pay attention to the calling conventions for each library [and the common ways to do it, @_ and shift, are ridiculous]. Like C++, Perl has references. It needs these because it allows objects to reside on either the stack or heap. But there is no good reason for this distinction in a high-level garbage collected language, and it forces the programmer to explicitly reference (take address-of) and dereference using \, $, etc. (like & and * for C pointers!). Even Java references don't require explicit dereferencing and disallow address-of.

Perl has these issues partly because it was an early introducer of new higher-level features, and didn't want to break compatibility with older Perl programs by removing lower-level functionality and freedoms. But this means the language requires much more cognitive space to understand than newer languages like Python and Ruby, and leaves less cognitive space available for solving the problem at hand.

Wednesday, June 29, 2011

Backpacking Gear Test 2011



For last year's Backpacking Gear Test I had a base weight (without fuel, water, fuel) of 16 lbs and a total pack weight of 22 lbs. This year I experimented with some different equipment for a base weight of 14 lbs and a total pack weight of 19 lbs: a reduction of 11%.

Gear Weights

I took the 2011 gear on an overnight hike from Old Coast Road to Pico Blanco Camp in the Ventana Wilderness, 6 miles each way. This trail is NOT recommended, as it is very rough and difficult to follow.

Osprey Variant 52 Pack



This pack is slightly heavier than last year's Granite Gear pack, and should be more durable. With metal framing instead of just plastic, it better supports loads. It is actually intended for ski mountaineering/rock climbing, and was quite maneuverable when crawling over and under logs. The external gear attachment points were useful for boots for wading water crossings. The external pockets are too small for water bottles, so I carried all water and everything else inside the pack. This was important when crashing through tall brush. At 52 L the capacity is smaller than my other packs, but I was only carrying a bivy instead of a tent. With the expansion collar extended it has plenty of capacity for Jeep trips, though it isn't well balanced when packed that tall.

Marmot Alpinist Bivy



Sleeping under the stars was enjoyable in the bivy, though I might have a different opinion if it had rained. In the morning there was a small amount of condensation on the outside of the sleeping bag and inside of the bivy, and this condensation may have contributed to an early morning chill greater than the temperature warranted. Both did dry quickly once the sun rose.

As seen on the spreadsheet the other big weight savings was from omitting all the cooking gear and dehydrated food, and only bringing Powerbars. This is tolerable for an overnight, but would not be for longer. I may experiment next with other varieties of uncooked food for short trips. Hiking with the low weight was enjoyable, and this trail would have been even more difficult with my usual heavier load.

Saturday, June 18, 2011

Trust

What do pensions and nuclear power have in common? Both require managers empowered to make prudent, long-term safety decisions. In the case of pensions the basic principles are well-known; this isn't "nuclear science". But in both cases public pressure for short-term pain aversion make safe operation impossible, independent of the selflessness of management. And incompetent, corrupt, or untrustworthy management makes it much worse.

The list of other systems and institutions incompatible with the current environment is probably quite long...