Git Product home page Git Product logo

Comments (22)

rafi16jan avatar rafi16jan commented on May 12, 2024 1

After weeks of busy routines I finally have the time to try to tinker with Nuitka and the Emscripten Compiler... And no avail, everything that needs the Python Runtime won't work (Nuitka, Cython, Pyrex, I only tried these 3).. But I found RPython, basicly it have a translator/transpiler that can translate/transpile a subset of python "staticly" to C without the Python runtime. By staticly means it can't be dynamic (one variable can only be one type, no lambda, only higher order functions, etc) and it surprisingly able to be compiled with emcc (Emscripten). Although the produced llvm give an error about unresolved symbol when executed in WebAssembly:

warning: unresolved symbol: pypy_debug_tracebacks

Even though I know this is Nuitka Github Repo but I want to ask for your help @kayhayen and any Pythonista who are fluent in C that came accross because I think this is the right idea to bring Python to the Web (performance wise). Compiling the full CPython or any other Python Runtime will make the download size very large and bringing many problems.

from nuitka.

kayhayen avatar kayhayen commented on May 12, 2024 1

Thanks for reporting. I do not mind reading good things about PyPy, which is behind RPython. I think it is good for what it does. I actually once contributed a small patch to it, a decade ago. :)

I am putting this to unsupported then, leaving the question tag, so people will find it.

from nuitka.

rafi16jan avatar rafi16jan commented on May 12, 2024 1

Although RPython will be the fastest subset of python for compilation, but it feels like it won't be that easy to target it to wasm. The current viable one is actually MicroPython, there are working POC for it

https://github.com/numworks/epsilon/tree/master/python
https://github.com/pmp-p/micropython-ports-wasm

But I am more interested in RPython performance wise, but if it is too complex to be targeted to wasm maybe we can search for another alternative like MicroPython.

from nuitka.

kayhayen avatar kayhayen commented on May 12, 2024

Nuitka depends on "libpython" to work. If you can load that, it's fine, but I doubt it.

from nuitka.

rafi16jan avatar rafi16jan commented on May 12, 2024

libpython is a C library right? isn't Webassembly compiles a LLVM compatible code (and its dependencies) to byte code? I want to try this

from nuitka.

kayhayen avatar kayhayen commented on May 12, 2024

@rafi16jan Go ahead, you are welcome.

from nuitka.

kayhayen avatar kayhayen commented on May 12, 2024

Meh, cannot assign you, but consider yourself in charge until you give up @rafi16jan

from nuitka.

rafi16jan avatar rafi16jan commented on May 12, 2024

Ok, I'll report

from nuitka.

rafi16jan avatar rafi16jan commented on May 12, 2024

Can you (or maybe the right question is, do you have time :D) to give us newbies guide/advice to debug this RPython and the C source it generated. We younglings aren't like you guys that can understand C the same way we understand Python. It's heaven and earth to us (maybe hell). We're generation that aren't used to compile things, unless it is java or .net haha

from nuitka.

kayhayen avatar kayhayen commented on May 12, 2024

Not enough time for Nuitka as it stands.

from nuitka.

rafi16jan avatar rafi16jan commented on May 12, 2024

Ok I understand

from nuitka.

ids1024 avatar ids1024 commented on May 12, 2024

Hm, rpython+wasm is an interesting option.

warning: unresolved symbol: pypy_debug_tracebacks

Try grepping the rpython/pypy source code for that function to see where it's defined and find out why it isn't being compiled/linked properly. From the name, I'm guessing you could replace it with an empty function with the same signature, at the cost of breaking tracebacks.

from nuitka.

CrazyPython avatar CrazyPython commented on May 12, 2024

@rafi16jan I know a bit of C, I’m willing to help.

from nuitka.

CrazyPython avatar CrazyPython commented on May 12, 2024

Maybe we can ask on the PyPy mailing list.

from nuitka.

rafi16jan avatar rafi16jan commented on May 12, 2024

@CrazyPython Nice, where do we start?

from nuitka.

rafi16jan avatar rafi16jan commented on May 12, 2024

@wolfv Sorry for tagging you hehe, how's your experience with the new MicroPython javascript port?

from nuitka.

wolfv avatar wolfv commented on May 12, 2024

It's quite straightforward nowadays to compile to webassembly. you just need to know which functions to export.
Nowadays you should also be able to find libpython compiled to webassembly. however, it will be much larger than micropython (which is the big advantage). MicroPython compiled is only ~200kb, so in the same range as modern JS frameworks.

from nuitka.

rafi16jan avatar rafi16jan commented on May 12, 2024

@wolfv Is there already a way to interact with DOM or WebAPIs? Because I ask another port to WASM what's the difference between his port and the official port, he promises that he will add DOM interaction and even asyncio support with requestAnimationFrame. Take a look at this

from nuitka.

rafi16jan avatar rafi16jan commented on May 12, 2024

Not related to Nuitka, but I have make an ES6 Module of the official MicroPython WASM port. https://www.npmjs.com/package/micropython

@appcypher @ids1024 @CrazyPython

from nuitka.

pmp-p avatar pmp-p commented on May 12, 2024

Nuitka depends on "libpython" to work. If you can load that, it's fine, but I doubt it.

@kayhayen libpython3.8.a is (now) easy to build with clang 10 ( emsdk tot-upstream ) and i did not find any problem running standard stdlib python code in repl.

https://pmp-p.github.io/python-next/test.html patches here https://github.com/pmp-p/pydk/tree/master/sources.em

If anyone would like to experiment Nuitka on that lib i'm ready to help ( i'm on gitter and freenode )

@rafi16jan i made the asyncio micropython DOM support compatible with cpython too with the same module see the test page above.

from nuitka.

dhiahassen avatar dhiahassen commented on May 12, 2024

@pmp-p @rafi16jan @wolfv @CrazyPython , i am a very experienced C/C++ programmer , i will be there for help for any C/C++ related things

from nuitka.

rafi16jan avatar rafi16jan commented on May 12, 2024

@pmp-p @rafi16jan @wolfv @CrazyPython , i am a very experienced C/C++ programmer , i will be there for help for any C/C++ related things

Great! Months ago I've successfully fork RPython to be able to compile to WASM. Please give any feedback here https://github.com/rafi16jan/rpython-wasm

I would like to see someone continue the work since I'm busy with other things right now, also pardon me if there's bad C code since I'm very bad at C and strong typed languages in general

from nuitka.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.