Web/Tech

Learning Haskell

I stumbled onto Haskell around 2 months back while searching for resources on spreadsheet programming.

I wanted to do Buy vs Rent calculations before deciding to buy a house. Microsoft Excel is pretty good. However, after a while it simply did not scale up. You cannot define your own functions and there are no local variables available. It has been my experience that learning in the context of real problem is much faster and easier. This time, it launched my exploration of functional programming. Enter Haskell.

Haskell is a pure functional programming language. Transition from imperative programming to functional programming (and too a pure one) was very difficult. But slowly, I got the hang of it. I re-did Buy vs Rent calculations in Haskell (it's not complete yet).

To explore Haskell further, I decided to implement a small subset of GNU Make features in Haskell. Within a few days (1 day of "thinking" and reading, followed by a day of coding), I was able to get a working system (see make.hs). To use it, simply call 'make' function, passing it a list of rules and a target:

make [(makeCCRule "test")] "test.o"

Simple, C compilation and linking rules are included. But you can define your own rules (a tuple of dependencies, target and list of commands to run when the target is out of date with its dependencies). Haskell allows you to focus on your application logic without causing undue distractions of memory management, maintaining state or even declaring types (it provides type inferencing). It is amazing how much you can do in less than 90 lines of Haskell code (including comments and empty lines). 

I haven't tested it thoroughly and there is no error handling. The system is easy to extend with your own "definition" of what it means to have a target out of date with its dependencies. With a little bit of refactoring it won't be that hard to support pattern like rules (.c to .o, etc.). Please send me feedback on how to improve this (I would love more modularity using type classes, for example).


Virtual Gold Rush

 Via the Division of Labour, This BussinessWeek article, Innovation in the Age of Mass Collaboration, describes how a conservative mining company discovered gold by opening up its proprietary database on the Internet and offering a prize:

The contestants identified 110 targets on the Red Lake property, more than 80% of which yielded substantial quantities of gold. In fact, since the challenge was initiated, an astounding 8 million ounces of gold have been found—worth well over $3 billion. Not a bad return on a half million dollar investment.


Cisco Ups the Stakes in the Outsourcing Game

SAN JOSE, Calif. // Wim Elfrink's climb up the corporate ladder has taken him from Holland to France, Italy, Switzerland and the United States.
But his latest promotion will take the Dutch polyglot far from his Western comfort zone. As the chief globalization officer at Cisco Systems Inc., Elfrink is taking his wife, two daughters and the family dog from suburban Silicon Valley to Bangalore, India.

...

The 50,000-person company wants 20 percent of senior managers working at the proposed Globalization Center in Bangalore by 2010. The executives will be a mixture of rising stars from San Jose and Bangalore and talent plucked from acquisitions and competitors worldwide.

International business experts say Cisco's executive migration is a shrewd move that should give high-ranking employees critical insight into one of the world's fastest growing economies.

Source: Cisco Shifts Executives to India - baltimoresun.com