Functional Programming with Java 8

Posted on by Robert Demmer

The recording of our March 12th webinar featuring Venkat Subramaniam, Functional Programming with Java 8, is now available on JetBrains YouTube Channel.

In this presentation, we discuss how Java 8 now facilitates a functional style of programming and why we should care about it. Using multiple examples, during this live coding session, we will explore the strengths and benefits of the new Java 8 language features.

Learn more about IntelliJ IDEA 13.1 and its support for Java 8.

http://youtu.be/Ee5t_EGjv0A

About the Presenter:

Dr_Venkat_Subramaniam_200x200Dr. Venkat Subramaniam is an award-winning author, founder of Agile Developer, Inc., and an instructional professor at the University of Houston. He has trained and mentored thousands of software developers in the US, Canada, Europe, and Asia, and is a regularly-invited speaker at several international conferences. Venkat helps his clients effectively apply and succeed with agile practices on their software projects.

Venkat is a (co)author of multiple books, including the 2007 Jolt Productivity award winning book Practices of an Agile Developer. His latest book is Functional Programming in Java: Harnessing the Power of Java 8 Lambda Expressions. You can reach him by email at venkats@agiledeveloper.com or on Twitter at @venkat_s.

Comments below can no longer be edited.

6 Responses to Functional Programming with Java 8

  1. Ramesh says:

    March 31, 2014

    Awesome session. Thanks a lot venkat and. Jetbrains

  2. Gernot Starke says:

    April 1, 2014

    A slight issue with your Predicate…

    The pure-lambda version of “isPrime” works like a charm:

    protected boolean isPrime(final int number) {

    return number > 1 &&
    IntStream.range(2, number)
    .noneMatch(index -> number % index == 0);
    }

    But the Predicate-version does not compile:

    Boolean doesNotWork =
    number > 1 &&
    IntStream.range(2, number)
    .noneMatch( index -> isDivisible(index));

    The right-hand-side of the latter lambda expects a method… not a Predicate.

    Otherwise – a great intro, especially your explanation of “intent”

    • Andrey Cheptsov says:

      April 2, 2014

      >> expects a method

      Sorry but didn’t get what you mean. noneMatch expects IntPredicate in this particular case.

  3. Philip Herbst says:

    April 1, 2014

    Hi, I think the problem with the predicate version is that the IntStream needs a special primitive predicate type, because primitives don’t work with generics.

    This works
    {code}
    IntPredicate isDivisible = divisor -> number % divisor == 0;
    return number > 1 && range(2, number).noneMatch(isDivisible);
    {code}

    By the way if you use IntelliJ refactoring “extract method” on the code snippet the ide infers the right type
    {code}
    index -> number % index == 0
    {code}

  4. Andy Heilveil says:

    April 9, 2014

    Nitpicking: I see no lazy reduction of work done in the example of “doubling the first even number less than 3”. IE the same number of compares is done in the for-loop implementation. Nothing is gained performance wise. I’d agree that being able to assign a value via a for-loop is syntactically convenient.
    The internal lazy implementation of the stream class operators keeps the stream version from performing wastefully, but is not a performance improvement over a for loop.

  5. Annotated Java Monthly, April 2014 | JetBrains IntelliJ IDEA Blog says:

    May 5, 2014

    […] There have been a number of outstanding talks and articles last month, starting with the electric React Conference in London. If you were not among those lucky to attend, the organizers have released several sessions available on YouTube. Dr. Venkat Subramanian kindly joined us this March for a fantastic talk on functional programming in Java, which you can re-watch on our blog. […]

Subscribe

Subscribe for updates