News for hackers. Stuff that matters.
Re:Advantages of Functional Programming in Java 8 by odabaxok on Tuesday September 06, 2016 @06:28AM (#12434879)
I believe you can achieve the same in Java by static import.

EDIT: Also, I think the parent comment was not complaining about the missing possibility of creating standalone functions, but rather saying that not every functionality can be forced into objects, i.e. there is still need of standalone functions in OOP.

Re:Advantages of Functional Programming in Java 8 by ajuc on Tuesday September 06, 2016 @06:42AM (#12434951)
You still have to put each method in some class in java, in C++ you can just put it in namespace. It makes more sense, even if in practice the difference is minimal.

> there is still need of standalone functions in OOP

Yes, and that's what I've shown?

Re:Advantages of Functional Programming in Java 8 by ivan_gammel on Tuesday September 06, 2016 @09:20AM (#12435766)
It's a syntax issue. Final class with private constructor and all members being static is effectively a namespace.
Re:Advantages of Functional Programming in Java 8 by scott_s on Tuesday September 06, 2016 @10:16AM (#12436143)
I think it's more than just syntax - it's culture. In C++, free standing functions has been a part of the culture of the language since the beginning. The design of the language encourages them - there are even cases, such as operator overloading, where it's preferable to implement it as a free standing function rather than a class method. In Java, when I write a class that is a collection of static methods, I feel like I'm fighting against the language and it's culture, even though they are sometimes used.
Re:Advantages of Functional Programming in Java 8 by ivan_gammel on Wednesday September 07, 2016 @03:25AM (#12441440)
How much do you write code on Java?

Such functional namespaces were part of Java from the very beginning (Math is a good example and with release of Java 8 now there are many more in standard library). I have not seen an enterprise project yet, in which there's no something ending with Utils or Helper, that is just a collection of functions. Such naming is an anti-pattern, of course, but still, almost every developer in Java world uses this and has it part of it's development culture.

Re:Advantages of Functional Programming in Java 8 by ajuc on Wednesday September 07, 2016 @04:00AM (#12441546)
> Such naming is an anti-pattern, of course

This is exactly the cultural problem with too strict adherance to OOP :)

It's like people saying "nails are anti-pattern of course, but people still use them, so we've added hammer-heads to our screwdrivers".

Re:Advantages of Functional Programming in Java 8 by scott_s on Wednesday September 07, 2016 @10:11AM (#12443509)
Yes, that was the point I was getting at. It's obviously part of how real Java code is written, but I feel like I'm going against how the language was designed when I do it. (Clearly, everything is not an object, and a class is not always the most appropriate way to group code.)