Recent

Author Topic: RANT: Python (it's not funny)  (Read 6258 times)

MarkMLl

  • Hero Member
  • *****
  • Posts: 6676
RANT: Python (it's not funny)
« on: January 12, 2021, 03:25:56 pm »
I find myself dithering over debugging some software written in Python, which hides behind Electron as the user interface. In part this is due to unfamiliarity with the available tools, and in part due to a nagging feeling that implementing a plugin- no matter how clever the algorithms- by embedding a web browser (and repeating this for /every/ plugin for a particular program) is a trifle profligate.

I find that I'm not the only person to have misgivings: https://drewdevault.com/2016/11/24/Electron-considered-harmful.html but Liam puts it fairly succinctly:

Quote
> You remind me of something I looked at a while ago.
>
> I noted some things that might be quite doable in the browser, or as a
> browser add-on. I had been looking for a reason to play with Python. I
> don't really want to learn Javascript. So I discovered someone had
> created a way to write Firefox plugins in Python.
>
> That sounds good, I thought. Just the ticket.
>
> I had a look.
>
> Yes, it was a tiny Javascript plugin that embedded an entire Python
> interpreter and then another, bigger Javascript program that translated
> Python calls to Firefox calls, and it would have to be embedded into
> your addon. So your 2 kB Python addin would need a 300MB wrapper to
> work, and would thus end up considerably larger than the browser itself.
>
> I am not sure now but they might have ported Python to Javascript in
> order to do it.
>
> "Perhaps not, eh?" I thought as I metaphorically backed away.

No matter how much we all loathe Python, it seems to me that using Lazarus's technology to provide an efficient wrapper UI instead of Javascript and HTML5 would be generally useful.

The same, potentially, could be said about a Lazarus wrapper about C++ code. And refusing to countenance this due to a difference in stackframe use etc. is a pretty lame excuse IMO and will contribute to Pascal's continued slide towards irrelevance.

MarkMLl
MT+86 & Turbo Pascal v1 on CCP/M-86, multitasking with LAN & graphics in 128Kb.
Pet hate: people who boast about the size and sophistication of their computer.
GitHub repositories: https://github.com/MarkMLl?tab=repositories

lainz

  • Hero Member
  • *****
  • Posts: 4460
    • https://lainz.github.io/
Re: RANT: Python (it's not funny)
« Reply #1 on: January 12, 2021, 03:53:03 pm »
Well you can create a local server with Lazarus, create endpoints, and create the GUI with web technologies.

Start the .exe and that opens in your default browser. Yo can work with files and databases. All in the user PC.

MarkMLl

  • Hero Member
  • *****
  • Posts: 6676
Re: RANT: Python (it's not funny)
« Reply #2 on: January 12, 2021, 04:23:45 pm »
Who in God's name needs a browser in order to display a progress bar, half a dozen buttons and some non-interactive vector graphics?

MarkMLl
MT+86 & Turbo Pascal v1 on CCP/M-86, multitasking with LAN & graphics in 128Kb.
Pet hate: people who boast about the size and sophistication of their computer.
GitHub repositories: https://github.com/MarkMLl?tab=repositories

lainz

  • Hero Member
  • *****
  • Posts: 4460
    • https://lainz.github.io/
Re: RANT: Python (it's not funny)
« Reply #3 on: January 12, 2021, 04:28:21 pm »
Who in God's name needs a browser in order to display a progress bar, half a dozen buttons and some non-interactive vector graphics?

MarkMLl

Well, no, not that simple UI. I mean an UI that's good =)

MarkMLl

  • Hero Member
  • *****
  • Posts: 6676
Re: RANT: Python (it's not funny)
« Reply #4 on: January 12, 2021, 07:43:25 pm »
But in this context "good" UIs aren't needed... I'm talking about an Inkscape plugin here that really doesn't have a UI to speak of.

Oh, and I'd settle for something that takes less than a minute to start up. Because having to wait 70 secs or so for. every. operation. "get's old fast" as they say.

MarkMLl
MT+86 & Turbo Pascal v1 on CCP/M-86, multitasking with LAN & graphics in 128Kb.
Pet hate: people who boast about the size and sophistication of their computer.
GitHub repositories: https://github.com/MarkMLl?tab=repositories

lainz

  • Hero Member
  • *****
  • Posts: 4460
    • https://lainz.github.io/
Re: RANT: Python (it's not funny)
« Reply #5 on: January 12, 2021, 10:16:20 pm »
I can see me in the future, why do you need 'X' stuff, if you can use Electron or a web app? Web apps are not old...  :D That 'X' stuff at least takes a GB of file download, just for uxing 'XZ' language.

Yep, we're all getting older, all will be replaced with something else.

Why do you need Inkscape? If there are web apps that does the same vector stuff online? Why downloading Inkscape...  :D

(Justk joking, I use Inkscape, but I've seen web apps that does vector too).

MarkMLl

  • Hero Member
  • *****
  • Posts: 6676
Re: RANT: Python (it's not funny)
« Reply #6 on: January 12, 2021, 10:20:46 pm »
Because of the plugin (Inkstitch). Which I'm trying to debug, to find out why it takes 70 secs to run (short answer: CJK founts. Longer answer: what can be done about it?).

I've just had a thoroughly frustrating early-evening trying to get enough Python, Electron, NPM and GOK what else installed that I have some chance of debugging it. There's got to be a better way...

MarkMLl
MT+86 & Turbo Pascal v1 on CCP/M-86, multitasking with LAN & graphics in 128Kb.
Pet hate: people who boast about the size and sophistication of their computer.
GitHub repositories: https://github.com/MarkMLl?tab=repositories

lainz

  • Hero Member
  • *****
  • Posts: 4460
    • https://lainz.github.io/
Re: RANT: Python (it's not funny)
« Reply #7 on: January 12, 2021, 10:37:42 pm »
Do you have an SSD drive? Or a hard disk?

Usually Electron and all the like takes time to load from disk, if you use an SSD you have better startup times.

Edit: I can say that is true, because LazPaint uses python for scripting, when I had an HDD it was slower, now with an SSD runs really fast. Remember that scripting is usually running a command line process...
« Last Edit: January 12, 2021, 11:45:13 pm by lainz »

MarkMLl

  • Hero Member
  • *****
  • Posts: 6676
Re: RANT: Python (it's not funny)
« Reply #8 on: January 13, 2021, 09:59:00 am »
Disk. Most of that particular problem is fixed by removing the CJK founts. All of the Python stuff is bundled up into some sort of binary with Electron, I'm currently trying to sort out the details.

Granted that the plugin author has pulled in a vast amount of stuff from other open source projects- I can even see some FORTRAN in there- but there has to be a better way.

MarkMLl
MT+86 & Turbo Pascal v1 on CCP/M-86, multitasking with LAN & graphics in 128Kb.
Pet hate: people who boast about the size and sophistication of their computer.
GitHub repositories: https://github.com/MarkMLl?tab=repositories

lainz

  • Hero Member
  • *****
  • Posts: 4460
    • https://lainz.github.io/
Re: RANT: Python (it's not funny)
« Reply #9 on: January 13, 2021, 04:47:42 pm »
Too much megabytes in fonts being loaded into memory?

And not ever used?

Well yes that is a problem indeed.

MarkMLl

  • Hero Member
  • *****
  • Posts: 6676
Re: RANT: Python (it's not funny)
« Reply #10 on: January 13, 2021, 04:56:59 pm »
And the rest. A vague recollection of the messages suggest that the two CJK packages were taking in excess of 300Mb on disc, and even somebody who like me appreciates pretty typefaces has to wonder why that lot's being installed for a European- sorry, BRITISH (now that we've Brexited) locale. Then there's the convenient-but-inefficient plugin mechanism which runs a program from scratch for every operation, and the inefficient-and-inconvenient architecture based on Python+Electron.

I can't comment on how difficult it would be to integrate a modified FPC+LCL runtime with Inkscape, since there appears to be no recent documentation of the interfaces.

MarkMLl
« Last Edit: January 13, 2021, 05:05:36 pm by MarkMLl »
MT+86 & Turbo Pascal v1 on CCP/M-86, multitasking with LAN & graphics in 128Kb.
Pet hate: people who boast about the size and sophistication of their computer.
GitHub repositories: https://github.com/MarkMLl?tab=repositories

lainz

  • Hero Member
  • *****
  • Posts: 4460
    • https://lainz.github.io/
Re: RANT: Python (it's not funny)
« Reply #11 on: January 14, 2021, 02:00:37 am »
Yeah so the problem was not the tools, but how these are being used.

Edit: you can bring some links so we can look at? I use inkscape for fun and sometimes for work, mostly icons.

What kind of plugin you want to make? The same plugin but in fpc?
« Last Edit: January 14, 2021, 03:45:48 am by lainz »

MarkMLl

  • Hero Member
  • *****
  • Posts: 6676
Re: RANT: Python (it's not funny)
« Reply #12 on: January 14, 2021, 09:48:38 am »
I'm inclined towards the viewpoint that this amount of overhead is a tools problem, not just one of inappropriate use. And I'm not trying to rewrite it, merely fix a couple of the problems. https://inkstitch.org/

MarkMLl
MT+86 & Turbo Pascal v1 on CCP/M-86, multitasking with LAN & graphics in 128Kb.
Pet hate: people who boast about the size and sophistication of their computer.
GitHub repositories: https://github.com/MarkMLl?tab=repositories

PascalDragon

  • Hero Member
  • *****
  • Posts: 5446
  • Compiler Developer
Re: RANT: Python (it's not funny)
« Reply #13 on: January 14, 2021, 09:53:57 am »
I'm inclined towards the viewpoint that this amount of overhead is a tools problem, not just one of inappropriate use. And I'm not trying to rewrite it, merely fix a couple of the problems. https://inkstitch.org/

I really hope that this year I'll be able to build my "embroidery addon" for my sewing machine, then I'll probably play around with inkstitch as well ;)

MarkMLl

  • Hero Member
  • *****
  • Posts: 6676
Re: RANT: Python (it's not funny)
« Reply #14 on: January 14, 2021, 10:12:31 am »
I really hope that this year I'll be able to build my "embroidery addon" for my sewing machine, then I'll probably play around with inkstitch as well ;)

https://github.com/MarkMLl/pesdump might have some useful stuff. I've since attempted to modify it to patch files but it turns out that the Brother machine I have access to is /very/ picky about having everything consistent... I can trivially crash its firmware resulting in a (watchdog?) reset.

A great deal of work's gone into Inkstitch... lots of people (including Torvalds) appear to have dipped their toe in the water but I think it's the most mature project by far. And compared with the cost of Brother's own software it's worth supporting (you can get "informal copies" cheaply, but they're NBG without one of Brother's dongles).

I'm still trying to work out how things hang together, but with the number of things that take plugins these days I'd have thought that there would be a niche for a good development too which allowed the appropriate DLL/so/binary to be customised.

(Slightly later) Extension invocation is described at https://inkscape.org/develop/extensions/ although I've yet to work out how an extension modifies the live image.

Considering some stuff I've done in the past where a communications program could invoke a nested shell, hence a copy of Lazarus, hence debug a nested copy of itself, I find myself wondering whether a facility whereby Lazarus could be invoked in lieu of a program to be debugged and would transparently pass on all (shell) variables, (command line) parameters and open handles (in particular stdin and stdout) would be useful.

That would allow somebody working on something like an Inkscape extension to switch between running his binary and running the full development environment with a one-line change to a configuration file (Inkscape .inx file in the current case). https://wiki.inkscape.org/wiki/index.php?title=Script_extensions

MarkMLl


« Last Edit: January 14, 2021, 12:05:36 pm by MarkMLl »
MT+86 & Turbo Pascal v1 on CCP/M-86, multitasking with LAN & graphics in 128Kb.
Pet hate: people who boast about the size and sophistication of their computer.
GitHub repositories: https://github.com/MarkMLl?tab=repositories

 

TinyPortal © 2005-2018