Why not Haskell? (2011)

栏目: IT技术 · 发布时间: 3年前

At one point, I think I qualified as a Haskell ninja — I understood and used monad transformers, I had a bunch of modules up on the module sharing system including C bindings, I was even credited for providing feedback on a Haskell paper.

But I haven't done any of that in months, maybe a year. And much like my post-mortem about why I stopped looking at O'Caml in 2005 (which I think in part is what drove me to Haskell), I figure Haskell deserves one too.

First, the good: Haskell is truly beautiful. I cannot think of another thing I've played with that has been so mentally rewarding over such an extended period of time. It's permanently changed the way I think about programming, from computation all the way through aesthetics.

That sort of statement may also be true about e.g. Lisp but I found that there wasn't a whole lot to get about Lisp (that's kind of the point of Lisp, after all), whereas each extra month with Haskell gave me an extra month of new perspective on what it means to compute from type classes to laziness to combinators to, yes, monads. (Man, I feel like someone trying to explain what an acid trip is like.)

But despite all that experience, I conclude that writing Haskell code is hard. I don't mean that in the "math is hard, let's give up", sense, but that getting from an empty page to a program that does the job is a harder process than it is with e.g. Perl. A resulting correct Haskell program is likely more reliable, maintainable, and perhaps faster, but getting to that point (framing your problem the right way, knowing how to profile or deal with space leaks, understanding when unsafePerformIO is actually the right thing) is just too much effort.

Here's a diagram summarizing the problem:

Why not Haskell? (2011)

If you've written a Haskell program that runs, it's highly likely to be a correct solution; but the set of runnable Haskell programs is much smaller than the space of programs that get the job done, and frequently I'm more interested in being done.

I find myself digging up Haskell sometimes for when I want sketch something out mathematically: writing a program to answer a question like "how many different ways can I seat n people at m tables given these extra constraints?" is a delight in Haskell. But for the sorts of code I write, those parts are the small ones; the bigger ones are parsing file formats when the input language is not well specified or interacting with some grungy library.

(That point is the only point I wanted to make, but since there's nowhere else to shove it in, I'll add: I also recently dug up some old Haskell code I'd written in the past and found I was unable to compile it due to the "DLL hell" that is package versioning of Hackage. It made me grumpy.)

So, Haskell, I conclude: it was definitely worth my time, even if it had only been so I can understand PL research papers. I can wholeheartedly endorse you learning it as well. But I'm sad to say I don't imagine myself basing a new major project (or company) around it.

Strangely lately I've been writing a lot of code in Go, which seems to have attracted a lot of other people I know. I think of the Go language as sort of the anti-Haskell: visually ugly, semantically warty, written with apparently little regard for the state of the art in research — but on the other hand, incredibly pragmatic throughout. A shining example of worse is better.


以上所述就是小编给大家介绍的《Why not Haskell? (2011)》,希望对大家有所帮助,如果大家有任何疑问请给我留言,小编会及时回复大家的。在此也非常感谢大家对 码农网 的支持!

查看所有标签

猜你喜欢:

本站部分资源来源于网络,本站转载出于传递更多信息之目的,版权归原作者或者来源机构所有,如转载稿涉及版权问题,请联系我们

数据结构与问题求解

数据结构与问题求解

韦斯 / 清华大学出版社 / 2011-8 / 89.50元

《数据结构与问题求解(Java语言版)(第4版)》是专为计算机科学专业的两个学期课程而设计的,从介绍什么足数据结构开始,继而对高级数据结构与算法进行分析。《数据结构与问题求解(Java语言版)(第4版)》以独特的方式,清晰地将每种数据结构的接口与其实现分离开来,即将如何使用数据结构与如何对数据结构编程相分离。《数据结构与问题求解(Java语言版)(第4版)》从抽象思维和问题求解的角度出发,为数据结......一起来看看 《数据结构与问题求解》 这本书的介绍吧!

JS 压缩/解压工具
JS 压缩/解压工具

在线压缩/解压 JS 代码

图片转BASE64编码
图片转BASE64编码

在线图片转Base64编码工具