Exchange Resource to use Javascript with Perspective

Would IA consider something like Brython to bridge the gap between Python and JS?

1 Like

Having never heard of Brython, my first thought was that it was using an approach like Pyodide, that is, using WASM, but actually it's relying on on-the-fly transpilation of (pure) Python code to JS... so with Brython you've got:

  1. The same compatibility limitations as Jython (no C extensions, reliant on an external translation layer understanding each new Python version's syntax)
  2. A similar maintenance situation (we'd be relying on the brython-dev organization, which doesn't accept external funding)
  3. A 'fractal' scripting language(s) problem. Brython is Python 3, so wouldn't be able to run in Vision or anywhere on the Gateway - only in the browser. So we'd be introducing Python 3...except, not everywhere :smile:

Basically: It's a really hard problem.

This is still the future I'm most optimistic for. WebAssembly gets better every day, and is close to being "mainstream" usable. It's also got great third party momentum behind it - every major browser supports it, it's not owned by a single organization, etc. It also addresses some significant security concerns with the current "just blindly run code authored in the Designer on the Gateway" model, with restricted access to external interfaces and built-in limitations on memory usage and runtime. With WASM, we'd be able to offer a parallel (Jython will almost certainly never go away, for backwards compatibility reasons, but may in some distant future be disabled by default) execution environment that's polyglot - if you want to write JS, you can, and we'll run it on the backend or on the frontend as appropriate. If you want to use Python 3, you can. If you want to use Kotlin, you can. And so on, and so on. There will probably be one or a few "blessed" languages we provide documentation examples in, but if we get to that point, there's probably no point in preventing end uses from making those choices.

However, all of this is still very much theoretical, with absolutely no timeline to implement nor guarantee it even will happen as I've described here.

6 Likes

I agree with you on the limitations (and personally I'd accept #1 as it's no different than what we already have), although I wasn't necessarily talking about directly plugging Brython into Ignition, more the general concept of having a Python 2.7 to JS parser (in-house dev) so users could use a familiar syntax for client-side scripting.

Of course that's a whole extra thing to develop and support so I don't blame y'all for saying no right now :sweat_smile:

EDIT: I can already imagine all the forum posts and support tickets for "why can't I use system.foo.bar() from the Perspective Client Scripting component" :laughing:

2 Likes

Is it possible to make an expression language so powerful that you won't need another one?

In game development, for ease of use, visual scripting languages are used. In Unreal Engine, they utilize Blueprints and Unity offers Unity Visual Scripting. Which is allowing non-programmers, such as art teams, to do some work. However, the backbone of these engines remains C++/C#.

Is it feasible to have something similar in Java? I suppose it's a long shot.

3 Likes

An expression language powerful enough to encompass all other languages would be a purely functional language. Lisp is fun, and Haskell's cool, but how many new projects are getting made in them?

Making an "IAScript" or whatever bespoke general purpose language has been floated as well... but it has lots of the same problems, plus it's an ongoing maintenance debt for us to manage.

1 Like

I've thought about this at times as well... or just using Lua.

What's special about Python (though rapidly becoming less special because we're stuck on Jython 2.7) is/was the vast ecosystem of libraries you are/were able to use.

4 Likes

I can only imagine the mess this will create with answering posts on the forum :grimacing:

"Well... to do it in JS, do this
Python3, like this
Kotlin, like this
Rust, like this
Go, like this
YoMamma, like this :wink: "

9 Likes

While this is true, the nice thing is that syntax really isn't that different between most "mainstream" languages right now. It's not Lisp or Haskell or APL or Brainfuck :joy:

4 Likes