Is it possible to improve the quality of generated Java code?

64 views
Skip to first unread message

Wei Liu

unread,
May 28, 2015, 1:27:35 AM5/28/15
to xtend...@googlegroups.com
Hi Guys,

Before that let me appreciate the amazing work and help you've offered when I tried Xtend. The thing is, no matter how amazing Xtend is, sometimes it's required that you switch to Java because of platform limitations, and when you want to be programming with Java again and you want to use the generated code, it becomes nightmare...

an example:

boolean x = !a && !b;

generated:

boolean _not = !a;
boolean _not_1 = !b;
boolean _and;
if (!_not) {
 _and = false;
} else {
 _and = _not_1;
}

I personally find this to be crasy.

Sven Efftinge

unread,
May 28, 2015, 1:40:26 AM5/28/15
to xtend...@googlegroups.com
Hi,

yes it is possible. You seem to use an old version.
The latest version would have generated:

final boolean x = ((!a) && (!b));

still not optimal, since it prints superfluous parentheses, but already much better.
Btw. please also tell us about the concrete situations, where it is required to switch to Java.

Regards,
Sven

--
You received this message because you are subscribed to the Google Groups "Xtend Programming Language" group.
To unsubscribe from this group and stop receiving emails from it, send an email to xtend-lang+...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Wei Liu

unread,
May 28, 2015, 2:58:58 AM5/28/15
to xtend...@googlegroups.com
Thanks for the quick reply Sven, it's definitely better the new generating algorithm.

For me it's mostly because IntelliJ based IDE is catching up so fast .. that it's now the main stream, and xtend is not well supported in IntelliJ (in my case Android Studio). It actually causes me lots of pain during the last few months making xtend generated Java code compile.

In spite of that pain, I still think Xtend is a very good programming language, it opened a door to me towards functional programming and eventually leads to to Scala and Guava (for Java) both I work intensively on a daily basis. (Xtend is amazing but these things are just way more mature).

My opinion on Xtend

Pros
  •  Very short learning curve, a few hours is enough to get started
  •  Compact syntax, beats Java definitely, beats Scala very frequently too.
  •  Small footprint.
  •  Very active development, and the support to developers has been amazing too.
  •  Lamda is better with Xtend compared to Scala. (With scala only if it's a function)

Cons
  •  IDE support. Eclipse used to be best but now IntelliJ seems to take over.
  •  Lacking further functional programming helper classes. Functional programming is addictive so when you get started, you want to make the most of it, and with Xtend it's just not possible.
  •  Pattern matching.. would this be possible, ASAIK it's the best thing Scala offers.
  •  Generated code quality. It should be higher to make you fully confident to write code with it.

Would I reconsider using Xtend in future?

Yes!

You received this message because you are subscribed to a topic in the Google Groups "Xtend Programming Language" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/xtend-lang/_0cDOOiRrFI/unsubscribe.
To unsubscribe from this group and all its topics, send an email to xtend-lang+...@googlegroups.com.

Artur Biesiadowski

unread,
May 29, 2015, 3:40:53 AM5/29/15
to xtend...@googlegroups.com
  •  Lacking further functional programming helper classes. Functional programming is addictive so when you get started, you want to make the most of it, and with Xtend it's just not possible.
There are plenty functional-like libraries for java and they should work with xtend without any issues. Just do some static or extension imports and they will work seamlesly.

 
  •  Generated code quality. It should be higher to make you fully confident to write code with it.

While it might help a bit for debugging of active annotations etc, I don't think that you are doing it right if you depend on generated code quality. All other java dialects generate bytecode directly and you would not expect decompiled version of it to be nicely looking java. Why for xtend in particular you expect to be able to move to java only environment with generated classes at any time?

Think about generated java code more as implementation detail and debug help, not as a lifeline to reduce possible exit cost.

Carl Perfect

unread,
May 29, 2015, 5:07:08 PM5/29/15
to xtend...@googlegroups.com


On Friday, May 29, 2015 at 9:40:53 AM UTC+2, Artur Biesiadowski wrote:

  •  Generated code quality. It should be higher to make you fully confident to write code with it.

While it might help a bit for debugging of active annotations etc, I don't think that you are doing it right if you depend on generated code quality. All other java dialects generate bytecode directly and you would not expect decompiled version of it to be nicely looking java. Why for xtend in particular you expect to be able to move to java only environment with generated classes at any time?

Think about generated java code more as implementation detail and debug help, not as a lifeline to reduce possible exit cost.


Much agreed.
Then again, the presence of java files is one more benefit of xtend: should everything go wrong for you, you have java files.
Unlike other bytecode generating languages: in those case, you will loose everything should you choose to move away from them.

Especially for the ones that redefine a completely new standard library (scala, kotline): you are left with absolutely nothing.

Reply all
Reply to author
Forward
0 new messages