After you've done some functional programming, you start to wonder how you ever could have considered methods on a “Point” class a good idea
2
19
6
@stilkov What do you mean with "Point" class?
1
@dkrizic A class with two or three coordinates. And the kind of method I'm referring to is something like "distance"
1
@stilkov Ok, "Point" literally. A method like double d = p1.distance( p2 ); ?
1
@dkrizic Yes. So many concepts conflated in that example.
1
@stilkov So what do functional languages improve in this example?
1
@dkrizic You just build a function distance(p1, p2) without feeling guilty. Not that you couldn't do that in Java, but you typically don't.
2
1
@stilkov Ok, now I get you, but like @rotnroll666 I do not feel guilty adding Point#distance, I don't know how to do it better in Java
1
@dkrizic @rotnroll666 That's my point: what's idiomatic in Java doesn't necessarily make sense.
2
@stilkov @dkrizic I understand that functional programming solves a lot problems but i don't get why this is a particular good example.
2
Replying to @rotnroll666
@rotnroll666 @dkrizic My point was that once you get used to writing free functions, being forced to use objects everywhere feels just wrong

Sep 12, 2013 · 8:39 AM UTC

2
2
Replying to @stilkov
@stilkov @rotnroll666 Fact is: In Java static methods need a compile unit (not oo class) to live in and are not "free"
Replying to @stilkov
@stilkov @dkrizic Ok… Understood. public abstract class Utils {} ;)
1
2