Live data from Hacker News

FastHTML – Modern web applications in pure Python

fastht.ml

81–90 of 229 posts

Re: FastHTML – Modern web applications in pure Python

#81
FastHTML is an impressive and innovative idea. It seems like a web development tool similar to Streamlit, but with more precise control.

FastHTML's concept led me to consider a feature that allows direct deployment of PyQt code as web services, even without HTML knowledge, like "PyQtWeb."

PyQtWeb > FastHTML > [Streamlit, Gradio]

Re: FastHTML – Modern web applications in pure Python

#83
post #67

Python is fast compared to something? Maybe fast enough to generate HTML.

Fast enough for YouTube, Instagram, and Dropbox. If you need to scale up bigger than that then maybe reach for something else I guess. Today's HN launch of FastHTML's home page was running on a $5/month hobbyist account at Railway.app, where it averaged 1% utilization of 1 VCPU. (The trick, as always, is to optimise the inner loops in your app as needed; often that just means using pre-existing fast libs for that bit…

YouTube instagram and Dropbox definitely don’t scale thanks to python. They scale thanks to the massive infrastructure they built around some python code. Cdn caches etc. we all know this. And they could probably save money by migrating to a more performant and safe language. But they have money firehoses and household brand recognition so they don’t care.

Re: FastHTML – Modern web applications in pure Python

#86
Hi Jeremy, congratulations for the launch and the website looks very nice indeed.

I am honestly mostly interested in your reason, to mix HTML/CSS generation into the Python code. Disclaimer, I am very biased towards separation of concern and like my backend just returning JSON/XML/whatever data and a templating system. Of course this increases the ramp-up time to learn a framework, but then it is IMHO very powerful, flexible and fast.

Could you perhaps elaborate on your choice for FastHTML and what tradeoffs you see?

Re: FastHTML – Modern web applications in pure Python

#87

Python is fast compared to something? Maybe fast enough to generate HTML.

Python is glue, used to call and integrate other faster languages. Most of what is done with Python is calling fast C and C++ code.

Back in ancient times, a software project I was working in, failed, precisely because of Python performance with the Zope framework, it was too slow to render a webpage that required more than a few interesting calculations.

Today the language is almost the same, but computers have a thousand times more memory, and the CPUs are similarly faster.

The exact same project would have been successful today, just like neural networks are cornerstones of modern computing, because of the advances in hardware.

Re: FastHTML – Modern web applications in pure Python

#88

Sorry, but I hate server-side "helper" functions that generate HTML. For one thing it's never the same as what eventually gets shown on the page. 99.9% of the time you're missing attributes when needs to be hacked around. Debugging is a nightmare. Refactoring is hell. And css programmers have no clue what to do with this. Maybe I'm missing something here. Why not a templating engine?

> Maybe I'm missing something here.

I think you are missing how htmx (https://htmx.org/) is intended to be used. You still have your regular HTML page and by interacting with that HTML, you trigger server-side functions that return HTML. That HTML is used to update only a small part of your page. htmx works with HTML fragments while HTML templates work with entire pages.

Re: FastHTML – Modern web applications in pure Python

#89
post #75

Python is fast compared to something? Maybe fast enough to generate HTML.

ROI is more important than silly benchmarks. https://www.tiobe.com/tiobe-index/ But, we can play the benchmark game, if that tops your morning cereal. Competes with Go. Blows most popular TS frameworks out of the water. https://www.techempower.com/benchmarks/#section=data-r22&hw=... For you: https://gprivate.com/6chku

That benchmark makes Go look good, and JS very good. The upper part of the table belongs to Go, and the very top is JS.

The bottom of the benchmark table are all slow Python implementations xD

Re: FastHTML – Modern web applications in pure Python

#90

Oh my goodness. I like to keep things boring where possible and swore I would never stray from Django + HTMX + Django Ninja, but I am exceedingly tempted to use this in an upcoming project. Lovely architectural choices - bravo!

It's a bit of a tangent, but do you have any go-to resources for learning how to use Django-ninja with HTMX? I haven't really put a lot of time into it, but HTMX seemed difficult to use with JSON APIs on first attempt. I'm only really familiar with Django and DRF, but if love to switch at some point.

Htmx isn’t designed to work with JSON APIs at all. It needs HTML back from the server. You can detect when a request comes from htmx with a header it adds though so that allows you to return a different response if you want.
Post reply on HN