py/js parralel examples/course?
Hi, Currently at high-school senior classes programing is taught in C/C++ (in my country, Lithuania). This is mostly because graduation-exams are allowed to be taken with it (and programming olympiads, though now they allow py <https://olympiad.org.za/programming-olympiad/rules/>). And teachers are used to it and have dedicated textbooks. But it is kind of clumsy for learning basics - py/js are much more popular and fun for that. Python mostly rocks for its syntax, and JS for its application in web-dev. Few personal initiatives are to moderninze the content. But most of them from C-syntax world -- Java/C#/JS, and few Py. *I think best would be to make a course/textbook with parallel code examples for JS/PY *(maybe some version with C/C++ for reference - for teachers to be easier to switch) Parallel JS-PY is also possible with some edu-environments: blockly/processing/reeborg *Maybe you know of any such courses -- for programming basics?* ps.: I tried to put up simple <http://codeintro.popo.lt/2015/10/14/pazintis-su-programavimu-1-veiksmai-ir-s...> example/article <http://codeintro.popo.lt/2015/10/14/pazintis-su-programavimu-1-veiksmai-ir-s...> how it could look like (in my native lang). -- Jurgis Pralgauskis tel: 8-616 77613; Don't worry, be happy and make things better ;) https://galvosukykla.wordpress.com/
found simple example of Scratch-PY https://learn.edublocks.org/tutorial/home-learning#2 https://edublocks.org/Basic-Coding-Set.pdf and in kind of direct python in blocks https://app.edublocks.org/#Python On Thu, Oct 8, 2020 at 6:05 AM Jurgis Pralgauskis < jurgis.pralgauskis@gmail.com> wrote:
Hi,
Currently at high-school senior classes programing is taught in C/C++ (in my country, Lithuania). This is mostly because graduation-exams are allowed to be taken with it (and programming olympiads, though now they allow py <https://olympiad.org.za/programming-olympiad/rules/>). And teachers are used to it and have dedicated textbooks.
But it is kind of clumsy for learning basics - py/js are much more popular and fun for that. Python mostly rocks for its syntax, and JS for its application in web-dev.
Few personal initiatives are to moderninze the content. But most of them from C-syntax world -- Java/C#/JS, and few Py.
*I think best would be to make a course/textbook with parallel code examples for JS/PY *(maybe some version with C/C++ for reference - for teachers to be easier to switch) Parallel JS-PY is also possible with some edu-environments: blockly/processing/reeborg
*Maybe you know of any such courses -- for programming basics?* ps.: I tried to put up simple <http://codeintro.popo.lt/2015/10/14/pazintis-su-programavimu-1-veiksmai-ir-s...> example/article <http://codeintro.popo.lt/2015/10/14/pazintis-su-programavimu-1-veiksmai-ir-s...> how it could look like (in my native lang).
-- Jurgis Pralgauskis tel: 8-616 77613; Don't worry, be happy and make things better ;) https://galvosukykla.wordpress.com/
-- Jurgis Pralgauskis tel: 8-616 77613; Don't worry, be happy and make things better ;) https://galvosukykla.wordpress.com/
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
# 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-s... - `%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.urner@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
- 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.turner@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-s... - `%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.urner@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
On Wed, Oct 7, 2020 at 8:06 PM Jurgis Pralgauskis < jurgis.pralgauskis@gmail.com> wrote:
*I think best would be to make a course/textbook with parallel code examples for JS/PY *(maybe some version with C/C++ for reference - for teachers to be easier to switch) Parallel JS-PY is also possible with some edu-environments: blockly/processing/reeborg
In py-js web development json is an important connection/bridge between the two languages: py-server <- {json-serialized-py-dict} <-> network <-> {json-serialized-js-object} -> browser
participants (4)
-
C. Cossé
-
Jurgis Pralgauskis
-
kirby urner
-
Wes Turner