Consider using bytecode instead of AST
almarklein opened this issue · 0 comments
almarklein commented
Currently, PScript
parses the Python AST to generate JavaScript. It may be advantageous to use bytecode instead. Considerations:
- Bytecode is also also available in frozen applications (currently, the source code must always be available in order to obtain the AST).
- Bytecode is not standardized and changes per Python version (and implementation, e.g. Pypy). It's probably not too hard to keep up to date each version, and the AST suffers a similar fate except that its specified better.
- With bytecode it's easier to trace the flow of the program, making type inference much easier, so it might work well for #4
- Bytecode is lower-level, and we'd mis out on a the higher level "structure" of the code that the AST provides. We'd have to do some research to see if this is a problem.
- A change like this is so profound (and so much work) that it should probably just be a new project.
- A change like this should probably be part of a larger initiative to make the language typed (with inference), and more predictable (maybe more Pythonic, but at the least far less JS surprises).