[SOLVED] Jython on docker?

@marcel_erkel yeah, client did the trick. I guess docs would need some update here and there to get it sorted for wide crowd of people :wink:

just for my curiosity… what’s benefits of jsr over dsl?
Am not judging anything, but tinkering with very common example of Time Of Day (DP): DSL and JSR

  1. DSL version is shorter (40ish lines vs. 60ish + config)
  2. DSL version looks way lighter in terms of cpu usage
  • dsl takes 1 core at max 20% for second
  • jsr takes 2 cores at 74% and 80% for 2seconds
  1. DSL version is much more user friendlier in terms of “programming skills” – which can be solved by some kind of GUI sure.
    and this being said by someone who programs in python quite often, this jython feels bit messy especially at the begining where you need to know what to import from where somehow
  2. instalation and configuration is simply not yet there, yes can be done, but it’s not really straight and not for regular Joe at least.

This is not indeed exact, but … what’s the deal here?

no flame, just genuine question

I feel limited by the DSL. Jython gives me the option to use functions, classes, add python libraries using pip. It’s much more normal programming.

Code reuse also is much simpler:

(I probably need to update that topic due to the changes since 2.5.0.M1)

I don’t really know the ToD implementations so I can’t comment on why the DSL version uses less lines of code than the Jython version and why it apparently uses more CPU (there is a thread here on the forum which shows the opposite… I don’t really care as long as I don’t notice it).

When using the official openHAB Docker container, all that is needed to install Jython and the openHAB helper libraries is to download two files to the /etc/cont-init.d directory and restart the container. It doesn’t get much simpler than that (this is PR Scott referenced).

But if you prefer the DSL that’s fine with me :slight_smile:

yeah I clearly get some advantages of having ability to import stuff and use whole programming environment as such… but if we take OH rules as something what should drive internal stuff, I don’t see much need for it. eg. yes for programmers which likes to tinker around the code all the time.
But for non-programming people this looks bit harsh. Different story would be if there will be some intuitive gui on top of that maybe.

What I was really surprised is how it performed to achieve very same stuff, where dsl in my test case was more than twice as fast as jsr.
And frankly, working with classes is not for everyone, reusable code is nice, but usual OH implemetantion probably does not normally need it anyways.

anyway, beside documentation and some stuff on this forum, where I can find out which parts of OH engine should I import to work with items, triggers, rules, states etc.? is there anywhere some kind of complex doc or is it something which is currently work in progress?

as I said, I would like to give it a shot, as I know python well. Yet jython feels bit ugly for me still, so I guess need to give it some time.

I use Python elsewhere without classes. I expect I can use Jython too but I just installed it last night and have not yet tried it.

1 Like

sure, you indeed can