Python or Java?

I’m reading around the forum - and was in doubt - is the system based on Java or Python? Or both? :smile:

The heavy lifting in the system is largely written in Java. There is some ongoing work to allow you to write your automation rules in Python/Jython, as well as other scripting languages.

Awesome… Would be great to also implement Python for Scripting / Automation Rules

see wiki re Python et al JSR-223

I just want to point out that the default rules and scripting are not written in Java but a Domain Specific Language based on Xbase but having the closest resemblance to Xtend. If you have experience programming in event based programming environments (e.g. Astrisk or FreeSwitch rules, Tasker rules, etc) you will be right at home.

Go directly for Python with the JSR-223 plugin.
It will save you lots of trouble and you won’t have to deal with the massive amount of quirks of xtend (actually the xtend subset).
I wish I would have started with python! :unamused:

Forced to comment here. Been in the software biz for a LONG time, C (and ++), VB, Pascal, Python/Jython,Java et al (and ad nauseam) coder/supervisor/eldergeek. Pretty much not emotionally attached to any language TOO much. Python/Jython is a great Swiss Army knife of a language…a great one. (Desert island…only one language…that’s the one…that territory). Java is the 800 lb gorilla…lumbering etc. but enterprise library powered. All of those language tools (from Python to Java…etc) have their appropriate applications. Sometimes they overlap with each other enough to start “language wars”. Fair enough. They are TOOLS. Not everything is a nail — you don’t always need a hammer.

1 Like

Thanks for all the answers… I can see your point @bob_dickenson :smile: - and will be more “around” with the other languages also…

A good way to start for me will then be the Python - since i’ve done some programming in that language before :smile:

By all means I think starting with Python is a good idea. There is enough to learn with OH as it is, not need to unnecessarily add yet one more thing.

However, to expand on @bob_dickenson’s post, having used it as long as I have, I am firmly of the opinion that it is a very well suited for this sort of programming. If I were king for a day the only other language I’m familiar with that I think comes close in suitability would be Erlang.

So once you get familiar with the rest of OH, give the Rules DSL a chance.

I’m an intermediate or hack coder, meaning I understand programming but have not stayed current on many fronts, but I find Xtend based openhab scripting bizarrely unsimple for home automation.

I can’t wait to get an alternative working in opanhab2.
I’m also amazed that there are alternative languages - that is amazing.

That said - I’m currently still using the xtend stuff.

In my experience when the code for my rules start to feel overly complex I have always found alternative and much simpler way to do it in the language. It follows an actor based programming approach as opposed to the more popular structural, functional, or OO approaches and I find trouble occurs when one tries to code the Rules DSL as if it were C or Java.


For a non programmer what is the first language to learn for openhab? Javascript or other?

Right now probably Python.

1 Like