photools.com Community

IMatch Discussion Boards => IMatch Scripting and Apps => Topic started by: ggblue on July 25, 2018, 01:41:57 PM

Title: Scripting with Javascript or Python (or..) ?
Post by: ggblue on July 25, 2018, 01:41:57 PM
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
Title: Re: Scripting with Javascript or Python (or..) ?
Post by: Mario on July 25, 2018, 01:51:33 PM
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.
Title: Re: Scripting with Javascript or Python (or..) ?
Post by: thrinn on July 25, 2018, 06:10:03 PM
Just to add my very personal opinion:
But in the end, IMatch can be used with nearly all languages that are able to use Web Services.
Title: Re: Scripting with Javascript or Python (or..) ?
Post by: Mario on July 25, 2018, 06:28:37 PM
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 (https://nodejs.org/en/). A perfect environment for small scripts, micro services, and more.

In combination with a software like Electron (https://electronjs.org/) you can write "real" Windows / Linux apps with Node.js.

See the Match Help System App (https://www.photools.com/imatch-help-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.
Title: Re: Scripting with Javascript or Python (or..) ?
Post by: ggblue on July 25, 2018, 09:48:02 PM
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...).