News for hackers. Stuff that matters.
Re:Evolving Java Without Changing the Language by axod on Thursday October 22, 2009 @04:46AM (#896401)
Thanks for the examples, and I completely agree about regexps... Personally though, I would be more worried about typos, potential bugs or misunderstandings with the Haskel. For me, the Haskel is too close to regexp land.

If you look at the Java code you've pasted, there's not really anywhere you could typo a character or 2, and it still compile. You'd have to typo a lot, or completely write it in the wrong way for it not to work. It's absolutely explicit and clear what it's doing.

With the Haskel code, you could mistype or misread a single character, and it'd completely change the meaning of the code.

I agree it's more verbose than the Haskel example, but also IMHO more solid/safe.

Re:Evolving Java Without Changing the Language by wiggles on Thursday October 22, 2009 @12:54PM (#897082)
Have you ever written any ML/Haskell?

It's nearly impossible to get past the type system unless your code is correct, especially for small chunks of code.

Re:Evolving Java Without Changing the Language by jrockway on Thursday October 22, 2009 @01:46PM (#897255)
No, he is right; however, Java has the exact problem.

The place where this code will screw up is in the logic of the comparison routine. It will be difficult for the types of x and y (or a and b in the Java example) to be wrong, but it is easy to say:

    compare (length x) (length x)
or

    compare (length y) (length x)
instead of

    compare (length x) (length y)
Your tests will catch this, though.