Hacker Newsnew | past | comments | ask | show | jobs | submit | hss54's commentslogin

Please, get rid off the primes example, as it is horrible inefficient (in the sense of, "Ok, let's find the first n primes by a simple well-known algorithm, like the Sieve of Eratosthenes") and a simple (non-pure) array-based approach will kick its ass.

Such a toy-example just contributes to the wrong belief that Haskell is just useful in academics or teaching. Some time ago I did implement the sieve in several languages and I also considered Haskell but set for an unpure approach (IOUArray) and it was extremely fast (getting close to C/C++ and outperforming Go, Java, etc.). Obviously such an example is not good to present Haskell's novel ideas but this toy example is worse then no example.

edit: Sorry, did not want to appear nit-picky, I like the language and the new design.


> Please, get rid off the primes example, as it is horrible inefficient (in the sense of, "Ok, let's find the first n primes by a simple well-known algorithm, like the Sieve of Eratosthenes") and a simple (non-pure) array-based approach will kick its ass.

The primes example may be a bit awkward for people with no background in math but it's also an excellent example to demonstrate lazy evaluation in Haskell.

The interesting bit is that primes is an infinite list, containing all prime numbers. Don't try to print the whole list or count the sum unless you have a computer with infinite memory :)


Even though it's a good example, I think extra care should be taken to avoid the stereotype that Haskell is elegant for math and academic stuff but not for the real word.


It's just as if you showed off insertion sort. Even if it looks good, it's not the best algorithm to show off.


Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: