- I didn't look for JS to Python tools - https://www.amazon.com/s?k=javascript+and+python listed a few books that may be helpful; though I'm not sure if any are open source / Creative Commons
- "Think Python 2e: How To Think Like a Computer Scientist" could be ported to Python and JS (and/or translated). https://greenteapress.com/wp/think-python-2e/ - There'd need to be some sort of way to display the comparative code samples as grouped together but not with tabs. On 10/15/20, Wes Turner <wes.tur...@gmail.com> wrote: > # Python and JS resources, Jupyter notebooks and multiple languages, tools > > Both Python and JS are interpreted scripting languages. > While it is possible to compile Python and JS to machine > code instead of interpreting; > typically, Python and JS are interpreted (converted to byte code) and > then executed within a VM (Virtual Machine). > > There are many different VMs for Python and/or JS. > Python may run in the CPython, PyPy, Jython (Java), IronPython (.NET), > or Stackless Python VMs. > Javascript may run in the V8 (Chromium (Blink), Node) or Gecko (Firefox) > JS engines. > https://en.wikipedia.org/wiki/Comparison_of_JavaScript_engines > > Most server-side JS is executed in Node.js ("Node"), which is built on V8, > which is written in C++. > Most server-side Python is executed in CPython, which is written in C. > > Client-side execution may be browser-based or app-runtime-based. > Client-side JS typically executes in a browser (V8, Gecko) or in an app > runtime like Electron (Chromium & Node (v8)). > > A transpiler is a thing that transforms code written in one language to > code written in another language. > https://en.wikipedia.org/wiki/Transpiler > > For example, Babel compiles ES6+ (ECMAScript (JS)) to JS. > Python may be executed in a browser as WASM (WebAssembly) or as JS: > > - Brython is a version of Python and the Python standard library > which is manually ported to JS. > - Pyodide is a version of Python, the Python standard library, and a > number of SciPy libraries which are compiled to WebAssembly (WASM) > by emscripten (and possibly soon Clang (LLVM) instead) > so that they run in browsers. > - PScript is a transpiler and a subset of the Python language that > compiles Python to JS. > - Transcrypt is a Python to JS transpiler > > > Each of these approaches offer various opportunities to utilize and > to learn about the differences between Python and JS. > For example, the PScript intro docs mention that it's generally > faster to re-write tight-loops in raw JS. > But, while PScript does compile its own code into AMD js modules, > the python `import` operator is not yet supported. > Pyodide does not (yet?) support `import` of arbitrary modules either; > but does include many SciPy packages which are already-compiled to WASM. > > Some Jupyter notebooks could show the input JS/Python and the output > Python/JS/WASM from these tools; and maybe also a > hand-optimized/manually-ported comparative example. > > It's unfortunately probably rare to find a transpiler that produces > "idiomatic" code in the target language in many cases or even in any case. > > ## Jupyter notebooks > > There are a number of tools for publishing books from Jupyter notebooks: > - nbsphinx > - fastdoc > - jupyter-book > > There are various ways to work with multiple languages in a Jupyter > notebook: > - https://github.com/jupyterlab/jupyterlab/issues/2815 lists > - https://github.com/minrk/allthekernels > - SoS notebook > - https://github.com/jupyter/jupyter/wiki/Jupyter-kernels > - IJavascript, ITypeScript; IPyKernel (the default), xeus-python > - `conda install -c conda-forge -y nodejs` > - `%script` magic > - > https://ipython.readthedocs.io/en/stable/interactive/magics.html#cellmagic-script > - `%script bash` = `%sh` > - `%script python` = `%python` > - `%javascript` = `%js` > - `%pfile`, `%pycat` -- show a source file with syntax highlighting > - > https://ipython.readthedocs.io/en/stable/interactive/magics.html#magic-pfile > - > https://ipython.readthedocs.io/en/stable/interactive/magics.html#magic-pycat > - [ ] add a magic / parameter for JS syntax highlighting w/ Pygments > - https://gist.github.com/jiffyclub/5385501 > > > ## Tools` > > ### Brython > - Src: https://github.com/brython-dev/brython > - Docs: https://github.com/brython-dev/brython > > ### CPython > - Src: https://github.com/python/cpython > - Docs: https://docs.python.org/3/ > > ### Electron > - Wikipedia: https://en.wikipedia.org/wiki/Electron_(software_framework) > - Src: > - Docs: > > ### Pscript > - Src: https://github.com/flexxui/pscript > - Docs: https://pscript.readthedocs.io/en/latest/ > - Docs: https://pscript.readthedocs.io/en/latest/intro.htm > > ### PyJS > - Wikipedia: https://en.wikipedia.org/wiki/Pyjs > - Src: https://github.com/pyjs/pyjs > - Most recent commit: 2015 > - Docs: http://pyjs.org/ > > ### Transcrypt > - PyPI: https://pypi.org/project/Transcrypt/ > - Docs: http://www.transcrypt.org/documentation > - Docs: http://www.transcrypt.org/documentation#media > - "Feature comparison matrix of 24 browser Pythons." > https://stromberg.dnsalias.org/~strombrg/pybrowser/python-browser.html > - "4 tools to convert Python to JavaScript (and back again)." > - "Making a Webpack Python loader." > > https://medium.com/@martim00/making-a-webpack-python-loader-87215d72292e > > ### Pyodide > - Src: https://github.com/iodide-project/pyodide > - Docs: https://pyodide.readthedocs.io/en/latest/ > > ### Node.js > - Wikipedia: https://en.wikipedia.org/wiki/Node.js#Overview > - Src: https://github.com/nodejs/node > - Docs: https://nodejs.org/en/docs/ > - Docs: https://nodejs.org/api/ > > ### WebAssembly > - Wikipedia: https://en.wikipedia.org/wiki/WebAssembly > > > On 10/15/20, kirby urner <kirby.ur...@gmail.com> wrote: >> Greetings Jurgis -- >> >> I'd say the answer to only-C compsci in school, or only-Java, >> was the phenomenon of Code Schools, with their Bootcamps. >> One discovered the short cut into industry was not a compsci >> degree, but a crash course in exactly what you're saying: a >> combo of py and js. >> >> As you know es6 is looking a lot like Python. I'm coming to >> js through React world wherein a recent revolution got all >> the developers turning their classes, a new thing, transpiled >> by Babel, into functions only. You could do that now, and >> yet preserve precious state in your Component objects. Yes, >> I know, that's all JS echo chamber, as seen from the outside >> by a classical Python player. The two worlds combine through >> Redux and Django, right? Learn all that in Code School, forget >> college, and land a job. Leave compsci to the ones wanting >> to support whole new languages and so on. It's a big world >> with room for many career tracks. >> >> Because JS world has been such a moving target, and because >> textbook companies publishing to wood pulp (paper) especially >> fear obsolescence, tying the curriculum to a "for the ages" language >> has been a pretty good strategy. C isn't going anywhere, C++ >> either, and they both take you deep into the guts of the machine, >> thinking low level bits and bytes, and what better time than when >> you're still young in high school and wide open to all this new >> information. Presumably you have time to concentrate and access >> the equipment (not a given in many childhoods I realize, with many >> fighting for that privilege through adulthood). >> >> I'm not dissing the high school approach therefore, and think the >> Code School alternative has been, for many, a good compromise, >> as in "no need for more college, time to jump into industry". PY >> has proved more anchoring than JS in that it hasn't morphed so >> radically over the years. Academia has put a lot of weight on it >> and it has borne the weight well. JS inspires functions as objects >> (passable as arguments) as much as PY does. >> >> The door I've left open is for colleges and/or high schools to >> offer more tracks, a greater variety. Python has made huge >> inroads as everyone's "first language" in the curricula around >> here (less so JS, because of the reasons I mentioned -- morphing >> so fast). One needn't abandon the C/C++ track as if it's now >> obsolete. We're just not accustomed to offering so many branch >> points in early education. There's a bias around here towards >> college vs. not college bound. Anyway, long discussion and >> much that parallels what you're thinking, I'm thinking. >> >> Kirby in Portland, Oregon >> > > > -- > Wes Turner > https://westurner.org > https://wrdrd.com/docs/consulting/knowledge-engineering > -- Wes Turner https://westurner.org https://wrdrd.com/docs/consulting/knowledge-engineering _______________________________________________ Edu-sig mailing list -- edu-sig@python.org To unsubscribe send an email to edu-sig-le...@python.org https://mail.python.org/mailman3/lists/edu-sig.python.org/ Member address: arch...@mail-archive.com