Live data from Hacker News

Java 7 is now available

oracle.com

81–90 of 218 posts

Re: Java 7 is now available

#81
post #69
post #63

Earlier quoted context omitted.

I have to say, I think it's easier to verify the correctness of [31, isLeapYear(year) ? 29 : 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31][M-1] than your formula. Even a dictionary wouldn't be bad. And if it were wrong, it would be easier to fix it.

Correctness should be verified by tests not 'looking at the code'. The aforementioned code can never be verified as correct because February requires a year to be present to know the number of days. Doesn't java have a massive calendar library to address exactly these sorts of human questions? I mean sure you'd still be looking at code like: public int getDaysInMonth(DateTime date) throws CalendarFactoryFactorExcepti…

> Correctness should be verified by tests not 'looking at the code'.

Tests can prove the presence of bugs, but they are (in general) hopelessly inadequate to prove their absence; and once a test finds a bug, you still have to be able to understand what the code is doing in order to fix the bug.

In practice, code inspections and tests find quite distinct sets of bugs with some overlap, so it's valuable to do both of them. That's why all decent programming processes require both.

(This is probably one of the few cases where you could in fact verify that the code is correct by exhaustive testing — but only by comparing it against a known-correct implementation.)

Re: Java 7 is now available

#82
post #43
post #32

Earlier quoted context omitted.

Yes [1]. Invokedynamic (JSR-262). Quote from an older article [2]: "... enable[s] implementers of compilers for dynamically typed languages, that is, the people who develop compilers for languages such as JRuby and Jython, to generate bytecode that runs extremely fast in the JVM." [1] http://blogs.oracle.com/jrose/entry/jsr_292_launched_in_java [2] http://java.sun.com/developer/technicalArticles/DynTypeLang/...

Whoo-hoo! Time for the Perl port.

Good luck with that wish.

Re: Java 7 is now available

#83
post #72

There is a good amount of stuff to get excited about in this release. - Try-with-resources-Catch-Block [0] - Fork/Join libraries from Doug Lea (author of Executor framework) [1] - Inferred/Simpler generics in declarations (should have been in Java 5) - NIO2, brand new/robust filesystem APIs [2] - NIO2, treat ZIP/JAR files like directories of files for R/W [3] - SDP support [4] - String-in-switch (NOTE: check on perfo…

For version 8, I think it is a stretch to say that it will support 'closures'. [0]

The closures that are proposed are more like a bolted on psuedo solution, basically syntactic sugar that makes the language more complex. You can only use them in SAM (Single Abstract Method) situations. If only they just added a simple lisp like lambda expression...

[0] http://cr.openjdk.java.net/~briangoetz/lambda/lambda-state-3...

Re: Java 7 is now available

#84

Earlier quoted context omitted.

> The community splintered, the language and platform really lost any ability to maintain momentum. This is the mindset I've never understood. Do you stop using a hammer to bang in nails because the hammer "community" has splintered, or the development of hammers has stagnated? No, you still use it to fulfill a job it solves.

I don't think this is a valid analogy. The language/tools/support/ability-to-hire-developers are all a fluid ever-changing thing. Hammers aren't. Take this post.. people are excited about updates . I'm just saying the updates are kind of too little too late for me.

Well, people want different things. I just want the hammer.

New language features are all fun, but unless they actually result in faster execution, or allow you to do things you could not do before, they're only use is to make some developers happy, which I don't think is particularly important.

It looks like there's some real solid good APIs here though which is great to see.

At first thought I imagined it'd just be useless pandering to developers like "You can now do closures or first class functions" or something equally useless.

Re: Java 7 is now available

#85
post #72

There is a good amount of stuff to get excited about in this release. - Try-with-resources-Catch-Block [0] - Fork/Join libraries from Doug Lea (author of Executor framework) [1] - Inferred/Simpler generics in declarations (should have been in Java 5) - NIO2, brand new/robust filesystem APIs [2] - NIO2, treat ZIP/JAR files like directories of files for R/W [3] - SDP support [4] - String-in-switch (NOTE: check on perfo…

> And one that I can't get confirmation on if it's in 7 or got pushed, index-access for List and Maps

I just tried it out, it didn't get added to 7.

> String-in-switch (NOTE: check on performance implications of this for tight loops)

I haven't checked the performance, but I tried decompiling a String switch statement:

  String test = "asdf";
  switch (test) {
    case "sss":
      System.out.println("sss");
      break;
    case "asdf":
      System.out.println("asdf");
      break;
  }
That decompiles to:

  switch(test.hashCode()) {
    case 114195:
      if(test.equals("sss"))
        byte0 = 0;
      break;
    case 3003444:
      if(test.equals("asdf"))
      byte0 = 1;
      break;
  }
  switch(byte0) {
    case 0: // '\0'
      System.out.println("sss");
      break;
    case 1: // '\001'
      System.out.println("asdf");
      break;
  }
So it's one switch on the String's hashcode, with calls to equals to verify that the string is a match (and an if/else if/else block if you have multiple strings in the switch that have the same hashcode), assigning the result to a temp variable, and then a switch on a temp variable to execute your code.

It looks like it would be fairly quick.

Re: Java 7 is now available

#86
post #69
post #63

Earlier quoted context omitted.

I have to say, I think it's easier to verify the correctness of [31, isLeapYear(year) ? 29 : 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31][M-1] than your formula. Even a dictionary wouldn't be bad. And if it were wrong, it would be easier to fix it.

Correctness should be verified by tests not 'looking at the code'. The aforementioned code can never be verified as correct because February requires a year to be present to know the number of days. Doesn't java have a massive calendar library to address exactly these sorts of human questions? I mean sure you'd still be looking at code like: public int getDaysInMonth(DateTime date) throws CalendarFactoryFactorExcepti…

Yes, something like that. But better use joda time because the standard API sucks. joda: new DateTime().monthOfYear().getMaximumValue()

Re: Java 7 is now available

#87

Earlier quoted context omitted.

I don't think this is a valid analogy. The language/tools/support/ability-to-hire-developers are all a fluid ever-changing thing. Hammers aren't. Take this post.. people are excited about updates . I'm just saying the updates are kind of too little too late for me.

Well, people want different things. I just want the hammer. New language features are all fun, but unless they actually result in faster execution, or allow you to do things you could not do before, they're only use is to make some developers happy, which I don't think is particularly important. It looks like there's some real solid good APIs here though which is great to see. At first thought I imagined it'd just be…

Come on, let's get honest. The ecosystem matters. A lot. The community, and level of interest and delight in using the language matters.. Yes, even to you. It determines what third party tools are available, how easy it is to hire developers, and what machines the platform actually runs on. Your argument suggests you'd be just as happy and productive developing today in Pascal.

"You can now do closures or first class functions" or something equally useless.

Flamebait, but I'll take it. I think the dust-up over the possibility of this being added to Java really seemed to contribute to the decline and apparent disinterest of a lot of folks (I'd really be interested in Bob Lee's opinions here, since he was someone who's ideas I was particularly aligned with at the time and has since gone pretty quiet).. That said, lack of first class functions in Java isn't a trifle. It's why Java isn't all that much fun to program in compared to more expressive languages... and a bigger problem is that more than any other language I'm familiar with Java suffers from the problem of not being able to see enough ideas in a given amount of source code. I'm explaining that terribly, but I just mean that Java code is at least 60% scaffolding that isn't material to the author's intent.

Closures, or first class functions done nicely would be a big step in alleviating that issue, IMHO.

Re: Java 7 is now available

#88

Does it come with more patents? Serious question. I'm thinking Oracle tried to put a lot more locks on this version of Java, to make it theirs , and not so open source anymore.

Wasn't the feature freeze before Oracle bought Sun?

Re: Java 7 is now available

#89
post #72

There is a good amount of stuff to get excited about in this release. - Try-with-resources-Catch-Block [0] - Fork/Join libraries from Doug Lea (author of Executor framework) [1] - Inferred/Simpler generics in declarations (should have been in Java 5) - NIO2, brand new/robust filesystem APIs [2] - NIO2, treat ZIP/JAR files like directories of files for R/W [3] - SDP support [4] - String-in-switch (NOTE: check on perfo…

One other great feature in JDK8 will be defender methods which will allow interfaces to carry default behavior for methods. This will be the mechanism for adding default behavior in the collection libraries without breaking classes that extend them. It will also have a lot of great use cases in new library development.

Re: Java 7 is now available

#90

Earlier quoted context omitted.

I don't think this is a valid analogy. The language/tools/support/ability-to-hire-developers are all a fluid ever-changing thing. Hammers aren't. Take this post.. people are excited about updates . I'm just saying the updates are kind of too little too late for me.

Well, people want different things. I just want the hammer. New language features are all fun, but unless they actually result in faster execution, or allow you to do things you could not do before, they're only use is to make some developers happy, which I don't think is particularly important. It looks like there's some real solid good APIs here though which is great to see. At first thought I imagined it'd just be…

> New language features are all fun, but unless they actually result in faster execution, or allow you to do things you could not do before, they're only use is to make some developers happy, which I don't think is particularly important.

I think you don't appreciate how some language features can help you reduce the size and complexity of your code. Those are the kind of features that are sorely lacking in Java, and that means huge, bloated code bases.

I'm tired of visually parsing 20 lines of a Java method and filtering out all the boilerplate iteration junk just to find the one or two lines that actually do something. Often this kind of thing can be reduced to a few simple, relevant lines when you have closures, for example.

Post reply on HN