Python Vs JAVA for sikuli scripting

Asked by Prateek Sahu

Currenty I am using Python for sikuli scripting...

Is it possible that I may switch to JAVA

which one will be better???
and If I wish to use JAVA for scripting...
will it be possible to run that script using Jython interpreter...

Question information

Language:
English Edit question
Status:
Solved
For:
SikuliX Edit question
Assignee:
No assignee Edit question
Solved by:
RaiMan
Solved:
Last query:
Last reply:
Revision history for this message
Best RaiMan (raimund-hocke) said :
#1

-- If I wish to use JAVA for scripting
Java itself is not a scripting language, it is principally a compiled language and the resulting byte code is run with the JVM.
So you might use Java in any runnable fashion and use Sikuli's Java API, to access the Sikuli features.

-- which one will be better???
Sinced this depends on many aspects, the question cannot be answered. Principally scripting is "better" for rapid development or "quick-and-dirty" solutions (scripting languages that are nearer to Java are e.g. Scala or Groovy). Other scripting languages like Jython or JRuby have their own grammar, that is not Java compatible, but allow to seamlessly access and use any Java classes, that are made available somehow.

-- will it be possible to run that script using Jython interpreter
plain Java code: no (principally spoken, but there are "complex" possibilities)
You have to pack your features into Java classes, that you can import and use in a Jython script.
One example might be the unit test feature, that selects some test cases from test case classes and runs them using a test runner.

So both in Java and Jython you need at least:

import myClasses;
myClasses.run(some, parameters, given);

Supposing myClasses can be found on Java class path, this should run both in Java (you still need a main class and a compile-and-run) and in Jython.

Revision history for this message
Prateek Sahu (prateek-sahu01apr) said :
#2

Thanks RaiMan, that solved my question.