Earlier quoted context omitted.
JavaScript is optional even on the client side nowadays with the advent of PyScript via WASM, etc.
I did not know that. Is it true? Can I have dynamic updates (something like what AJAX does) without refreshes? If so, I need to do some research in this area! I assume I can use any programming languages for WASM as well?
Htmy – Async, pure-Python rendering engine
81–90 of 90 posts
Re: Htmy – Async, pure-Python rendering engine
#82I was looking for something like this a few weeks ago. I typically use Django and hate the template engines limitations. I needed to make some reusable components and the best option available was switching to jinja to get their macro support, bleh. This reminds me of the best part of Flutter UI composition, but in a language I always return to. Have you done any benchmarking? I don't even know what the comparison wo…
The renderer is as simple/minimal as possible at this point (the focus was on the core feature set I needed until now), so it's performance is as bad as it can be :) There's plenty of room for improvement. I'll work on a few optimizations as I have time, but contributions are more than welcome.
Re: Htmy – Async, pure-Python rendering engine
#83Earlier quoted context omitted.
I just completely disagree. Async is syntactic sugar that can be reduced to sync code with callbacks. It doesn’t exist on equal footing. If you want to call sync code from async code, you just… call it. If it performs blocking IO, it’ll block, but that’s exactly what it would do if called from other sync code, too. By contrast, calling async code from sync code requires a special blocking wrapper (Python) or unavoida…
> Async is syntactic sugar that can be reduced to sync code with callbacks The whole point of introducing async was to get away from callback hell.
Re: Htmy – Async, pure-Python rendering engine
#84Earlier quoted context omitted.
But does it actually work that way? If I `await fetch_from_api()` in the first component before returning the tree with the second component that fetches from my backend, `fetch_from_api()` has to resolve before Htmy finds out about the second component.
You’d have to structure it differently, it’s definitely not a free lunch
Re: Htmy – Async, pure-Python rendering engine
#85Would love to see some benchmarks for all these libraries that compare them to Jinja2.
They are almost always slower, because jinja uses some compilation tricks. But, it usually doesn't matter compared to remote database access.
Re: Htmy – Async, pure-Python rendering engine
#86Earlier quoted context omitted.
> By contrast, calling async code from sync code requires a special blocking wrapper (Python) ... That's exaclty my point. If you don't have async by default in your platform you need to do stupid things to fake it. If function calls and main in Python were innately async you could be calling async code just as easily as sync code. > [...] or unavoidably breaks control flow (JavaScript). async/await syntax avoids it…
> would require small revolution that might happen at some point. or python could have blessed gevent and done away with all the nonsense.
Re: Htmy – Async, pure-Python rendering engine
#87Earlier quoted context omitted.
> would require small revolution that might happen at some point. or python could have blessed gevent and done away with all the nonsense.
I hope that someone does an oral history of why gevent wasn't seen as the solution here. The existence of models like Twisted, and a general idea that yields to an event thread should be explicit in some way, I think caused the exact kind of fracturing of the ecosystem that everyone was trying to avoid. "Everyone will write async code" simply didn't happen in practice.
Re: Htmy – Async, pure-Python rendering engine
#88Re: Htmy – Async, pure-Python rendering engine
#89Earlier quoted context omitted.
You’d have to structure it differently, it’s definitely not a free lunch
Right, but if this framework enabled that optimization, I’d expect it to have some examples showing how you’d implement it. As far as I can tell, there’s no way to structure your code to allow parallel component rendering with this framework.
I want to have at least the same level of concurrency when the new, better optimized renderer lands.
Re: Htmy – Async, pure-Python rendering engine
#90Earlier quoted context omitted.
I did not know that. Is it true? Can I have dynamic updates (something like what AJAX does) without refreshes? If so, I need to do some research in this area! I assume I can use any programming languages for WASM as well?
Sure, dynamic updates are possible. Re language support, I'm only aware of PyScript for Python, and Blazor for C# already being fairly mature. But there are other language ports in progress.