Array syntax & Bitwise operators

504 views
Skip to first unread message

lum...@gmail.com

unread,
May 4, 2015, 10:50:39 AM5/4/15
to xtend...@googlegroups.com
As I primarily work in the field of AI, I was faced with the fact that Xtend syntax is a bit verbose when dealing with primitive or array operations.

Array Operators

As I understood it from earlier threads on this subject, array/list indexing syntax is not supported because of limitations in the inferencing / type engine.
It was mentioned that after refactoring the type engine, this would be possible.

Array index by 2.3
Array Access Enhancement

The use cases where I ran into issues:
(Please correct me if I'm wrong in any of the cases :) )
  • Array/List access and update. E.g.: array[i] += x  becomes array.set(array.get(i)+x)
  • Multi-dimensional array construction required me to write my own extension methods.
Bitwise operators

Personally, one of the first things I did when working on Xtend was to create bitwise operator extension methods for Long and Integer using &&, ||.
a.bitwiseAnd(b).bitwiseXor(c).bitwiseAnd(d) in my view isn't a viable alternative to a & b ^ c & d.

(Sidenote: For this and other dealings with Inline, I created an TypeReplacer ActiveAnnotation. This just generated methods given a set of target classes (int, long, etc) and replaces the target generic type) 

Apart from the ambiguity of && and ||, and the lack of a ^ operator; I haven't run into any problems.
Ideally, the normal bitwise operators would be accessible in Xtend; but I can see where this would conflict with lambda definitions.

At the moment I find myself
 implementing extensive or mathematical algorithms in Java to avoid the syntactical overhead of Xtend.
Given the above I think it's prudent that a decision gets made on type inferencing support for distinguishing between lambda and other usage, or a choice is made on alternative concise syntax for the above cases.
The issue has lain relatively unaddressed for the past 4 years, with every few months someone mentioning it again.

I'd love to gain some insight into the problems faced during previous efforts to solve these problems.



Sebastian Zarnekow

unread,
May 4, 2015, 11:07:00 AM5/4/15
to xtend...@googlegroups.com
Hi,

the main problem is the syntactic ambiguity. That's the case for array access syntax and bitwise operators. It's not a limitation of the typesystem but a more fundamental problem with the parsing and lexing. That is, the problem is rooted at an earlier stage of the processing pipeline.

I can see that Xtend is not as concise as Java when it comes to binary operations, especially bitwise operators. That's a current limitation that we want to get rid of in the long run. Unfortunately it's not the most pressing issue for use at the moment.
I'm afraid there is not much more that I can say about this topic.

Best,
Sebastian

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

mark.je...@gmail.com

unread,
Feb 14, 2016, 1:40:47 PM2/14/16
to Xtend Programming Language
I really tried to become a fan of Xtend, I really tried, but if functionality of Java gets taken away to make room for "new" features, then unfortunately I'm out. Why introduce ambiguity by implementing lambdas in your own way while a little later Oracle did the same thing without introducing ambiguities? And why did you not at that point change the Xtend lambdas to look like those of Java, so all the points OP complained about can work again?

I started using Xtend because of, and only because of the extension methods. If there was an Xtend (Xtend lite or whatever) with just that import extends keyword and the syntactic x.method() first parameter swap, and none of the other syntactic stuff (like var/var/as and lambdas) then I'd be really happy.

Artur Biesiadowski

unread,
Feb 14, 2016, 4:05:54 PM2/14/16
to Xtend Programming Language, mark.je...@gmail.com
Maybe look into Scala? Recently, they got a way to have extension methods without uneeded allocations (http://docs.scala-lang.org/overviews/core/value-classes.html). For non-trivial math/AI problems it might be a good pick for other reasons.

As for java8 syntax for lambdas - for me, xtend one is considerably more concise and powerful. But of course it is personal preference.

Denis Kuniß

unread,
Feb 16, 2016, 4:47:35 PM2/16/16
to Xtend Programming Language, mark.je...@gmail.com
Common, it's not fair to blame the Xtend language design for that!
Please consider, Xtend originally was introduced as template language for Xtext. I guess, initially this was its main purpose.

As I remember, I have used lambdas in Xtend already in 2012, years before Java 8 comes out (2014). In fact, Xtend was out even before Java 7 was released (Xtext/Xtend - June 2011, Java 7 - July 2011). See
https://en.wikipedia.org/wiki/Xtend#History
https://en.wikipedia.org/wiki/Java_version_history#Java_SE_7
https://en.wikipedia.org/wiki/Java_version_history#Java_SE_8

As for Artur, for me the lambda syntax in Xtend is more concise than in Java 8 and closer to other famous functional languages.

Furthermore, language design - especially general purpose language design - is not a trivial thing. Taking over syntax elements from another language is not always as easy as it seems due to parser and lexer tooling constraints. From that point of view I would say: Xtend is well done and quite innovative.

Denis

Norbert Sándor

unread,
Mar 9, 2016, 5:34:10 PM3/9/16
to Xtend Programming Language, mark.je...@gmail.com
> Xtend is well done and quite innovative

I completely agree, and I think that most design decisions of the language are good (or acceptable).

But many of Xtend's features need enhancement to catch up with mainstream languages - even with Java!
Just see the issue tracker for important feature requests (and bugs).
(I know it's open source, etc - this is not an offense against anyone, just an opinion!)

I "feel" that the progress of Xtend development is so slow that new languages like Kotlin/Ceylon/Scala/etc. will take over it completely.
There is no roadmap so the users don't see what is the planned direction of the development.
Another problem is that Xtend is not "advertised" well enough, for a new user it may seem to be only a spin-off of Xtext.

Somewhat "personal": I was very sad when I've first seen that the Idea plugin is under development - before polishing the Eclipse plugin.
The Eclipse plugin still has very serious problems (eg. refactoring almost always fails, debugging is uneasy/difficult, etc.) - I simply cannot recommend Xtend as an alternative of Java to anyone without great IDE support.

I could go on...


> I really tried to become a fan of Xtend, I really tried, but if functionality of Java gets taken away to make room for "new" features, then unfortunately I'm out.

I hope that the main developers of Xtext/Xtend have some strategy for these problems - and they share it with us :)
Xtend should stay/become sexy enough to attract users - not only for Xtext language development because it is not enough for a language to stay "sustainable".

--
Norbi

Sven Efftinge (sven@efftinge.de)

unread,
Mar 9, 2016, 11:35:38 PM3/9/16
to xtend...@googlegroups.com
Hi Norbert,

I'm a bit sad reading about all these IMHO exaggerated complains. As you might understand the committers would love to spend lots of time on pushing Xtend forward and sorting out the last rough edges. Also it would be cool to have money to spend on marketing just like Jetbrains does with Kotlin, but there is simply not someone who wants to spend it atm.

We will be very happy to further maintain and develop Xtend to make it better, and we have customers who want us to it, but they are mostly interested in Xtext use-cases so we focus on that. I personally use Xtend on a daily basis and am much more productive than I was with Java, but of course there is always something to do. I actually don't think it needs a ton of money, but there needs to be at least some funding to work on new features and enhancements. Also marketing is best done through real people from the community. So you really should write articles and blogpost about what is cool and why you still care. That is the best marketing you can't buy for money. But if everybody expects others to do that, no one will do it in the end.
Also we are of course open to high quality pull-requests.

Sven

--

Norbert Sándor

unread,
Mar 10, 2016, 4:43:11 AM3/10/16
to Xtend Programming Language
Sorry for being a bit negative :)
I don't want you to take it as offense - it is more of just friendly criticism :)
You make a very good job at developing Xtext and Xtend, and I know that resources are always limited...

I think there are things that may work well for PR in case of an open source project, eg.
- Release often and maintain the news page (http://www.eclipse.org/xtend/news.html), so your users and new visitors see that there is progress.
- Do a clean-up in the issue tracker, so visitors don't see that there are many - even 4 years old - NEW issues (I know... it's huge work).
- Share a roadmap with the community, it's important for us to see which features/fixes get into the language in the short and long term (this could be a very simple one: based on votes and priorities in the issue tracker, combined with time-based releases).

I don't use Xtend at work, only for experimenting in hobby projects - like http://norbertsandor.github.io/xtend-ioc/ - and I like it very much.
But I think its main advantage is active annotations, and if another widely used modern language (like Kotlin) gets a similar upgrade then Xtend will be in a very difficult position...

BR,
Norbi

dustContributor

unread,
Mar 11, 2016, 8:21:31 PM3/11/16
to Xtend Programming Language
I'll say first that I think the state of the Eclipse plugin could be better, like syntax highlighting as I mentioned before, formatter "keep new lines" no really keeping new lines (cant separate chained method calls into new lines because formatter combines them again), not having feature parity with Java, like method references and enums (latter being easily solved by just declaring the enum in Java of course, former one not so much easy to solve).

Beyond that, Xtend has so many language decisions that make me think "Duh, why dont other languages do exactly the same?". Like being able to treat all static methods as extension methods, the 'it' variable in lambdas, or just implicit 'it' on lambdas altogether, val and var with type inference, optional semi colons, etc. Its just great, and I dont even use that much its most touted feature (active annotations).

So don't get bogged down by the complaints, Xtend is great. Its just so nice that we get annoyed very easily by the little rough corners it has :D
Reply all
Reply to author
Forward
0 new messages