Slashdot Mirror


Sneak Peak at Java's New Makeover

SadatChowdhury writes "Aside from templates as already reported in a past slashdot article , a little snooping around revealed the details of the following newly revealed features in the upcoming release of Java 1.5 (codenamed: Tiger) : Autoboxing , Enhanced-For-Loop, Enumerations and Static Imports . Must read for Java fans." In related news: jdkane writes "Sun Microsystems delays a much-anticipated Java specification by three months to comply with guidelines designed to keep Web services interoperable. Says Ralph Galantine, group marketing manager for Java Web services at Sun: "We thought that this change was important for the industry, so that there was no conflict between J2EE 1.4 and the WS-I, "We thought it was worth taking out to the summer." It's very refreshing to hear that a big software company is looking out for the industry, instead of just their own."

17 of 114 comments (clear)

  1. New and Improved for()! by themo0c0w · · Score: 3, Interesting

    I am in awe of the new for() statement. Instead of all that fooling around with the C-style syntax (great for procedural, sucks for OO), they just go ahead and adapt it for collections much like iterators in other high-level languages: for (String s : c) { //do stuff on s's in c } Wheeeee!

    --
    ph34r teh p0w3r 0f th3 c0w
    1. Re:New and Improved for()! by Twylite · · Score: 5, Insightful

      I am in awe of the new for() statement. Java was designed to be logical and readable, but unfortunately for (String s : c) means nothing to most developers.

      The JCP is a classic case of committee design: everyone has their own ideas based on their experience, and doesn't really understand the purpose or path of the Java language. Most JCP suggestions are calls for Java to look more like C++ or Python.

      --
      i-name =twylite [http://public.xdi.org/=twylite], see idcommons.net
    2. Re:New and Improved for()! by The+Mayor · · Score: 3, Insightful

      Yes, but people that have old code with variables or methods named "foreach" (methods being the more likely one here...I have written several classes with a method called foreach()) will still compile with the new compiler. Backwards compatibility doesn't mean that new code will work with older compilers; it means old code will work with the newer compiler.

      --
      --Be human.
    3. Re:New and Improved for()! by bwt · · Score: 4, Insightful
      I agree with using "in" instead of ":", but I see no reason to change "for" to "foreach". Needlessly proliferating keywords is a bad thing, but given that they have to add ":", the more readable "in" is better.
      for (String s in c)
      seems like the best syntax to me.
  2. Also Concurrency/Memory/Threads/Isolation by LarryRiedel · · Score: 4, Informative

    There are some other interesting changes coming to provide a more coherent memory model, vastly improved concurrency support, and intra-JVM application isolation. Java is getting much better at providing access to the capabilities of the underlying OS, and the JVM working more like a little multi-process OS itself...

    Larry

  3. Autoboxing by vandel405 · · Score: 3, Insightful

    "Autoboxing"

    Hmm... extremeley Microsoftesque. Much like VB5 and 6's variant data type and C#'s boxing rules.

    Seriously, with a language like C you can feel like you actually know ALL the rules, and it makes you feel safe. With the beasts that are VB.net/VB6 and C#, and the one that Java is becoming, you always have that lingering "What If" in the back of your head. Seriously, you end up programming with the idea "Nah, they wouldn't let me make that mistake" constantly in the back of your head.

    1. Re:Autoboxing by zero_offset · · Score: 4, Interesting
      Seriously, with a language like C you can feel like you actually know ALL the rules, and it makes you feel safe. With the beasts that are VB.net/VB6 and C#, and the one that Java is becoming, you always have that lingering "What If" in the back of your head.

      I agree with you fully when it comes to VB and Java, but C# does not deserve to be lumped into this category. Everybody knows VB wasn't really "designed", it just sort of "happened" over the years. Java had a lot more design work behind it, but it still suffers from weird evolutionary lumps that always "feel wrong" when you're using it. However, C# went through a very long and intensive design period, with more well-defined goals than Java (the set-top-box language), and I believe with a LOT more R&D-phase input from the real world (as anybody who participated in Don Box's .NET listserv discussions can tell you).

      C# is a lot like C in that the language itself is limited and well-defined, although not to the extreme basics of a 12-keyword universe like C, owing primarily to the additional keyword overhead needed to express certain modern concepts, many (most?) of which are OOP-related. In that sense it's a little like C++.

      For an experienced programmer, the trick is to first understand the .NET class hierarchy (hint: avoid books that harp too heavily on web services buzzwords; web services are just a few pieces of the very large .NET puzzle). Next, understand the C# language on it's own. Most of the books out there seek to tackle both of them simultaneously, and that's a big hinderance to learning, and probably what causes people to make statements like that made by vandel405, above.

      Don't judge the subject matter by the quality of instruction...

      --

      Slashdot quality declines as the number of hot grits posts decreases. - Provolt's Law, Apr-09-2005

    2. Re:Autoboxing by Pseudonym · · Score: 3, Insightful
      Seriously, with a language like C you can feel like you actually know ALL the rules [...]

      The price you pay is that you have to write a lot more rules yourself, which takes a lot of time (and hence money). The "beasts" as you refer to them (not that I think VB is a serious development language) do not require you to reinvent the wheel every time.

      Yes, in C you can use libraries, but the more libraries you use, the more rules you have to know and the less you feel like you can know them all. Let's face it, programming is a complex task. Either you get the complexity out of a can or you provide it yourself.

      --
      sub f{($f)=@_;print"$f(q{$f});";}f(q{sub f{($f)=@_;print"$f(q{$f});";}f});
  4. Happy to see Java gain features. by HFXPro · · Score: 3, Informative

    I for one will like the new features Java is gaining. All too often when programming in Java for school (the main place I use Java), I often find myself wishing and wanting some of the features of C++. I've even gone so far as to write a perl script to allow me to create my own templates and have it convert the template to a proper .java file. Has anyone else resorted to this hack?

    On the other hand, Java still is not my preferred language. C\C++ will probably always be my language of choice. They are what I learned first, what I enjoy programming in most, and which I plan to never quit using. Being able to use several design paradigm's is extremely nice, which is why my other favorite language is OCaml. However, I am still picking up its nuisances so things are subject to changing.

    I would like to know, however, why the professors at my school bash C and C++. I for one can see the weaknesses of the languages, yet I can also find weaknesses in many other languages including the languages of functional and declarative paradigms. I think a lot of their disdain for C and C++ are due to memory management. However, manual memory management has never really been a huge problem with the way I write my code. Anyone else care to respond on if this is an academia thing to hate C and C++ or just my school? Perhaps all my teachers have their heads on tripods just like the people they complain about. Especially since, they do not work to try and improve the current programming languages.

    --
    Reserved Word.
    1. Re:Happy to see Java gain features. by The+Cydonian · · Score: 3, Interesting
      C\C++ will probably always be my language of choice. They are what I learned first, what I enjoy programming in most, and which I plan to never quit using.

      Personal biases are, imho, always a good thing, as long as it's not BASIC. (sorry, couldn't resist)

      Anyone else care to respond on if this is an academia thing to hate C and C++ or just my school?

      The view here is that Java is by far *enforced* on most courses, although most lecturers I personally speak to seem to prefer Lisp/Scheme and C/C++ over Java. For instance, we had a course on data abstraction where the labs were in Java, but the lecturer taught in pseudo-code (claimed he didn't know any language other than C). Worked fine for me; I aced a project on image manipulation using only pseudo-code! B-)

  5. Thanks to C# by GCP · · Score: 3, Insightful

    Nothing like a little competition. Notice how we go for years with Sun assuring us that the language is "just fine, trust us, we know what's good for you, you don't, all you need are more libraries, you're not a language designer but we are, trust us, you don't need any more features in the language itself, you just don't get it....".

    C# comes out with a better language, and suddenly for the first time since inner classes were added in the mid-90's, the language starts evolving useful C#-looking features....

    What I want next from Java is for Sun to invent delegates and properties.

    Competition is a wonderful thing, and it's good to finally have some in the Java space.

    --
    "Those who have never entered upon scientific pursuits know not a tithe of the poetry by which they are surrounded."
  6. Java# by barnsleyBigUn · · Score: 5, Interesting

    Most of the new language features are copying or implementing similar to the C# features Sun has persistently decryed!

    Autoboxing ... same as boxing in C#

    the for-iterator [for(Sting s: Collection)] statement is actually "nicer" (in that intent is clearer from the code) in C# [foreach(String s in Collection)]

    Generics ... well both languages have/will have generics now ... still not 100% convinced but prefer to have them than not to have them ;-)

    Enumerations ... C# has them same as C/Pascal, now suddenly Java is getting them (are they going to revisit the library and clean up a lot of their class constants into enums now??)

    I propose they go full how and add the extremely powerful attributes from C# as well ... being able to add custom metadata to any method/property, for example how to serialise to XML correctly, is great!!

    In short ... competition is great for Java!!!

    1. Re:Java# by galore · · Score: 3, Interesting

      it's in the works: http://www.jcp.org/en/jsr/detail?id=175

      also, i don't think java is really "copying" C# features. you could say the same thing about most of C#'s features. in reality, both environments borrow heavily from years of computer science precedent.

  7. Yuck. by crmartin · · Score: 5, Insightful
    It's someone or others' law that all programming languages eventually grow too many features to remember. (Hell, it might even be my law.) So, let's see -- we're getting:
    • templates from C++;
    • a new style of emun that does everything the Pascal enum does with a syntax that looks like a C enum except that it can have methods, AND MORE;
    • a whole new foreach syntax that has the stellar advantage that the syntax doesn't resemble anything on God's green earth except Smalltalk, which is a pure prefix language like Lisp instead of an algol block language like C, C++, Java, C-hash, pascal or Ada (where the other features come from);
    • generics using the template model from C++, which was a horrible hack on top of C++ because it was hard to make a backward compatible syntax (so instead we got ANOTHER class of macro to add to the #define) when C++ was a horrible hack on top of C so that at least C++ could compile C programs (except now it can't);
    • a grammar that is going to be about LL(497) (doesn't anyone remember how ugly parsing C++ got to do templates, and how long it was before it worked?);
    • and a whole wonderful new term ("autoboxing") for the notion that primitive types and class types ought to both have all the properties of types.
    I know I'm probably just getting old, but Jesus!, why do we need to repeat all the mistakes of the past?
  8. Covariant return types instead of full Generics by Opiuman · · Score: 3, Insightful

    Just like one of the top requests for enhancement in the Java bug-parade states, covariant return types could have done most of the work of Generics without the additional clumsy syntax. (i.e. sub-classes could override return values of overriden methods to return sub-classes of the original return values instead)
    overall, I'd rather have this than nothing...

  9. Yes, although generics != templates by melquiades · · Score: 4, Insightful

    The poster is a little off in calling the new feature "templates", and you're correct in calling them "generics".

    Templates were C++'s way of simulating generic types. The difference is that templates are essentially macros in fancy clothing, and generate a different flavor of the class for every combination of type parameters, while generics are a much cleaner, more abstract construct, better grounded in the theory of types, which use polymorphism to achieve their genericity.

    Don't know if that made any sense....

    In any case, this will be a fantastic feature, and they're done a much better job with it than C++ did with templates.

  10. Re:Silly Java... by Pseudonym · · Score: 4, Insightful

    The colon syntax is not random. It's well-known and well-understood mathematical notation, namely Zermelo-Frankel set comprehension notation:

    { x \in N : x > 10 }
    --
    sub f{($f)=@_;print"$f(q{$f});";}f(q{sub f{($f)=@_;print"$f(q{$f});";}f});