Preview of Java 1.5
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."
For years java zealots have told us that features like automatic boxing and templates are dangerous because they hide what really happens.
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 what about VM sharing? Will it be in java 1.5, or will we still have to wait 30 seconds for java programs to start up?
Private property is the central institution of a free society (David Friedman)
Java can walk on water and I'm still not going to use it to develop anything I expect anyone to use. Give me a native optimizing compiler and I just might reconsider.
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.
Why will this happen ?
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.
Java's goal where to simplify and objectize C++. However during this process some of the most promising parts of C++ where thrown out - operator overloading and generic programming. But this Java's power was seriously crippled and it will never reach the state-of-art level of academic theory of OO-languages.
Secondly the Java interpreter scheme was extremely promising, too. However, SUN fuck this advantage totally up by concentrating on their modified C++ clone. MS did recognize this potential much better with their
Some people will now protest that "There is this Gonzo++ implemenation of the Java VM." This is indeed true, people got stuff from C++ to Lisp running on the Java VM. But this argument is rather pointless: the power of a modern VM system does not lie alone in the interpreter, but in the system libraries, too. And SUN failed unlike MS to provide decent interoperability here, because their Java VM was never really meant to run with other languages.
Personally i think that these design flaws will kill Java in the long term. There might exist many apps with Java these days, but this holds for Cobol, too. Even people in the OSS community start to realize this and move the MS's .NET system with projects like MONO etc.
Owner of a Mensa membership card.
With none of the performance.
Anyone still convinced that Java is neato needs another viewpoint; Paul Graham's is reasonable.
Anyone convinced that Sun is anything different than Microsoft, oh, except for being less successful, is delusional. How's that Java standard comin'?
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.
"What's that? Oh yes sir! I'll have those UML diagrams detailing the Bloggorgian-Rienmarch Reverse Upside-Down Cake Factory Singleton Dweeboid Pattern for you by next month! Then we can start coding!"
Chr0m0Dr0m!C
Yes, I noticed this as well. I found it pretty interesting, and it reminded me of the old IE/Netscape browser wars. One implements the new features of the other. Let's just hope they don't get too carried away and bloat the language. :-/
:-)
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.
Beware: In C++, your friends can see your privates!
It's interesting that you say that about teaching, and I think you have a point. I'm a CS student at Cambridge University (currently avoiding finals revision) where Java is the fundamental teaching programming language, the one they teach you right up front, the examples language for code fragments in algorithms situations (well, along with ML) etc.
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...
There certainly is a tradeoff: If a language gives too many options to do one thing, it becomes confusing. A programmer usually develops a certain coding style. She prefers certain constructs over others. When you read code, you have to adjust to the style of the programmer who wrote the code, and possibly recognize constructs which you're unfamiliar with because they're not part of your coding style. Take the proposed for-loop extension as an example. Every Java programmer instantly recognizes the head of an "iterator for-loop". It's an idiom. The proposal adds syntactical sugar to supposedly help identifying this very frequently encountered situation, but it does the exact opposite: There are now two ways of looping over an iterator, and you have to be familiar with both if you want to quickly understand other people's code. If you want a good real-world example of what too much syntactical sugar does to a language, take a look at some Perl programs.
Some of these things are certainly nice (typesafe enums...) - but wouldn't it be nice to try and keep the java language *simple*?
... varargs? Why? It is an object-oriented language - take use of that polymorphism!
... */}
... */}?
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.
Next term try teaching them Python instead.
Then, when they understand the concepts, you can introduce them to the syntactic nightmare that is Java.
-- Help Digitise the Public Domain at DP.
Those two languages are far simpler, and let you really hammer the points about programming down without getting the kids confused about syntax rules.
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).
N4st0r, trixx0r h0bb1tz0rz! Th3y st0l3 0ur pr3c10uzz!
no!
because the JIT overhead is not re-occuring, it happens once.
Ok, let's all try to see how Sun can be incredibly stupid. .NET was announced almost 3-3.5 years ago. Sun saw it coming and did nothing. Bitching about how MS products sucks is not the solution. You should have used your advantage and experience in the Enterprise instead of letting MS slowly steal it from you. If Sun could have cared for what the industry has been complaning about in their technology, and implemented the necessary changes, by the time .NET is out, it would be just a ripoff. But look what we have here now: Sun, is trying to catch up with MS in the field where it had for years. You have a huge user base, you have a mature technology, why do you wait for opponents to catch up ? Java is not dead yet, but it's not hard to see why it'll be dead at the end, when you look at what Sun is doing..
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!!
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.
.NET APIs doesn't matter to me when programming in C#--I can just use Gtk#.
.NET, or by binding to an existing cross-platform toolkit, or by creating a new cross-platform toolkit just for C#.
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.
Java isn't an interpreted language, in the traditional sense. Interpretation implies that the runtime environment interprets the source as it progresses, and e.g. that errors that would have been caught compiletime by others, are reported runtime.
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 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 using the more recent VMs, but as vendors put effort into still more optimizations, I'd not expect the results to be worse now.
Another aspect of this that you might not have considered is how the JVM is at an advantage over static compilers, as it has the possibility to generate native code *runtime*, using real information on e.g. branching to generate native code which'll keep the CPU pipelines filled. A static compiler cannot do this to the same degree, so it is possible to construct scenarios where Java performs better than natively compiled binaries.
The next great MMORPG.
To be quite honest, I dont care at all if .net is better than Java. The point is that .net is controlled by Microsoft, and currently only runs (officially) on M$ products. Mono might be outlawed by Microsoft at any point. You are at their mercy.
.net, or nothing. Do not think this will not happen.
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.
Too late! I just started to learn java about 5 months ago in school; whatever chance they had to make that language "easy"(a subjective matter of course) went out the window long ago. Nonetheless I am still learning and Java remains one of my favorite languages to date.
...for getting less simple, but it was never simple to begin with. Simple would be to use weak-vars-strong-values typing like python. Making everything an Object and using that plus typecasts to do generics is not "simple", it's a hack. It uglifies your code, makes it less efficient, and (ironically) breaks strong typing.
Generics are also a hack, but at least they are an overt, clean one.
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.
Mono is alpha ! and is not, will not and never be any kind of a dotNet on a non MS platform.
;-)
;)
Bill stated this clearly : "we will not port the platform to a non MS platform". This includes opening the code source or whatever that could their endanger captive user resources.
If you still think Java is a niche, is because since nearly 10 years you was sleepy
Java is not the "magic key" for "IT magic kingdom", it is real, effective, efficient and fit your need.
Java is real freedom. Because i can change my OS, the product i use, the business model i got without beeing linked to a provider.
For does who still see Sun as the "big bad wolf", i never pay Sun a buck and i did so in a legal way.
I run linux on clusers, with JBoss, a IBM VM on top of Dell machine (the only stuff i have to pay)! And the architecture i got could manage any kind of a load (as long as my ISP link will manage to pass it to me), because i can add whatever new machine i want (tnx to the multilevel clustering nature of the solution).
It is real, effective, efficient and fit my need
What MS fears the most is Linux + Java. Because it is a more powerfull that they can even provide.
If the Linux gurus where stoping the bashing against Java and looks at the marvelous project made from the opensource comunity they will understand that Java is realy an opportunity to strengthen Linux as an OS leader.
-SLK
Any language that uses whitespace syntactically is TOTALLY unsuited for teaching.
JavaScript is a scripting language. Microsoft's .NET framework includes bindings to one low level languages (C#), one mid level language (VisualBasic), and one scripting language (JavaScript). If you pick up Visual Studio, you get bindings for J# and C++, too. Plus, lots of people are looking forward to F#, a functional language.
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 to VisualBasic or JavaScript.
Obviously, JavaScript is available for the Java Virtual Machine, as are a huge number of other languages. However, Sun has never really embraced those alternative languages. That's a real shame.
And that's why the parent of the parent poster included Java, C#, and JavaScript in the same post.
Slashdot is jumping the shark. I'm just driving the boat.
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 was extremely promising, too. However, SUN fuck this advantage totally up ... MS did recognize this potential much better with their .NET system providing a platform for a huge range of languages ranging from C++, C#, Java, VB to even Eiffel.
What exactly is the failure of the Sun VM? It runs on different CPU's and OS's. It has a published VM language for which people can implement compilers. Oh your argument is that the system libraries are inadequate. In what way do you feel they are less in capability than .Net?
And SUN failed unlike MS to provide decent interoperability here, because their Java VM was never really meant to run with other languages.
The common definition of interoperability and MS Interoperability(tm) are slightly different. Essentially, the MS definition is a very small subset of the more common definition. As far as MS is concerned, Interoperability is the ability for MS programs and languages to speak with one another.
So let me ask you, what is the real benefit of the CLR? Do you find yourself writing a lot of C++ in the morning and extending it with VB in the afternoon? No you say, it's to allow multiple programmers to work on the same monolithic application in their language of choice? Oh so the ui guys can code in VB and the backend people can write in C++ or C#. Mmmm ... I've seen many languages interoperate in monolithic applications such as C, Fortran, Tcl, Java so I'm not exactly sure what MS has added as new. And if we're talking about most applications which are distributed (ie. non-monolithic) nowadays, then the point of a CLR becomes even less clear.
Mensa member, beware of the high IQ
I don't often pick on people, but I think the combination of this signature with the post forces my hand. A more apt signature for this post would have been: MS shill, beware of the FUD
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 expect J2EE with JSP to kick the crap out of PHP, PERL and others.
Based on upvotes, Ageism is the only "-ism" Slashdotters care about and think isn't SJW
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.
Confucius say, "Find worm in apple - bad. Find half a worm - worse."
Of course you can handle pointers!! I'm tired of running into Java programmers who are scared of lower level code (read: C).
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.
I'll see your senator, and I'll raise you two judges.