Preview of Java 1.5 461
gafter writes "An early access prototype implementation of
the proposed new J2SE 1.5 language features is
available. The prototype includes
generics (JSR 14),
typesafe enums, varargs,
autoboxing, foreach loops, and static import
(JSR 201). In other words, all the new language features
planned for 1.5 except
metadata (JSR 175). The
prototype includes full sources for the compiler,
written in the extended language. You can download the prototype from
java.sun.com.
It requires J2SE 1.4.1 and provides some examples of how to use the new language constructs. The prototype includes an experimental type
system (variant type parameters)
for Generic Java that is being considered
for Tiger (1.5) based on a paper by
Igarashi and
Viroli at ECOOP 2002 .
Comments and votes for the new type system are
being gathered at
bugParade."
good and bad ...? (Score:4, Interesting)
Re:good and bad ...? (Score:5, Funny)
Because no language is complete without printf.
Anyway, I'm glad to see Java finally getting generics. This will make it a little easier to manage very large projects in Java. The only problem I see is that generic java usually sucks compared to the brand-name stuff (e.g. Lavazza [lavazza.it]).
Mod parent funny! (Score:2, Informative)
Re:good and bad ...? (Score:5, Informative)
isn't syntactic sugaring all about making code more readable? I think boxing , generics, typesafe enums, static imports make the java language more simple to use.
It's just looking over the fence to the "sibling" languages (c++, c#) and copy what they do better.
Re:good and bad ...? (Score:5, Insightful)
Re:good and bad ...? (Score:3, Informative)
Ah, but Java's two for-iterator loops are slightly different. The 'foreach' IIRC provides you with a single variale that points to successive items in your collection...it does not provide you an iterator. This means you can traverse the
Re:Loops and iterators. (Score:3, Funny)
I think you meant hold-over. But since you were talking about Pascal, maybe hangover is a bit more appropriate. ;)
Re:good and bad ...? (Score:5, Insightful)
Type-safe enums were added to eliminate previously verbose and obfuscated code. It simplifies the code without complicating the language.
There are iterators for doing stuff like foreach-looping
What does polymorphism have to do with an enhanced the for-loop or variable arity functions? The enhanced for-loop ensures that collections are properly iterated across (no out of bounds exceptions). You honestly think that
for (int i = 0; i < C.length; ++i) {/*
is more complex than
for (int i : C) {/*
Also look at what you can do with variable arity functions. Say you have a constructor for a collection class and you want to be able to initialize a variable number of default values. Well, now you can. Apple's Cocoa (Foundation) library uses this to allow easy construction of NSDictionary objects.
id d = [NSDictionary dictionaryWithObjectsAndKeys:@"foo", @"bar", @"biz, @"baz"];
The other way to do it would have been
id d = [[NSMutableDictionary alloc] init];
[d setObject:@"foo" forKey:@"bar"];
[d setObject:@"biz" forKey:@"baz"];
Aside from Cocoa's long parameter naming scheme, the first method is a shorter and a lot easier. It also uses fewer messages.
Re:good and bad ...? (Score:3, Interesting)
In a way, yes. The first uses the (little) possibilities the core language offers. The second uses a language feature that depends on a specific part of the class library.
So, even if the resulting code itself is easier to read, if conflates two layers of the language that should better be cleanly separated, IMNSHO. It basically boils down to the fact that you cannot change the cla
In a way, no. (Score:3, Interesting)
for (int i : C) {}
or more properly
for (CMemberType cMem: C) {}
is something that I have to scratch my head about. The fact that people conflate i with c_mem and confuse a collection member with a loop index tells me that the new construct is going to give problems.
Yeah, yeah, Law
Collections should be first-class entities (Score:4, Insightful)
You can already declare arrays in-line. So if they were to define an appropriate constructor, you could do List l = new ArrayList(new Object[] { "foo", "bar", "baz" }).
That is verbose of course. What they really should do is add collection manipulation stuff to the language, so you could go List l = ( "foo", "bar", "baz" ) and be done with it.
I believe that that scripting languages get most of their advantages (more functionality with less code, easy to develop in, etc) because they have collections as first-class entities. It's not as if it would be polluting the language... How often do you write code that doesn't use some kind of aggregate data type? For the language to not recognize that is just silly.
Re:good and bad ...? (Score:2, Interesting)
I agree. Enumerated types are something Java has been lacking for too long, so these type-safe enums will be welcome (though Joshua Bloch, the specification lead on JSR 201, has a nice alternative in his excellent Effective Java book).
I really don't care much about the rest. I'll give the generics and the autoboxing a go, but I don't really like the new for loop syntax. Firstly I think it's ugly, they've compromised to avoid adding a new keyword (I don't really know why, they were happy to add new keywo
Re:good and bad ...? (Score:3, Informative)
Cleaning up the core libraries should never mean rearranging them according to some fleeting sense of pure aesthetics. Even a cleaned-up Java has to provide some amount of backward compatibility for existing code. Chan
Re:good and bad ...? (Score:3, Interesting)
for(i = 0; i < count; i++) {
You can use iterators for this, but (depending on the implementation) it is likely to be slower, since the object in question must create an iterator instance.
Iterators should be used (in fact, are pretty much a necessity) on types that are not easily indexed, such as hash tables or linked lists. As long as the Java language doesn't have support for iterators, developers creating non-indexable container class
No subject. (Score:5, Funny)
Just had to get that trolling out of the way. Now let the educated and well-formulated arguments begin.
Re:No subject. (Score:3, Interesting)
Re:No subject. (Score:2)
Java's slowness is an inherent property, sorry. It's just a function of its design, not a flaw. 'Serious' 3D grahics will always be done at a lower level than languages such as Java, if 'serious' means 'state of the art'.
Re:No subject. (Score:4, Insightful)
I'm tired of running into C programmers who are scared of lower level code (read: Assembly).
I'm tired of running into GUI users who are scared to use the command line.
I'm tired of running into calculator users who are scared of using a slide rule.
I'm tired of running into automatic transmission drivers who are scared of manual transmisions.
I'm tired of running into people who use drive automobiles and are afraid to use a horse and buggy.
In fact, I don't think scared is the issue here at all. The real issue is automation. Something that always makes people more productive, and requires greater machine resources. (See all above examples.) In fact, using your own argument against you, I would argue that anyone here, even a Basic programmer, can learn to program Assembly, use a command line, use a slide rule, etc. In fact many of us were Basic programmers. Many of us do or did these other skills. That fact that you can be "macho" and learn pointers is missing the real issue. Automation.
In Java, you are trading machine performance for human performance. You simply eliminate the possibility of even having the all of the most common C/C++ bugs that plague so much modern software.
CPU cost is going down. People cost is going up. This trend has been going on for a long time. (Have you noticed this trend in the past 20 years?)
Back in the early 60's and 70's there were huge debates about whether "high level" languages (like the C you advocate) would ever be useful because the compiled code was so much less efficient than hand written code. (And yes, I know that argument in the late 70's that compilers would eventually write better code than by hand.) But the point remains, that even if this is or is not true, high level languages won.
Think about why that is for a moment.
In any sufficiently complex C/C++ system, you either end up implementing garbage collection, or end up with some complex disciplined memory management strategy, and still end up with object lifecycle bugs. In C/C++ you sometimes end up implementing your own miniature Lisp, even if you've never seen Lisp. But your own implementation of Lisp ends up poorly specified, and not throughly debugged.
Sounds like what C# has that makes it better... (Score:4, Interesting)
Re:Sounds like what C# has that makes it better... (Score:5, Insightful)
To me, Java was a lanaguage with a minimum of "redundant" features. You can write a "for" loop without using "foreach". You can use a class instead of a struct. And so on... I'm actually a bit surprised that Sun are throwing in features the language doesn't really always seem to need. I thought that was C#'s area.
Re:Sounds like what C# has that makes it better... (Score:2)
Re:Sounds like what C# has that makes it better... (Score:3, Interesting)
And hats off to Microsoft for doing so, C# is a nice language.
I agree, however, that the next release of Java will raise a few eyebrows wrt 'fixing' Java's current 'problems' (if you could call them that - they're more like syntactic unpleasantries).
Should be interesting
Too litttle, too late. (Score:2, Insightful)
Now that java has them too, they are suddenly the biggest thing since sliced bread. Most modern languages have had automatic boxing for ages, and never made a big deal about it.
And about the new templates: they are just syntactic sugar. For example if you have an ArrayList, the elements will still be stored on the heap as Integer objects. That is very inefficient.
And w
Re:Too litttle, too late. (Score:2, Insightful)
mod up. this is major pita that makes java almost unusable for small&trivial stuff. (ironically - the stuff it was designed for)
Re:Too litttle, too late. (Score:2, Interesting)
It's correct to say that the start-up time for JVMs is a concern (more so than actual Java execution speed) but fortunately things are getting better in this respect. Java 1.4.2 (which is in beta at the moment) has made some significant improvements in this area.
The irony of your sig (Score:2)
A lot of the features added to 1.5 are syntactic sugar for laziness. I guess that means this is true progress, according to your signature.
Shared-VM conspiracy (Score:2)
This immediately sparked a campaign of, well... complaining. But it seems to have worked. In a matter of hours, the comment had disappeared.
Now, I still have no positive evidence that Sun WILL put shared-VM into 1.5, but at least subtle, but solid evidence that they d
Re:Too litttle, too late. (Score:5, Informative)
Without seeing (in the Java source code) how the templates are implemented I can't say that I agree or disagree with your statement that they will be inefficient, though I'm inclined to disagree based on your example. Templates or not, objects are going to be stored the same way. The difference is how those objects are retrieved. Right now you have to cast everything coming out of an ArrayList (unless the Object reference is sufficient)...not only is that being moved to the language but you also gain compile-time type checking. That will only serve to reduce errors and make the software more reliable. Templates are optional anyway - you don't have to use them. I'm looking forward to them.
I don't think you're ever going to see VM sharing. If applications can share VMs then one rogue app could bring down other apps by trashing the VM (never supposed to happen) or by poor thread management.
Either way you look at it, it's a good year to finally be going to JavaOne...
Re:Too litttle, too late. (Score:5, Informative)
Slashcode swallowed some brackets even though I was in text mode
What I mean is the following: If you create for example an ArrayList of ints, the most efficient way to store these ints internally would obviously be an int[] and not an Object[]. But even though java uses templates, it still stores primitive types such as int in an Object[], so there is a huge temporary object creation overhead. Whenever you store an int in your IntArrayList, a new Integer object is created on the heap and an old Integer object has to be garbage collected. In
The
"Templates or not, objects are going to be stored the same way. The difference is how those objects are retrieved. Right now you have to cast everything coming out of an ArrayList (unless the Object reference is sufficient)...not only is that being moved to the language but you also gain compile-time type checking. That will only serve to reduce errors and make the software more reliable. Templates are optional anyway - you don't have to use them. I'm looking forward to them."
Me too. It is not that I dislike the new features. I just think that they could have been implemented better, faster and earlier.
"I don't think you're ever going to see VM sharing. If applications can share VMs then one rogue app could bring down other apps by trashing the VM (never supposed to happen) or by poor thread management."
VM sharing does not mean that all java programs must run in one process. But for most desktop applications this would make a lot of sense. You are right about the thread management, but you could always restrict the number of threads an application can create. Just have a nice XML file which describes how much resources each application may allocate. That is the way
If sun will not do VM sharing, you will never see decent client applications written in java. Just think about it: for each java application you start, the whole swing library has to be JIT-Compiled anew. What a huge waste of processing power!
Re:Too litttle, too late. (Score:3, Insightful)
Sure, its implementation may be in terms of what already exists (i.e. internally you still have Lists of Objects, being cast into Integers or whatever). However, the burden of typecasting is removed from the programmer into the compiler, which is very significant and not syntactic sugar at all!
Re:Too litttle, too late. (Score:3, Insightful)
And don't forget Java Web Start apps, like this (Tetris) [infoether.com] and this (GForge client) [infoether.com].
Java Web Start is great stuff - always downloads the latest version, easy to deploy... don't know why more folks aren't using it...
Tom
Simplicity lost (Score:5, Interesting)
Anonymous inner classes was first major ugliness which came into language - not very clear, hard to explain to a newcomer. But with all these new proposals, significant complexity is added to code in terms of visual overview. This is not critical for developers - perl hackers are faring very well, despite of having language 10 times as complicated as java as far as syntax is concerned - but pure-OO, java-is-new-pascal-for-algorithms academic society will probably start looking for a new language soon... (ok, maybe not really 'academic', I'm thinking more about secondary-level school programming basics).
Re:Simplicity lost (Score:5, Insightful)
Actually though I think for this kind of teaching you can just use the simple subset of Java that's been about since 1.1 - after all, you're teaching principles of programming and OO - you can teach actual Java *development* down the line and cover the complexities, bells, whistles and dongles then...
Good ol days (Score:3, Funny)
Re:Simplicity lost (Score:2)
Don't get me wrong, I also code Java and I love the new features; the trick, as you say, is to focus on teaching a subset. Nevertheless, I await with dread the point next semester when a student points to a piece of example code with an in
Re:Simplicity lost (Score:3, Insightful)
Then, when they understand the concepts, you can introduce them to the syntactic nightmare that is Java.
Re:Simplicity lost (Score:2)
Re:Simplicity lost (Score:2)
Re:Simplicity lost (Score:3, Insightful)
Re:Simplicity lost (Score:3)
Java has several interactive interpreters. One such is DynamicJava.
Plus some very powerful debugging tools TOTALLY missing from Python that are very important for teaching programming.
As someone who has taught programming at a university level, and is also a practicing programmer I find the broken syntactical structure of Python completely disqualifies it as a teaching language. The use of non printing characters as syntax elements is ridiculous on the face of it.
Re:Simplicity lost (Score:2)
Besides, if the answer is that you must use these new features or doing X isn't easy, might that not suggest the new feature has made life simpler for developers?
Teach the kids Scheme or Smalltalk. (Score:5, Insightful)
Smalltalk has, essentially, only one operation: the message send. Send object X a message Y, and get Z back as a result. Even simple things like addition are implemented this way. While not blazingly fast (except in certain specialized implementations), the message-send semantic is surprisingly efficient: many complex real-world systems have been constructed using Smalltalk.
Scheme also enjoys the advantage of being small and simple, yet powerful. You don't need to know what the lambda calculus is to see how effective and intuitive Scheme's procedural semantics is. ("Lather, rinse, repeat." See? Tail recursion. It was there all along.)
Either way, it's better to use a simple language to teach students how to formulate plans for doing things (i.e., algorithms), and then hit them with fanciful syntax later rather than drop them into a popular, but bewildering for newcomers, language (which I consider C++ and Java to be).
Fork? (Score:2)
(Click 'Reply to This' to comment about no/no open standards etc)
---
Oh no! (Score:4, Funny)
Er. Or, not.
Teach basics in python, algorithms in ocaml, bit-grinding in C.
Interested in learning more about these generics (Score:5, Interesting)
More constructively, maybe the implementation will improve on things from all that time and experience.
Java is the best defense against the
Generic Java (Score:5, Informative)
(Excuse my whoring, but Sun's link to GJ was 404.)
Java is passe (Score:2, Interesting)
Also, after trying to live with it for years, I have concluded that "100% pure Java" just doesn't meet my needs. "99% pure" is good enough for me: it
Mini Ask Slashdot (Score:2)
I was about to install Java + JBoss + Tomcat + Apache httpd (and maybe Apache Cocoon) and see what I can do with it. I'm not a seasoned developer (just had a few classes a few years ago), so I'm trying to figure out the best way to offer a scalable web platfrom mainly for database entry and reporting without much custom programming. I'm also interested in application services, but that's more into the
Re:Mini Ask Slashdot (Score:2)
But, in any case, there are lots of alternatives. I suspect that for most applications, you are probably better off using PHP, mod_perl, mod_python, or maybe Zope.
Re:Mini Ask Slashdot (Score:2, Interesting)
Now, if you're talking about a secure, robust Tomcat installation, using apache httpd to serve static content, well, that's another matter.
Tomcat is for one of the examples of the success of Java code married to the Open Source model; Sun likes Tomcat becuase they farm out RI work for the Servlet and JSP specs, leaving engineers to concentrate on, well, coming up with more convoluted specs. S
Re:Mini Ask Slashdot (Score:2)
Tomcat has improved since the merge of the JServ project. I agree it was a nightmare 2 years ago but the situation has improved.
Re:Mini Ask Slashdot (Score:3, Informative)
for an out-of-the-box solution. To deply an app, just copy the app into the deployment directly. To configure, fire up a browser and point it at port 8080 (I think).
Haven't come across many app servers as simple as that.
Re:Java is passe (Score:3, Informative)
Java:
-Java as a language is not a standard but doesn't change much at ALL.
-Every API is developped through the Java Community Process
-C# + CLR is standardized (yes only a language and a VM)
-Other API's are NOT standardized and are in full control of Microsoft
I think that mono will have some major problems in the future. Sure they can implement C# and CLR, but they virtually have to reengineer all other API's, because there are no formal specs available.
Re:Java is passe (Score:5, Insightful)
How is that different from C++ and the Win32 APIs? The fact that Microsoft controls the Win32 APIs doesn't matter to me when programming in C++--I just write my code in Gtk+ or wxWindows. Likewise, the fact that Microsoft controls the
Furthermore, you don't need Sun-style central control over everything in order to get good cross-platform toolkits, as toolkits like Qt, FLTK, and wxWindows show. C# will have good cross platform support, either by successfully cloning
You see, the fact that C# doesn't come with philosophical baggage like WORA and "100% purity" is an advantage as far as I'm concerned. What WORA and "100% purity" has brought us is lousy implementations of Java on Linux, and APIs that don't even let me access environment variables.
Generics (Score:5, Interesting)
It seems to me that languages like Java and C# really don't need them.
Re:Generics (Score:5, Interesting)
1) C++ is a systems programming language. The lack of pointers would make it entirely unsuitable for that purpose. For normal use, you should use references or smart pointers. Not doing so is no excuse. Using a C-style array when you don't need it is akin to deliberately writing an infinite loop. It's entirely the programmer's fault.
2) The object model doesn't lack anything that Java's model has, except introspection (which is fragile at best). If anything, Java's model is equally broken, because everything is not an object. What exactly about the object model is missing?
3) What's wrong with the C++ syntax? How is it that different from Java's syntax?
From my POV, peoples' biggest problem with C++ is that it doesn't prevent you from hurting yourself. That's okay. I hate all the consumer protection bullshit, and Nader and his "don't run with scissors" party, so I have no problem with my language having some teeth. I do a lot of low level programming, and I find that C++, more than any other language, allows one to do that will still maintaining a high level of abstraction.
Is the single instance of VM in? (Score:5, Interesting)
Kjella
Re:Is the single instance of VM in? (Score:3, Informative)
Sun are apparently looking at the work that Apple did to provide this functionality with the Apple implementation of 1.4, but it's not likely to be in 1.5 (see this chat transcript [sun.com] for the official line. Maybe 1.6 for non-Apple VMs?
varargs - shmarargs (Score:2, Interesting)
Dylan (Score:3, Interesting)
But whereas the features were elegantly incorporated into Dylan since the beginning and are consistent and easy to use, I suspect that in Java they are a hack.
Wasn't Java designed to be a simple language?
The problem: Improving programmer productivity (Score:5, Interesting)
These additions seems to put Java on par with C#, but to make a quantum leap in expressiveness you need a dynamically typed scripting language.
Most applications these days can be written in higher-level languages, resulting in 5-10 times less source code compared to Java/C#, and making them correspondingly simpler to code and maintain.
Java doesn't really have a kick-ass companion scripting language. In MS world, VB plays this role. VB is really popular, but (I think most people would agree) a crap language and not really that high level. JavaScript just doesn't seem to cut it (pretty much only used in browsers).
Why doesn't Sun take a hint and phase JavaScript out in favor of a powerful multi-purpose high-level language like Python [python.org] or Ruby [ruby-lang.org]? That'll put them miles ahead of Microsoft in terms of increasing programmers' productivity... and programmers' quality of life.
Re:The problem: Improving programmer productivity (Score:4, Informative)
Look here [com.com] for more info. My guess is Sun is brewing something with the next edition of SunONE and Forte. Notice how Sun is targetting there new tool at VB users.
Its possible these features were added to java 1.5 so Forte can have a VB like ide to generate java code easier. After all, enums make things easier to read and are essential for new programmers to read your code.
Competition is great and I believe a great RAD and ide that is based on a fairly good langauge will give
Re:The problem: Improving programmer productivity (Score:5, Informative)
Re:The problem: Improving programmer productivity (Score:3, Insightful)
The point is that Sun really hasn't endorsed any alternative bindings to the Java platform. They certainly haven't endorsed any dynamically typed "scripting" languages similar
Re:The problem: Improving programmer productivity (Score:3, Informative)
Sure, for small programs its not perfect (as you'd have to still run the VM), but this way you can integrate Java applications and use Python to script these applications.
Re:The problem: Improving programmer productivity (Score:5, Informative)
Sun deserves all that will happen (Score:3, Insightful)
You have a company that has a strong position in the Enterprise, and you have a technology that is pretty much accepted. Meanwhile your opponent is busy with conquering the desktop since it can't provide solutions strong and stable enough for the enterprise. What in god's name did you think MS was going to do? Was Bill Gates supposed to turn the others in the room and say "hey this was fun, let's do it again!" after MS has owned the complete desktop ? OF COURSE they'll try to dominate the Enterprise too!!
Java Vs .net (Score:5, Insightful)
The ONLY reason that Sun hasn't relinquished control of Java, is that if they had done so, Microsoft would have been free to embrace/extend/ corner the market.... The same as what they did with Internet explorer.
So, how many non-geeks use anything but, or even know of anything but IE?
Businesses would standardise on MS java, and java on any other platform would become unuseable.. (just as there are web pages that are only useable in IE).
By stating "I'm using C# over Java" you are selling you sole to the devil...You wait till microsoft start extending DRM into the specification, therby relegating projects like Mono to the sidewalk, at this point it will be M$
So, Its your choice. Choose to go with the, arguabily faster/easier to code offering by our (sarcasm) good friends at Redmond, or choose to fight Microsoft by writing code that will run on all platforms from mobile phones to IBM mainframes. Believe me when I say we will all be better off in the long run.
Re:Java Vs .net (Score:5, Interesting)
Most major corporations who are planning on moving to Linux if they have not done so are cancelling and puting their plans on hold thanks to SCO.
If you use mono at work assuming its mature enough and ms pulls a sco you can kiss your linux workstation goodbye.
According to MS halloween documents, legal fud got a negative response form %80 of all bussinesses.
More Wrong Choices (Score:5, Interesting)
I program Java for several customers, from scientific to business apllications.
Autoboxing is yet another way of hiding overhead; the wrapper classes still exist, but are now a big "secret" masked by autoboxing.
Why add autoboxing to make containers look more "natural with POD types, then ignore the crying need to operator overloading in scientific and engineering applications? Why one piece of syntactic sugar as opposed to another?
Overall, I'm not terribly impressed. The new generics seem weak; I don't see an emphasis on fixing bugs, stability, or independent standardization. Much as I like Java, 1.5 does not address most of my needs.
Why a Large Bank Junked Java (Score:4, Informative)
I am working with a large bank at the moment, one of the largest in the world and they have largely junked Java, except for running browser applets.
They liked Java, the class libraries were great but, sorry, it is too slow. I'm not talking about incompetent coders. They even had Sun in looking at some of the apps. The end result was a customised virtual machine - but it was still too slow and the incompatibilities were a killer. The VM had to work identically across the bank's generations of systems from different vendors. One gotcha, IIRC, was synchronisation, making it difficult to run a JVM across processors and to exploit them properly for performance.
End result was a switch back to C++ for back end apps. Java could still be used but only for non-critical front-end stuff. The bank may consider C#, but it seems that Java has had its day.
Maybe this sounds like a troll, but Sun should release their control of the Standard. This will slow things down, think how long it takes to get stuff into C++, but that stability gives everyone room to think as to whether a change is really necessary.
I don't like the idea of C# but at least MS handed it over to ECMA.
Re:Why a Large Bank Junked Java (Score:4, Interesting)
NEWSFLASH: Java not solution for all code projects (Score:3, Informative)
I don't like the idea of C# but at least MS handed it over to ECMA.
Microsoft has handed C# to the ECMA, not .NET.
The language is insignificant compared the the framework, that is the large set of APIs, libraries, documenation, and endorsements that come with the language.
C# being offered to the ECMA is a marketing ploy.
Look at ECMAScript. It's a standard isn't it? Now how come we still have to be careful which browser we're in when we write
ENUMs, yay! (Score:3, Redundant)
What am I going to bitch about now?!
Everyone's bashing java (Score:5, Insightful)
Generics are also a hack, but at least they are an overt, clean one.
Re:Everyone's bashing java (Score:3, Interesting)
1. improve programmer productivity
2. improve quality of code
3. improve efficiency (speed/space) of developed software
However, I am sure Java's generics are nothing more than heavy syntactic sugar. Still, anyone who complains about generics in Java doesn't know very much about progr
Java is pragmatism over principals (Score:5, Insightful)
Java rarely wins in any particular niche. Relatively simple GUIs and COM objects are owned by VB (and Delphi). C++, C, and assembly rule in performance. Perl rules text processing. Python rules in ease of reading. ANSI C, Perl, Python may be more portable. Smalltalk, Eiffel, Lisp, Ruby, ML, Haskel, Forth, and a variety of others are a lot more true to a pure language concept. However, Java does an adequate job in most cases, and when you start crossing boundaries, it'll often be easier to do so in Java-land.
Java isn't innovative. However, it's constantly being improved. Sure, things like JDBC, Collections, SWING, NIO (async I/O), generics, threads, and concurrent garbage collection were available in some form elsewhere previously. They're all packaged into nice, free, portable, well documented, easy to use parts of Java though, and I'm happy to have them.
Java isn't as free as Emacs. However, it's mostly free as in beer, and it doesn't force it's freedom on you. It's certainly a whole lot freer than most things from Redmond. I admit, I don't care if a language is handled by a standards body, unless the company in question holds other monopolies it can abuse. I seriously don't think Sun is going to do anything so wacky as polluting the language to make COM (*cough* MS) or Object Pascal integration (*cough* Borland) easier.
Java's support base and (free) developer tools are just plain great. I love Eclipse, and IDEA and recent JBuilders are pretty nice too. VS.NET is good stuff as well, but contenders like Python are sorely lacking in this arena.
I still write plenty in other languages, but every year the percentage I write in Java goes up.. They keep filling holes (soft references, regexes, async I/O, .1s GC pauses) that were keeping me out of Java. I'm happy to see some more syntatic sugar in Java.. The things they're addressing will make a whole lot of code more readable.
iteration (Score:3, Interesting)
for (int i : C) {... }
also allow :
for (int i : C.iterator) { }
so that iterators other than the default (the SimpleIterator named "iterator") could be used.
This would not complicate the iterator syntax much and would make using different iterators easy - and thats something that is often needed.
Since the "C" above is an expression, it could be a function that returns an "Iterable" - allowing interesting hackery to provide alternate iterators using inner classes or other fun. However while I think this allows programmers to do about what they need, it does not make things exactly readable and that is a bit bothersome.
Another thing I'd like, and would like to have efficient and easy to use, is a way to iterate over the indexes of an array - in particular a multidimensional array. I get tired of doing things like the following (which I can't get to indent easily) :
It would be much easier to do something like
Re:I'll care when native compilers become the norm (Score:5, Insightful)
You mean like GNU gcj?
For languages that are intended for general purpose use and especially for situations where performance/efficiency is important they're just a BAD idea.
You seem to think that by compiling stuff to native code things magically run fast when the problems are actually library design, class loader design, bad memory management, and other issues. Java's JIT is about as fast as natively compiled C code and Java's lousy performance is living proof for the fact that making a great native code compiler is not sufficient for getting good performance.
Python and Perl programs often run rings around equivalent Java programs in terms of actual, end-user visible performance and memory usage, despite being interpreted. If anything, the compromises people need to make to make languages easily compilable into native code make it much harder to build efficient systems in them.
Of course, it's not like we needed any more proof of that: the inefficiency and bloat of systems like Windows, Gnome, and KDE demonstrate the same point, as did several generations of systems before them. And generation after generation of programmers repeats the same mistake you are making.
Re:I'll care when native compilers become the norm (Score:3, Insightful)
because the JIT overhead is not re-occuring, it happens once.
Re:I'll care when native compilers become the norm (Score:5, Interesting)
That is impossible. Java has to do the same as the C code, plus the extra overhead of doing the JIT. There is no way Java can be "as fast".
Ah, the "impossible" word. ;-)
You're presuming that the ahead-of-time compiler can "know" everything that the JITC can. That isn't true, in many common cases.
Another point regarding JITC compilation is that it can be for the exact target processor, something not typically the case for traditionally compiled programs.
All that said, current JVM performance certainly varies between 'better than C++' and 'worse than C++', with pathological cases in both directions.
The current 1.4 JVMs actually took a hit on some math operations, though that is supposed to be fixed in 1.5.
I hope gcj gets to the point where it supports the latest language spec. The libraries are tougher, and many of them aren't needed for interesting projects. For certain applications, an ahead-of-time compiler is nice.
By the way, for a good example of a 'fast' Java program, check out Eclipse from www.eclipse.org [eclipse.org].
Re:I'll care when native compilers become the norm (Score:5, Informative)
Re:I'll care when native compilers become the norm (Score:3, Insightful)
I don't see any performance issues in my J2EE apps.
Java is slow largely becuase of JVM startup and GUI framework. But J2EE Apps don't have to worry about either of these. The J2EE Server's JVM is started only on Application startup, which only happens when you need to restart your J2EE Server. And there's no GUI layer ( JSP for presentation ).
Truth is in large server-side apps, I'd
Re:I'll care when native compilers become the norm (Score:5, Informative)
Anyway, there is a plenty of native compilers for java. I'm not sure if you have heard about certain compiler from free software group called Antilope or something like this - I think it is called gcc. They have a frontend for java, gcj, which compiles java source/bytecode to same intermediate stage as other compilers, thus sharing optimizing backed. If you don't care about paying few bucks, JET is very good compiler, written specifically for java, supporting 1.4.1. There is also few others, but I can tell only about these two from my experience.
Both these compilers are available for few years now. Problem is not with lack of native compilers, or performance of java in mixed mode offerred by Sun hotspot - problem is with mindset of poster. If you are not willing to use java - no problem. But please say it is 'religious' - everybody will agree with you, as you can have any beliefs you want. But do not try to back up religious statements with fake arguments.
Re:I'll care when native compilers become the norm (Score:2)
A language is a language, none are 'perfect', and the only realistic benchmark of a language is the job to be done. Demanding a native compiler of Java negates the purpose and design of the language.
I have my favourites (go Python!), but languages have gone from machine code to assembly to C, and as great as C is, I hope we don't stop there.
Re:I'll care when native compilers become the norm (Score:5, Informative)
Re:I'll care when native compilers become the norm (Score:2, Informative)
And as the 1.5 compiles to compatable byte code, can automaticly use the new 1.5 features (with the exeception of new classes.
Re:I'll care when native compilers become the norm (Score:2, Insightful)
When it comes to performance, it's about time to kill the old idea that java performs so incredibly bad. Look at e.g. this [aceshardware.com] article for a measurement of how well java performed a few years ago. I didn't at first glance find any articles doing similar comparisions
Re:Finally... (Score:3, Informative)
Introducing new keywords may break old programs if they have a variable with a name identical to that of one of the new keywords. Using the colon sidesteps this.
Re:Sounds Promising (Score:2, Informative)
I think I get what you are trying to say, but the examples are bad. The first one doesn't require a cast now, as you are casting from a subclass to a superclass:
JPanel jp = new JPanel();
JComponent jc = jp;
works just fine (just tested in 1.4.1). I imagine the same applies to the second one too. Also, if this wasn't the case generics wouldn't
Re:I doubt that Java will succeed. (Score:2)
Re:I doubt that Java will succeed. (Score:5, Insightful)
Java is growing. Its not horribly complicated and buggy like MFC and the win32api and your not locked in with
Corporations use Java for servlets and they use if for the built in libraries, low cost and portability.
Java is a great language and I am sick and tired of legalists complaining about it. First the LISP academics complained about Unix or anything non lisp. THe unix haters manual was a result of this. It went nowhere. Now we have smalltalk and Eifel purest who claim that everything else is inferior.
Your little world may be great in University teachings but in the real world they lack functionality and libraries to accomplish real world bussiness tasks.
Mono is very alpha and lacks many of the winform libraries that are mature on Windows. If you use it your asking for vendor lockin eventually which is Microsoft's goals. Look at the hasle SCO has made in the corporate world in regards to Linux? If Microsoft begins taking a similiar approach and everyone uses Mono then they are SOL. Its all Windows lockin. The microsoft version will always be better and more supported so your PHB's have a great argument to switch to Windows.
I chose to live in the real world and use what everyone else is using and that is java.
Re:I doubt that Java will succeed. (Score:2)
it will never reach the state-of-art level of academic theory of OO-languages.
the very nature of the native machine that the software runs on is not object oriented so some mapping glitches are expected you cannot expect to treat everything as an object and get an efficient program, so when given the choice of Integer and int I would blindly choose int and only wrap it in an Integer object only when needed, as you said it is an academic theory.
Secondly the Java interpreter sch
Re:I doubt that Java will succeed. (Score:5, Insightful)
That may change over the coming years with
Re:I doubt that MS FUD will succeed. (Score:3, Insightful)
The Java system is based on the cleaning of a partly object-orientated language: C++. I know C++ coders will hate me for this, but if you compare C++ to real object-orientated languages like Smalltalk or CLOS, you'll have to admit that it's the plain truth.
C++ is fast and less OO, Smalltalk and CLOS are slow and more OO. Since both classes of languages exist, obviously each user has different requirements and choose their level of OO and performance accordingly.
Secondly the Java interpreter scheme w
Re:I doubt that Java will succeed. (Score:3, Insightful)
>>>>>>>>>
I've seen many C++ libraries, and I've never seen an evil abuse of operator overloading. Of course, I work mostly alone, so I don't encounter crappy programmers that often. But I don't think that a language should sacrifice completeness and orthogonality for the sake of bad programmers.
Some of which are evident in the C++ standard libraries as glaring examples of how irresistively seductive t
Re:All the features of C++ (Score:2)
Businesses use Java because its cheaper and quicker to get results then C/C++ or Eiffel. Not because of the features of the language or speed but because of the built in libraries.
For speed C++ is there but higher maintanability and higher development costs outway its benefits for most server oriented tasks.
After all if your app uses sql heavily its not the VM/execution speed that is the bottleneck but latency
Re:All the features of C++ (Score:4, Funny)
Re:All the features of C++ (Score:3, Informative)
Avoid this crap. Go C++, or better yet Eiffel with C, and stop kidding yourself that Java getting a shiny "for" syntax is a reason for celebration.
Hm,
can you give in your wisdome a hint which library and toolset to use to let my Eifel/C program run on my YOPY, on my Mac and on my Windows PC?
I mean: there is an Eiffel compiler for YOPY, isnt it? And its GUI library is compatible with the one on my Mac, surely it is?
Tzzz.
Java neither has all the features C++ has, nor does C++ have all the features Jav
Re:All the features of C++ (Score:3, Informative)