Thursday, September 5, 2013

Experimental Human Factors Take on Functional Programming

As a functional programmer, one often takes the productivity advantages of functional programming as an article of faith: Versus imperative and object-oriented counterparts, functional programs must be shorter, more robust, quicker to develop, and easier to maintain. Designers of programming languages and compilers harp on the supposed benefits of their languages and implementations. But when it comes down to it, where is the evidence? There is admittedly a lot of problems when forming a rigorous question and experiment to compare languages. An empirical study is even more difficult because there are really few large software systems that are implemented equivalently in multiple languages. Still, there turns out to be a few studies on the productivity and usability side of functional languages and mixed paradigm languages (e.g., Pankratius et al's "On the Benefits of Combining Functional and Imperative Programming for Multicore Software"). The results appear to be quite consistent: functional programs are shorter but they aren't any quicker to develop for even relatively skilled programmers. Performance is generally found to be on par. Moreover, fancy type systems have the disadvantage in that they could complicate the programmer's understanding of the program and prolong the debugging process.

Wednesday, September 4, 2013

Gadget History with the Galaxy Gear Smartwatch

Gadgets are proliferating again. When smartphones were first introduced in the early 2000s, they promised to reduce the gadgets we all have to tote around. Instead of carrying a GPS, cell phone, MP3 player, and flashlight (because one of the first apps for all smartphones is inevitably a flashlight app), all these devices consolidate into a single one. Then came the tablet and e-reader. They supposed to target a different market, substituting for laptops and physical books. Now comes the beginning of what may be a bevy of smartwatch announcements with the Galaxy Gear Smartwatch from Samsung, despite a number of smartwatches being introduced years before. Don't forget Google Glass. Looks like we've moved from carrying around a lot of cheap gadgets each of which have limited capabilities to carrying around a lot of expensive gadgets each of which have extensive and potentially overlapping capabilities. This is great for advertising brokers. Now they can push ads to you on multiple screens. They might even figure out how to make the ad experience across gadgets seamless under the guise of enabling you to continue where you left off on another device.

Galaxy Gear boasts 70 native Android apps that can run on its 315 mah battery. From the looks of things, there is a good sampling of phototaking and fitness apps. For fitness, wearable tech isn't uncharted territory. Companies have been linking heartbeat monitors, pedometers, and such to portable consumer electronic devices for a while, first with the mp3 players, then with phones. What is really the killer app here?

Friday, August 2, 2013

C++ Parsing Gotchas

C++ is a complicated language. Even just parsing the language is troublesome. Scott Meyer included the most vexing parse as part of his Effective STL book (Effective STL: 50 Specific Ways to Improve Your Use of the Standard Template Library ). Recently, I encountered another parse issue that ultimately warranted new syntax in recent C++ revisions: the dependent type parse. The idea is simple, type names and value names (i.e., functions or variables) may overlap. That is to say, one might have a type t and a function or variable t in the same namespace. Thus, the parser has to disambiguate. This potential overlap comes up when parsing dependent type names (e.g., set<T>::iterator). Specifically, when declaring a function with a dependent type parameter such as void f(set>T<::iterator I), the compiler will complain that the keyword typename must be inserted in front of the whole dependent type name. Thus, void f(typename set>T<::iterator I) compiles.

What C++ parse gotchas have you encountered?

Thursday, July 25, 2013

Quality of Computer Science Higher-Education, Part 1

A recent discussion about H1-B quotas and tech workers on Hacker News brought up a very interesting question for me. The observation is that US companies are finding it hard to staff programming positions. Some comments suggested that higher-education is producing a lot of unqualified graduates. There was also a claim that the quality of CS education has declined substantially. Having been on three sides alluded to in this discourse, doing the hiring, teaching, and job-seeking, I thought it would be interesting to see what data we have and what we can glean from the said data.

Aside: I like to collect some data on the whole fizzbuzz phenomenon (i.e., the majority of job applicants not being able to program fizzbuzz). If you like to contribute your perspective and see the aggregate results of where the skills gap is, please consider taking my survey.

Tuesday, July 23, 2013


Over the past few months, munis have a hit hard, very hard. Even after the mild recovery since the end of June, index funds such as MUB (duration 7.17 yrs, distribution yield 2.97%) are down in excess of 7% YTD. High-yield munis, HYMB (duration 12.02 yrs, distribution yield 5.89%), are taking it even worse with a YTD drawdown of almost 12%. In a perfect storm of rising yields, illiquidity, high redemptions, and a default from Detroit to boot, munis are facing considerable challenges. HYMB, especially, is exhibiting considerable discount to NAV at the 3-5% level. Unfortunately, as others have noted, for highly illiquid assets such as muni bonds, the market price might actually be more accurate than the NAV. That said, even with the Detroit bankruptcy, which has been thrown back into court, the credit impact on HYMB should be muted as Detroit only comprises 1.33% of NAV and even all of Michigan only 3.53%. There is, however, the risk of other municipalities defaulting, but that risk has been there for a while. Note that muni bonds typically have high recovery rates (as high as 68%). The remaining headwinds of rising rates and redemptions will likely be challenging enough for the muni market. As the economy recovers and state coffers get replenished, the credit spread ought to tighten, but whether enough to counter the effect of rising rates is another question.

Thursday, February 28, 2013

Max Drawdown

When it comes down to it, finance is about risk and return. One of the purest measures of risk is max drawdown. This is pretty much the worst-case scenario: one bought at a peak (not necessarily the absolute peak) and a trough (not necessarily the absolute trough) such that the drawdown is maximum, i.e., you have maximum loss. I was curious, if one takes a look at the S&P 500 components from max drawdown only, what does it look like? The time period for this simple study spans 5 years from today, February 28, 2013. Choosing a 5 year period does unfortunately eliminate 25 of the S&P 500 right off the bat due to those symbols not having data running that far back.

S&P component Max drawdown (5 yrs) Std Dev (daily return)

The above table shows the 10 components with the least max drawdown over the period. An interesting variety of businesses are represented here. It isn't just a list of defensive utilities or consumer staples. We have automotive parts retail, the Golden Arches, industrial equipment, a pharmaceutical, a pharmaceutical waste disposal, healthcare IT, two utilities, and a discount retailer. Note that although these names tend to be low beta, they are hardly low PE. Note that having the least max drawdown doesn't necessarily imply having the smallest standard deviation of daily returns.

S&P component Max drawdown (5 yrs)

This second table shows the 10 components with the greatest max drawdowns. This list is certainly more concentrated than the first table. All except for 3 are financials/insurers/reinsurers. We have the old guard news media represented by Gannett (GCI), aerospace/defense by Textron (TXT), and renewable energy by First Solar (FSLR). If risk averseness is the game, then drawdowns is quite an interesting measure. It shows the worst-case for a single roundtrip trade. Note that trading results may be much, much worse than the max drawdown if a strategy gets repeatedly drawn down in a losing streak. Nevertheless, max drawdown gives some insight into the amount of risk we are taking on. In particular, max drawdown should give some insight into what kind of reserves should be kept. This, of course, isn't foolproof since past drawdowns do not necessarily predict future drawdowns.

Another interesting aspect of max drawdown is that there is really no relationship between max drawdown and daily returns. A regression between the two shows an R2 of a mere 0.0027.