[Python-ideas] Towards harmony with JavaScript?

Carl Smith carl.input at gmail.com
Sat Aug 12 13:44:41 EDT 2017


Alberto,

CoffeeScript is a popular language that is widely considered to represent
JavaScript's best bits, and it only has anonymous functions, so there's a
large part of the JS community that disagrees with you there.

Browsers actually do identify anonymous functions, based on the
variable/property names that reference them, so the following function
would be identified as `square` in tracebacks:

let square = function(x) { return x * x };

In any case, passing anonymous functions to higher order functions is
commonplace in real-world JS. Chris may be right about using decorators as
a Pythonic alternative [I haven't really considered that properly to be
honest], but you can't just tell people not to do something that they see
as elegant and idiomatic.

Best -- Carl Smith


-- Carl Smith
carl.input at gmail.com

On 12 August 2017 at 17:22, Nick Coghlan <ncoghlan at gmail.com> wrote:

> On 12 August 2017 at 06:10, Chris Barker <chris.barker at noaa.gov> wrote:
> >
> >> > Taking this off the list as it's no longer on topic.
> >
> >
> > not totally -- I'm going to add my thoughts:
> >
> > 1) If you want a smoother transition between server-side Python and
> > in-browser code, maybe you're  better off using one of the "python in the
> > browser" solutions -- there are at least a few viable ones.
>
> More experimentally, there's also toga's "web" backend (which allows
> you to take an application you developed with the primary intention of
> running it as a rich client application on mobile or desktop devices,
> and instead publishing it as a Django web application with a
> JavaScript frontend).
>
> Essentially, the relationship we see between Python and JavaScript is
> similar to the one that exists between Python and C/C++/Rust/Go/etc,
> just on the side that sits between the Python code and the GUI, rather
> than between the Python code and the compute & storage systems.
>
> As such, there are various libraries and transpilers that are designed
> to handle writing the JavaScript *for* you (bokeh, toga,
> JavaScripthon, etc), and the emergence of WASM as a frontend
> equivalent to machine code on the backend is only going to make the
> similarities in those dynamics more pronounced.
>
> In that vein, it's highly *un*likely we'd add any redundant constructs
> to Python purely to make it easier for JS developers to use JS idioms
> in Python instead of Pythonic ones, but JavaScript *is* one of the
> languages we look at for syntactic consistency when considering
> potential new additions to Python.
>
> Cheers,
> Nick.
>
> --
> Nick Coghlan   |   ncoghlan at gmail.com   |   Brisbane, Australia
> _______________________________________________
> Python-ideas mailing list
> Python-ideas at python.org
> https://mail.python.org/mailman/listinfo/python-ideas
> Code of Conduct: http://python.org/psf/codeofconduct/
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20170812/74ff592a/attachment-0001.html>


More information about the Python-ideas mailing list