News for hackers. Stuff that matters.
Re:A Python-to-JavaScript Transpiler with BabelJS and Source... by fuhrysteve on Thursday March 31, 2016 @08:10AM (#11396536)
I'm a little horrified to suggest this seriously, but this could be a cool way to accomplish consistent field validation between server and client.

I wrote this little library https://github.com/fuhrysteve/marshmallow-jsonschema#complet... to convert marshmallow schemas to a JSON representation with the intention of passing it to a browser or mobile device for rendering. Imagine if you could also pass native code to be used by the client for validation. In other words: write your validator in python and use it server side - but also convert it to javascript so that the client can attempt to validate it before bothering to send a web request.

Re:A Python-to-JavaScript Transpiler with BabelJS and Source... by azazel75 on Thursday March 31, 2016 @08:22AM (#11396608)
Javascripthon supports converting either a python source file or a python function object directly, but actually using the embedded js interpreter to do the transpilation takes some time due to BabelJS code bootstrap time.

Having a "HOT" interpreter with an execution context that is persistent and can be used to convert code to ES5 on the fly has been already implemented by duckpy creator and i plan to intergate it very soon.

See https://github.com/amol-/dukpy/issues/4

Re:A Python-to-JavaScript Transpiler with BabelJS and Source... by ivan_ah on Thursday March 31, 2016 @02:32PM (#11399427)
Interesting idea. In the context of educational software, the "validation logic" would be the answer checking. The backend could do the checking in Python, but the same logic can also be shipped to the client as js for offline usage.

related: a LaTeX to .js "transpiler" for the exercises https://ximera.osu.edu/

Now if only someone could transpile SymPy to javascript...