[<<][compsci][>>][..]
Wed Oct 14 14:14:57 CEST 2009

Java vs. Other

* primitive types

Primitive types are not objects, however they can be wrapped as such.
int -> Integer
float -> Float
double -> Double


* Java and functional programming

Maybe Java generics[1] is the best place to link FP and Java.
Generics are FP-style parametric polymorphism(PP).  This is different
from inheritance based polymorphism.  I.e. the most general container
without PP needs the least common denominator: the universal reference
type `Object'.  This however does not enforce that all elements in the
container are of a more specific type.  Generics allow a solution to
that by providing a generic template that can then be specialized to a
more specific type.  This is akin to C++ templates, except that Java
generics type-check in _parametric_ form, and all their
specializations are well-typed, in contrast with C++ templates which
type-check in expanded form using a heuristic type checker.


* OO vs FP in context of Java

FP: - algebraic data types      somewhat analogous to class hierarchies
    - parametric polymorphism   abstract collections
    - higher order functions    parameterize computational processes

The main difference is that in class-based, single dispatch OO,
methods are _tied_ to classes, while in FP this coupling is less
strict.

[1] http://www.javaworld.com/jw-02-2000/jw-02-jsr.html?page=2



[Reply][About]
[<<][compsci][>>][..]