←back to thread

22 points ninocan | 1 comments | | HN request time: 0s | source

Context: I was tasked with migrating a legacy workflow system (Broadcom CA Workflow Automation) to Airflow.

There are some jobs that contain rather simple JavaScript snippets, and I was trying to design a first prototype that simply takes the JS parts and runs them in a transpiler.

In this respect, I found a couple of packages that could be leveraged: - js2py: https://github.com/PiotrDabkowski/Js2Py - mini-racer: https://github.com/bpcreech/PyMiniRacer Yet, both seem to be abandoned packages that might not be suitable for usage in production.

Therefore, I was thinking about parsing and translating Javascript's abstract syntax trees to Python. Whereas a colleague suggested I bring up an LLM pipeline.

How much of an overkill that might be? Has anyone else ever dealt with a JavaScript-to-Python migration and could share heads-ups on strategies or pitfalls to avoid?

Show context
huem0n ◴[] No.43378187[source]
If you have any async JS, that's going to seriously complicate things. Theres no AST mapping for that (python async is not the same).

Pitfalls to watch our for? Tons of them. Comparison is very different, modulus is different, .sort is different, object destructuring doesn't map nicely to python, lambda's won't map nicely to python, promises won't map to python. Labelled loops won't map nicely to python.

If your JS snippets are truly simple, just LLM translate and manually check. They're pretty good at the simple stuff.

replies(1): >>43378231 #
egeozcan ◴[] No.43378231[source]
Random idea: Couldn't Babel translate async code to callbacks?
replies(1): >>43380684 #
1. rs186 ◴[] No.43380684[source]
You could if you want your codebase to be an unmanageable mess.