The *main* difference is that Scala is very much designed for maximum
compatibility with existing Java bytecode, whereas Haskell has its own
ecosystem.  Hence, null has to be supported.

Given an effects system (it'll come one day, honest...), Scala could easily
enforce non-nullability without any need for annotations or trailing
punctuation on type names.  In the meantime, we're already getting value
types in Scala 2.10 which, like Java's primitives*, cannot be subclassed by
Null.  I dearly hope to see more work in this direction with subsequent
released!

* Scala's type system has Any at the top, then AnyVal (equivalent to
primitives) and AnyRef (equivalent to Object) as the only two subtypes of
Any.  Then there's a whole bunch of stuff in the middle, then Null which
can subtype any AnyRef, then Nothing**, which can subtype anything.  Prior
to 2.10, the only possible subclasses of AnyVal were Int, Double, etc.
(equivalent to Java's primitives), this is about to change...


** A good example of a statement returning Nothing is "throw new
Exception()", it really does return nothing, not even Unit (which is
equivalent to void)



On 4 June 2012 16:32, clay <[email protected]> wrote:

> On Monday, June 4, 2012 10:14:07 AM UTC-5, KWright wrote:
>>
>>
>> Haskell uses Maybe, which is directly equivalent to Scala's Option.  It
>> just does it a bit more elegantly because the lack of subtyping allows for
>> full H-M type inference.
>>
>
> The major difference between Scala's Option and Haskell's Mabye is
> that Scala's Option is optional (I tried to avoid the pun) in that you can
> simply use null if you choose. Haskell doesn't let you use a null value for
> any reference type, so the language affords you that non-null guarantee at
> the compiler level like Kotlin and Fantom.
>
> Java has third party libraries like Functional Java that supply an Option
> class. The problem is that any other Java library or API that you use won't
> use that.
>
>

-- 
You received this message because you are subscribed to the Google Groups "Java 
Posse" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/javaposse?hl=en.

Reply via email to