Monday, January 29, 2018

Re: javascript transpilers

2018-01-30 5:18 GMT+01:00 Mike Dewhirst <miked@dewhirst.com.au>:
On 29/01/2018 9:03 PM, Nick Sarbicki wrote:
Going SPA when you don't know JS is very much a baptism of fire.

Angular is personally my favourite too and essentially forces the SPA model. But it has a much bigger learning curve compared to Vue and React (the other two common names thrown about nowadays). The others are also easier to not force into a SPA model.

Figure what's the minimum requirement first ;-).

Single page is pretty close to the way the application currently works so that is promising. It is a lightweight training framework. Simple architecture of courses, instruction(s) and questions with answers aggregating a total score for the student.

I won't publicise the URL because the server isn't heavy-duty. But if there is any individual interest I'm happy to give it off-list. Today I released the beta to the first client who (generously) is using it for his troops to do online training on how to use some Windows software.

So back to the minimum requirement ...

The single (question) page has previous-question and next-question links which morph into previous-instruction and next-instruction links when at the first and last question respectively. So that is the SPA similarity.

When you click the [Save] button after answering a question there is no indication the answer has been saved without adding a line of text (via the view) after answer.save()

Refreshing the page resends the [Save] and reprints the line of text saying the [Save] was successful. Too clunky.

If you are using django in the "normal" way - you should just be able to add the message to the messages contrib package. Then the message should show when saving? Because when you click on the save button you should post your form and that method should (when successful) add the message?
 

It was that behaviour which made me start this thread.

I checked out typescript and it looks great but it is javascript. It seems to let you code in ECMAScript 6 which is looking more like Python and as Nick mentioned, has a compilation step (which I suppose is like a minification step anyway) to get it into the version currently supported by all browsers.

Typescript is more of a object oriented language than javascript is - at least compared to ECMAScript 5. It also has some support for typing - and great unittest support - which is criticle when writing javascript....
 

That prompted me to look more closely at a few of the transpilers in the link I posted in the thread-starter. One stood out for me ... http://www.transcrypt.org/

It seems the compilation to javascript takes place in the CI process and it can be debugged in Python or Javascript. You can use both javascript and/or python libraries. Written by a Dutchman which is possibly interesting ;)

What you have to remember is that you still need to transpile it when running in development mode. So it really doesn't matter where you do your transpilation. You need to setup the transpilation even in development - a webb browser can't run python natively.
 

The Angular thing is interesting. https://medium.com/@chriscordle/why-angular-2-4-is-too-little-too-late-ea86d7fa0bae

https://www.infoworld.com/article/3213244/javascript/whats-new-in-angular-5-easier-progressive-web-apps.html

From those articles, it seems React is lighter-weight than Angular and for me that probably means easier to learn. It is still daunting though. Vue also assumes javascript know-how.

Yes react is more lightweight. However it is like comparing the flask framework with django. The difference is very similar. React is more a library and angular is a framework.
 

I think my best plan is to postpone a decision and make a start on DRF anyway. No matter what happens that is a prerequisite.

I hope it isn't wishful thinking but Transcrypt looks more attractive than learning javascript plus a javascript framework.

The main problem here is that you will still need to learn javascript - because you need to understand what will happen when your client-side code fails (and it will :-)). And my other point is still valid. Look at the user base. When you have problems with transcrypt, how many users can you rely on to get help? If you have a pure javascript problem - how many users can you rely on for help?

I do hope that you find a solution that works for you though :-)
  

Thanks to all for the excellent and very professional feedback.

Cheers

Mike


Regards,

Andréas
 


On Mon, Jan 29, 2018 at 9:15 AM Andréas Kühne <andreas.kuhne@hypercode.se <mailto:andreas.kuhne@hypercode.se>> wrote:

    If that is the case - I would recommend looking into creating a
    single page app - with Django restframework on the backend if you
    want to continue with Django. For the frontend you will however be
    required to learn some sort of JS framework - however this doesn't
    have to be THAT bad. I personally like angular 5 - which is
    written in typescript - a javascript based language - that
    actually removes most of the pain. HOWEVER JS knowledge is good to
    have anyway....

    There are other frameworks that don't require that much JS
    knowledge and Jason suggested GWT which sounds like it could be
    worth a shot, as long as it doesn't add to much complexity. The
    main reason for using that would be a large user base, so you can
    get help. The python transpiled JS versions don't really have the
    greatest user base :-)

    Regards,

    Andréas

    2018-01-29 0:00 GMT+01:00 Mike Dewhirst <miked@dewhirst.com.au
    <mailto:miked@dewhirst.com.au>>:

        That seems unanimous :(

        Jani asked what problem I need to solve. Without going into
        analytical detail, all the code is serverside and now the
        project needs to move towards AJAX for user experience reasons.

        M

        On 29/01/2018 5:44 AM, Nick Sarbicki wrote:


            Agree with everything already said.

            Only thing I want to add is that while js has historically
            been a horrible language, the modern standards have helped
            rectify this. Modern js can be almost pleasant to work
            with nowadays.

            I wouldn't spend time transpiling python to js. Just try
            to learn js and maybe transpile from a modern standard to
            the browser standard. It's almost as easy as python to
            pick up.

            Django compressor helps greatly in the last case.


            On Sun, 28 Jan 2018, 16:49 Avraham Serour,
            <tovmeod@gmail.com <mailto:tovmeod@gmail.com>
            <mailto:tovmeod@gmail.com <mailto:tovmeod@gmail.com>>> wrote:

                If you don't want and don't have the time to learn JS
            you may as
                well consider outsourcing the frontend work, I've
            worked in places
                that did just that and everybody was happy, the
            internal team
                liked python and the outsourced company people liked
            UX and JS.

                On Sun, Jan 28, 2018 at 6:09 PM, Jani Tiainen
            <redetin@gmail.com <mailto:redetin@gmail.com>
                <mailto:redetin@gmail.com <mailto:redetin@gmail.com>>>
            wrote:

                    Hi,

                    You don't describe to what extent you need to use
            JavaScript -
                    IOW, what problem you need to solve with JavaScript?

                    Depending you needs you might get away with basic
            knowledge
                    and usage of some helpful JavaScript
            library/framework.

                    On Sun, Jan 28, 2018 at 12:44 AM, Mike Dewhirst
                    <miked@dewhirst.com.au
            <mailto:miked@dewhirst.com.au>
            <mailto:miked@dewhirst.com.au

            <mailto:miked@dewhirst.com.au>>> wrote:

                        I have avoided javascript like the plague.
            However it
                        seems I have to bite the bullet.
            Interestingly, there are
                        now a number of Python -> Javascript transpilers.

            http://stromberg.dnsalias.org/~strombrg/pybrowser/python-browser.html
            <http://stromberg.dnsalias.org/%7Estrombrg/pybrowser/python-browser.html>
                       
            <http://stromberg.dnsalias.org/%7Estrombrg/pybrowser/python-browser.html>

                        Where would be a good place to start a
            discussion on the
                        topic?

                        I am self-employed  with multiple demands on
            my time so I
                        cannot afford to allocate sufficient time to
            learn it let
                        alone undertake formal Javascript training. My
            hope is to
                        pick it up by osmosis and wonder if a
            transpiler would help.

                        Thanks for any pointers

                        Mike

                        --             You received this message
            because you are subscribed to
                        the Google Groups "Django users" group.
                        To unsubscribe from this group and stop
            receiving emails
                        from it, send an email to
            django-users+unsubscribe@googlegroups.com
            <mailto:django-users%2Bunsubscribe@googlegroups.com>
                       
            <mailto:django-users%2Bunsubscribe@googlegroups.com
            <mailto:django-users%252Bunsubscribe@googlegroups.com>>.
                        To post to this group, send email to
            django-users@googlegroups.com
            <mailto:django-users@googlegroups.com>
                        <mailto:django-users@googlegroups.com
            <mailto:django-users@googlegroups.com>>.
                        Visit this group at
            https://groups.google.com/group/django-users.
                        To view this discussion on the web visit
            https://groups.google.com/d/msgid/django-users/fa0e9f0b-fece-344d-74f2-5b9470b40657%40dewhirst.com.au.
                        For more options, visit
            https://groups.google.com/d/optout.




                    --         Jani Tiainen

                    - Well planned is half done, and a half done has been
                    sufficient before...
                    --         You received this message because you
            are subscribed to the
                    Google Groups "Django users" group.
                    To unsubscribe from this group and stop receiving
            emails from
                    it, send an email to
            django-users+unsubscribe@googlegroups.com
            <mailto:django-users%2Bunsubscribe@googlegroups.com>
                    <mailto:django-users+unsubscribe@googlegroups.com
            <mailto:django-users%2Bunsubscribe@googlegroups.com>>.
                    To post to this group, send email to
            django-users@googlegroups.com
            <mailto:django-users@googlegroups.com>
                    <mailto:django-users@googlegroups.com
            <mailto:django-users@googlegroups.com>>.
                    Visit this group at
            https://groups.google.com/group/django-users.
                    To view this discussion on the web visit
            https://groups.google.com/d/msgid/django-users/CAHn91od4EbPY210baiuJq59cf2nEue6TQ1-3wiU8auk-uLKCYQ%40mail.gmail.com
                   
            <https://groups.google.com/d/msgid/django-users/CAHn91od4EbPY210baiuJq59cf2nEue6TQ1-3wiU8auk-uLKCYQ%40mail.gmail.com?utm_medium=email&utm_source=footer>.


                    For more options, visit
            https://groups.google.com/d/optout.


                --     You received this message because you are
            subscribed to the Google
                Groups "Django users" group.
                To unsubscribe from this group and stop receiving
            emails from it,
                send an email to
            django-users+unsubscribe@googlegroups.com
            <mailto:django-users%2Bunsubscribe@googlegroups.com>
                <mailto:django-users+unsubscribe@googlegroups.com
            <mailto:django-users%2Bunsubscribe@googlegroups.com>>.
                To post to this group, send email to
            django-users@googlegroups.com
            <mailto:django-users@googlegroups.com>
                <mailto:django-users@googlegroups.com
            <mailto:django-users@googlegroups.com>>.
                Visit this group at
            https://groups.google.com/group/django-users.
                To view this discussion on the web visit
            https://groups.google.com/d/msgid/django-users/CAFWa6tJ_kfQ6RdW_d_QmXXTPt%2Bpt7HKPtnt_7eie17O60yaoaQ%40mail.gmail.com
               
            <https://groups.google.com/d/msgid/django-users/CAFWa6tJ_kfQ6RdW_d_QmXXTPt%2Bpt7HKPtnt_7eie17O60yaoaQ%40mail.gmail.com?utm_medium=email&utm_source=footer>.
                For more options, visit
            https://groups.google.com/d/optout.

            --             You received this message because you are subscribed to
            the Google Groups "Django users" group.
            To unsubscribe from this group and stop receiving emails
            from it, send an email to
            django-users+unsubscribe@googlegroups.com
            <mailto:django-users%2Bunsubscribe@googlegroups.com>
            <mailto:django-users+unsubscribe@googlegroups.com
            <mailto:django-users%2Bunsubscribe@googlegroups.com>>.
            To post to this group, send email to
            django-users@googlegroups.com
            <mailto:django-users@googlegroups.com>
            <mailto:django-users@googlegroups.com
            <mailto:django-users@googlegroups.com>>.
            Visit this group at
            https://groups.google.com/group/django-users.
            To view this discussion on the web visit
            https://groups.google.com/d/msgid/django-users/CAGuvt90b-QZ54tvfNAKDBMUV-saEMXsb4G72gLiRSp2tzxjqKw%40mail.gmail.com
            <https://groups.google.com/d/msgid/django-users/CAGuvt90b-QZ54tvfNAKDBMUV-saEMXsb4G72gLiRSp2tzxjqKw%40mail.gmail.com?utm_medium=email&utm_source=footer>.
            For more options, visit https://groups.google.com/d/optout.


        --         You received this message because you are subscribed to the
        Google Groups "Django users" group.
        To unsubscribe from this group and stop receiving emails from
        it, send an email to django-users+unsubscribe@googlegroups.com
        <mailto:django-users%2Bunsubscribe@googlegroups.com>.
        To post to this group, send email to
        django-users@googlegroups.com
        <mailto:django-users@googlegroups.com>.
        Visit this group at https://groups.google.com/group/django-users.
        To view this discussion on the web visit
        https://groups.google.com/d/msgid/django-users/f92268fe-a077-a2d1-f8d4-64810031e2ae%40dewhirst.com.au.


        For more options, visit https://groups.google.com/d/optout.


    --     You received this message because you are subscribed to the Google
    Groups "Django users" group.
    To unsubscribe from this group and stop receiving emails from it,
    send an email to django-users+unsubscribe@googlegroups.com
    <mailto:django-users+unsubscribe@googlegroups.com>.
    To post to this group, send email to django-users@googlegroups.com
    <mailto:django-users@googlegroups.com>.
    Visit this group at https://groups.google.com/group/django-users.
    To view this discussion on the web visit
    https://groups.google.com/d/msgid/django-users/CAK4qSCescFKH4vTrxSy1E3-HJ4n5-BZd5iw7%2BDQmuSkDqiua-g%40mail.gmail.com
    <https://groups.google.com/d/msgid/django-users/CAK4qSCescFKH4vTrxSy1E3-HJ4n5-BZd5iw7%2BDQmuSkDqiua-g%40mail.gmail.com?utm_medium=email&utm_source=footer>.
    For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com <mailto:django-users+unsubscribe@googlegroups.com>.
To post to this group, send email to django-users@googlegroups.com <mailto:django-users@googlegroups.com>.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CAGuvt91kwYH89pHpMCEV8gOzztNVddRCfCho8dBse4yGH900EA%40mail.gmail.com <https://groups.google.com/d/msgid/django-users/CAGuvt91kwYH89pHpMCEV8gOzztNVddRCfCho8dBse4yGH900EA%40mail.gmail.com?utm_medium=email&utm_source=footer>.
For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/35695cf3-8408-a566-2a11-092a269907ed%40dewhirst.com.au.

For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CAK4qSCeiUScRfhWmiHwithcbnMgo9yrxpXNFR3fPA10JtKSY0A%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment