Earlier quoted context omitted.
There really is not much you can do to a language to make you code faster. I guess people just like the novelty of a new language.
If you mean that time spent actually coding a program is a rounding error of the time spent conceiving it, then that's an interesting point. That said.. 1. OF COURSE you can make languages that are faster or slower to write code in. 2. Trivializing anyone who jumps ship on a language as being enchanted with the 'novelty of a new language' is obnoxious and arrogant.
Java 7 is now available
121–130 of 218 posts
Re: Java 7 is now available
#122There 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…
Try Scala! (So do I ;)
Re: Java 7 is now available
#123Looks like this version is not open source. Is there an open-source version of Java 7? Edit: Yes! http://openjdk.java.net/ has an announcement at http://mail.openjdk.java.net/pipermail/announce/2011-July/00... . So why would anybody "accept the Oracle Binary Code License Agreement for Java SE"?
Re: Java 7 is now available
#124Looks like this version is not open source. Is there an open-source version of Java 7? Edit: Yes! http://openjdk.java.net/ has an announcement at http://mail.openjdk.java.net/pipermail/announce/2011-July/00... . So why would anybody "accept the Oracle Binary Code License Agreement for Java SE"?
Re: Java 7 is now available
#125Earlier quoted context omitted.
> 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": Sys…
Really appreciate you going through the trouble to do that and post the results so we don't need any hand-waving. This looks the same as the original proposal -- using the hashCode and final verification via equals. So in a typical case scenario you have the 1-time calculation of the String's hashCode (which is then cached by java.lang.String) and the two method calls. .equals() is the only thing that could get away…
I checked what happens when you use an enum, and it generates some funky code. It creates an anonymous inner class with a static initializer for an array of ints. It uses the ordinal value to assign a sequential number starting with one. Then the switch statement is on intArray[theEnum.ordinal()], and the case statements start with 1. Here's the code:
class Test2{
public static void main(String[] args) {
MyEnum en = MyEnum.ONE;
switch (en) {
case ONE:
System.out.println("one"); break;
case TWO:
System.out.println("two"); break;
default:
System.out.println("default");
}
}
}
enum MyEnum {
ONE, TWO, THREE;
}
Decompiled (after being compiled with jdk1.7.0): public static void main(String args[])
{
MyEnum myenum = MyEnum.ONE;
static class _cls1
{
static final int $SwitchMap$MyEnum[];
static
{
$SwitchMap$MyEnum = new int[MyEnum.values().length];
try
{
$SwitchMap$MyEnum[MyEnum.ONE.ordinal()] = 1;
}
catch(NoSuchFieldError nosuchfielderror) { }
try
{
$SwitchMap$MyEnum[MyEnum.TWO.ordinal()] = 2;
}
catch(NoSuchFieldError nosuchfielderror1) { }
}
}
switch(_cls1.$SwitchMap$MyEnum[myenum.ordinal()])
{
case 1: // '\001'
System.out.println("one");
break;
case 2: // '\002'
System.out.println("two");
break;
default:
System.out.println("default");
break;
}
}
I wonder why it doesn't just switch on the ordinal directly. It's also worth noting that it has to make an array for MyEnum.values().length. This means if you have an enum with a lot of values, you're wasting a lot of memory (especially since it creates this array every class you use a switch in).
I tried with an enum with 40 values, and it didn't switch to a map. Maybe there's some higher threshold where it would switch to a map instead (but again, I don't understand why it wouldn't switch on ordinal() directly).Re: Java 7 is now available
#126Earlier quoted context omitted.
If you mean that time spent actually coding a program is a rounding error of the time spent conceiving it, then that's an interesting point. That said.. 1. OF COURSE you can make languages that are faster or slower to write code in. 2. Trivializing anyone who jumps ship on a language as being enchanted with the 'novelty of a new language' is obnoxious and arrogant.
Yes, it is harder to come up with the actual design, architecture, algorithms, testing of your program than the actual coding. You should definitely use what makes you more comfortable but criticizing/hating a language because it is not adding whatever is currently hot under the Sun is also obnoxious and arrogant. C++ is a lot older than Java and can be also a pain to write programs in and yet for whatever reason peo…
There really is not much you can do to Java at this point
Because it's basically perfect? Okay.
At any rate, really my point was not "Java sucks, I'm over it"... my point was that I think the community of programmers that surround a language are for better or worse stewards of the direction, best-practices, idioms, and common ideologies that affect my experience developing in it. Jim's arguing that he's not like that.. fine, but most of the rest of us are. We use libraries written by other developers, work with other developers... the community matters and shapes our experiences as a [Insert Language] Programmer. I'm just saying that for me, that community was thriving at one point, and then around when Java 5 came out fragments started showing.. things got worse, and now I don't really see much to get excited about. The frameworks are ridiculously heavy, I hope I never accidentally figure out what an Enterprise Service Bus is for, and generally I just feel like the direction of the language (and probably the platform) seems rather driftless.
Re: Java 7 is now available
#127Looks like this version is not open source. Is there an open-source version of Java 7? Edit: Yes! http://openjdk.java.net/ has an announcement at http://mail.openjdk.java.net/pipermail/announce/2011-July/00... . So why would anybody "accept the Oracle Binary Code License Agreement for Java SE"?
The OpenJDK may have more bugs. Check out [ http://stackoverflow.com/questions/1977238/why-should-i-use-... ].
Re: Java 7 is now available
#128Earlier quoted context omitted.
@felipemnoa: Downvotes are presumably for snarky 'You must suck and reading/writing code then' comments. Isn't a positive contribution to the discussion. Also, 'making the difference' and 'being totally irrelevant' are two very different things. Programming languages matter. I'd be surprised if Mr. Spolsky disagrees.
I think it is. If people haven't learnt yet that the single most important skill you need as a programmer is being able to read any code, in any language, and take a good guess at what it does, be able to hold abstract programming concepts in your head, and match them up to random code listings you have never seen before.... Before you can write code, you need to know how to read it.
(Probably with Perl, I guess...)
...sorry Perl guys. Couldn't resist.
Re: Java 7 is now available
#129Earlier quoted context omitted.
@felipemnoa: Downvotes are presumably for snarky 'You must suck and reading/writing code then' comments. Isn't a positive contribution to the discussion. Also, 'making the difference' and 'being totally irrelevant' are two very different things. Programming languages matter. I'd be surprised if Mr. Spolsky disagrees.
I think it is. If people haven't learnt yet that the single most important skill you need as a programmer is being able to read any code, in any language, and take a good guess at what it does, be able to hold abstract programming concepts in your head, and match them up to random code listings you have never seen before.... Before you can write code, you need to know how to read it.
Each method only had tiny differences but spotting them, as pivo's original comment argues, is a total nightmare.
Refactoring brought it in at 1,500 lines. Now you can glance at any method and see the actual difference to the default that they do.
Are you seriously suggesting there's little difference between a programming language that encourages 20,000 line behemoths filled with dross compared to a concise 1,500 line program. That there's not a massive mental overhead to reading through what is essentially a book compared to a short essay?
As that's what's being discussed, but you don't seem to get it.
There's reading code, and there's reading pointless code.
Re: Java 7 is now available
#130Earlier quoted context omitted.
Good, about time. If they only get those features slated for Java 8, they'll be at the same level C# was six years ago. :-)
And only if Microsoft would improve their x-platform vm. Oh wait...