Eclipse introduces Xtend - syntax sugar for Java

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! :slight_smile:

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 :slight_smile:

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 :slight_smile:

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 :slight_smile:

http://tinyurl.com/82quk9y ;D

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. :wink:

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 :confused:

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 :slight_smile:

Change is scary!

More like change means learning stuff, and learning stuff means not doing stuff and getting things delivered.

Cas :slight_smile:

Not if one is learning the right stuff for the right problem.