[Info-vax] Python for x86?

Craig A. Berry craigberry at nospam.mac.com
Thu Apr 20 07:29:24 EDT 2023


On 4/19/23 7:27 PM, Arne Vajhøj wrote:
> On 4/14/2023 7:22 PM, Arne Vajhøj wrote:
>> On 4/14/2023 8:19 AM, Simon Clubley wrote:
>>> - Python is an excellent way to add automation/scripting capabilities to
>>> a wide range of applications.
>>>
>>> Try doing the following with Perl: :-)
>>>
>>> https://docs.blender.org/api/current/info_overview.html
>>
>> It is possible to embed Perl as well.
>>
>> I would say Perl and Python is similar in that regard.
>>
>> https://docs.python.org/3/extending/embedding.html
>>
>> https://perldoc.perl.org/perlembed
> 
> Of course JSR 223 is pretty cool in this regard.
> 
> import javax.script.ScriptEngine;
> import javax.script.ScriptEngineManager;
> import javax.script.ScriptException;
> 
> public class EmbeddedScript {
>      public static void test(String language, String source) throws 
> ScriptException {
>          System.out.println(language + ":");
>          System.out.print(source);
>          ScriptEngineManager sem = new ScriptEngineManager();
>          ScriptEngine se = sem.getEngineByName(language);
>          se.eval(source);
>      }
>      public static void main(String[] args) throws ScriptException {
>          test("javascript", "for(i = 0; i < 3; i++) {\r\n" +
>                             "    print(\"Hi from JavaScript!\")\r\n" +
>                             "}\r\n");
>          test("python", "for i in range(3):\r\n" +
>                         "    print(\"Hi from Python!\")\r\n");
>          test("ruby", "for i in 1..3 do\r\n" +
>                       "    puts 'Hi from Ruby!'\r\n" +
>                       "end\r\n");
>          test("php", "<?php\r\n" +
>                      "for($i = 0; $i < 3; $i++) {\r\n" +
>                      "    echo \"Hi from PHP!\\r\\n\";\r\n" +
>                      "}\r\n" +
>                      "?>\r\n");
>          test("groovy", "for(i in 1..3) {\r\n" +
>                         "    println \"Hi from Groovy!\"\r\n" +
>                         "}\r\n");
>          test("perl", "for(1..3) {\r\n" +
>                       "    print(\"Hi from Perl!\\n\");\r\n" +
>                       "}\r\n");
>          test("lua", "for i = 1,3\r\n" +
>                      "do\r\n" +
>                      "    print(\"Hi from Lua!\")\r\n" +
>                      "end\r\n");
>          test("Lisp", "(dotimes (n 3)\r\n" +
>                       "    (format t \"Hi from Lisp!~%\"))\r\n");
>          test("tcl", "for {set i 0} {$i < 3} {incr i} {\r\n" +
>                       "    puts \"Hi from Tcl!\"\r\n" +
>                       "}\r\n");
>      }
> }
> 
> outputs:
> 
> javascript:
> for(i = 0; i < 3; i++) {
>      print("Hi from JavaScript!")
> }
> Hi from JavaScript!
> Hi from JavaScript!
> Hi from JavaScript!
> python:
> for i in range(3):
>      print("Hi from Python!")
> Hi from Python!
> Hi from Python!
> Hi from Python!
> ruby:
> for i in 1..3 do
>      puts 'Hi from Ruby!'
> end
> Hi from Ruby!
> Hi from Ruby!
> Hi from Ruby!
> php:
> <?php
> for($i = 0; $i < 3; $i++) {
>      echo "Hi from PHP!\r\n";
> }
> ?>
> Hi from PHP!
> Hi from PHP!
> Hi from PHP!
> groovy:
> for(i in 1..3) {
>      println "Hi from Groovy!"
> }
> Hi from Groovy!
> Hi from Groovy!
> Hi from Groovy!
> perl:
> for(1..3) {
>      print("Hi from Perl!\n");
> }
> Hi from Perl!
> Hi from Perl!
> Hi from Perl!
> lua:
> for i = 1,3
> do
>      print("Hi from Lua!")
> end
> Hi from Lua!
> Hi from Lua!
> Hi from Lua!
> Lisp:
> (dotimes (n 3)
>      (format t "Hi from Lisp!~%"))
> Hi from Lisp!
> Hi from Lisp!
> Hi from Lisp!
> tcl:
> for {set i 0} {$i < 3} {incr i} {
>      puts "Hi from Tcl!"
> }
> Hi from Tcl!
> Hi from Tcl!
> Hi from Tcl!
> 
> PS: You need ABCL, GHroovy, JACL, JRuby, LuaJ, Perlito5 and Quercus
>      in classpath.
> 
> PPS: Some of the script code may not be optimal - I am not
>       familiar with all the languages.
> 
> PPPS: everything is pure Java and should run fine on VMS Itanium
>        and in the future VMS x86-64 (Java 1.5 on VMS Alpha is too old
>        for some of these).

Seems odd to omit BeanShell from a list of embedded scripting
capabilities based on Java:

<https://github.com/beanshell/beanshell>


I think Java people often prefer to do their scripting in a subset of
Java rather than some other language.



More information about the Info-vax mailing list