TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

Haskell Is Exceptionally Unsafe (2012)

107 pointsby kirkbackusover 10 years ago

9 comments

jonsterlingover 10 years ago
As others have said, it's not nearly as bad anymore as It was when Bob wrote that post, but I would say, please do not take that as a reason to not take what he says very seriously. I use haskell because it is a very practical tool, (bona fides: I am an experienced haskell developer and I actually use it full time for my job---not an armchair evangelist) but it has become very clear to me that the next great thing will be more like ML than like Haskell. There are of course many important lessons to be learned from Haskell though!
评论 #8480850 未加载
评论 #8481117 未加载
评论 #8481442 未加载
评论 #8481740 未加载
评论 #8480992 未加载
carterschonwaldover 10 years ago
I'd like to point out that the example at the end of the blog post is only runnable in GHC 7.6 and Older. As of GHC 7.8, you can't define your own custom typeable methods, you can only ask GHC to derive a typeable instance
wyagerover 10 years ago
&gt;The most blatant violation is the all too necessary, but aptly named, unsafePerformIO<p>The only time it&#x27;s necessary is when you&#x27;re using the FFI or working with language internals, at which point there&#x27;s really no way for the type checker to work anyway.<p>One should avoid using exceptions in pure code. This is well established. Instead, use any of the many type-safe exception mechanisms, like Maybe or Either. Having written probably in the high thousands or low tens of thousands of LoC of Haskell, I&#x27;ve never once used a user-defined exception or undefined.<p>The point of this article seems to be &quot;If your code breaks, it&#x27;s no longer type safe.&quot;. I don&#x27;t think this is news to anyone.
评论 #8480964 未加载
评论 #8481007 未加载
bjterryover 10 years ago
There was some discussion on this topic a while back which I remember. For convenience, it is linked here: <a href="https://news.ycombinator.com/item?id=4380900" rel="nofollow">https:&#x2F;&#x2F;news.ycombinator.com&#x2F;item?id=4380900</a>
tailrecursionover 10 years ago
I want to question the importance of soundness in type systems. Suppose you could catch 99% of type-based errors instead of 100%, and in addition, use a compiler switch to see all the case statements where a class of a type is missing. The intended benefit of this system is that it accepts all correct programs. Correct meaning, the program runs and returns the correct answer.<p>Would such a language be viable? Or is it absolutely necessary to catch all possible type errors. In the past, tools like lint have been considered useful, although lint is not at all the kind of type system that I envision, namely a system that is in practice catching all the errors that ML catches -- it just doesn&#x27;t (and cannot) guarantee it catches them.<p>The restrictive nature of static type systems today is legendary, but I wonder sometimes whether people realize how restrictive they are. If you can&#x27;t make your idea work with functors or typeclasses, chances are good there&#x27;s no way to get it to compile and you have to write functions in longhand.
评论 #8481758 未加载
评论 #8480975 未加载
评论 #8481377 未加载
评论 #8481000 未加载
coolsunglassesover 10 years ago
Harper&#x27;s an accomplished person in CS and has done great work, but he&#x27;s not putting a good argument forward here.<p>I&#x27;ve talked to Harper about this post and his opposition to Haskell before. I mentioned that it was leading people to believe they could ignore typed FP, not redirecting to an ML derivative. Harper expressed dismay at this.<p>There are more advanced languages than Haskell, they aren&#x27;t ML, and PL researchers&#x2F;experimenters are still working out how to make them work nicely for day to day stuff.<p>First: <a href="http://www.cs.ox.ac.uk/jeremy.gibbons/publications/fast+loose.pdf" rel="nofollow">http:&#x2F;&#x2F;www.cs.ox.ac.uk&#x2F;jeremy.gibbons&#x2F;publications&#x2F;fast+loos...</a> (This isn&#x27;t a throw-away reference, informal reasoning has worked extremely well in practice. Yes, I&#x27;m making <i>that</i> argument as a user of a pure, typed FP language.)<p>unsafePerformIO is primarily used to change thunk-memoization behavior [1]. Also, it says unsafe right on the tin. Nobody uses it in practice in ordinary code. It&#x27;s not something you have to incorporate when reasoning about code.<p>Giving up reasoning about your Haskell code as if there were semantics-violating unsafePerformIOs lurking in the depths is similar to giving up reasoning about any code because a cosmic ray might flip a bit.<p>Lets consider the rather remarkable backflips Standard ML and OCaml had to perform in order to make FP work with strictness and impurity.<p>You can ignore unsafePerformIO because very very few people ever need it and you&#x27;ll almost never have a reason to use it. Just don&#x27;t use it.<p>Similarly, writing total functions is the cultural default in Haskell. The compiler warns on incomplete pattern matches which you can -Werror as well.<p>You can&#x27;t define your own Typeable instances as of GHC 7.8 - only derive them, so that soundness issue is gone. Typeable itself is not popularly used, particularly as SYB has fallen out of favor. One critical aspect of why I like Haskell and the community around it is the willingness to fix mistakes. Meanwhile, ML implementations still use the value restriction.<p>&gt;the example once again calls into question the dogma<p>Oh please. Haskell is an ensemble, multi-paradigm language with the right defaults (purity, types, immutability, expressions-only) and escape hatches for when you need them.<p>Haskellers appreciate the value of modules a la ML, but typeclasses and polymorphism by default have proven more compelling in the majority of use-cases. There are still some situations where modules (fibration) would be preferred without resorting to explicit records of functions. For those cases, Backpack [3] is in the works. It won&#x27;t likely satisfy serious ML users, but should hopefully clean up gaps Haskell users have identified on their own.<p>Harper&#x27;s case is over-stated, outdated, and not graced with an understanding of how Haskell code is written. Informal reasoning works if the foundations (purity, types, FP) are solid.<p>[1]: <a href="https://github.com/bitemyapp/blacktip/blob/master/src/Database/Blacktip.hs#L47-L54" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;bitemyapp&#x2F;blacktip&#x2F;blob&#x2F;master&#x2F;src&#x2F;Databa...</a><p>[2]: <a href="http://caml.inria.fr/pub/papers/garrigue-value_restriction-fiwflp04.pdf" rel="nofollow">http:&#x2F;&#x2F;caml.inria.fr&#x2F;pub&#x2F;papers&#x2F;garrigue-value_restriction-f...</a><p>[3]: <a href="http://plv.mpi-sws.org/backpack/" rel="nofollow">http:&#x2F;&#x2F;plv.mpi-sws.org&#x2F;backpack&#x2F;</a>
评论 #8480689 未加载
评论 #8480915 未加载
评论 #8480723 未加载
评论 #8480791 未加载
评论 #8480758 未加载
accessrightover 10 years ago
So basically it is &quot;unsafePerformIO&quot; and &quot;error&quot; that is the problem?<p>So if you do not use them (which I never do and it is recommended not to) then the problem is not relevant?
评论 #8481545 未加载
评论 #8483216 未加载
reirobover 10 years ago
Here the reddit thread about this article, from 2 years ago: <a href="http://www.reddit.com/r/haskell/comments/y74vn/robert_harper_haskell_is_exceptionally_unsafe/?already_submitted=true" rel="nofollow">http:&#x2F;&#x2F;www.reddit.com&#x2F;r&#x2F;haskell&#x2F;comments&#x2F;y74vn&#x2F;robert_harper...</a>
qwertaover 10 years ago
Being unsafe never stopped Ruby or PHP, while Ada is still nowhere.
评论 #8481178 未加载
评论 #8482152 未加载
评论 #8481124 未加载
评论 #8481777 未加载