The Artima Developer Community
Sponsored Link

Java Community News
What's On Your Java SE 7 Wish List?

19 replies on 2 pages. Most recent reply: Jan 5, 2007 2:44 PM by Gregor Zeitlinger

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 19 replies on 2 pages [ « | 1 2 ]
Bill Venners

Posts: 2284
Nickname: bv
Registered: Jan, 2002

Re: What's On Your Java SE 7 Wish List? Posted: Dec 29, 2006 3:55 PM
Reply to this message Reply
Advertisement
Another one I was discussing with Ted Neward at JavaPolis was tuples. One pain point in using Java is multi-valued returns require us to create a class to hold the multiple values. Scala has very nice set of Pair, Triple, Tuple4, Tuple5 classes, each of which is parameterized by a set of types of the held values. I'd like to see something like that in Java, to solve the current pain of doing multi-valued returns.

Juan Carlos Flores Beltran

Posts: 1
Nickname: juanflores
Registered: May, 2003

Re: What's On Your Java SE 7 Wish List? Posted: Jan 1, 2007 12:26 PM
Reply to this message Reply
Hi,

There are two features which I would like to have integrated in Java. One is real-closures and the second is a concept known in Objective-C as Categories.

Regarding real-closures I agree all arguments given in favour of that feature.

In order to explain best the "categories" concept I will quote wikipedia.

START Quotation:

Categories

Cox's main concern was the maintainability of large code bases. Experience from the structured programming world had shown that one of the main ways to improve code was to break it down into smaller pieces. Objective-C added the concept of Categories to help with this process.

A category collects method implementations into separate files. The programmer can place groups of related methods into a category to make them more readable. For instance, one could create a "SpellChecking" category "on" the String object, collecting all of the methods related to spell checking into a single place.

Furthermore, the methods within a category are added to a class at runtime. Thus, categories permit the programmer to add methods to an existing class without the need to recompile that class or even have access to its source code. For example, if the system you are supplied with does not contain a spell checker in its String implementation, you can add it without modifying the String source code.

Methods within categories become indistinguishable from the methods in a class when the program is run. A category has full access to all of the instance variables within the class, including private variables.

Categories provide an elegant solution to the fragile base class problem for methods.

If you declare a method in a category with the same method signature as an existing method in a class, the category's method is adopted. Thus categories can not only add methods to a class, but also replace existing methods. This feature can be used to fix bugs in other classes by rewriting their methods, or to cause a global change to a class's behavior within a program. If two categories have methods with the same method signature, it is undefined which category's method is adopted.

Other languages have attempted to add this feature in a variety of ways. TOM took the Objective-C system a step further and allowed for the addition of variables as well. Other languages have instead used prototype oriented solutions, the most notable being Self.

END Quotation

Well, we all know that some part of the JRE is well designed and other not. This concept would help to improve the framework. Furthermore we implement a lot of utility classes in order to provide that funtionality which is not supported by classes of the JRE. Categories is an elegant way to extend given Types without changing their identiy. E.g the String class would remain teh String class but with improved functionality.

I have work as an software developer using objective-c for a long time and can confirm that this feature comes with great flexibility and elegance.

bye
Juan Carlos Flores Beltran

Carsten Saager

Posts: 17
Nickname: csar
Registered: Apr, 2006

Re: What's On Your Java SE 7 Wish List? Posted: Jan 3, 2007 11:14 AM
Reply to this message Reply
1. Combined types
void foo(Interface1&Interface2 bar);

To express that I need here the objects that implement both. In generics you can already say <T extends A&B>...

While we're at it:
 
new Object() implements Interface1,Interface2{...}

would make this really useful and easy to write wrappers.

2. Scala views to have (controlled) coercion without creating new instances

3. Properties that can be declared in interfaces and guarantee
  
a.set(x);
assert(a.get().equals(x));

I am not so picky, but when a property promises to behave like a member, why not having a nice
a=x;assert(a.equals(x));
?

4. Friend declarations like in C++

5. Limited Types
so that you can implement
void foo(Interface bar)

by
void foo(Interface&Internal bar)

Great when implementing APIs to avoid constant downcasts.

And finally: Yes, closures are nice.

David Beutel

Posts: 29
Nickname: jdb
Registered: May, 2003

Re: What's On Your Java SE 7 Wish List? Posted: Jan 4, 2007 10:34 AM
Reply to this message Reply
> one that I always catch and wrap
> after passing a constant "UTF-8" to is
> UnsupportedEncodingException thrown by
> java.net.URLEncoder's encode
> method.

That's the best way, because the code that passed in "UTF-8" knows that it cannot cause an UnsupportedEncodingException. In that case I wrap it in AssertionError. Making it always unchecked would be wrong for code passing an unknown String.

It gets tedious, but you can refactor to eliminate duplicate code, and/or use a constant UTF8 Charset with APIs that accept it (e.g., InputStreamReader).

Gregor Zeitlinger

Posts: 108
Nickname: gregor
Registered: Aug, 2005

yield Posted: Jan 5, 2007 2:44 PM
Reply to this message Reply
I would like to see the addition of the yield keyword to make implementing iterators easier.


public class Car {
public Iterable<CarPart> getParts {
for(Wheel w : wheels) { yield w; }
yield engine;
if (cdPlayer != null) yield cdPlayer;
}
}


The syntax is mostly from C# 2.0.
(http://msdn2.microsoft.com/en-us/library/9k7k7cf0(VS.80).aspx)

Yield is actually a subset of what you can do with ruby co-routines - but I prefer the yield version for it's simplicity.

Flat View: This topic has 19 replies on 2 pages [ « | 1  2 ]
Topic: Cross-Cutting Concerns with Spring 2.0 AOP Previous Topic   Next Topic Topic: Custom Bean Scopes with Spring

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use