
Xtend – Modernized Java - eurg
https://www.eclipse.org/xtend/documentation.html
======
weddpros
I've used xtend last year, before I switched to Scala. Eclipse integration is
better with Scala (autocompletion among others), and Scala has more to offer.
Biggest pain point: stack traces point to the Java translations, not to
xtend's source code. That made me switch to Scala.

~~~
IReadYourCode
Autocompletion in the Xtend editor is quite excellent, you might want to try a
recent version. The last time I tried the Scala IDE (during the first Coursera
lecture), Scala's autocompletion suggested may invalid proposals. It felt more
like the editor was guessing about types than actually doing proper type
analysis. If you happen to have a Java stack trace from Xtend code and click
on a stack frame, Eclipse will open the Xtend file and highlight the proper
line in your Xtend code.

~~~
weddpros
Good to hear Xtend got better... but too late for me, I'm afraid. I learnt to
like Scala, but I'm working with node.js now (coffee-script)...

I think Scala is a good language, but maybe it has too many features for me.
Xtend did not leave me a bad impression anyway :)

------
tinco
"Modernized Java", it's basically a slightly uglier C#.

Not that I'd argue C# isn't modern, it's in fact one of the most 'modern'
languages I can imagine at the moment, but it's kind of wry that C# did such a
good job of keeping current where Java lagged so terribly behind.

~~~
bad_user
Same can be said for the JVM vs CLR, only in reverse.

~~~
commentzorro
I had always thought that the CLR was considerably ahead of the JVM, though
admittedly only anecdotally. What is in the JVM that is not in the CLR that
makes the JVM further ahead, so to speak.

~~~
windust
Working with the JVM, there is definitively more cross-platform support (I
know there's Mono for CLR but it's not the same support Oracle's JDK gets), GC
has a ton of heavy hitters investing time (from IBM JRockit acquisition to
collaborations with Azul's Zing) and while I haven't seen first-hand CLR's
optimization the JIT optimizations are pretty impressive.

------
dtech
I don't see any advantages in this over Scala.

~~~
ZoFreX
Probably easier to write for Android with Xtend than Scala.

~~~
bad_user
Why is that? Tooling support at this point is much better for Scala than it is
for many JVM languages, including Xtend.

Checkout:
[https://github.com/pocorall/scaloid](https://github.com/pocorall/scaloid)

You can do that in combination with IntelliJ IDEA for example, which has
awesome support for both Scala and Android. Google's new Android Studio is
actually the same as IntelliJ Android plugin that they distribute as part of
their open-source distribution. It's also the best IDE ever.

------
kushti
Oh, how many "next Java" options we have now... Kotlin, Ceylon, Gosu, Xtend,
Java 8 :) (Scala not mentioned as I refuse to call it "the next Java", it's a
new player)

~~~
andrewflnr
Had not seen or forgotten Gosu. Thanks. Not that I'm likely to use it, Kotlin
will be my first choice when I get back to my Android app.

~~~
stewbrew
Doesn't Kotlin target jvm 1.6?

~~~
andrewflnr
Honestly, I don't know. No one seems to have mentioned anything like that as
an obstacle to kotlin on android, but I haven't done a ton of research.

------
cpfohl
It's like Coffeescript for Java...

I hereby suggest it be renamed "Coffee".

~~~
xutopia
That would be an evil prank on us all though... We'll have job offers with "12
years of Coffee experience with jQuery".

------
txmikester
I've used Xtend many times over the last few years. In fact, I'm using it
right now at my "real" job for an internal project. I'm mostly a Clojure guy
who still has to do a lot of Java work to pay the bills - when I can't use
Clojure on a project, Xtend is a breath of fresh air.

The current form of Xtend has been around for a few years now, and has
steadily improved. Its origins go back many years, to the OpenArchitectureWare
project where its predecessor (called Xpand) was used as a templating and
model transformation language for the framework. Since oaw moved to the
Eclipse foundation (5-6 years ago?), most of the tools have been dropped,
reworked, or merged in with other Eclipse projects.

Out of all this reworking for the new generation of Xtext came Xbase, which is
an expression language that you can just drop into your DSL and have pretty
much the entire Java language available (type system, expressions, scoping,
etc.). If you're doing serious modeling/DSL work, this is about as good as it
gets without going to something like MPS (which is awesome, but has its own
set of limitations). Xtend is essentially this Xbase language in stand-alone
form, with a few other goodies. There is also another project called Xcore
which lets you create EMF models in plain text, mixing behavior along with
structure, and it uses Xtend/Xbase as well. This is one of the reasons why I'm
not too worried about Xtend becoming "abandonware" or anything like that - its
main components are pretty essential to some key projects in the Eclipse
ecosystem.

So why wouldn't you just use (Scala, Groovy, etc.)? Well for one thing, I can
(and have) bring Java developers up to speed on Xtend in about an hour (less
if they know anything about functional programming). You can see some benefits
in more concise code right away, and it only takes a couple days to get
productive with it. No one can do that in Scala or Clojure. If you're looking
for a strategic platform to build your next JVM architecture on - well, that's
not really Xtend's place, you're looking for Scala or Clojure (hint - the
latter). But there are a lot of projects where Xtend is a very nice fit, and
as a bonus, I've found that developers who learn Xtend first have a much
easier time learning a more "serious" language like Scala or Clojure later.

------
thescrewdriver
Compared to other JVM languages Xtend seems to be seeing very little adoption
or interest. I have yet to encounter anyone who's actually using it.

~~~
pjmlp
It is a me too language from Eclipse foundation without any clear roadmap why
anyone in the industry would care to use it given the more mature JVM
languages, specially given its dependency to Eclipse and generation of Java
code instead of bytecode.

~~~
kitd
Xtext, the Eclipse/JVM language development toolkit behind Xtend, is in many
ways more interesting than Xtend itself. In fact (I may be wrong) but Xtend
was really done as an Xtext example/test/advertisement.

I have used Xtend a little (not in production) and it was interesting when
first introduced. I suspect Java 8 will make it redundant.

~~~
pjmlp
My feelings as well. I just looked into it as a possible language for Android
development given the stagnation on Java compliance on the platform, but
Kotlin looks much better suited for it given Google's investment into InteliJ.

------
eurg
Xtend seems to be a very conservative, but sensible iteration on Java. Does
anybody have some experience with it, knows some pitfalls, etc.?

~~~
creatio
I think its only usable with eclipse. I do wish it had ADT and pattern
matching.

------
th3iedkid
MPS from jet-brains offers another good option something called baseLanguage
with very good DSL equivalents for a lot of use-cases combined with one more
called SModel language.But its not parser based one like xtend is , its AST
based projection editing and manipulation platform.I've been learning it for
sometime.

------
noelherrick
What I would hope is that these features get rolled back into Java. Xtend
could be a testing ground that shows how something would work, similar to the
way browsers have their own proprietary implementations of an idea that then
serve as examples to the W3C.

~~~
thescrewdriver
I find it sad that some view JVM languages which aren't Java as a testing
ground for features which could be added to Java. Other JVM languages are
worthy of usage independent of the Java language. Not everything can be back-
ported to Java and keep the language backward compatible.

~~~
pjmlp
The main problem is that the enterprise sees:

JVM == Java and CLR == C# (or VB.NET for VB shops)

Given the size and skills of the said teams, usually you cannot sneak in
alternative languages anyway.

So for many of us, regardless how much we like alternative languages, those
are the ones we are allowed to play with.

------
salvatoreromeo
coming from java, xtend is probably the best choice right now (also compared
to java8) because you are up and running in few hours. really! and the
development time will decrease significantly. You can create full projects in
a fraction of time. Active annotations are also very useful to generate common
boring code (Logging, patterns, ...) also from configuration or HTML files, or
to generate files like javascript to call your backend service. the only
drawback is that it only works in eclipse. Eclipse has full support, meaning
that debugging, refactoring, click from stacktrace and so on are available and
work perfectly. just try it for 30 minutes, you'll not come back!

------
yawz
This all looks OK to me but my first worry would be ease of debugging. I
eyeballed the doc but couldn't see anything specific to debugging. Anyone has
some experience they could share?

~~~
IReadYourCode
You can debug Xtend code using the Eclipse Java debugger and debug Xtend code
just like you would usually debug Java.

During debugging, you can select for every stack frame if you want to see the
Java code or the Xtend code. This makes sense since Xtend code gets compiled
to Java code which then gets compiled to byte code.

------
reactor
They surely need to find a solution for proper debugging. Nobody likes mental
gymnastics needed when debug stack traces to a language other than the
language you write the s/w in.

~~~
IReadYourCode
Xtend isn't supposed to replace Java. It enhances it. That's why Xtend doesn't
compile to byte code but to Java code.

If you do imperative programing in Xtend, there will be exactly one Java
method for each Xtend method. I.e. the "Xtend stack trace" (if it would exist)
is exactly the same as the Java stack trace.

If you do a more function style of programming and use lambda expressions,
each lambda will be a anonymous class in Java 7 or older. So you'll see them
in your stack trace. But I guess that you would also see them in Java 8.

------
chalgo
JVM languages seem to be the flavour of the month at the moment. Why do IDE
makers feel the need to invent their own languages?

~~~
IReadYourCode
Because many languages were designed with only the compiler in mind, but IDEs
have requirements regarding language design, too…

Example 1: text-based preprocessors such as the ones you find in C or C++ are
a nightmare for IDE developers. They turn static analysis into a game of
guessing because your source code can manifest itself into too many
variations.

Example 2: SQL: If a user wants to write "SELECT mycolumn FROM mytable;" but
he/she has only written "SELECT " and now trigger auto-completion… it can not
work, because the IDE has no idea from which table it can list the columns. If
the language would have the syntax the other way around "FROM mytable SELECT
mycolumn" auto-complete could easily propose the tables first and all the
columns from a specific table later.

------
ninjazee124
Better to use Java 8 with Lombok extensions.

~~~
fved
Anyone with any sense of taste avoids Lombok. It's a terrible hack. Rather use
Scala which gives you far more. Maintaining Lombok + Java is a pain.

~~~
jonhohle
I dislike nearly everything about Lombok but `val`. Everyone else seems to be
the opposite :-(

------
thomasfl
Xtend seems for me to be like coffeescript. It gives nice syntax like blocks
to java.

------
zak_mc_kracken
Xtend has been around for a while and I think one of the reasons why it didn't
catch on is because it generates Java, which severely limit its performances.

These days, "modernized Java" would probably be Ceylon or Kotlin.

------
NanoWar
What's that «guillemets» nonsense??

~~~
IReadYourCode
It's finally a syntax that doesn't get into your way when you want to generate
stuff.

Think of XSLT. Every time you want to generate a "<" or ">" you need to escape
it.

Think of PHP. Every time you want to embed a command you need at least two
characters to escape it: <? ?>

Xtend choose «guillemets» because they're concise and very unlikely to occur
in the string/text/file your generating. You might want to use UTF-8 or
ISO-8859-1 encoding.

~~~
lmm
<? is easier to type and no harder to read than «.

~~~
txmikester
Sure, until you are trying to generate php.

The templating engine is one of the parts carried over from the old Xpand
project on which Xtend is based. Xpand's sole purpose was as a templating
language for writing code generators in MDE projects, and as such they tried
to make it easy to generate any kind of code, so they chose a non-ASCII
delimiter.

It's really not a problem in practice - type < and then ctrl-space and code
completion will fill it in for you. The only real gotcha is that you have to
make sure your project is set to use UTF-8 encoding, which unfortunately is
not the default setting in Eclipse.

------
antocv
Everyone and their dog is writing a language these days. Oh well.

Id rather improve on applications and libraries we already have.

~~~
mattgreenrocks
> Id rather improve on applications and libraries we already have.

Can you be more specific?

Also, working on tooling is _way_ more interesting than working on apps...at
least for me. There are actually hard problems to solve ;)

~~~
chalgo
You're trying to invent solutions to problems that nobody have.

