I’m going to buy a book about AspectJ on Amazon.com after I move just because I can get it for a few bucks plus shipping.
Personally, I would like something that’s just a little less verbose than Java but has roughly the same functionality. This would be no good if I couldn’t use libraries of code similar to the ones that come with the JRE. There are things that I can do without. I can even do without the AWT, but I need to have some way to at least create a graphical application window and switch between full-screen exclusive mode and regular mode. And I need to have sound support similar to Java’s.
Some examples of verbosity:
imports:
import java.awt.*;
I would prefer to just type “import java.awt;”
indentation:
public class A extends B implements C {
//indent here
public void method() {
//indent twice here
}
}
Since I usually have one main class per file, there’s no need for indentation within the class. In fact, I would rather have it be LIMITED to one main class per file (though inner classes would still be allowed). The syntax could just be:
public class A extends B implements C;
public void method() {
//indent only once
}
That may sound a little bit pendantic, but I’m indenting most of every file for nothing. If I have 3 nested for loops, my variable names take up all the space I have available after indentation. Some people would call this bad programming practice and tell me that my code is too complicated. I call this “why shouldn’t my code fit on the screen”.
In practice, I actually don’t indent the main class in the file, but Eclipse fights me on this by auto-indenting too far.
access modifiers:
In Java, I type:
public void methodA() {}
public void methodB() {}
…
public void methodZ() {}
In C#, I can type:
public {
void methodA() {}
void methodB() {}
…
void methodZ() {}
}
I would much rather type:
public:
void methodA() {}
void methodB() {}
…
void methodZ() {}
Granted, it’s not immediately obvious upon looking at a method in the middle what it’s access modifier is. In a class, I have all my public methods/classes/variables first, protected second, package third, and private last. I think that makes good sense and allows the access modifier blocks to be adequately descriptive.
no “final” required for parameters:
I have to type:
public void methodA(final int a, final int b, …, final int z)
to make it so I can’t set parameter variables equal to other values. This should just always be the case, no “final” required.
simpler enums:
This isn’t too important (and may be slightly off topic), but enums don’t need to have the capability to define different methods on each element of the enum. I think this kind of breaks enums a bit, but it does make them more powerful. I don’t normally use this capability.
I love enums, but I have a minor objection to them. If you define a static final variable in an enum class definition, you can’t use it in the enum element constructor calls. I define a separate class to store flag constants because of this. I don’t know if this can be fixed though because static variables are probably defined after enum elements so that the enum elements can be used in the variables.
simpler Runnables:
I understand that Runnable is an interface and has to be implemented this way. However, I don’t want to type:
Runnable myRunnable = new Runnable() {
public void run() {
//method here
};
It’s not that big of a deal. I just have to type it alot. There should be some abbreviation, like the following:
Runnable myRunnable = {
//method here
};
Essentially, I want to be able to define code blocks as variables, just like in functional programming languages. It’s basically C# delegates, though less verbose. For methods with parameters, I could type:
ActionListener myListener(ActionEvent event) = {
//method here
};
This would basically be a shortcut for one-method interfaces. The one-method interfaces would just be delegates instead.