Comments (18)
Hi, thanks for you feedback. Transcrypt is primarily meant to be able to the Python syntax and class base inheritance to build readable, maintainable applications on top of the JS library world. Some elaboration given at http://www.transcrypt.org/introduction.html. It is a niche project situated somewhere between Pypyjs (fully rooted in Python ecosystem) and Brython (largely rooted in Python ecosystem) on one hand and e.g. RapydScript (fully rooted in JS ecosystem, a tin layer on top of JS, no multi inher, no bound func. ptrs)
So it primary design goal wasn't cooperation with Python libs but seamless coop with JS libs. Having said that, the project got much further in the direction of a complete Python3.5 implementation than I initially expected. It also lacks some essentials, like metaclasses. Nevertheless it should be able to cooperate with a large set of Python libs, probably with small modifications.
I have not yet looked into that, the priority in development currently lies with further adaptation to the JS world by the addition of sourcemaps.
As I proof of concept I did a port of a very tiny part of NumPy, called Numscrypt. It can be pip installed and used from both CPython and Transcrypt. I both installed it without any environment manager and under miniconda (on Linux), which both proved to be unproblematic.
So in principle it's possible to have a pure Python library installed "in the usual way" and use it both from CPython and Transcrypt.
Admittedly it would be a great benefit if more pure Python libs could be used from Transcrypt. Given the fact that many people use virtualenv or something like it, it would also clearly be a great benefit if it would cooperate with that.
However that's something I have not looked into at all. Two things will be required:
- Transcrypt has to somehow cooperate with these environment management tools. I honestly don't know what that takes at the moment, but it is a requirement.
- Transcrypt has to be complete enough to indeed run the library in question. That's the main hurdle. However complete it may become, it will always remain a subset of CPython. This was a deliberate design choice, speed is favoured over completeness, this tool should generate truly useable JS code that runs fast enough to drive production sites.
So: Once I'm done with the sourcemaps, I'll probably do some experiments, to find out if it's feasible to make some important pure Python libs available to Transcrypt using a standard installation procedure and something like virtualenv. The outcome may be one of both:
- It may be doable with sacrificing the speed of compactness of Transcrypt code. In that caseit what's necessary to do this, will certainly be implemented, because indeed the benefits are worthwhile.
- It may not be doable without bloating Transcrypt, making the generated JS less readable or bulky. In that case Trancrypt will stick with its orignal design goals: lean and mean.
So unfortunately for now I'll have to refer to PyPyJs (experimental) and Brython (fully functional) if you need a more complete support of Python libs.
An alternative I have not yet mentioned is to port certain Python libs to thin layers on top of comparable JS functionality.
All in all, with the first version out, there's still a lot to do. Sorry I cannot give you a more conclusive message at the moment, but this is how it stands...
Kind regards
Jacques
from transcrypt.
Come to think of it:
At some point I'd like to be able to experiment with installing and using pure Python libs. Could you tell me which ones you need most, so I can start there. This will not be something that will be done tomorrow, but if experiments are done, I'd like them to focus on the most useful ones first.
Note that the distribution model of Transcrypt is a bit different from JS, although JS is moving in that direction. Currently may JS libs are loaded on the fly from a CDN. Transcrypt was made primarily for pages that are complete, dynamic apps rather than HTML with a bit of JS scripting. A page is usually (but doesn't have to be) represented by a single JS target file, compiled from Transcrypt. Including a Python lib would make the size of this JS file grow considerably, unless it's only a thin layer on top of a dynamically loaded JS lib. This is not to say that it shouldn't be done, but it's something to reckon with.
J
from transcrypt.
@JdeH As I promised earlier, RapydScript-ng now has both multiple inheritance and bound function ptrs. Method binding can be controlled on a per module or per class basis depending on whether you want the classes to behave like python or like JavaScript.
https://github.com/kovidgoyal/rapydscript-ng#method-binding
from transcrypt.
@kovidgoyal Remember you telling me that. Would be nice if there be comes a join between your fork and the main branch of Rapydscript. Still Glyph wants to have libs from the Python ecosystem. Think that only Brython and PyPyJs can offer that out of the box.
from transcrypt.
That depends on the maintainer of the original RapydScript, @atsepkov, the last time we talked about it, he disappeared without resolving the issue, so I dont know what his feelings on merging are.
I dont think using libs from python directly in either rapydscript or transcrypt is a practical goal. The JS runtime is too different in too many details from the python VM. It is conceivable to port some selected python libraries with relatively little manual effort, but trying to support direct imports of arbitrary python modules would mean sacrificing a lot of performance and JS interoperability -- which is not congruent with the goals of at least RapydScript. You'd basically end up with the beasts that are pyjamas/brython, et. al. That kind of thing will only become practical is someone re-implements the python interpreter on top of WebAssembly with decent performance.
Not to mention that if you are looking to use third party libraries in the browser/node, I would suggest using javascript libraries rather than python ones. It's a more natural fit, and RapydScript at least is explicitly designed with this goal in mind.
from transcrypt.
As is Transcrypt. Still I'd like to invest some effort in at least supporting part of the Python-only CPython libs, since people are used to them and indeed they usually have an elegant Pythonic API.
from transcrypt.
Sure, that is a goal I can sympathise with. In fact you can find implementations of a few of pythons stdlib modules in the rapydscript-ng stdlib -- re, gettext, math, random
I suggest we should pool our efforts in porting libraries where possible.
from transcrypt.
Yes, I would like that! Currently I am a bit busy, but I'll look into your implementations of those libs you mention. Are they on GitHub with rapydscript-ng? Also feel free to use any code from the Transcrypt or Numscrypt distributions. I also others will jump upon the library wagon. I want to focus upon the kernel of Transcrypt, which doesn't leave me the time to look into many libraries. I've made an exception for Numscrypt, which is a VERY modest start.
from transcrypt.
All stdlib modules are here: https://github.com/kovidgoyal/rapydscript-ng/tree/master/src/lib
from transcrypt.
OK great. I plan to take a look at them soon.
from transcrypt.
At some point I'd like to be able to experiment with installing and using pure Python libs. Could you tell me which ones you need most, so I can start there. This will not be something that will be done tomorrow, but if experiments are done, I'd like them to focus on the most useful ones first.
The 2 libraries that I'm most interested in are attrs
and automat
.
from transcrypt.
Thanks, will look into them.
from transcrypt.
@kovidgoyal I took a peek at the sourcecode of your re library and it looks quite good to me.
I'd like it to be simply pip-installable for Transcrypt users.
Your other libs may be just as good, but I haven't looked at them yet, since Python style re's in my view are more urgent.
For practical reasons I feel the need in general to divide tasks with regard to Transcrypt. Especially I want to concentrate on further developing the core, since there's still a lot to do there. For simplicities sake I prefer to do that alone currently, but together with earning a living that leaves me insufficient time to also work on libraries.
Still I would like it very much if such libraries are developed. Seems you (and Alexander, I presume) have already done quite some work here.
If you're willing and find the time, could you:
- Draw up a number of autotest cases for it with good coverage
- Use Transcrypt's autotest facilities to test back to back with CPython (look at what I did for Transcrypt itself and Numscrypt, to get the hang of it.
- Package your lib for upload to PyPi, with at least the keywords: re, regular expression, Transcrypt and probably also Rapydscript and / or RapydscriptNG
- Test installation under Windows and Linux (and if you have the possibility, OSX)
I will then download it, run the tests and if it all works I'll add a chapter 'contributions' to Transcrypt.org with a link to your package (PyPi, Github and/or homepage).
Of course feel totally free not to invest the time, I know this is quite some work.
from transcrypt.
There are tests already, see the tests/regexp.pyj module. I'm afraid I dont have the time/interest to do all that, sorry. But you are welcome to use the code and tests directly, if you want to. If you do decide to import the code into Transcrypt, just credit me for it.
from transcrypt.
Alright, thanks anyhow. For now I will focus upon the core of Trancrypt, but it's good to know that it exists. And of course if it's used you and Alexander will be credited for it. Currently I have no plans to distribute libraries as part of Transcrypt, I think it's better if they're independent of this project and separately installable via PyPi.
from transcrypt.
Hi guys, sorry if this information is available somewhere but i couldn't find it.
To which version of js do your transpilers convert to?
Es3 es5 (hopefuly) or es6 ?
Tks
from transcrypt.
rapydscript-ng compiles to either es 5 or es 6 controlled by a compiler option
from transcrypt.
Transcrypt currently only compiles to JS5. JS6 support will be added with the Python 3.6 compatible version.
from transcrypt.
Related Issues (20)
- object() constructor HOT 7
- Support for regex library? HOT 1
- Missing types in the typing module
- List concatenation not working HOT 3
- Can't compile curly braces in format string
- parcel_demo needs to be updated to use Parcel V2
- Adding two lists converts to a string HOT 2
- Is Transcrypt Dead? HOT 5
- nodejs_demo doesn't work as described on web site; does via readme HOT 2
- Compile error when importing a long (path and class) name HOT 2
- Feature: `__` private members/name mangling in classes HOT 1
- No error is thrown in list.pop(idx) when the index is out of range HOT 1
- Can you please maintain directory structure in __target__/ ? HOT 1
- A boolean operator is translated to a bitwise operator, not a boolean operator HOT 1
- A method in the second base class is not called even when the first base class is empty.
- Minification error on del[] HOT 1
- Python built-in map() to support more than one iterable HOT 3
- How to compare two methods?
- ... in python code aborts compilation HOT 1
- Add python 3.12 syntax support HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from transcrypt.