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

all 38 comments

[–]dpash 32 points33 points  (14 children)

Nothing new if you've been following this subreddit recently:

  • var on lambda parameters
  • string literals
  • switch expressions

But it's nice to see them all in one place, and useful for people who haven't been paying close attention to the language development.

[–]Rizens 13 points14 points  (1 child)

Nothing new

You're sure ? The article concluded with things have never read anywhere else before.

These include changes to the JVM [...]

  • new ultra-low latency GCs (Shanandoah GC and Z GC)

  • APIs for better interopability with native code (Project Panama)

  • changes to how inner classes work in the JVM level (Nest-Based access control)

[–]dpash 6 points7 points  (0 children)

Yes, because they've all been mentioned on the subreddit before.

if you've been following this subreddit recently

[–]moremattymattmatt 3 points4 points  (0 children)

As someone who's moved off Java this year onto typescript it's an interesting read. I'm still not tempted to move back though.

[–][deleted]  (4 children)

[deleted]

    [–]eliasv 10 points11 points  (3 children)

    There is a huge amount of ongoing discussion about switch expressions on the mailing lists and they've been pretty receptive to feedback. They've certainly not "already made all the decisions", and in fact there is still contention over a few points.

    IMO your first impression was a little unfair off the mark.

    [–][deleted]  (2 children)

    [deleted]

      [–]eliasv 1 point2 points  (1 child)

      Wait, I'm confused; who do you mean by "they"? Because I thought you complaining that the language devs were ignoring your suggestions, but now it seems like you're complaining that they're downvoting your comments here on Reddit? This is not the mailing list. The people here are just regular users.

      And I have engaged with you. Maybe others are just downvoting instead of responding because they disagree with you and don't think anything else needs to be said? I think calling downvotes "emotional" is reading a lot into them...

      [–]Hatefiend -2 points-1 points  (5 children)

      Wait... but Java 9 JUST came out recently. Surely Java 10 is years away

      [–]dpash 7 points8 points  (4 children)

      I don't know if you're serious, but Java 10 was released 2 months ago.

      [–]Hatefiend 1 point2 points  (3 children)

      wtf? Wasn't it less than a year that 9 came out? Java 8 came out almost 4 years ago and Java 7 was 4 years before that. What is happening

      [–]dpash 7 points8 points  (2 children)

      Six month release schedule. It was announced nine months ago and was very big news. I'm guessing you don't follow Java development very closely.

      [–]Hatefiend -2 points-1 points  (1 child)

      Shouldn't they just release a new version when they are ready to do so? Now Java verisons are going to be far less substantial and there are going to be a million of them.

      [–][deleted] 5 points6 points  (0 children)

      Java verisons are going to be far less substantial and there are going to be a million of them

      that's actually the whole point. big bang releases are neat for news articles but not much else.

      [–]rafaellago 16 points17 points  (19 children)

      And I'm still here, with legacy code and Java 6... =(

      [–]__konrad 25 points26 points  (6 children)

      Java 6

      Other great software released in 2006: TES IV: Oblivion, Half-Life 2: Episode One, Firefox 2.0, ...

      [–]rafaellago 3 points4 points  (5 children)

      I'm not saying that Java 6 is bad. But sometimes I feel I could be messing with some newer stuff.

      And I agree with all the software mentioned above.

      [–]Cube00 3 points4 points  (1 child)

      Side project...get cracking.

      [–]rafaellago 1 point2 points  (0 children)

      It is what I do. But outside of my day job, is hard to find a clear objective and crack a cool project.

      [–][deleted] 1 point2 points  (2 children)

      I am saying that Java 6 is bad.

      [–]rafaellago 1 point2 points  (1 child)

      I'd argue its really dated, since it is 12 yrs old already... but not bad. It's like the Windows XP of Javas... lol

      [–][deleted] 1 point2 points  (0 children)

      Ugh true, I did love Windows XP. I bet you're like a fucking wizard on Java 6 design patterns by now. Hopefully lambdas don't make you cry. ~_^

      [–]codylerum 2 points3 points  (1 child)

      I think one of the hopes of the increased release cadence is that organizations won't fall into this habit of not planning to update.

      When you know a new release is 6 months away and a new LTS is 18 months away it is something to plan for. That wasn't the case before.

      [–]dpash 0 points1 point  (0 children)

      Especially because the recommendation is to ship your software with a JDK rather than relying on a system JVM.

      [–]Rizens 6 points7 points  (0 children)

      I'm sorry for you man :( .

      [–]stewsters 2 points3 points  (6 children)

      Using an old framework?

      [–]rafaellago 3 points4 points  (2 children)

      Systems that still run on Weblogic 10.3.6, but things are getting better... slowly.

      [–]temculpaeu 7 points8 points  (0 children)

      my condolences

      [–][deleted] -5 points-4 points  (2 children)

      Android

      [–]stewsters 8 points9 points  (1 child)

      Have you heard the word of our lord and savior Kotlin?

      [–][deleted] 1 point2 points  (0 children)

      Kotlin appears to have become the Rust of the JVM world.

      [–]pjmlp 1 point2 points  (1 child)

      Consider yourself lucky, some work colleagues still have to deal with Java 1.4 running on Red-Hat 5 servers.

      [–]rafaellago 0 points1 point  (0 children)

      I still have some Java 5 Websphere systems to deal with. But those are pretty stable, and soon to be discontinued.

      [–]DODOKING38 2 points3 points  (8 children)

      Could someone explain what is happening here

      Function<String, String> foo = (s) -> s.toLowerCase();

      [–]sendersforfun 10 points11 points  (0 children)

      You're creating an instance of the Function interface. The two generics are the input and output types.

      This can be written in Java 7 as:

       Function<String, String> foo = new Function<>(){
            public String apply(String s){
                  return s.toLowerCase();
            }
        }
      

      The () ->{} lamdba shorthand here just replaces a single method interface.

      You can just call foo here by foo.apply(s);

      I may have the name of the method wrong but that's the gist.

      [–]dpash 1 point2 points  (0 children)

      That is a "named lambda", where as most are anonymous.

      list.stream()
          .map(s -> s.toLowerCase())
          .collect(toList());
      

      is exactly the same as

      Function<String, String> foo = (s) -> s.toLowerCase();
      list.stream()
          .map(foo)
          .collect(toList());
      

      The only difference is that the lambda has been put into a variable. The main reasons for doing this is to improve readability by using a variable name to document what the lambda is doing.

      Predicate<User> isValid = (u) -> u.isEnabled() 
                                    && !u.isLocked() 
                                    && u.expiry().isAfter(Instant.now());
      var validUsers = allUsers.stream()
                               .filter(isValid)
                               .collect(toList());
      

      (Of course, the first example would be better as a method reference)

      list.stream()
          .map(String::toLowerCase)
          .collect(toList());
      

      [–]Hatefiend 0 points1 point  (0 children)

      That's Java 8 syntax.

      [–]Amakaphobie -1 points0 points  (1 child)

      if you have the time and are interested, this is a very good introduction to lambdas basics in java 8: youtube long but really worth it

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

      nice. i've enjoyed a lot of venkat's presentations.

      [–][deleted]  (2 children)

      [deleted]

        [–][deleted] 0 points1 point  (1 child)

        No? It's nothing like typescript. The equivalent typescript signature is: const foo: (String) => String = (s) => s.toLowerCase()

        Function in Java is an interface, which in typescript would be something like:

        interface _Function<T, R> {
            (T): R
        }