Hi,<br _moz_dirty="" />I am comparing some aspects of Haskell with Java.<br _moz_dirty="" />Below is a simple Haskell program with a sub-class.<br _moz_dirty="" />It is followed my attempt to code the same concepts in Java.<br _moz_dirty="" />Two questions:<br _moz_dirty="" />1) Are the two examples close enough? (very subjective)<br _moz_dirty="" />2) In this example, what are the advantages of the Haskell type checking over the Java type checking? <br _moz_dirty="" />3) Are there more general advantages of Haskell type checking over Java type checking?<br _moz_dirty="" /><br _moz_dirty="" />Regards,<br _moz_dirty="" />Pat<br _moz_dirty="" /><br _moz_dirty="" /><br _moz_dirty="" /><br _moz_dirty="" />==== Haskell program===<br _moz_dirty="" />data C<br _moz_dirty="" />data D<br _moz_dirty="" /><br _moz_dirty="" />class A t where<br _moz_dirty="" />instance A C where<br _moz_dirty="" />instance A D where<br _moz_dirty="" /><br _moz_dirty="" /><br _moz_dirty="" />class A t => B t where<br _moz_dirty="" />instance B C where<br _moz_dirty="" />instance B D where<br _moz_dirty="" /><br _moz_dirty="" /><br _moz_dirty="" />=====Java Program===<br _moz_dirty="" />import java.lang.Class;<br _moz_dirty="" /><br _moz_dirty="" />interface A<T> {}<br _moz_dirty="" />class A_INSTANCE<T> implements A<T> {}<br _moz_dirty="" /><br _moz_dirty="" /><br _moz_dirty="" />interface B<T> extends A<T>{}<br _moz_dirty="" />class B_INSTANCE<T> implements B<T> {}<br _moz_dirty="" /><br _moz_dirty="" /><br _moz_dirty="" /><br _moz_dirty="" />class C {}<br _moz_dirty="" />class D {}<br _moz_dirty="" /><br _moz_dirty="" />public class DEMO1 {<br _moz_dirty="" />public static void main(String args[]) {<br _moz_dirty="" /><br _moz_dirty="" /><br _moz_dirty="" />A_INSTANCE<C> ac = new A_INSTANCE<C>();<br _moz_dirty="" />A_INSTANCE<D> ad = new A_INSTANCE<D>();<br _moz_dirty="" />B_INSTANCE<C> bc = new B_INSTANCE<C>();<br _moz_dirty="" />B_INSTANCE<D> bd = new B_INSTANCE<D>();<br _moz_dirty="" /><br _moz_dirty="" />System.out.println("Object's Class name =>"+ ac.getClass().getName());<br _moz_dirty="" />System.out.println("Object's Class name =>"+ ad.getClass().getName());<br _moz_dirty="" />System.out.println("Object's Class name =>"+ bc.getClass().getName());<br _moz_dirty="" />System.out.println("Object's Class name =>"+ bd.getClass().getName());<br _moz_dirty="" /><br _moz_dirty="" /> }<br _moz_dirty="" />}<br _moz_dirty="" /><br _moz_dirty="" /><br _moz_dirty="" />