On 17/05/2018 18:19, Steven D'Aprano wrote:
On Thu, 17 May 2018 15:50:17 +0100, bartc wrote:
Of course, full-on Python code is pretty much impossible to port
anywhere else anyway.
*rolls eyes*
Any pair of languages will have code that is hard to port from one to the
other without jumping through hoops. Try porting C code with lots of
dynamic memory allocations and pointer accesses to COBOL, or Scheme code
using continuations to Python, or Hyperscript text chunking code to
Fortran.
But hard does not mean "pretty much impossible".
Normally you'd use the source code as a start point. In the case of
Python, that means Python source code. But you will quickly run into
problems because you will often see 'import lib' and be unable to find
lib.py anywhere.
That's one problem. Others might involve how to deal with something like
__globals__ which doesn't have an equivalent in the target language. And
we haven't started on features that are specific to Python.
But most non-esoteric languages will have functions, variables,
assignments, expressions, loops and so on. The basics. Algorithms
expressed using those will be simplest to port.
When I was looking at benchmarks involving multiple languages and wanted
to port one to a new language, I usually ended up working from Pascal or
Lua because they tended not to use advanced features that made the job
harder.
--
bartc
--
https://mail.python.org/mailman/listinfo/python-list