Scripting with Javascript or Python (or..) ?

Started by ggblue, July 25, 2018, 01:41:57 PM

Previous topic - Next topic

ggblue

Hi folks,

some days before I have installed the new-new version of imatch (2018) with a
modern state of the art scripting environment.

But... My old stable IM 5.7 time-saving workflow (similar to the old-state sinus / gamb WF)
needs now a ticket to the future.

This means investing a lot of work and time.
Drinkin' too much coffee and get too less sleep.
But that's ok because of the benefits in advance.

To come to the right funamental decisions before I start I have some questions:

1. Which scripting language is recommendable for the back-end scripts?
    Javascript is more recommended for front-end works in combination with HTML.
    Python is recommended for the back-end and shall have a better language design, a better debugger and a complete std-lib.

2. Has anyone experiences in programming with python?
    Are IDE's for Python recommended?
    Which Python release should I take?

3. Which decision is better for working offline (no Internet... sometimes that happens)?

4. Last but not least:
    Any reasons for starting with Javacript?
    Which codebase (python or javascript) has more future (e.g. IMATCH 2020)?

I am not a bloody beginner in programming. But my primary coding skills are in the Mainframe World (Cobol, PL/1 and a bit JEE).
So I'd have to settle into Javascript as well as in Python. This makes for me no difference.

Thanks in advance for your opinions and tips!
ggblue

Mario

Which type of "scripts" do you plan to write?

The native scripting environment for IMatch is modern JavaScript and HTML 5. That's what's driving IMatch apps.
There are excellent tools, the debuggers in browsers are great etc. Very convenient and fast development environment.
I assume you have studied the IMatch Developer Center so you are aware of the options and tools. If not, start here:

https://www.photools.com/developer-center/

There is no "back end" in IMatch.
You can access your database also via IMWS (the one embedded in IMatch or the standalone version included in IMatch Anywhereâ„¢).
And then you can use any language you like. Most languages allow you to utilize web services like IMWS. Python, Go, C#. PHP, , Java, Koitlin, ...whatever suits you best.

You can work very comfortably with Python and JavaScript in Visual Studio Code. Many plug-ins, built in debugger etc.
-- Mario
IMatch Developer
Forum Administrator
http://www.photools.com  -  Contact & Support - Follow me on 𝕏 - Like photools.com on Facebook

thrinn

Just to add my very personal opinion:

  • If you are new to JavaScript and Python you might consider that it is maybe easier to learn just one new language instead of two. I suspect you can not totally avoid using JavaScript because IMatch Apps make heavy use of HTML5 and JavaScript.
  • Most of the examples that Mario supplies with IMatch are using JavaScript. These examples are immensely helpful to understand how to write Apps for IMatch.
  • I have no experience with Python so I can not comment on the language design or if Python is better suited for the "backend". Or what exactly would be considered "backend" programming in the IMatch context. But JavaScript has evolved quite a lot from the beginnings as a browser-only (frontend) script language.
  • While their are some posts on programming IMatch in Python or other languages, the vast majority of script related posts is centered around JavaScript. So, if you have any questions (and I for my part had a LOT of questions when I started with Apps in IMatch!), chances are better to get help from other users when you use JavaScript.
But in the end, IMatch can be used with nearly all languages that are able to use Web Services.
Thorsten
Win 10 / 64, IMatch 2018, IMA

Mario

#3
Python is a great language. I use it myself to automate thigns, for DevOs and other things. But you cannot do "front end" with Python. And you cannot run Python scripts "in" IMatch.

Server-side (no UI) code can be written in JavaScript using Node.js. A perfect environment for small scripts, micro services, and more.

In combination with a software like Electron you can write "real" Windows / Linux apps with Node.js.

See the Match Help System App for example. This app was written in TypeScript (the "better" JavaScript) with Node.js and Electron for the user interface.

All word extraction, index-building and cleanup for the table of contents and the search engine in the help system (both online and in the Help App) is performed by Python scripts.
Which run as part of the IMatch build process. The build process itself is controlled using Windows Powershell scripts, which drive external applications, compilers, Grunt and WebPack. Yay!
(Just showing off here).

I would absolutely do my first IMatch App steps in JavaScript and HTML. Easy to see what is happening in the browser, very good debuggers in both Firefox and Chrome. Once IMWS is understood, its much easier to write scripts which use it in other languages.

Learning JavaScript is not harder (or easier) than learning Python. Both are 'C'-style languages and hence many syntax elements are similar.
-- Mario
IMatch Developer
Forum Administrator
http://www.photools.com  -  Contact & Support - Follow me on 𝕏 - Like photools.com on Facebook

ggblue

Hello Mario and Thorsten,

thanks a lot for your really informative answers. My considerations go in that direction. First Javascript to get familar with the
imatch webservice. Second python for the more batch orientated parts.

My hope is to write better structured code for the complex parts in a language like python.

I'll inform you about my proceedings (and bother the forum with my questions...).