The one thing I like, and would love to see in Java, is optional double dispatch. No more bloody visitor pattern - a wart admittedly hiding an instanceof tumour!
What exactly? Any itch that JNA wouldnāt scratch?
The one thing I like, and would love to see in Java, is optional double dispatch. No more bloody visitor pattern - a wart admittedly hiding an instanceof tumour!
What exactly? Any itch that JNA wouldnāt scratch?
Some way like in C# to just specify a Java method should just bind to a native shared library without requiring the JNIEnv or jobject parameters. Does JNA do that already?
eg.
private native(LIBRARY, āglEnableā) nglEnable(int flags);
I think thatād need to be supported at the VM or classloader level at the very least wouldnāt it? (Not really thought much about it) I suppose annotations would work just as well for it mind.
Cas
Somewhat similar. In JNA you could do
public class WHATEVER {
static {
Native.register("LIBRARY");
}
public native void glEnable(int flags);
}
The Native.register() method in the static initializer takes the library name, and maps all methods marked native to that library.
oh ho! Thatās quite nifty, definitely want some of that. I bet it needs a native library to make it work though.
Cas
Well, yes, it uses JNI under the hood. However, the native lib self extracts from the JAR, and the JAR includes bindings for Windows, Mac, Linux, Solaris and OpenBSD - x86, amd64 and sparc. Thereās an ARM version somewhere too, though not currently in the standard JAR.
Anyway, more at https://github.com/twall/jna
Itās pretty funny that I can call getter-setter methods like property, make me forget type (public or private) of my vars.
Why depend on the vision of language extensions devised by someone else, when you can spend months making your own! Like here: Stratego/Spoofax. Iāve never bothered looking into eclipseās weaving frameworkā¦hummā¦stop! I waste too much time as it is!
Itās funny. Iām perfectly fine with dynamic languages where one can shove any old method into any container, but for some strange reason multiple inheritance makes my eyes start to twitch.
Multiple dispatch is awesome. Sorry Cas, but I cry every time I need to write a visitor pattern.
Errā¦nevermind.
Ah! But you can run the eclipse compiler from a command line.
Whatās this multiple dispatch thing? Is it runtime polymorphic method dispatch? What might the syntax look like? Iām all for it.
Cas
The Xtend page has a syntax suggestion at the bottom - basically another keyword attached to methods.
This. I find the bastardised code example in the landing video to be terribly unreadable. If I came part way into someone elseās project and all the code looked like this, I would be politely stepping back out the way I came in.
The types, returns, visibility modifiers all add a level of detail with no ambiguity. Its nice to see āvoidā and know exactly what you get out of that method, etc.
A default return type of void isnāt so bad. Unless they went for full-blown type inference and not just local (even scala just does local) I expect it requires return types for everything else? Itās nice to have return types explicit, but itās all statically compiled, so itās not like you can compile bad code based on that confusion.
Multiple dispatch is crazy awesome, but thatās a major language feature that completely changes the syntax and semantics of method definitions and calls, and isnāt something easily bolted on. If itās just syntax sugar for double-dispatch, thatās not nearly as interesting.
This is not the only effort to āreplaceā Java. There is also Ceylon.
http://planet.jboss.org/post/introduction_to_ceylon_part_1
Me personally I donāt understand what people have to moan about Java. It saved me incredible amounts of development time 8 years ago, it still does today. Switching to a language with more syntactic bells and whistles is not going to change any of that because development time is still determined by the complexity of the programming problem at hand, not by which tool you use to solve it. Who cares if I you can save a few keystrokes, most time lost is spent thinking, not typing
People trying to replace Java with some funky new syntax keep forgetting why Java was so popular in the first place: it looks just like C/C++. Did I already say that?
Cas
Change is scary!
More like change means learning stuff, and learning stuff means not doing stuff and getting things delivered.
Cas
Not if one is learning the right stuff for the right problem.