Recent

Author Topic: Interoperability between Electron JS and native Pascal  (Read 498 times)

setghm

  • Newbie
  • Posts: 4
Interoperability between Electron JS and native Pascal
« on: February 16, 2025, 05:24:49 am »
Hi guys, I'm currently looking into how ElectronJS projects made with Lazarus work and found this on the official wiki:

Quote
To run it you must compile all three projects to create the three needed js files.
https://wiki.freepascal.org/pas2js_Electron_Web_Application

So does this mean that all the pascal code is transpiled into javascript files?

If so, my question is if there is any way to make interoperability between Pascal and Javascript, since I would like to make a project that uses native libraries like JwaWinsock2 and Sockets while creating a web interface for a desktop application.


Thaddy

  • Hero Member
  • *****
  • Posts: 16652
  • Kallstadt seems a good place to evict Trump to.
Re: Interoperability between Electron JS and native Pascal
« Reply #1 on: February 16, 2025, 06:14:20 am »
In this case , Yes, the pascal code becomes javascript.
It is not really recommended to combine that with native units and that again n.b. Windows only units? Makes no sense..
You'd better use the network stack of Node.js or a browser.
Node.js is great for making desktop applications like you want and these would be true cross plastform.
You can use Node.js for both the client-side as the server-side.
But you can also force a browser in kiosk mode with much the same effect.
If you want scalable web applications, server or client, to a Pascal programmer the combination of Node.js and Pas2js is a marriage made in heaven.
« Last Edit: February 16, 2025, 06:30:04 am by Thaddy »
But I am sure they don't want the Trumps back...

Thaddy

  • Hero Member
  • *****
  • Posts: 16652
  • Kallstadt seems a good place to evict Trump to.
Re: Interoperability between Electron JS and native Pascal
« Reply #2 on: February 16, 2025, 01:11:53 pm »
Forgot to add that the native Windows code you want to use has no speed advantage over the node.js network stack at all. The opposite is true: node.js and sockets.io are quite a bit faster.
But I am sure they don't want the Trumps back...

setghm

  • Newbie
  • Posts: 4
Re: Interoperability between Electron JS and native Pascal
« Reply #3 on: February 16, 2025, 07:09:37 pm »
This Python project does exactly what I would like to do in Pascal: create a web interface while using all the capabilities of the "native" language.

https://github.com/python-eel/Eel

setghm

  • Newbie
  • Posts: 4
Re: Interoperability between Electron JS and native Pascal
« Reply #4 on: February 16, 2025, 07:17:23 pm »
In this case , Yes, the pascal code becomes javascript.
It is not really recommended to combine that with native units and that again n.b. Windows only units? Makes no sense..
You'd better use the network stack of Node.js or a browser.
Node.js is great for making desktop applications like you want and these would be true cross plastform.
You can use Node.js for both the client-side as the server-side.
But you can also force a browser in kiosk mode with much the same effect.
If you want scalable web applications, server or client, to a Pascal programmer the combination of Node.js and Pas2js is a marriage made in heaven.

Well, that's a good point, although I think that if I have to learn how to use the NodeJS API in Pascal that is going to be transpiled to Javascript it would be better to use JS directly.
Ok, maybe in the sense of writing the cleanest code as it is done with Typescript but that is not what I am looking for, which is to use all the capabilities of the language that I am going to use.
And well, the thing is that I would not only like to use network units like JwaWinsock2 and Sockets but I would also like to use other units and functions of the language, for example to manage hardware and to process files, all this showing a graphical interface written with HTML and CSS.
Of course, NodeJS may already have its own implementation of these features, but again, if I am going to transpile my Pascal code to Javascript, then it would be better to use the NodeJS ecosystem directly.

I hope I made myself clear. Thanks.  :)
« Last Edit: February 16, 2025, 07:20:46 pm by setghm »

setghm

  • Newbie
  • Posts: 4
Re: Interoperability between Electron JS and native Pascal
« Reply #5 on: February 16, 2025, 07:29:12 pm »

 

TinyPortal © 2005-2018