Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

I think there is a different point to it all: Java doesn't have first-class functions.

In OCaml (and without doubt other programming languages as well), you can use a function to make "objects"/"values" that you want made ("constructors"). If you want to parametrize the function ("factory"), you just partially apply it to some arguments. If you need to make other objects before you can make the desired object ("dependency injection"), you pass other functions as arguments. If you want to do something else instead of creating a new object (e.g. "singleton pattern"), you write a different function.

It's just functions, all the way down.



Perhaps you missed the Java 8 release, which has lambdas. Though your statement certainly holds true for previous versions.


Its not a Java problem as this JavaScript demonstrates.

Its not a language feature X problem.

There is something which drives people to make a factory for a dynamic and another static language. Instead of writing the thing they want they write a thing to give them what they want.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: