MAIN FEEDS
Do you want to continue?
https://www.reddit.com/r/java/comments/49prnu/var_keyword_proposed_for_java/d0usqs6/?context=3
r/java • u/adila01 • Mar 09 '16
312 comments sorted by
View all comments
Show parent comments
4
You couldn't use it for parameters. Type inference in Java-like typesystems makes it too hard, if not impossible.
1 u/[deleted] Mar 10 '16 [removed] — view removed comment 2 u/vytah Mar 10 '16 That's why Haskell library developers, even though Haskell can infer almost all types in the program automatically, specify explicit type signatures for public functions. 2 u/[deleted] Mar 10 '16 [removed] — view removed comment 1 u/[deleted] Mar 10 '16 it's useful to keep in mind that, in a certain sense, most haskell code could be considered "generic" from the java perspective.this haskell: add a b = a + bis (roughly): public static <T> T add(T a, T b) { return a + b; }(technically the java won't compile, but c'est la vie.) it's an imperfect comparison for a couple reasons but close enough for discussion, i think.broadly, java is more concerned with the name of things, where haskell is more concerned with the structure of things.
1
[removed] — view removed comment
2 u/vytah Mar 10 '16 That's why Haskell library developers, even though Haskell can infer almost all types in the program automatically, specify explicit type signatures for public functions. 2 u/[deleted] Mar 10 '16 [removed] — view removed comment 1 u/[deleted] Mar 10 '16 it's useful to keep in mind that, in a certain sense, most haskell code could be considered "generic" from the java perspective.this haskell: add a b = a + bis (roughly): public static <T> T add(T a, T b) { return a + b; }(technically the java won't compile, but c'est la vie.) it's an imperfect comparison for a couple reasons but close enough for discussion, i think.broadly, java is more concerned with the name of things, where haskell is more concerned with the structure of things.
2
That's why Haskell library developers, even though Haskell can infer almost all types in the program automatically, specify explicit type signatures for public functions.
2 u/[deleted] Mar 10 '16 [removed] — view removed comment 1 u/[deleted] Mar 10 '16 it's useful to keep in mind that, in a certain sense, most haskell code could be considered "generic" from the java perspective.this haskell: add a b = a + bis (roughly): public static <T> T add(T a, T b) { return a + b; }(technically the java won't compile, but c'est la vie.) it's an imperfect comparison for a couple reasons but close enough for discussion, i think.broadly, java is more concerned with the name of things, where haskell is more concerned with the structure of things.
1 u/[deleted] Mar 10 '16 it's useful to keep in mind that, in a certain sense, most haskell code could be considered "generic" from the java perspective.this haskell: add a b = a + bis (roughly): public static <T> T add(T a, T b) { return a + b; }(technically the java won't compile, but c'est la vie.) it's an imperfect comparison for a couple reasons but close enough for discussion, i think.broadly, java is more concerned with the name of things, where haskell is more concerned with the structure of things.
it's useful to keep in mind that, in a certain sense, most haskell code could be considered "generic" from the java perspective.
this haskell: add a b = a + b
add a b = a + b
is (roughly): public static <T> T add(T a, T b) { return a + b; }
public static <T> T add(T a, T b) { return a + b; }
(technically the java won't compile, but c'est la vie.) it's an imperfect comparison for a couple reasons but close enough for discussion, i think.
broadly, java is more concerned with the name of things, where haskell is more concerned with the structure of things.
4
u/vytah Mar 10 '16
You couldn't use it for parameters. Type inference in Java-like typesystems makes it too hard, if not impossible.