Java-Gaming.org Hi !
Featured games (83)
games approved by the League of Dukes
Games in Showcase (521)
Games in Android Showcase (127)
games submitted by our members
Games in WIP (589)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
 
    Home     Help   Search   Login   Register   
Pages: [1] 2
  ignore  |  Print  
  Eclipse introduces Xtend - syntax sugar for Java  (Read 5743 times)
0 Members and 1 Guest are viewing this topic.
Offline woogley
« Posted 2011-11-05 00:50:57 »

http://www.eclipse.org/Xtext/xtend/

It is not a new JVM language, instead it compiles to Java source code, ala CoffeeScript -> JavaScript
Offline sproingie

JGO Kernel


Medals: 202



« Reply #1 - Posted 2011-11-05 01:11:36 »

Good lord, the name sounds like a "male enhancement" pill  Tongue  Besides, I already have tons of syntax sugar for Java, it's called Scala.   Grin

Actually, it's a pretty nifty idea as IDE features goes.  Looks a lot like Lombok on steroids.   I hope it's actually portable and something I can fit into a maven or sbt pipeline.
Online theagentd

« JGO Bitwise Duke »


Medals: 361
Projects: 2
Exp: 8 years



« Reply #2 - Posted 2011-11-05 02:54:05 »

I don't see the point at all. I'd rather write the code that this generates by myself. I mean, the uber StringBuffer wrapper "optimization" isn't that impressive. It doesn't seem to reduce the amount of code you have to write in any meaningful way.

Myomyomyo.
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline Nate

« JGO Bitwise Duke »


Medals: 158
Projects: 4
Exp: 14 years


Esoteric Software


« Reply #3 - Posted 2011-11-05 07:46:54 »

This looks pretty damned amazing! I will definitely be trying this out. No one has gotten improving Java right yet. This attempt looks really good!

Offline kappa
« League of Dukes »

JGO Kernel


Medals: 78
Projects: 15


★★★★★


« Reply #4 - Posted 2011-11-05 08:34:13 »

Oh this is nice indeed. No need to wait for Java to add syntax sugar, just add an IDE plugin.
Offline JL235

JGO Coder


Medals: 10



« Reply #5 - Posted 2011-11-05 09:05:48 »

I thought Java already did the StringBuffer optimization when concatenating multiple strings on one line? A lot of the other changes seem pretty minor, and the '@SurpressWarnings("all")' is pretty much a step back (the whole point of warning is to catch errors).

I'm not very impressed, and at least CoffeeScript adds some pretty major syntactical changes to JS.

Offline Cero
« Reply #6 - Posted 2011-11-05 11:53:41 »

yeah I'm going to write code that only works in eclipse and nobody else will even understand - good idea.

Offline Scarzzurs
« Reply #7 - Posted 2011-11-05 12:34:30 »

Hmm, seems a lot like "Java for people that doesn't like the core values of java".
But if that's the case: Why not change language entirely?
Aight, I guess you could argue that this way you get to keep your libraries...

Sounds like a goods decision to compile to java files, although they are hardly as readable as what a good java programmer could write. :-)

Anyways, it's not for me, I'm not an IDE-guy :-)

- Scarzzurs

My games and Projects:
BlastingPixels.com,
Old website
Offline pjt33
« Reply #8 - Posted 2011-11-05 12:37:05 »

Um. One of the big selling points at the top is "In contrast to Java, Xtend removes unnecessary noise." And then you scroll down to the sample code and see that it has removed the need to type System.out before println, but now appears to require you to add "def" before any method declaration. Yep, that looks less noisy.
Offline princec

« JGO Spiffy Duke »


Medals: 421
Projects: 3
Exp: 16 years


Eh? Who? What? ... Me?


« Reply #9 - Posted 2011-11-05 13:33:31 »

Inexcusable pile of wank. Deliberate fiddling to make it look different.

Cas Smiley

Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline JL235

JGO Coder


Medals: 10



« Reply #10 - Posted 2011-11-05 13:42:34 »

Looking through the docs, there are some nice language features, and I think it'll certainly look more terse. But one nice aspect I've just realised: there is no runtime library! So it's just a pure language alternative to Java, which is kinda nice. It'll certainly make it much easier to mix this and Java in a project, although personally I don't recommend ever recommend doing that.

Offline sproingie

JGO Kernel


Medals: 202



« Reply #11 - Posted 2011-11-05 17:30:27 »

One could sarcastically, yet convincingly, argue that yes indeed, boilerplate is one of the core values of Java, but it's nice to see something that challenges this assumption.  The lack of a runtime requirement is a bonus, generation of idiomatic ("readable") java is another ... what this ultimately means is it's a bunch of simple-to-medium-complex macros for a language that otherwise lacks macros.  So in the end it's nothing that blows my skirt up, but neither can I get myself worked up about something that dares sully the pristine perfection of Java which is perfect as it is now and always.

It'd be nice if Lombok worked with it, but I suspect this will be an Eclipse-only thing for a while yet.


Offline JL235

JGO Coder


Medals: 10



« Reply #12 - Posted 2011-11-05 23:49:15 »

This would be especially useful as a Java alternative for those writing applets, as most JVM languages have runtimes of several megabytes, which is just too big to include.

Offline R.D.

Senior Devvie


Medals: 2
Projects: 1


"For the last time, Hats ARE Awesome"


« Reply #13 - Posted 2011-11-06 00:43:38 »

Oh this code looks so ugly Sad Why would I want my code written in that just because I don't know how to uses makros in eclipse? Or just typing another ";" Oh I don't see where the features will help me... I would not use it even when not writing a game :|
Online theagentd

« JGO Bitwise Duke »


Medals: 361
Projects: 2
Exp: 8 years



« Reply #14 - Posted 2011-11-06 02:54:36 »

Because there were too few compilation steps between Java and machine code already? Am I the only one here completely missing the point of this?

Myomyomyo.
Offline Nate

« JGO Bitwise Duke »


Medals: 158
Projects: 4
Exp: 14 years


Esoteric Software


« Reply #15 - Posted 2011-11-06 23:01:49 »

Change is really scary, eh guys? Wink

I don't think this is perfect. I want *minimal* changes to Java that reduce typing and improve readability. I like the type inference, property access, switch, and template expressions. I don't like the rest. I may be able to ignore what I don't like, except the default access. I'll play around with it.

Offline JL235

JGO Coder


Medals: 10



« Reply #16 - Posted 2011-11-07 03:59:30 »

I think type inference is a definite win, if it is done well. Some of the Haskell error messages can be difficult to decode, especially if your new to it.

But most of all I think in this modern age, we should be able to get rid of the semi-colons. Languages like Ruby deal with it fine, I don't think it's ever been an issue. I don't even think they should say it's optional, because that kinda makes you feel like it's advised. It makes you feel 'why make it optional if it's not needed at all?'

Offline gouessej
« Reply #17 - Posted 2011-11-07 10:44:44 »

Hi

As I already said, in my humble opinion, Java's syntax should not be modified anymore, it should be kept simple. Xtend only makes a few changes but if a developer does not like the core syntax of Java, he can use another language instead of "dirtying" ours. The JVM can support other languages and using several languages.

I can use a metaphor to explain what I mean. Imagine you're with your girlfriend/boyfriend, you look at her/him and you think she/he should change some major aspects in her/his physical appearance. If she/he does so, maybe she/he will become unhappy. In such a case, I would rather break off and look for someone else. It is the same thing with programming languages: If you don't like some major aspects in the syntax of a language, rather use another one.

Java is more verbose but more concise. Xtend only change a few things but it still looks like something else, another language.

Offline princec

« JGO Spiffy Duke »


Medals: 421
Projects: 3
Exp: 16 years


Eh? Who? What? ... Me?


« Reply #18 - Posted 2011-11-07 10:50:38 »

True about the semicolons though we have to remember one of the key features of Java that made it popular in the first place was its extremely close lexical compatibility with the C and C++ family of languages. This is sort of what bothers me about efforts like Xtend - it seems like twiddling for twiddlings sake, without really realising what they're losing while they're at it. C is not a pretty language really, but the fact is, if you are used to coding in C, you feel comfortable when things look like C. Randomly adding stuff and taking it away - eg. "def", semicolons - does not make the language more comfortable for anyone.

IMVHO they should have concentrated on fixing real deficiencies felt by programmers (and they have got some of this right by the looks), such as:
1. Type inference - this is a great idea. Haven't looked at Xtend's implementation but the concept is really sound.
2. The ability to use byte and short literals in code such as 123b or 12345s.
3. The addition of unsigned to the language, with appropriate numerical suffixes eg 255ub.
4. Multiple inheritance. I'm fed up with writing boilerplate composites when the compiler could provide some shortcuts for me.
5. Easier JNI. I suppose that's not achievable with this though.
6. I'd still kinda like the reinstatement of the const keyword.
7. An annotation for extension points in class inheritance.
8. structs and mapped objects.
ofc, all in addition to the stuff provided by Project Coin.

Cas Smiley

Offline princec

« JGO Spiffy Duke »


Medals: 421
Projects: 3
Exp: 16 years


Eh? Who? What? ... Me?


« Reply #19 - Posted 2011-11-07 10:52:12 »

re: properties - we already have a perfectly good syntactical feature for these, it's called the . operator. #facepalm

Cas Smiley

Offline nsigma
« Reply #20 - Posted 2011-11-07 11:21:21 »

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!  Smiley

5. Easier JNI. I suppose that's not achievable with this though.

What exactly?  Any itch that JNA wouldn't scratch?

Praxis LIVE - open-source intermedia toolkit and live interactive visual editor
Digital Prisoners - interactive spaces and projections
Offline princec

« JGO Spiffy Duke »


Medals: 421
Projects: 3
Exp: 16 years


Eh? Who? What? ... Me?


« Reply #21 - Posted 2011-11-07 11:43:00 »

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 Smiley

Offline nsigma
« Reply #22 - Posted 2011-11-07 11:54:48 »

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 Smiley

Somewhat similar.  In JNA you could do

1  
2  
3  
4  
5  
6  
7  
8  
9  
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.

Praxis LIVE - open-source intermedia toolkit and live interactive visual editor
Digital Prisoners - interactive spaces and projections
Offline princec

« JGO Spiffy Duke »


Medals: 421
Projects: 3
Exp: 16 years


Eh? Who? What? ... Me?


« Reply #23 - Posted 2011-11-07 11:58:44 »

oh ho! That's quite nifty, definitely want some of that. I bet it needs a native library to make it work though.

Cas Smiley

Offline nsigma
« Reply #24 - Posted 2011-11-07 12:17:30 »

oh ho! That's quite nifty, definitely want some of that. I bet it needs a native library to make it work though.

Cas Smiley

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

Praxis LIVE - open-source intermedia toolkit and live interactive visual editor
Digital Prisoners - interactive spaces and projections
Offline ReBirth
« Reply #25 - Posted 2011-11-07 13:39:02 »

It's pretty funny that I can call getter-setter methods like property, make me forget type (public or private) of my vars.

Offline Roquen
« Reply #26 - Posted 2011-11-07 14:16:35 »

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!

Quote
4. Multiple inheritance. I'm fed up with writing boilerplate composites when the compiler could provide some shortcuts for me.
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.

Quote
The one thing I like, and would love to see in Java, is optional double dispatch.  No more bloody visitor pattern
Multiple dispatch is awesome.  Sorry Cas, but I cry every time I need to write a visitor pattern.

Quote
Java is more verbose but more concise.
Err...nevermind.

Quote
Anyways, it's not for me, I'm not an IDE-guy
Ah! But you can run the eclipse compiler from a command line.
Offline princec

« JGO Spiffy Duke »


Medals: 421
Projects: 3
Exp: 16 years


Eh? Who? What? ... Me?


« Reply #27 - Posted 2011-11-07 14:22:30 »

What's this multiple dispatch thing? Is it runtime polymorphic method dispatch? What might the syntax look like? I'm all for it.

Cas Smiley

Offline nsigma
« Reply #28 - Posted 2011-11-07 15:12:19 »

What's this multiple dispatch thing? Is it runtime polymorphic method dispatch? What might the syntax look like? I'm all for it.

Cas Smiley

http://tinyurl.com/82quk9y  Grin

The Xtend page has a syntax suggestion at the bottom - basically another keyword attached to methods.

Praxis LIVE - open-source intermedia toolkit and live interactive visual editor
Digital Prisoners - interactive spaces and projections
Offline Suds

Senior Newbie




Lead Developer, DefeatThePurpose Entertainment


« Reply #29 - Posted 2011-11-16 03:51:09 »

yeah I'm going to write code that only works in eclipse and nobody else will even understand - good idea.

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.

Pages: [1] 2
  ignore  |  Print  
 
 
You cannot reply to this message, because it is very, very old.

 

Add your game by posting it in the WIP section,
or publish it in Showcase.

The first screenshot will be displayed as a thumbnail.

xFryIx (58 views)
2014-11-13 12:34:49

digdugdiggy (37 views)
2014-11-12 21:11:50

digdugdiggy (30 views)
2014-11-12 21:10:15

digdugdiggy (26 views)
2014-11-12 21:09:33

kovacsa (48 views)
2014-11-07 19:57:14

TehJavaDev (51 views)
2014-11-03 22:04:50

BurntPizza (51 views)
2014-11-03 18:54:52

moogie (66 views)
2014-11-03 06:22:04

CopyableCougar4 (65 views)
2014-11-01 23:36:41

DarkCart (150 views)
2014-11-01 14:51:03
Understanding relations between setOrigin, setScale and setPosition in libGdx
by mbabuskov
2014-10-09 22:35:00

Definite guide to supporting multiple device resolutions on Android (2014)
by mbabuskov
2014-10-02 22:36:02

List of Learning Resources
by Longor1996
2014-08-16 10:40:00

List of Learning Resources
by SilverTiger
2014-08-05 19:33:27

Resources for WIP games
by CogWheelz
2014-08-01 16:20:17

Resources for WIP games
by CogWheelz
2014-08-01 16:19:50

List of Learning Resources
by SilverTiger
2014-07-31 16:29:50

List of Learning Resources
by SilverTiger
2014-07-31 16:26:06
java-gaming.org is not responsible for the content posted by its members, including references to external websites, and other references that may or may not have a relation with our primarily gaming and game production oriented community. inquiries and complaints can be sent via email to the info‑account of the company managing the website of java‑gaming.org
Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines | Managed by Enhanced Four Valid XHTML 1.0! Valid CSS!