4 ms·
Since PyPy compiles RPython to C, couldn't one write a web app in RPython, compile it to C, then to JS (with asm.js) and enjoy a quick page load and smaller fil
by throwaway41597 11y ago
Since PyPy compiles RPython to C, couldn't one write a web app in RPython, compile it to C, then to JS (with asm.js) and enjoy a quick page load and smaller file size?
By the way, is RPython a nice language to program in?
- throwaway41597 11y agocorrection: the C to JS step would be done with Emscripten (asm.js is a subset of JS not a compiler) Thank you for the answers
- icebraining 11y agoThe differences are described here: https://rpython.readthedocs.org/en/latest/rpython.html https://rpython.readthedocs.org/en/latest/rpython.html
- throwaway41597 11y agoThanks but to be honest, I'm not proficient in Python, so it's hard to guess if those restrictions would hurt, although they seem fairly small. I was more asking for personnal opinions and projects using it. I wasn't able to quickly find any, it even seems pretty much nobody writes RPython code or maybe people call it Python code so googling is hard.
- detaro 11y agoI don't know of any real projects outside of interpreters that use it. It has downsides (long compile times come to mind) and I'm not sure how well you can utilize the strengths (like the JIT) for non-interpreters. EDIT: Writing it is more restricted than normal Python, so you have to think about what you do (especially type hints, to make sure it gets what type your variables are) and the long feedback cycles due to compile time are annoying, but still very comfortable. And for building interpreters, the more or less "free" JIT is magic :)
- aidos 11y agoI've never worked with RPython. Looking through that list it doesn't look dreadful. There are a couple of things that jump out though - you can't use kwargs in function definitions which is probably used quite a lot in dynamic settings. Eg in Python one might do (warning; crazy, contrived example): def create_thing(**kwargs): thing = dict(id=gen_id()) thing['other_data'] = kwargs return thing thing = create_thing(name='name', foo='bar') You could avoid it, and generally in Python you're better off being explicit about everything. But it's definitely a feature that gets used a fair amount, especially in libraries where you don't explicitly know what the api call takes concerning user data. An easy (more explicit) workaround would be: def create_thing(other_data=None): thing = dict(id=gen_id()) thing['other_data'] = other_data or {} return thing create_thing(dict(name='name', foo='bar')) It's just a little more work for the calling code.
- Veedrac 11y ago> is RPython a nice language to program in? Not really, if only for the insane compile times. The PyPy authors also heavily discourage using it except for interpreters.
- masklinn 11y ago> By the way, is RPython a nice language to program in? It's a nice language to develop VMs in, it's a terrible language to do general-purpose programming in.