
sebastian.sylvan:
On 1/15/06, Donald Bruce Stewart
wrote: sebastian.sylvan:
On 1/15/06, Isaac Gouy
wrote: Haskell now ranked 2nd overall, only a point or so behind C:
It was always obvious that the "Write the program as-if lines of code were not being measured" clause relied too heavily on contributors willingness to co-operate.
http://shootout.alioth.debian.org/gp4/faq.php#implementlist
Maybe we finally have enough motivation to move to some other measurement of program volume :-)
I was just thinking about that. Some code is very obfuscated due to
No Sebastian, this is very obfuscated: http://www.cse.unsw.edu.au/~dons/pretty.html
;)
I think saying obfuscated is very unfair. We took advantage of some strengths of Haskell, such as type inference, to reduce the number of lines. No worse than, say, the SML MLton entries do -- and why not leverage this advantage, since our language can do it?
In fact, we have 1 line entries for some of the problems that are just not competitive, though very instructive. It would be nice to be able to publish those.
I wasn't talking specifically about Haskell, but all languages (don't like browsing around other languages only to see highly compact and ugly solutions, which really don't give me a good taste for the langugae). Still, some Haskell implementations are clearly obfuscated to save lines in certain circumstances (like: "thread im om = do (x::Int) <- takeMVar im; putMVar om $! x+1; thread im om" int he cheap concurrencybenchmark, most people don't write Haskell code with semi-colons, and when they do they usually sequence them vertically, not horizontally).
Though often the case, using ; is not without precedent. A quick grep in the ghc source reveals many: get bh = do a <- get bh; b <- get bh; return (a :% b) mappM f (x:xs) = do { r <- f x; rs <- mappM f xs; return (r:rs) } sequenceM (x:xs) = do { r <- x; rs <- sequenceM xs; return (r:rs) } do { bty1' <- kc_larg_ty bty1; bty2' <- kc_larg_ty bty2; return (InfixCon bty1' bty2') } repE (HsApp x y) = do {a <- repLE x; b <- repLE y; repApp a b} .... So for one liners, it's often better than plugging it together with >> and >>= -- Don