Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

Haskell SMP is superior

Name: Anonymous 2008-05-16 6:46


$ ghc smp3.hs -O2 -o smp3 --make -threaded
Linking smp3 ...
$ time ./smp3 +RTS -N1
[90,7,7,0,5,63,7,11,31,3]

real    0m1.409s
user    0m1.406s
sys    0m0.002s
$ time ./smp3 +RTS -N2
[90,7,7,0,5,63,7,11,31,3]

real    0m0.834s
user    0m1.564s
sys    0m0.046s
$ time ./smp3 +RTS -N4
[90,7,7,0,5,63,7,11,31,3]

real    0m0.545s
user    0m1.576s
sys    0m0.036s

module Main where
import Data.Maybe
import Control.Parallel.Strategies
import Control.Parallel

factors n = let candidates = [2..floor (sqrt (fromInteger n))]
            in catMaybes $ map (\x ->
                                      if n `mod` x == 0
                                      then Just (x, n `div` x)
                                      else Nothing) candidates
bigNums = [2000000000000..]
answer = (parMap rwhnf) (length . factors) (take 10 bigNums)

main = print answer

Name: Anonymous 2008-05-16 7:24

I am a programmer. I have dealt in many languages, but I have ended up with Haskell. Haskell is the best language for implementing general programs.

Haskell is fast. It's no Common Lisp/Scheme, but it's head and shoulders above comparable high-level languages.
Haskell is memory-managed.
Haskell supports just the right level of features. It doesn't have Schemes's feature fetish.
Haskell has an expansive, (mostly) cross-platform API. It's not perfect, but it sure beats writing everything yourself.
Haskell and its API are constantly being improved.

In any program of significant size, the problem isn't writing your Bloom filters or splay trees with elegant syntax. It's a problem of communication with other programmers (including library-writers). Haskell's strict typing, rigid structure, documentation system, and excellent developer tools (aka Eclipse) all help you out.

It's not perfect. Sure, first-class functions would be nice, but you never use them except on your homework assignment where you pass the comparator to a sort function. If you're building a little toy program, it's a pain to put everything in an object, but you'll be thankful you did once that program gets big enough. The syntax sucks, but it's familiar. Sure, GHC is slow, but suck it up big balls.

Haskell isn't perfect, but it's the best in practice.

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List