Xtend - to what extend usable? :)

Hello all,

maybe this question needs to go to Offtopic, but it has been on my mind since i dug deeper into the nice design patterns by @rlkoshak et al…
Is there any documentation on how much of the (in my eyes great) syntax and semantics of Xtend are usable within rules?
At least extension methods (maybe even classes in script files) woulds be very welcome (to me)!

Cheers,
Alex

Rules do not support classes, extensions, or arrays. I’ve not encountered too many other features that are not supported in Rules.

If you desire classes and such you should look into the JSR233 add on which is, or soon will be available on OH 2. You can write rules in Jython, JavaScript, or Groovy with it.

It is also important to note that the Rules DSL is approaching end of life. It will eventually (probably not soon but eventually) be replaced with the currently in progress Experimental Rules Engine.

So to answer the question you haven’t asked, no, don’t expect support for classes etc to be added to the existing Rules DSL.

1 Like

I wasn’t aware of the fact that the existing Rule DSL was approaching its EOL. That raises some questions for me (having maybe a thousand LOC invested in the current setup):

  • Not having poked into the Experimental Rules Engine, is there some migration scenario forseeable?
  • I love lambdas and design patterns layed out in this community (also thanks to you @rlkoshak), will this (and maybe more) be supported on the new Rules Engine?
  • Thanks for the hint on JSR233, would it be worth to migrate to that platform and stay there for the forseeable future as an alternative to the new Rules Engine?

I know, seems like some eight-balling needs to be done, i just want to see the direction in which the development of the rules platform will be going and take it from there. Any thoughts? :slight_smile:

I suspect there will be some sort of migration scenario or at a minimum, the current Rules DSL will continue to work in OH 2. I would expect that it simply will no longer receive any updates or changes.

Even better, it will support reusable code. So rather than posting a bunch of design patterns and example that you have to retype into your Rules, we will be able to share libraries of code that can be used directly. That and the ability to create Rules in PaperUI I think are the two main drivers for the Experimental Rules Engine.

My admittedly limited understanding is that JSR233 will be a first class rules engine and somehow integrated with or work with the Experimental Rules Engine. So you wouldn’t be going very wrong migrating to it. I just don’t know if it is released on OH 2 yet.

My use of the term End of Life may be a bit strong. I expect the default Rules DSL to continue to work in OH for a long time. It just wont be advancing or have new features added to it as all the focus right now and into the future will be on the new Rules Engine.

1 Like

It seems like JSR223 is already in the OH2 nightlies, and you were right about being able to use the classes built in e.g. Jython in the experimental rules engine, at least it seems to me after reading throught this loooong PR discussion on github.
Still trying to wrap my head around the IDE integration though, but i’ll try and port some code over when i manage to get it running!