News for hackers. Stuff that matters.
Re:Haskell and the "foul stench of cargo cult mathematics" by jrockway on Monday December 27, 2010 @06:23PM (#2043981)
A programming language where you have to tell it the type of expressions if the type is ambiguous? That would be a deal killer, no wonder nobody uses Haskell. Java handles this much better:

    Integer i = new Integer(5);
I mean, look at how concise and readable that is. Java knows that 5 is an Integer and you don't even have to tell it.

Oh wait, the opposite.

Basically, the author seems upset that "5" is a Number rather than an Integer. But that's fine, because it's true. 5 is a real fraction. 5 is a complex fraction. 5 is a double. 5 is a char. 5 is an unsigned long long. 5 is a lot of things to a computer. So sometimes, you have to tell it which one you want.

This isn't cargo-cult mathematics, but rather reflects that Haskell is a computer programming language. There is a lot of math in there, sure, but at the end of the day, you are writing computer programs to run on computers. And computers don't know what an Integer is. It just knows that it has some bits in memory and that it should interpret them in a certain way.

This guy's blog is weird.

Re:Haskell and the "foul stench of cargo cult mathematics" by Zaak on Monday December 27, 2010 @08:46PM (#2044295)
> Basically, the author seems upset that "5" is a Number rather than an Integer. But that's fine, because it's true. 5 is a real fraction. 5 is a complex fraction. 5 is a double. 5 is a char. 5 is an unsigned long long. 5 is a lot of things to a computer. So sometimes, you have to tell it which one you want.

A contributing factor here is that there are no subtype relations in Haskell. In math, "5" is all of those things simultaneously, but in Haskell it can only be one at a time.

Re:Haskell and the "foul stench of cargo cult mathematics" by thesz on Tuesday December 28, 2010 @07:39AM (#2045313)
>In math, "5" is all of those things simultaneously, but in Haskell it can only be one at a time.

How is that?

Excerpts from ghci dialog:

  Prelude> :t 5
  5 :: (Num t) => t
  class (Num a) => Fractional a where
    (/) :: a -> a -> a
    recip :: a -> a
    fromRational :: Rational -> a
  Prelude Data.Complex> :i RealFrac
  class (Real a, Fractional a) => RealFrac a where
  ...
  Prelude Data.Complex> :i RealFloat
  class (RealFrac a, Floating a) => RealFloat a where
  ...
  Prelude Data.Complex> :i Complex
  data (RealFloat a) => Complex a = !a :+ !a
  instance (RealFloat a) => Eq (Complex a)
So, 5 is an Int, Integer, Rational, Double and Complex (which, actually, could be Complex Int or Complex Double).
Re:Haskell and the "foul stench of cargo cult mathematics" by Zaak on Thursday December 30, 2010 @03:48PM (#2053562)
(Num t) => t means that the value can have the type of any member of class Num, but it can't be more than one type at a time. There are no subtypes in Haskell.