News on Monday
more>>
SharePoint Tech Report
more>>


   

 
 
Download Current Issue
ISSUE 2/1/2010 PDF

Need Back Issues?
DOWNLOAD HERE

Receive the print Edition?


 
blogs tab
Visual Studio 2010 Release Candidate Available Today
A Visual Studio 2010 release candidate is available on MSDN.
02/09/2010 09:45 AM EST

Is Microsoft eyeing Office subscription pricing?
Microsoft may be preparing to offer a new Office pricing option called "union," which charges the same for cloud as on-premises.
02/01/2010 09:38 AM EST

Facebook rewrites PHP runtime
Facebook is about to open source its own PHP runtime, written from scratch for speed.
01/30/2010 08:53 PM EST

 

Events calendar tab
2/9/2010 to 2/13/2010
San Francisco
IDG World Expo

2/10/2010 to 2/12/2010
San Francisco
BZ Media

2/17/2010 to 2/25/2010
Atlanta
Python Software Foundation

2/19/2010 to 2/20/2010
Los Angeles
SCALE

2/21/2010 to 2/24/2010
Las Vegas
IBM


 
Most Read Latest News Blog Resources

Windows & .NET Watch: Haskell: It’s like Klingon, but with math!




April 15, 2009 — 
“I might as well be looking at Klingon script,” said a colleague when we were discussing Haskell, the much-admired programming language. Reading Haskell requires more than a casual acquaintance with the language, due to a programming idiom that emphasizes dense (or, if you prefer, concise) expressions, as well as Haskell's syntax, which is not part of the ubiquitous C language family. (“What? The return type is not the first thing in a function declaration?”)

“Real World Haskell,” which recently won a Jolt Award as the year’s best technical book, does an excellent job orienting the newcomer not only to Haskell’s syntax, but also to the language’s selling propositions, which are a strong type system and the ability to program without side effects in the functional style. Like Smalltalk and LISP, it is a language that will almost certainly broaden your approach to solving problems even if you do not have the chance to program in the language professionally. (On the other hand, I’ve heard it claimed that experts in the non-mainstream languages have a relatively easy time navigating between jobs in their more specialized communities.)

The book, by Bryan O’Sullivan, John Goerzen and Don Stewart, jumps right into Haskell’s type system. It correctly states that one reason why type systems are so talked about is that a type system “deeply colors the way we think and write code in that language.” There is, in my opinion, no hard-and-fast “correct” type system, and that is one reason why I don’t feel hypocritical recommending learning Haskell just a few columns after recommending learning Python, whose “duck typing” philosophy is pretty much antithetical to Haskell’s.

The short version of how these philosophies clash is whether a mismatch (say, passing an integer to a function that expects to manipulate a distinct “time” object) is detected at compile time or at runtime. I think there’s more to the debate than that, and the real question is whether explicitly answering “What have we here?” and “What sort of thing are we going to produce?” is a central, or a secondary, part of problem solving. I think there’s a good case to be made that it’s central.

I think this is especially true when considering side effects, which is the somewhat confusing name for everything that actually makes a difference to an end user. Generally, in a functional program, you concentrate on producing a single value that is the result of a calculation on your input parameters, and generally, if you send in the same input parameters, you expect to get the same output. A side effect is anything that deviates from that expectation: obvious things like debiting a credit card or sending an e-mail, but also work-a-day things like changing the value of a variable that is not explicitly passed in or out.

To me, this emphasis on “a place for your stuff” is the big advantage of functional programming. Haskell does a great job of enforcing discipline when it comes to side effects. When you program in Haskell, you really do feel that you are working on a nice, isolated component.

This straightforward model is married to powerful abstractions, though. Learning Haskell can definitely be draining as you try to follow the point of some complex abstraction of a function that returns functions that work on functions of the type passed in to the first function… Complex Haskell can have all the brain-twisting complexity of void pointers, but with added mathematical rigor.

O’Sullivan et al. do a superb job of jumping right into the “why” of Haskell and, joy of joys, the first function written does not output “Hello, World.” By the middle of the book, they return to familiar tasks with database manipulation, a podcast aggregator and GUI programming. By the end of the book, they’re dealing with such interesting topics as concurrency in general and software transactional memory in particular.

I do not know if learning Haskell will get you a job. I know it will make you a better software developer.

Larry O'Brien is a technology consultant, analyst and writer. Read his blog at www.knowing.net.


Related Search Term(s): Haskell


Share this link: http://www.sdtimes.com/link/33399
 

Comments

04/17/2009 01:04:55 AM EST

I like Real World Haskell as well, but for people starting out with Haskell, I think "Learn You A Haskell" is a much better introduction to the fundamental concepts of the language: http://learnyouahaskell.com/

United StatesPaul Barry


04/17/2009 11:17:19 AM EST

This book is nice ~but let's no forget that haskell has some amazingly marvellous tutorials ( cf. http://haskell.org/haskellwiki/Learning_Haskell & http://en.wikibooks.org/wiki/Haskell ) that could complement any journey towards learning it. .\

United Statessteez


Add comment


Name*
Email*  
Country     


  • Comment
  • Preview
Loading