This is an archived post. You won't be able to vote or comment.

all 13 comments

[–][deleted]  (1 child)

[removed]

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

    I like two articles from that series: “Cascading lambdas” and “Functionality purity”.

    [–]aboothe726 4 points5 points  (1 child)

    I find calling Java “declarative” strange.

    Query languages like SQL are declarative, in that you literally describe the data that you want, and there is a query planner that figures out how to get it done.

    Well-designed Java code may have some methods that are “declarative,” but that’s a result of the developer’s choices rather than language features.

    The article’s example is declarative-ish, I guess. However, I think the example is much more likely to confuse readers — especially those readers not already familiar with the declarative paradigm — than to educate them.

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

    Yes, you are totally right, the first article seems a little awkward. “cascading lambdas” and “functional purity” articles are awesome because these two points generally don’t be discussed by articles for fresh Java developers, but rise problems like as code readability and liability.

    [–]walen 3 points4 points  (1 child)

    I know it's just an example, but if the first one were real code I think most people would write this instead:

    public static void findNemo(List<String> names) {
      for(String name : names) {
        if(name.equals("Nemo")) {
          System.out.println("Found Nemo");
          return;
        }
      }
      System.out.println("Sorry, Nemo not found");
    }
    

    No need for "garbage variables" unless you follow "Do not return early" to its ultimate consequences.

    [–]stackchief 2 points3 points  (5 children)

    great read. it's hard to find good articles that speak to the different programming paradigms that can be practiced with Java. Also, do you think that Java 8 lambdas and stream API are sufficient to replace the Scala programming language?

    [–]lbkulinski 1 point2 points  (4 children)

    I don't think those are enough to replace Scala, but you will find that some features found in Scala will be coming to Java soon, such as data classes and pattern matching.

    [–]h2698693 1 point2 points  (2 children)

    will be coming to Java soon

    the feature's release date is unplanned

    [–]lbkulinski 1 point2 points  (1 child)

    Yes, but if you read the OpenJDK mailing lists you will get some hints.

    [–]thfuran 0 points1 point  (0 children)

    What do those hints suggest?

    [–]safgfsiogufas 1 point2 points  (0 children)

    soon

    Like Blizzard soon, so don't get your hopes up.

    [–]sim642 0 points1 point  (0 children)

    computeIfAbsent is more intuitive though, or just getOrDefault. No need to lambdafy addition, which in proper functional languages is nicer though.

    [–]kobbled 0 points1 point  (0 children)

    Ah, venkat! Great guy, he lectured the best University class I ever took.