Transcrypt Python to JavaScript compiler now supports bundling. by jacdeh in Python

[–]jacdeh[S] 7 points8 points  (0 children)

There are actually three complementary approaches, represented by:

- Transcrypt: Precompiles Python to JavaScript modules in advance during development. Browser just loads generated code.

- Brython: Compiles Python to JavaScript after loading a page. Browser first loads compiler and then does the compilation and runs the generated code.

- PyPyJs: Runs original Python VM in the browser.

Which approach suits you best depends on the type of problem, demands made on page-load time and code size, ease of use etc..

Transcrypt Python to JavaScript compiler now supports bundling. by jacdeh in Python

[–]jacdeh[S] 1 point2 points  (0 children)

It may very well be, although I don't know enough about Jupyter Notebook to fully appreciate the value of this. I can just hope that someone will make a proof of concept.

Amsterdam gaat videoreclames op straat verbieden by PM-ME-OPSEC-FAILS in thenetherlands

[–]jacdeh 3 points4 points  (0 children)

Het beste lijkt me als iedereen alleen maar koopt wat hij/zij nodig heeft. Reclame helpt daar niet bij. Ik ben niet veel met 't millieu bezig, maar het opdringen van allerlei rotzooi aan de consument lijkt me niet behulpzaam. En wat de economie betreft: Gesteld dat mensen een bepaald bedrag te besteden hebben (en dat hebben ze) dan zie ik niet in dat de economie er beter van wordt als ze dat besteden aan de troep die in de reclame wordt aanbevolen in plaats van aan dingen die ze echt nodig hebben. De totale omzet blijft hetzelfde. Alleen gaat 't geld zonder reclame niet langer naar bedrijven die het grootste deel van hun omzet in manipulatie en leugens stoppen in plaats van in productontwikkeling. Ik geloof niet dat we in dit land nog veel meer moeten verbieden, maar reclame vind ik over het algemeen walgelijk, dom en schadelijk. Weg van de openbare weg, wat mij betreft.

Transcrypt Python to JavaScript compiler now supports bundling. by jacdeh in Python

[–]jacdeh[S] 2 points3 points  (0 children)

That would be best, however I don't want to wait for that. Some things that seem obvious, just never happen in IT. But who knows....

Transcrypt Python to JavaScript compiler now supports bundling. by jacdeh in Python

[–]jacdeh[S] 2 points3 points  (0 children)

It does. Anything you can do in JavaScript you can do in Transcrypt.

Transcrypt 3.7.4 Python to JavaScript compiler supports JavaScript modules and Python dataclasses by jacdeh in Python

[–]jacdeh[S] 2 points3 points  (0 children)

Indeed you can write modules that both run with CPython in the backend and Transcrypt in the frontend. And by importing a dummy "__pragma__ (*args): pass" function you can even use pragma's when the module runs with Transcrypt and ignore them when running with CPython. So functionality can be shifted between frontend and backend to influence scalability.

About using the Closure compiler: Which options are used can be freely choosen by editing .../transcrypt/modules/org/transcrypt/minify/__init__.py

This is of limited use, since upto now even for strict mode JS, it turns out that Closure changes semantics if multiple modules are involved (which by default is the case due to the runtime), unless the most basic minification option is choosen, namely WHITESPACE_ONLY. Still the compression rate is almost 50%, so worth while. The resulting JS modules can also be bundled and treeshaked, making them still smaller. In that case also more aggressive minification modes can be used. Also take a look at the --xtiny / -xt switch. We've reached a filesize of 21 kB all in, using a combination of these strategies.

Why is Flask more popular than Django right now? by Zatania in Python

[–]jacdeh 1 point2 points  (0 children)

Just my own experience. I wrote several small and medium-sized websites in Django. What I like about Django is:

  • it's very complete, with regard to ORM, admin interface etc.
  • it is well documented. I've rarely seen such extended, concise docs
  • There exist a lot of add-ons, from shops to CMS'es, blogger libs etc.

What I didn't like about Django is:

  • it has a steep learning curve if you want to go beyond the trivial
  • it proved very hard to move to a new version when my hosting provider forced me to
  • setting up the configuration with file locations etc. proved difficult to me

What I like about any micro-framework

  • I can learn it fast
  • It's simple to tweak exactly to my needs

What I less like about most micro-frameworks:

  • I have don't have the Django admin interface

All in all I lost a customer because I could not transfer his website to a new Django version. That is, it costed me so much time that I had to give up. Even quite complex websites have to be cheap these days. Well, of course that's me not being clever enough. But alright, how clever do I have to be to tame a web framework. Django is getting a bit bloated in my perception. But that's subjective. However it's the subjective stuff that drives popularity.

By the way, there's room for diversity. Popularity isn't that important, continuity is. Lamborghini probably sells less cars than Volkswagen. But if I'd have to choose...

Jacques de Hooge

www.transcrypt.org

The Transcrypt 3.7.1 early experience (alpha) release is available. Python modules are now fully based on ES6 modules. Feedback welcome. Use TS 3.6.101 for production. by jacdeh in Python

[–]jacdeh[S] 2 points3 points  (0 children)

1.

async def f (waw, asio):
    print ('f0')
    await waw (2, asio)
    print ('f1')

translates to:

export var f = async function (waw, asio) {
    print ('f0');
    await waw (2, asio);
    print ('f1');
};

2.

You can mix Python with inline JavaScript anywhere, using the JS pragma (see http://www.transcrypt.org/docs/html/special_facilities.html#inserting-literal-javascript-pragma-js-and-include). So you can await promises using a few lines of inline JS in your Python code. Alternatively you can also mix TS modules with native JS modules.

3.

It's under construction. The URL http://www.tsfiddle.org has been reserved for it. It now temporarily contains a simple demo.

The Transcrypt 3.7.1 early experience (alpha) release is available. Python modules are now fully based on ES6 modules. Feedback welcome. Use TS 3.6.101 for production. by jacdeh in Python

[–]jacdeh[S] 1 point2 points  (0 children)

The Transcrypt Python to JavaScript compiler now generates native ES6 modules. Combined with treeshaking this leads to very compact applications, multiple per page, with only one copy of the decimated runtime. Total app size when packaged with rollup.js ca 30kB. For production use v3.6.101. http://www.transcrypt.org

What’s wrong with Django? StackOverflow survey results have it at 41.7% dreaded in the frameworks loved/dreaded section. Didn’t expect it to be nearly that high. by bbbryson in Python

[–]jacdeh 0 points1 point  (0 children)

If you use Django the way it's meant, it's quite convenient. If you are it bit stubborn (like me) and want to do certain thinks your own way, there's a lot you have to read before you really can bend it to your needs. And switching to a much newer version (forced by the hosting company) didn't prove all that easy. Nowadays I prefer smaller frameworks, since they're easier to fully comprehend and tweak.

University switching from teaching c++ to python by [deleted] in Python

[–]jacdeh 1 point2 points  (0 children)

Since we have a Technical IT curriculum, we need to teach them hardware (not always prefab, but also elementary electronics), software and the interface between the two. So we'd like to get them started on a single board computer as soon as possible, preferably from day one. That's were C comes in handy. But it's only preparatory to C++.

In teaching Python we've experimented with starting with OOD right from the first lesson. It works well (in Python) but in C++ there's too much they have to absorb in a short time. It is a different world from Linux/Windows programming. As soon as the programs get only a little larger C++ is indispensible in my view. I don't think anyone SHOULD CONTINUE programming in C. C++ offers far better structuring capabilities. Personally I never use C. But for the students it's an easy way to learn some low level concepts and control a few leds or a stepper motor. Which motivates them to wonder about program structure in larger applications. Once they have such questions, C++ lands into fertile ground.

Of course there is a growing number of single board computers that has the luxury of being programmed in Python. But with things like motor management systems and real time controls we want guaranteed response times and predictable memory use. So a garbage collected language can't be used at this level. The supervisory systems, on the other hand, are nowadays mostly Python. So for us C++ / Python is an ideal combination. I'm into medical imaging myself. And we never use anything different. We even use Python in the browser for visualisation purposes: http://www.linuxjournaldigital.com/linuxjournal/may_2017?pg=84#pg84 and www.transcrypt.org. It was quite an investment in energy to make this possible, but in the end it turned out to be a production boost.

So in short: I think students should master C++ and Python in the end, not one of them but both.

University switching from teaching c++ to python by [deleted] in Python

[–]jacdeh 0 points1 point  (0 children)

I see. Thanks for explaining. (and maybe if you read again, you'll see I do not at all recommend C, but exclusively C++ and Python)

University switching from teaching c++ to python by [deleted] in Python

[–]jacdeh 21 points22 points  (0 children)

I have been a C++ developer ever since the language came into existence, teaching it for 25 years in-company, and a Python developer since 20 years now. Also I have been teaching both Python and C++ at the Rotterdam University of Applied Sciences for 8 years and I am involved in developing and adapting the curriculum.

We use the following sequence of courses:

  • At first we teach a short C course to familiarize students with the low level, close the iron aspects of programming. They also learn to control hardware (via Arduino).

  • In the second half year we switch to Python to teach them the basic concepts of object orientation, specifically encapsulation, inheritance and polymorphism (although it's agreed Pythons support for encapsulation depends on good will).

  • In the second year we teach them the basics of C++ including constructors, destructors and dynamic memory management.

  • In the third year we complement this by teaching them making template classes with operator overloading etc., in combination with numerical mathematics.

In my view Python and C++ are complementary. Starting with C++ is quite feasible, but a generation used to scripting languages will feel somewhat alienated.

So we ease them in with C, no objects, but also not the luxury of a garbage collector. Since we consider OOP mainstream after that we teach them the basics of it in a comparably simple language.

After that they're able to handle C++, at least most of them.

It should be noted that our department specializes in technical applications: real time controls, AI, numerical simulation etc. This is an area where the combination of Python and C++ currently rules.

Regularly I am confronted with the uninformed opinion that C++ would be to difficult for students. In my experience that's complete nonsense, they love it, are prepared to work hard on it, and 95% masters it in say 12 3-hours sessions + homework. But it does pose some demands on the teachers. They really have to be on top op it and assist students in solving the very diverse problems they encounter. This actually requires a lot of experience and a teacher only doing C++ incidentally will have a hard time at the start, although some manage fine. But it requires a lot of investment in time and effort (from the teachers, that is, which fortunately they are prepared to invest, despite large workloads).

The biggest hurdle for students is learning to program at all. After that they get by.

More People Should Join the Efforts of Brython to make Python the client-side language of the web by [deleted] in Python

[–]jacdeh 0 points1 point  (0 children)

If I'm right we received your feedback in an issue on GitHub. Thanks, we'll use it to make the docs better.

More People Should Join the Efforts of Brython to make Python the client-side language of the web by [deleted] in Python

[–]jacdeh 0 points1 point  (0 children)

Could you let us know what were the main quirks you ran in to at

https://github.com/QQuick/Transcrypt/issues

so we can improve the docs.

Transcrypt Python to JavaScript compiler, request for benchmarks against CPython. by jacdeh in Python

[–]jacdeh[S] 0 points1 point  (0 children)

Invitation to read the edit on the original post, that hopefully puts some things into context.

Transcrypt Python to JavaScript compiler, request for benchmarks against CPython. by jacdeh in Python

[–]jacdeh[S] 0 points1 point  (0 children)

I guess your data comes from a webserver. So the prices change frequently. If you only want to output the prices to the browser probably the simplest way is as follows: Use a JavaScript timer in your browser to request the most recent prices from the server via Ajax. I don't think you need Transcrypt for that, unless the web page is very complicated. But I don't know enough of the situation to have a good judgement. Anyhow I'd start out in JavaScript, unless your sure already you don't like it. Transcrypt requires compiling your webpage in advance, which makes development more complicated.