DEV Community

loading...

Discussion on: 12 Reasons to use Python, not JS, for Front End Web Development

Collapse
richardr91 profile image
richardr91

This is a super interesting product! As a budding dev, I've been learning Javascript and am just getting my feet wet with Python. I love how straight forward the syntax is but it makes me wonder...how does Anvil do on performance? While great for data management and processing, it's been noted that Python's speed is slower than Javascript. Does anvil support the shadow DOM? I really like the modular approach with web components and how much easier it is to manage DRY styling with SCSS. It would be a dream to streamline building with those technologies and Python!

Collapse
meredydd profile image
Meredydd Luff Author

Well, you're asking the right person - I'm a maintainer of the Skulpt Python-to-JS compiler we use!

The answer is that, inevitably, compiling Python to JS comes with a performance hit. Our responses are twofold: First, we're narrowing the gap, by improving the compiler/toolkit speed (one example: we just landed a deep refactor of Skulpt that speeds up compiled code 2x!). Having said that, front-end Python performance often isn't the bottleneck to making an app feel snappy - it's usually about, eg, being smart about how you load data from the back end.

Second, if you need to do something in JS, you can! Anvil supports calling JS objects from Python, and vice versa (see my Christmas DEV post where I build a 3D model with THREE.js). This means that you can build your whole app with Anvil, and if some part hits a performance limit (or any other limit), you can rewrite that particular component in JS. This is part of our philosophy of always offering an escape hatch -- if you need to go low-level, you can.

Collapse
richardr91 profile image
richardr91

In a world opinionated tools, I love the incorporation of an escape hatch! Often as a beginner, what starts off as a simple low level experiment, quickly whirlwinds into a much bigger undertaking what with trying to wrangle so. many. frameworks. Thanks for taking the time to answer to my questions. Off to play!