TranscryptOrg / Transcrypt

Python 3.9 to JavaScript compiler - Lean, fast, open!
https://www.transcrypt.org
Apache License 2.0
2.85k stars 214 forks source link

Marketing Transcrypt #124

Closed axgkl closed 7 years ago

axgkl commented 7 years ago

@JdeH : Check out the Agenda: https://www.pymunich.com/

Working on your 1000 stars, hope you like.

If you want me to drop any important untold message, e.g. whats in the pipe or what you need from people, tell me. A re module I know already. Or shocking examples of Transcrypt's superpowers, not on the website ;-)

JdeH commented 7 years ago

@AXGKI Great! Just what we need!!! About the untold message: I have to think about that one. But this is really what has to happen and I am very happy you're doing it. Hope others will follow.

pierrejean-coudert commented 7 years ago

Nice, @AXGKl :-)

JdeH commented 7 years ago

Will your talk be recorded on video and be available somewhere on-line? In that case I'd like to link to it from the website.

Another matter: Should you find the time, could you take a look at issue #126. It has been puzzling me for quite a while but I've no idea what causes this.

axgkl commented 7 years ago

Will send you the slides in any case but don't know if they record the stuff, lets see.

could not verify 126, lets discuss there.

JdeH commented 7 years ago

@AXGKl

I've been thinking about the untold message a bit and a few things came to my mind. Don't feel obliged to include them, though. I can imagine time is limited and you have a lot of other things to tell.

In the first place I think it is important to highlight the overall design goal of Transcrypt, which is:

"having a Py to JS compiler that produces code that can compete with native JS code with respect to speed, compactness and interoperability with any JS library, so is seriously usable for the production of large web applications"

As a consequence of this, some features of Python are off limits, most notable "eval" and "exec", which would imply slow, bulky in-browser compilation. Also a number of dynamic mechanisms have been simplified to achieve more speed (such as the descriptor mechanism).

Meanwhile features like multiple inheritance and operator overloading were considered important enough to have them in, but in an efficient way, operator overloading e.g. being locally switchable.

Sourcemaps and highly readable JS targets facilitate easy debugging. Native JS code can be included anywhere, but rarely needs to, as things like for-loops, i++ etc. are optimized.

Secondly the design decision to favor unimpeded access to JS libs over the use of Py libs deserves some explanation

The web developers community has produced a large number of high quality libraries. For any serious web development tool, unimpeded use of these libraries is an absolute necessity.

This is not to say that porting CPython libs wouldn't be useful! Having a Python style regex / re library would be great, as would be having a relevant part of sys available. Libs like e.g. libs math , random and time are already there, as is the humble turtle module. Message: If you want to port a CPython lib to Transcrypt: this is highly welcomed. Please include an autotest for it as well.

PS. I hope there are some useful elements in this... I've included a recommendation for your talk on the Transcrypt website, hope that's ok with you.

axgkl commented 7 years ago

All right, I'll work those points in, I share them in general - still I'll stress that the current absence of python ecosystem ports proved not an issue for me personally: Will show to a large part how natural it feels to use 'cool' and modern js libs, in the way a python guy always dreamed of using them.

Btw: Started with the config system - and having a powerful config system at hand I ran into a little "featurities" problem, crossed the 1000 lines :-/ - but I think it covers all features needed for Transcrypt. Since it covers more I'll put it as a standalone repo on my github, than you can forward any issues to me. For transcrypt you can just grab the module in a certain version which does what you want, to remain dependency free. Before I push a first version I just wanted to add a lot of tests, docu and maybe a handling of actions, not just switches. I.e. that you can also add functions, not just attributes to a config declaration class and the config module will call them directly (if given on the CLI), correctly parametrized, that makes any sense, imho.

JdeH commented 7 years ago

The points I mention are meant to optionally complement what you're telling from your personal point of view, so don't be distracted by them. I don't consider presence of Python libraries a prerequisite for the usability of Trancrypt either. There are enough good JS libraries available and in general they are more suitable to in-browser applications.

Still what we have in common is that we both know Javascript upto a level and have used in in practice. There's also a group of Python programmers that has avoided browser programming until now, since they perceive the use of JS as a significant barrier. When they start programming for the web in Transcrypt, they'll learn to know the JS world gradually as a sideeffect and start to use the many good JS libraries that are available.

Still I expect them to stick with Transcrypt rather than Javascript, since in my opinion Python has had a more coherent design right from the start than Javascript will ever have, despite its growth in every direction. I know that JS programmers will not agree with me. My first language for practical use (after Algol 60 in my education) was Basic. I thought the world of it and sometimes still dream in it ;). But looking back it was flawed, of course. Transcrypt is for Python programmers. They like things to be clear, well structured, simple yet powerful. As long as they have a reasonable API, libraries are secondary to that.

For some libs I think porting is too much trouble. A library like Matplotlib certainly has a high quality, but unless someone of the Matplotlib team writes a browser backend for it, I see no reason to port it when libraries like Plotly are available.

On the other hand, simple, familiar libraries like math and random are a nobrainer. They were ported in a few hours and will hopefully benefit many.

I think the overall message you should bring in your talk, is one that you feel comfortable with. If using Python libs isn't your thing, there's no need to advocate developing them.

The main point in my view is simply:

Transcrypt is useable for 'real world' web development: fast, small, reliable, compatible, easy to debug.

If that's in line with your experience, then that is the message most worth conveying. Many open source projects seem to be somewhere on the boundary between hobby and profession. While I like working on Transcrypt, above all I hope people perceive it as a professional, reliable asset.

Many people want to be on the safe side, and many will choose Typescript because it's backed up be a large company. I'd like to convince people that a bet on Transcrypt is, within reason, a safe bet, especially since it's open source and open to understanding by anyone.

JdeH commented 7 years ago

About the config system: I am currently contemplating if, how to, and up to which level add metaclasses. I know you probably could benefit from them in your config system. Could you enlighten me on which functionality you need for your usecase. Is it mainly the ability of new to have alternative behaviour for a class factory? A code example would help.

JdeH commented 7 years ago

In any case: Good luck on sunday!

axgkl commented 7 years ago

Hi, so I'll just put your statements on my slides to transcent the vision of the guy behind it, and try to prove that transcrypt already now lives up to that vision, with some simple examples, omitting js libs pretty much. Maybe I just grab one of your nice demos and tweak around a bit in pure python. To demo that all the nice and effective python we all love is right at hand and nearly 100% in. lambdas, list comprehens, array/dict ops, multi inheritance, imports... which are so annoying in js. In part two then I'll demo how Transcrypt works out in a professional use case involving (modern) javascript libs then. Specifically in one where component libraries have to be built, which might needed to be adapted in projects. I have 15 minutes for each block, so not too much time anyway. Adaptability of libs, in a project on site, w/o the need to master a 600MB nodejs/npm/(...)webpack whatever build pipeline on the server I deem alone nearly invaluable of an advantage. That should do the job to motivate people giving it a try, and put their perspective right, thats the goal of this all. Not that you are DOSed then by people complaining about exec not working...

Metaclasses I'll do in the other ticket, useful for others. https://github.com/QQuick/Transcrypt/issues/128

JdeH commented 7 years ago

I am very curious how it went...

axgkl commented 7 years ago

Hei, sorry for no ping back. Went well and I just put together the slides in a repo...

Details later (after the thingy had to pay back some family time dept, recover some sleep deprivation, answer some emails). Audience was not that big, around 30 people, since I applied so late I guess.... I was in the smallest room with no video sadly.

But many questions and (positive excited) disbelieve that what I said was possible :-)

axgkl commented 7 years ago

Hi again,

presentation is here:

https://axiros.github.io/transcrypt/#/

Feel free to use it in any way you want, source is here: https://github.com/axiros/transcrypt

30 minutes was just far too less time, recognized that when I was estimating the time - and decided to drop any details about the non transcrypt things, focussing practically exclusively on Transcrypt.

Feedback was quite good, from sceptic to very interested. Still: It was not a very big audience, some 30 people I guess, I was in the smallest room as said.

I would think though that you, as the author, should apply for one of the "big" PyCons (Europe or World) and market it (?)

A few people said in the break after the session that the topic is indeed very interesting.

axgkl commented 7 years ago

I just remember: One pretty experienced guy who evaled transcrypt already addressed the same question than https://github.com/QQuick/Transcrypt/issues/137 and that this was the reason to not pick it but go with a go -> js transpiler (gopherjs), offering "far more" on the pipeline side of things and as he said, "gochannels" which I understood are also connectable with server sided computing. Seems serious frontend guys really are into that module/hot reloading feature. So I would not close it - maybe its not that hard to do to generate more modules instead of putting all imports into the main one. Which then browserify together with webpack can then hot reload into clients on changes.

JdeH commented 7 years ago

@AXGKl About the size of the audience: While size is important, it's the quality of the audience that matters most. I guess the 30 or so people who choose your talk above something as generally accepted as Cython, really were interested. I am saying this because what I think Transcrypt needs most is an ambitious application in a publicly accessible site, that the gallery can link to. So even one or two persons using it seriously for a public site will make all the difference. I think Transcrypt can do much more that people would expect. As soon as that gets out, things will accelerate.

Unfortunately in this respect, currently I am working mainly on back-end medical research projects. Eventually they'll need a medical imaging web front-end, and I plan to use Transcrypt for that. In fact it was one of the main reasons to start its development. I know you're working on some very serious applications yourself, though these will probably not be publicly accessible. For now I can just hope that someone else comes up with some spectacular showcase or high profile reference. Seeing is believing.

Another point is SEO. When I search on "Python in the browser", Transcrypt isn't on the first page. That's bad, since that is what people will look for. Many of them won't look for "Python to JavaScript compiler", since they don't know that's the only way to indeed get "Python in the browser". Advices on SEO are often contradictory, I'll have to do some experimenting there.

About #137. I know knowledgeable developers want things like that, it's a big thing in the JS world, but there are many complications there, as I explained in my reaction on the issue. I've set my own priorities with the quality of the language- and compiler core.

The "unique selling point" of Transcrypt is the ability to set up large, fast, lean applications in a maintainable way (by virtue of the characteristics of Python). I remember Borland introducing its Turbo Pascal, that later morphed into Delphi and later on, when Microsoft bought Anders Hejlsberg, gave rise to a whole range of 'visual' development environments and also inspired IBM's Visual Age line of products.

At the time the Borland compiler hit the market, Pascal was the only decent language running on a PC, while C was still in the K & R stage. I owned a 2000 (guilders at that time) Pascal MT+ multipass compiler with a separate linker. For even a small application, during compilation I used to go for a walk in the park near my house, returning only to find out that the compiler had stalled after 5 minutes on an error. This was normal in that days. And anyone saying a single pass compiler without a linking phase could in fact be a serious tool would have been laughed at.

But after having compiled a few not so small applications in seconds rather than in half an hour or more, my mouth hang open, and I realized the superiority of the concept. They took the PC world by storm but were later on stripped of their essential developers by larger players. But even now Delhpi is popular, I've ran into it again for my newest medical project. It lags back, and eventually I will convert, partially to Python, partially to C++, but it's still a serious tool.

What I've learned from that is the following:

While it's essential to be open to good suggestions, and keeping track of them carefully, this shouldn't cause distraction from the original design goals. If overall compilation happens in seconds, I currently see no compelling reason to hot-load individual modules rather than the whole application. The amount of complexity it introduces will hinder Transcrypt in keeping up with essential developments on both the Python and JS language core front in this early stage. (Later on things may be different, Delphi, after all, has a linker...)

JdeH commented 7 years ago

@AXGKl About your slides:

  1. Beautiful, professional and to the point!
  2. Will make a 'publicity' section on the website, with links to your presentation, the podcast interview, articles etc. Hope this section grows.
  3. You state performance ratio 5, but using exactly your figures you were too modest, it's 3 unless I am mistaken. Also -e 6 -f switches should speed up even more, I'll experiment with that.
axgkl commented 7 years ago

omg, 5... remember that in chrome it was sth like 5, then I saw safari got down to factor 3 and made two shots, pasting them in and it was "late" in the sense of early. :-) Beamer resolution was not good enough that everybody could see the obvious lol...

JdeH commented 7 years ago

Would it be a lot of work for you to adapt that slide. If not, please do, it's probably easier for you than for me, have no experience with the tool...

There's a weird thing about Chrome, by the way. The JS5 code, generated as:

            var __iterable0__ = n_queen_positions;
            for (var __index0__ = 0; __index0__ < __iterable0__.length; __index0__++) {
                var existing_position = __iterable0__ [__index0__];

runs nearly twice as fast as the JS6 code, generated simply as:

            for (var existing_position of n_queen_positions) {

Seems Google has some work to do here.

axgkl commented 7 years ago

would not have written previous statement if it would not be online already ;-)

notices also chrome is much slower than safari, you can also give me like a 'transcryped optimized version' if you see sth. to tune getting the factor down more.

tool is simple, the whole presentation is show.markdown btw, make.py compiles it into the single page html (index.html)

have to go, wife needs me...

JdeH commented 7 years ago

First things first!

JdeH commented 7 years ago

I've included a link to your presentation on the Transcrypt site:

http://www.transcrypt.org/documentation#media

axgkl commented 7 years ago

quick one, related to marketing:

screen shot 2016-11-06 at 23 33 19

shouldn't the slogan be: "Transcrypt. Python For The Browser"?

No need to write a lot of justification IF you thought about it long and decided you want it like it is, no problem. Saying this just because there could be a chance you invented the slogan without much thinking and now nobody notices anymore that its actually misleading people to think what Transcrypt is, there is no Python IN the browser (for good reasons as you explained me long ago) ;-)

JdeH commented 7 years ago

It was done deliberately, focusing on the users' Python programs running in the browser, rather than on our tool generating JavaScript code for it.

Q: Is there any way I can run my beautiful Python programs in the browser? (Google, Google, Google) A: Yes, Transcrypt makes it possible to run your Python programs in the browser.

axgkl commented 7 years ago

You should have been there (and if only to correct the spelling):

https://www.youtube.com/watch?v=V1K8Mju_1oo

Funny, it seems the Netherlands is a global cluster of competing solutions for transpiling Python to JS for medical applications ;-)

JdeH commented 7 years ago

I've seen Almar's presentation on YouTube (and the typo).

Almar was the very first to react on Transcrypt (#1), and we had a constructive conversation. I've starred Flexx and he has starred Transcrypt, and we confirmed it was quite OK to use each other's code and ideas.

The Flexx compiler is only one element of what he's working on. He choose an approach where he's more or less independent of the Python version, by virtue of an extra AST abstraction layer, whereas I choose to deliberately follow Python versions. Both have pros an cons.

In the beginning some people reacted on Transcrypt with the question: Why yet another transpiler? Isn't that a waste of effort? But seeing the enormous diversity in e.g. the C++ compiler world, I think it's quite natural to have multiple comparable products.


We now have PyPyJs, RapydScript, Brython, PyJs, Transcrypt and some more, all of them with a different focus. I strongly believe in the path we're on, at the same time acknowledging that there are multiple routes to Rome (and people wanting to go elsewhere).

About giving presentations: PyCon US would be great, of course, but we need some budget for that if the conferences are abroad. Will not happen overnight, but I am contemplating turning QQuick into an official foundation, so legal person. This is one of the demands e.g. Mozilla poses, to make an open source project eligible for funding.


By the way, there's some merchandising on the site, should anyone think it's fun to wear a TS shirt, bag or cap. Got a TS shirt hanging in my study...

Europe: https://shop.spreadshirt.nl/transcrypt/ USA: https://shop.spreadshirt.com/transcrypt/

Also have two magnetic stickers on my car, as does my wife... Ordered them at: http://www.vistaprint.nl/

Just tried some guerilla marketing, like: https://github.com/samshadwell/TrumpScript/issues/195 just for the fun of it. This was after some people on Reddit thought that Transcrypt and Trumpscript were one and the same...


About the medical projects: Next tuesday I've an appointment with a prominent medical researcher of the Erasmus University to pick up where we left after the latest publication. Currently physicians can QC their data only locally. For the research it's only a side issue, but we cooperate e.g. with a team in Switzerland, so my plan is to make some of the most crucial data available via the browser. Since I've used bare bones OpenGL, and programmed the visualization part in Python (the rest in C++) it should be possible to port code to the browser using Transcrypt. It's still a few years off, main thing is we validate our non-invasive data with invasive data, but still, it's already on my mind...

axgkl commented 7 years ago

(#1) is really a great read. checked a bit through the pyscript stuff and I know I made the right decision, its not his sole focus , most obviously. A flexx/transcrypt combo would make a lot of sense, imho. The pyjs function is the only thing I would miss in Transcrypt...

axgkl commented 7 years ago

@JdeH

hi, I'm alive.

Next interesting conf - again here in munich:

https://www.papercall.io/pyconweb?mc_cid=8d23257436&mc_eid=61ec777d33

screen shot 2017-02-08 at 07 32 30

I think it would make tons of sense to present transcrypt - but unfortunately this time I can't do it, I'm currently in "the zone" for a product I have to create and I'm on lower layers, gui will come later and in my age I can only focus at one at a time, had to shift all with gui to around summertime :-/

Can't wait to get back to doing some Transcrypt though but first the framework below gui has to go in production.

CesMak commented 6 years ago

Anyone got Plotly to run in transcrypt? I just cannot even import plotly I did: pip install plotly

and if I simply type import plotly in my hello.py file I get:

transcrypt -b -c -m hello.py

Transcrypt (TM) Python to JavaScript Small Sane Subset Transpiler Version 3.6.95 Copyright (C) Geatec Engineering. License: Apache 2.0

'Module' object has no attribute 'targetCode'Traceback (most recent call last): File "/home/markus/anaconda3/lib/python3.6/site-packages/transcrypt/main.py", line 153, in main compiler.Program (transpilationDirs, symbols) File "/home/markus/anaconda3/lib/python3.6/site-packages/transcrypt/modules/org/transcrypt/compiler.py", line 233, in init '}\n' + File "/home/markus/anaconda3/lib/python3.6/site-packages/transcrypt/modules/org/transcrypt/compiler.py", line 231, in ''.join ([module.getModuleCaption () + module.targetCode for module in self.allModules]) + AttributeError: 'Module' object has no attribute 'targetCode'

My Code:


# Imports:
from org.transcrypt.stubs.browser import *
from org.transcrypt.stubs.browser import __main__, __envir__, __pragma__
from itertools import chain
import plotly

# Imports for Transcrypt, skipped runtime by CPython
if __envir__.executor_name == __envir__.transpiler_name:
    import numscrypt as num

# Imports for CPython, skipped compile time by Transcrypt
__pragma__ ('skip')
import numpy as np
__pragma__ ('noskip')

class SimactBasic():
    #global variables
    function_list = ['function_1','name2']

    def __init__(self):
        pass

    def function_1(self, arg1, arg2):
        print(arg1)
        print(str(arg2))

    def function_2(self, arg1, arg2):
        print(arg1+arg2)

    def parse_input(self):
        input_str = document.getElementById('input').value
        print(input_str)

        func = getattr(simactBasic,'function_2')
        # Call it
        func(1,2)
JdeH commented 6 years ago

You do not need to install the Python plotly module! Transcrypt just works seamlessly with the JavaScript version.

See example at:

http://www.transcrypt.org/examples#plotly_demo

Note that plotly is just grabbed from a CDN with:

<script src="https://cdn.plot.ly/plotly-latest.js" charset="UTF-8"></script>

This way of working also doesn't require any paid account to work with plotly in Transcrypt.

CesMak commented 6 years ago

Thanks :) I got it to work.

As sympy is not implemented as I guess is there a way to use symbolic math?

dhiahassen commented 4 years ago

@CesMak there is js libraries , nermada , algebrite , Math.js ( maybe all of them together can be around 90% of sympy )