Now that I have my first (public) Xtend API working, I thought I'd write down where I think XTend still needs to work to catch up with Java:
1) Having to write:
myMeaningFullIdentifierName = myMeaningFullIdentifierName + 1
instead of;
myMeaningFullIdentifierName++ (or ++myMeaningFullIdentifierName)
When you have a lot of "myMeaningFullIdentifierName" (as I had in this API) to increment/count (no loop index here), this gets old quickly.
Since this is an "on purpose" feature of Xtend, there is no hope of it ever being "fixed" AFAIK.
3) Lack of "synchronized" keyword
4) Lack of inheritance of @Data types.
Maybe I am just missing something here... Java hasn't got an @Data, but not having inheritance partly cancels out the benefits, I think. But as I will probably write my own alternative to @Data, this is only a short-term issue for me.
5) No "break" in loops.
So far, I could use a "return" as an alternative, but this isn't always possible.
The ++ and -- operators match one-to-one assembler instructions of the processor which allows to write efficient code
Am Samstag, 7. Dezember 2013 01:09:29 UTC+1 schrieb Sebastien Diot:Now that I have my first (public) Xtend API working, I thought I'd write down where I think XTend still needs to work to catch up with Java:
1) Having to write:
myMeaningFullIdentifierName = myMeaningFullIdentifierName + 1
instead of;
myMeaningFullIdentifierName++ (or ++myMeaningFullIdentifierName)
When you have a lot of "myMeaningFullIdentifierName" (as I had in this API) to increment/count (no loop index here), this gets old quickly.
Since this is an "on purpose" feature of Xtend, there is no hope of it ever being "fixed" AFAIK.Okay, I really think that ++ is the source of many bugs. But I agree that x+=1 would be nice to have. But that's probably not possible, because it would be ambiguous in Xtend. It could either be an assignment statement or it could be an expression with the "+=" operator.
3) Lack of "synchronized" keywordYou can write your own little active annotation for that.
4) Lack of inheritance of @Data types.
Maybe I am just missing something here... Java hasn't got an @Data, but not having inheritance partly cancels out the benefits, I think. But as I will probably write my own alternative to @Data, this is only a short-term issue for me.Last time I tried them, @Data types supported inheritance, what exactly doesn't work for you? BTW, subclassing and immutability don't mix well, so I actually believe that @Data should forbid inheritance ;)
5) No "break" in loops.
So far, I could use a "return" as an alternative, but this isn't always possible.I always find that break and continue make loops hard to read. Pretty much any case I've seen could be replaced either with "return" or with an if-statement.
The ++ and -- operators match one-to-one assembler instructions of the processor which allows to write efficient codeThe JIT compiler will replace x = x + 1 with inc. So you are actually not optimizing anything.
Could we then not have something non-ambiguous like inc(var,increment defaulting to 1)? It doesn't have to be "++"; I just want something short where the variable doesn't need to be repeated.
3) Lack of "synchronized" keywordYou can write your own little active annotation for that.
I know; I think it can be gotten around relatively easily. It's just that there is an issue for it, but it doesn't look like it is likely to be fixed it the near future.
5) No "break" in loops.
So far, I could use a "return" as an alternative, but this isn't always possible.I always find that break and continue make loops hard to read. Pretty much any case I've seen could be replaced either with "return" or with an if-statement.
This is a constant cause of arguments in our team at work. The boss thinks that "methods should only ever have one single return statement".
The main problem with using return in this case, is that sometimes you want to return more then one value, which requires creating a temporary object.
Still my argument is that if you really need to increment something, you are going to do it anyway, and so removing the ++ operator, from the point of view of an Xtend user, just seems like a pointless "just so" limitation, like taking away the toys of a kid, in the hope he/she will start behaving better (I tried; it doesn't work :D )
To recap, while I was being critical, I'm still quite happy with this first real Xtend project, and I intend to stick with Xtend unless I find a "blocker issue" down the road. I've been following Xtend for quite a while now, and so I can see that it is moving forward in what I consider to be the "right direction". The Killer Feature of Xtend for me are the Active Annotations. I intend to make heavy use of them, and without them, I might not have switched to Xtend at all. And what I'm waiting for, more then everything else, is the ability to *manipulate* the source code of existing methods in Active Annotations. I was using Scala at some point in the past, but manipulating the Scala source code with compiler plugins was a nightmare, which eventually led me to leave Scala behind. I've tried that in pure Java too, but if I remember well, I needed to write the code doing the manipulation *twice*; once for javac, and once for the Eclipse Java compiler, so I gave up on that as well.
> 2) Lack of inner, and in particular anonymous, classes (with the exception of lambdas)
>
> I think this gets fixed in 2.5, which should come out in December, if I get it right.
Yo, it didn't make it into 2.5 unfortunately, but this definitly on of the next language features we're going to
https://bugs.eclipse.org/bugs/show_bug.cgi?id=402388
https://bugs.eclipse.org/bugs/show_bug.cgi?id=376399
>
> 3) Lack of "synchronized" keyword
Agreed. Although relatively easy to ship your own lib, it should be there out-of-the-box.
https://bugs.eclipse.org/bugs/show_bug.cgi?id=418753
> 5) No "break" in loops.
Not a fan of this one. We don't even have a feature request for it so far.
You may open one and if you find enough supporters I'm open for discussion :-)
The only good argument I'm aware of, is the "jumps in your face" as a Java developer (see below).
On Sunday, December 8, 2013 8:33:03 PM UTC+1, Sven Efftinge wrote:> 2) Lack of inner, and in particular anonymous, classes (with the exception of lambdas)
>
> I think this gets fixed in 2.5, which should come out in December, if I get it right.
Yo, it didn't make it into 2.5 unfortunately, but this definitly on of the next language features we're going to
https://bugs.eclipse.org/bugs/show_bug.cgi?id=402388
https://bugs.eclipse.org/bugs/show_bug.cgi?id=376399
Any idea yet about an ETA for that?
>
> 3) Lack of "synchronized" keyword
Agreed. Although relatively easy to ship your own lib, it should be there out-of-the-box.
https://bugs.eclipse.org/bugs/show_bug.cgi?id=418753
Also, I assume there is a similar request for volatile. I found that the lack of volatile is in fact harder to work around then the lack of synchronize.
You end-up with something like:
Concrete-Xtend-Class extends Work-Around-Java-Class-Just-For-The-Volatile extends Base-Xtend-Class
> 5) No "break" in loops.
Not a fan of this one. We don't even have a feature request for it so far.
You may open one and if you find enough supporters I'm open for discussion :-)
The only good argument I'm aware of, is the "jumps in your face" as a Java developer (see below).
I'll try to live without, and see how well I do.
With regards to the synchronized keyword, it's in any case better to use ReentrantLock
http://docs.oracle.com/javase/6/docs/api/java/util/concurrent/locks/ReentrantLock.html
With regards to the synchronized keyword, it's in any case better to use ReentrantLock
http://docs.oracle.com/javase/6/docs/api/java/util/concurrent/locks/ReentrantLock.html