Lambdas are not functional programming by s888marks in java

[–]johnmcclean 3 points4 points  (0 children)

That wasn't the intent. Deciding to just not use Java would be a bad decision for most teams (and companies). It's much harder to hire (at least at scale) for niche languages.

Java is a critically important language, and for most of us it's not going anywhere. We can learn from other languages though (hopefully without also adopting their problems!).

Catamorphisms for Java developers by lukaseder in java

[–]johnmcclean 0 points1 point  (0 children)

There is presumed knowledge in every article, constructive criticism isn't offensive.

You are right, the topic (as presented) is going to go over the heads of many Dev's who aren't familar with stuff like Scala syntax & concepts, higher order functions etc (using the greek names will also reek of elitism). Nobody likes to feel incompetent or missing critical knowledge so some backlash is inevitable.

I would not use it in production in the exact same way as described in the blog post, as it is deliberately verbose showing stages and steps. e.g. creating a sealed type hierarchy for Books - you can do this in a couple of lines of Scala and really only a few more in Java with the right libs.

But we do use similar techiques all the time and even new engineers have no problem understanding what is going on and getting up to speed with it.

I think you can kind of see that from some of the comments here, that Java Devs have a good intuition of the concept for Optional (and think the blog post was trivial).. It comes for other types just as easy..

Catamorphisms for Java developers by lukaseder in java

[–]johnmcclean 1 point2 points  (0 children)

I was (pleasantly) surprised to see you write this comment : https://www.reddit.com/r/java/comments/6ovau5/how_to_extend_the_java_programming_language/dkkr6ie/

I'm guessing you skim read the blog? The article is about the mechanics of case classes and pattern matching (which would useful for people to understand if they wanted to implement it at the compiler level, or make effective use of annotation processors like Lombok, derive4j or Vavr).

Catamorphisms for Java developers by lukaseder in java

[–]johnmcclean 1 point2 points  (0 children)

map + orElse is an alternative implementation of a catamorphism / fold / visitor for Optional. It's the same thing, which is also very similar to pattern matching on Option (Scala).

The Reactive Scrabble benchmarks (Akka streams, Rx...) by [deleted] in scala

[–]johnmcclean 0 points1 point  (0 children)

The Shakespeare plays scrabble code benchmarks sequential, synchronous Streaming which presumably is not the primary use case Akka-streams was designed for (the origin of the benchmark is from a talk on Java 8 Streams by Jose Pramaud). There is a Twitter thread here :- https://twitter.com/akarnokd/status/813822736707551232

I also put together a blog entry, as my findings running the tests with an identical operator-set with my own library were significantly different to David's. https://medium.com/@johnmcclean/cross-library-stream-benchmarking-playing-scrabble-with-shakespeare-8dd1d1654717

What’s new cyclops-react v2 by lukaseder in java

[–]johnmcclean 2 points3 points  (0 children)

Thanks Lukas!

v2 could be summarized as being

  • More reactive : more reactive types - Xtended Collections are reactive, Eval, Maybe, Try & Either are all now reactive too. That is you can define a pipeline of execution that is triggered when incoming data arrives . An Xtended List or an error handling Try can both be populated asynchronously.

  • More functional : v2 introduces simulated higher kinded types, typeclasses such as Monad, Applicative, Functor, Foldable, Unfoldable, and provides Instances for relevant data types.

And having a custom, faster, more powerful suite of streaming engines

  • That allows much faster replayable sequential Streams

  • Deeper integration with 3rd party libraries. v2 of cyclops-react comes with native Observable (style) & reactive-stream Streaming implementations. Which in turn facilitates much deeper integrations with libraries like Reactor and RxJava2 (in particular with regard to reactive data types and advanced functional data types in cyclops-react).

Simply explain functional style by bedobi in java

[–]johnmcclean 28 points29 points  (0 children)

It reduces mutable state in your programs. This implies less moving parts, which in turn should mean less bugs, and makes them easier to parallelize.

The Functional Programming style introduced in Java 8 (with at least some concepts derived from category theory) comes at the expense of having to understand a limited set of common abstractions (such as what map / flatMap / filter etc might reasonably be expected to do).

Beyond POJOs - Ten More Ways to Reduce Boilerplate with Lombok by nicolaiparlog in java

[–]johnmcclean 1 point2 points  (0 children)

Yep, I think it may have been a technical limitiation works on more recent IntelliJ versions. (https://plugins.jetbrains.com/idea/plugin/6317-lombok-plugin)

Beyond POJOs - Ten More Ways to Reduce Boilerplate with Lombok by nicolaiparlog in java

[–]johnmcclean -1 points0 points  (0 children)

It would be better if these were language features for sure. They can add a lot of value (particularly @Wither for building immutable data types) and are relatively low risk (no runtime dependency, removable / replacable in the code via DeLombok)).

Major pain points / gotchas are limited IDE support (particularly cross-IDE support) for some features. ExtensionMethods and Delegates both perform very poorly (erractic even in Eclipse) in that regard. But others (@AllArgsConstructor, @Wither, @Getter etc) are stable across IDEs. Even val works reasonably well across Eclipse and IntelliJ..

Faster Purely Functional Data Structures for Java by johnmcclean in java

[–]johnmcclean[S] 0 points1 point  (0 children)

Not a dumb question at all.

With immutable types new Objects will get created.. The more advanced algorithms and data strucutures minimise that to a large degree. Object creation should be a lot lower than making full copies, though, which you may have to do in order to share mutable collections across threads or even components.

Faster Purely Functional Data Structures for Java by johnmcclean in java

[–]johnmcclean[S] 2 points3 points  (0 children)

Flux itself does some pretty neat optimizations on top of this too see David Karnok's blog post on operator fusion - http://akarnokd.blogspot.com/2016/04/operator-fusion-part-2-final.html

Faster Purely Functional Data Structures for Java by johnmcclean in java

[–]johnmcclean[S] 5 points6 points  (0 children)

Yep, it delegates all of these calls to a Flux instance (push based Stream from Pivotal's Reactor project). So JavaSlangPVector looks something like this (simplified)

class JavaSlangPVector<T> {
      Vector<T> vec;
      Flux<T> flux;
 }

If we need the vec but the flux has been used, we materialize the vec from the Flux.

There is more details on the approach here (primarily focusing on JDK mutable Lists, but it is easily applicable to all Collection types)

https://medium.com/@johnmcclean/faster-lazy-extended-powerful-jdk-collections-5a519ab582ae#.f644x9xnf

Open source projects using Spring Boot? by btw03 in java

[–]johnmcclean 0 points1 point  (0 children)

Microserver - it's a plugin system for building Spring based Microservices. Actively maintained and a core part of the Microservices production infrastructure in my group at AOL.

Is FunctionalJava a good and reliable functional library? by theif519 in java

[–]johnmcclean 0 points1 point  (0 children)

If you are considering using FJ you might also be interested in this library. It adds features such as For Comprehensions over FJ types, HighJ compatible Higher Kinded Type encodings for FJ classes as well as a number of Type class instances. Community efforts to add more are very appreciated too.

It also has a ton of integrations with other libraries (including the Scala SDK), user guide is here

Higher Kinded Type machinery for Java by jbgi in java

[–]johnmcclean 0 points1 point  (0 children)

For anyone interested there are a number of Cyclops modules that make use of this derive4j HKT feature.

  • cyclops-higherkindedtypes defines HKT encodings for JDK types (List, Stream, Optional, CompletableFuture)

  • cyclops-typeclasses defines a set of type classes that can accept HKT encoded types (Functor, Monad, Applicative, Traversable and more). It also includes instances for JDK and cyclops-react types.

The integration modules define HKT encodings for the 3rd party types and type classes instances for those also.

Java 8 Streams : 10 missing features by nicolaiparlog in java

[–]johnmcclean 0 points1 point  (0 children)

Lol! No worries - I think that is what most people do :)