Archive for October, 2009

Perpetual Motion, Hacking, and the Contemporary Philospher’s Stone

October 29th, 2009

Perpetual Motion

At age thirteen, I invented a perpetual motion device. Obviously, I was a genius. Recognizing the magnitude of my discovery, I decided to patent the machine in order to capture the associated rewards. Years of groping through Popular Science magazine — it was my pre-pubescent version of pornography — meant I knew where to find patent lawyers: pages -1 through page -5.

Excitedly, I called the patent attorney that seemed to be the most affordable. I confidently declared that I had invented a perpetual motion machine and required a patent. The attorney did not seem impressed. Apparently, I was not the first person to try and patent a perpetual motion device. In hindsight,  I am willing to bet that patent attorneys who advertise with Popular Science magazine are continuously flooded with similar claims. After signaling irritation that was detectable even to a thirteen year old, she informed me that she would send the requisite forms but could not proceed without a fully functional prototype to submit as evidence. Apparently, this guy named Newton did not think perpetual motion was possible, so the patent office was not very liberal in awarding patents for such inventions (anymore).

I proceeded immediately. First, I spent my accumulated birthday money on magnets from Edmund’s Scientific. Next, I used K’NEX to build the scaffolding for a ring of magnets that would surround the central magnetic rotor. When the magnets arrived, I hastily lashed them to my plastic toys and and let ‘er rip. The magnet slowly swung around before settling in at the weakest point of the rings magnetic field.

Frustrated, I retrenched and thought about what had gone wrong. I was able to deduce that the magnetic fields of the independent magnets become part of a system when joined with the other magnets. They would not independently push the rotor — it didn’t work like that. However, committed to my brilliance, I thought of various ways to work around the problem such as using the momentum of half-filled water canisters to overcome the “humps”. Obviously, I did not overturn the laws of the universe. My idea may have been naive, but I learned a lot about systems while enjoying the exhilaration of experimentation. This experience may have had a major impact on my life.

Hacking

When I was young (before my attempt at overturning the laws of the universe), I asked my father to help me learn how to program. Since these were the days of DOS and Norton Commander, QBasic was to be my playground. Although I learned basic programming logic, I did not progress far enough to be capable of implementing a Gorrillas clone. Sadly, given my age, I enjoyed the instantaneous rewards associated with sports more than the personal satisfaction offered by solving problems with computers. My growth as a programmer was arrested.

Then came the movie Hacker’s. Hacker’s resurrected my interest in programming. Hacker’s — with the help of a young Angelina Jolie — gave programming sex appeal. It became my ambition to become ‘Cereal Killer’ (seriously, Zero Cool/Crash Override was boring).

This happened to be the same era of AOL ‘proggies’ and ICQ. For about six months, a friend and I ran a site called The Digital Underground that was a AOL themed repository while also releasing our own 133t apps. We were cool. We knew it.

That lasted for at most nine months. That is roughly the intellectual half-life of VB, even to a young programmer. I left that world behind and ventured out to C, C++,  and Python. Using better tools, I made applications that were reasonably complex and much more rewarding: spam-bots.

Now, I was a h4×0r. Around freshman year of high school, I was making 1-2k a week working after school. This was when I started hating school. Partially because my after-school work was much more intellectually challenging and mostly because I was making “bank”.

Fortunately, my career in spam was not to be. After a little more than a year, my parents had caught on — they did not approve. This shifted my efforts to a more worthwhile and exponentially more challenging arena: markets.

The Contemporary Philosopher’s Stone

I think reading Matt Ridley’s, The Origins of Virtue, in 9th grade seeded my intellectual development (thanks, Mr. Ridley). I became fasinated with complex systems like Conway’s Game of Life, Rule 30, ants, and Axelrod. Nothing was more interesting to me than Cellular Automata, ANN’s, PSO, and genetic algorithms. Soon, I realized there was a potentially practical application. With spamming out of the way, I now combined all my interests: programming, complex systems, and trying to do the supposedly impossible. I set out to beat the market.

This is not a huge leap from my past projects. There are strong parallels between perpetual motion and trying to overcome the efficient market hypothesis. And, just like with past projects, my efforts led to procuring new tools. At various stages in the past eight years (I am still pursuing this path), I have become proficient or better in ASM x86, C, C++, Java, Lua, Perl, Python, Ruby, Lisp, Erlang, PHP (front-end), Pascal, and Haskell. I have reproduced many popular financial models while trying to understand and improve them. This was all far more rigorous than that I was being exposed to in school (undergrad) at the time.

This brings me to now. I have spent the past 8 years trying to come up with an algorithm that finds pockets of profitability in a cloud of probable randomness. This has given me what I believe is a powerful understanding of complex systems. Complex systems modeled on computers have become my contemporary Legos — and, I want to play all day long.

In all likelihood, I will not make a breakthrough discovery. The fog that is my ambition may be obscuring reality. I am exploring an alternate area of the landscape of solutions. I may be hill-climbing a local unexplored minima — but hold out because of the potential for maxima. However, f*ck it. I want to spend my time doing what I enjoy most.

Hello, Unemployment. Goodbye, Savings.

October 29th, 2009

I just sent the following letter of resignation. I did not want to quit now, nor is it an opportune time. I have approximately 4-5 months of savings. Considering the project I must implement will take 3-5 months — and will provide me with no income even after it is finished — I am pretty much parachuting without a net. Weeeeeeeee.

Dear Redacted,

Unfortunately, fundraising at the derivative of the non-profit organization that I started has been declining sharply. In the past few months, the amount raised is far lower than we require. This stagnation may be a reflection of some progress made or cyclical constituent fatigue. In either case, given the general state of funding for rare diseases right now, it threatens to arrest research progress that I am hoping will translate into improved clinical outcomes…soon.

While I happily shifted responsibility onto the willing members of the Chordoma Foundation and folded my established organization into their nascent one a few years ago, I believe I have to shoulder some of the burden again. Last year, I wrote an application that would serve small organizations with highly-motivated potential beneficiaries. It worked very well initially. However, due to mistakes in the design that were entirely my own, it has soured some of the fund-raisers and needs to be corrected. I have been trying to do a rewrite after work each day, but the context switching is proving to be an obstacle. Half of my time is spent recalling work I have already done. Consequently, I have been sacrificing good-practices in order to churn something out. I produced a mediocre product last year; I cannot afford to do so again. A high-quality, distributable product will require a full-time effort for 3-4 months.

While it was my intention to remain at Redacted in my current capacity while pursuing a PH.D in experimental economics hopefully starting next fall (more precisely, experimental economics with a strong focus on agent-based simulations), this does not seem to be an option anymore. I thoroughly enjoy Redacted, but I reluctantly must resign.

I will stay on until a suitable replacement can be found.

Sincerely,
John B Nelson

Consumerism and Programming Polyglots

October 28th, 2009

This is a follow up to Monday’s blog post, Back to PHP. In the scope of the project I need to develop, PHP is the best choice. My conclusion was correct. The reasoning I used to reach that conclusion was (mostly) incorrect. The post was basically a list of justifications that were a product of “Programming Polyglot Syndrome.” This post is a half-hearted retraction Monday’s post.

I dislike shopping for clothes. Unfortunately for me, social and professional conventions dictate that I must spend some time and energy dressing myself in something other than grey sweatpants and Birkenstocks. Shopping is a necessity and I shop hastily.

For example, I recently noticed my black dress shoes had a hole worn through the sole (oh, Aerosmith) last week. I headed to DSW. For me, the costs imposed by wearing cheap shoes are negligible. For most men, shoes are shoes. If they don’t look dirty, are properly shined, and are not 95% creased they look fine. Moreover, I care more about my checkbook than my feet (the later are mostly self-repairing, the former is not). Once I find a pair of shoes that are not pink, are not expensive, and are not four sizes too large, I am done. I am satisficing.

People who enjoy shopping are not satisficing. That frustrated me until this morning. An introspective friend of mine was describing why she enjoyed shopping so much. She was able to recognize that, for her, shopping is about buying possibilities. She doesn’t shop for new tops. She shops for the experiences she believes – rationally or irrationally – the top will elicit: the attention of some man she finds attractive or the jealousy of some woman she dislikes.* She is buying hope.

Now, because this conversation was taking place via GChat, I was doing other things at the time. At one point, I checked the traffic stats for the unexpectedly popular post I wrote on Monday, Back to PHP. In the Back to PHP post, I tried to justify switching back to PHP, a language with a lot of warts. Thinking about it in the context of my friend’s consumerism, I noticed that it’s roughly the same thing. I have a project that I have no strong interest in but I must write. By switching to PHP I was trying to optimize away most uninteresting parts of development – mainly deployment. Cognitive quirks lead me to half-conclude that PHP would make the development go swimmingly well, with no bugs, deployment issues, or mental energy required. Magic!

This is not the first time I have learned or relearned a language because I fostered the delusion that it would {motivate me; dissolve all complexity; …, cure cancer; bring about world peace}. Actually, for me, this is often the primary impetus. In most cases, given the context of the problem I actually set out to solve, this turns out to poor investment of my time.

That is not to say that learning many programming languages is a bad thing. Different languages have different conventions, paradigms, common practices, etc. Learning many languages and paradigms pays a dividend. You become a better programmer and you carry new ideas across language lines. There is nothing wrong with learning for the sake of learning. However, if you are learning something new to avoid doing something you don’t want to do, you are probably not going to make any gains in productivity for that project. You are just procrastinating.

In the case of my project, PHP is the best choice because initial deployment in environments that I do not control is one of the most important considerations. PHP is very simple to deploy initially and is very common. However, most of the justifications I provided were not related to this issue. I just wanted to (re)learn a language.

Although, to be fair, Factor might be my best bet. Forget all this introspection!

* This is actually pretty interesting if you think about it. “Peacockery” in fashion is more apropos than realized. Not only do people wear things that are ostentatious to attract attention, but doing so becomes a requirement for those who otherwise would be happy in sweat pants. Adopting fashion trends is less about conformity than it is about leveling the playing field for attention. It may be less about showing fitness with clothing acting as a proxy for wealth and more about Fisherian runaway. F*cking, peacocks.

P.S. “Programming Polyglot Syndrome” is almost an extension of NIH. Coding something from scratch can be more interesting than learning to properly deploy and use someone else’s code.

Going Back to PHP

October 26th, 2009

I consider myself a programming polyglot. I am proficient in five to seven languages and am competent in many more. Consequently, like many programming polyglots, I am a bit of a snob. PHP programmers tend to be unilingual or bilingual (Javascript). They are unenlightened. If you asked the average PHP programmer to explain a closure, they would probably express bewilderment. Brutes! Like I said, I am a bit of a snob (and the preceding text was satirical…mostly).

As is the case with much snobbery, this is ill-advised. Prior to PHP, I remember writing applications through CGI, mod_perl, or full-blow C extensions to Apache httpd. It was not very productive. Enter, PHP. From the beginning, PHP was designed as a template language to make web development easy. As such, additions to the language and its tool set were evaluated against a fitness function that emphasized ease of use and productivity for web development. At the time, it was the strongest solution to a problem of increasing prevalence.

Fast forward a few years. I had been out of the web development scene completely when a bout of temporary insanity inspired me to attempt building an online dating site (thanks, Markus Frind). Since I used Ruby extensively for non-webdev, Rails was my obvious framework choice.

Does Rails have advantages that cannot be replicated in PHP? Of course! The most glaring advantage of Rails over PHP is the fact that PHP is not Ruby. Ruby is lovely language. Seriously. Ruby allows you to think in code. It is incredibly productive. You can take very complex abstractions and implement them in Ruby with ease. However, web development is not very complex. Most web development is CRUD. Sure, Ruby might be slow (although 1.9 is looking nice) but most applications really do not require high performance. And when scalability does become an issue, Rails is rarely the bottleneck.

Do I miss ruby gems? Sure, but Pear works. Moreover, integration with PHP is often easier than it is with rails. When was the last time you noticed that popular api or library lacked a PHP interface? Most sites release official PHP libraries (s3, ec2, facebook, gdata, …)

Conversely, PHP has one several advantages over Rails. Most notably, immediacy. Deployment via SCP is very satisfying. Moreover, PHP now has many rapid-development frameworks that employ MVC and active record patterns (e.g. CakePHP). While you don’t have the elegant sexiness of Ruby, you have almost everything else.

Do PHP programmers tend to be weak programmers who produce mediocre code? Maybe. If so, it can probably be attributed to the law of large numbers. There is a virtual army of PHP programmers; there are very few DHHs. For large-scale, very complex problems it may be better to use a language that naturally excludes poor to mediocre programmers, but this is not true for web development. Besides, there is no shortage of criticisms of the rails community.

Finally, there is nothing to stop you from using PHP for the CRUD front-end and Ruby or some other language to do more complex heavy lifting (e.g. spidering, categorization, etc). It seems to have worked well for facebook.

echo "Hello, Old Friend";

UPDATE(OCT-27-2009 @ 1:39)

I mentioned below and repeated in the comments section that I have used Capistrano (a site which, given the current context, ironically uses PHP) and Passenger, but, for reasons I could not qualify, I thought PHP was simpler. Mark just helped finalize the thought for me: PHP is usually preinstalled and ready for rapid deployment — i.e. immediate initial deployment. Heroku is wonderful, but not every hosting service is Heroku. If you want an application with diverse end-users, PHP is more likely to be eligible for simplistic initial deployment. It may seem like a minor issue, but in my experience, it is not.

END_UPDATE
This post was motivated by an open-source project I am currently coding. It is not yet released but for the purposes of this footnote, pretend it will have a deployment pattern similar to Wordpress. I started writing it in Rails. However, after speaking with several people who will be end-users, I realized that the most important factor would be ease of deployment. While Phusion is a game-changer for deploying Rails applications, I think PHP is still easier for most web developers.

Also, for the sake of disclosure, I should make it clear that I am not an expert web developer. As you might notice from this blog, most of my work is in complex systems. Most of my time is spent writing code in C or C++ with Ruby acting as glue.

What Do You Say, Mickey Avalon?

October 13th, 2009

Remember the scene in the Hangover where the boys were poolside trying to piece together their night? The song that was playing in the transition was damn catchy. It is finally on YouTube.

Also, I thought the following clip was really funny. Most people disagree.