What Rule Languages are supported in the future and what Languages should be used for a new Setup?


i am confused about which rule languages exists and which are going to be deprecatedin the future.

In the Documentation Rules DSL link to a Tutorial about Xbase/Xtend.

And for ECMAScript 5.1 it says it is going to be deprecated and Links to JSR223 Scripting.

The JSR223 API can be used with all the Automation Add-ons I guess?

But 5 Sentences below the Links it says in the tutorial they are going to be the JavaScript Scripting add-on which implements ECMAScript 2021. Is ECMAScript 2021 also going to be deprecated or is it the same as ECMAScript 5.1?

Anyway if I read the table in the docs correctly from the 3 Languages I should use Rules DSL If I don’t to use a soon deprecated language nor Blockly?

But I also read that the Rules DSL (the same Xtend/Xbase I guess?) is the old one and using the JSR223 API is the new way?

So in the End I basically have the question in the title: Which Language should I use for a new Setup?

There are some very good threads on this topic around the forum. Here’s a recent one which includes a quick summary of the state of many of the rules systems:

1 Like

Thanks, thats really helpful and tells a pretty different story than the docs.

Okay, so the conclusion is to use JS Scripting?

Right, because Rules DSL is mostly based on Xbase/xtend.

That table needs to be updated. When OH moves to a new Java, ECMAScript 5.1 will no longer come with OH. However, it can be installed from the marketplace as an add-on. But the conclusion remains the same, you shouldn’t start with it. ECMAScript was released in 2009. It’s 13 years old. A programming language advances considerably over the course of a decade.

I suppose at some point it will become deprecated too. No specific version of a programming language retains support forever. But the 2021 part of ECMAScript is the year that it was released. This is a very recent version of JavaScript. There’s no reason to expect it to become deprecated in the foreseeable future.

Perhaps I need to rewrite that opening sentence. That table only lists the languages that OH ships with. They are there no matter what. You cannot remove them. But there are half a dozen additional languages that can be installed through an add-on, among which is JavaScript Scripting which provides ECMAScript 2021.

For the majority of OH’s existence, Rules DSL was all that existed. So the majority of the examples you find will be Rules DSL. Most of the examples in the docs will be Rules DSL. That’s all that is intended by that.

How is it a different story from the docs? Note, I’m the author of the docs in question and the answer on that thread. They should be telling the same story.

Not necessarily. It depends on your personal preferences and requirements. If you don’t know how to program, use Blockly. If you do know how to program, choose one of the modern languages that you already know or want to learn. Avoid ECMAScript 5.1 and Jython if you are just getting started (if you like Python look into HABApp). I probably wouldn’t choose Rules DSL either since the JavaScript Scripting add-on as well as the jRuby add-on are getting to be as easy to use as Rules DSL with more language features available.

1 Like

After I read that Table in the Documentation I believed there are three Options to make Rules:

  • Blockly

  • Rules DSL (Xtend/XBase)

  • And EMAScript 5.1 with the JSR223 API and the Automation Add-Ons

Blockly is GUI based and ECMAScript 5.1 is going to be deprecated and because ECMAScript 5.1 links to the JSR223 Site I thought that JSR223 is also going to be deprecated. So I should use Rules DSL.

In the Thread you say that you would treat Rules DSL as strictly Legacy and If I understand correctly only JavaScript Nashorn is based on ECMAScript 5.1 and the other Automation Add-Ons are not based on a version that is going to be deprecated soon.

I’ll take a note to revisit that page and see if I can make it more clear what was intended.

A lot of what’s in the Getting Started rules pages is going to be moved to the reference section of the docs so I’ll probably updated it as part of that. Based on the above discussion, that table may no longer be on that page anyway once we do that.

Correct, the things about Rules DSL that made it good (relatively simple and easy to learn) have been better implemented in Blockly. So if one is just getting started, I would not choose Rules DSL. However, there’s a decade’s worth of documentation and thousands of users who don’t want to nor should they have to rewrite their rules, so support will remain as long as that’s feasible.

The main point is I don’t want new users getting started on Rules DSL.

Another point that I’m certain isn’t clear, is you are not limited to just one language. You can mix and match and use the best language for the task at hand if you want.

Correct. The JS Scripting add-on provides a much more recent version of JavaScript with support for node libraries.

Almost. The Jython add-on is kind of a zombie. It only supports Python 2.7 (which two years past end of life) and there isn’t a lot of action upstream. At some point something is going to break and we’re not going to be able to fix it. So I would avoid that one.

The rest are good with active development and varying sizes of user communities here on the forum to help.

1 Like

I have a lot of rules in DSL from the beginning but never moved them to another language.

Question for me is do I need to do it from time to time or leave them there and the new ones than in js scripting?

That will work
DSL support isn’t going away anytime soon though so no worries

Once you’ve tried jruby and realised how NICE it is, you’d want to rewrite everything in jruby