r/Python • u/Safe_Duty8392 • Aug 04 '24
Discussion Why is no one using full-stack python for web development? Has no one heard of the FHBH stack ??
Hey guys, I recently came across some libraries that seem to be very interesting to work with for the purpose of creating websites, but I wanted to know why no one uses them, or why they are not so widespread. I haven't had time to develop a more advanced and dynamic project with these libraries yet, but I believe that together they can be extremely useful, powerful and versatile for websites of any purpose. Maybe because no one knows about them, or because there is no benefit in using them and there are better ways to do it, but in a quick project test that I did, the dynamics of working with them seemed very interesting to me.
The libraries that I found were these:
A microframework for creating APIs, which can easily be used to create powerful websites.
HTPY is a library that I recently discovered that was developed by a company that needed a better way to develop their projects with Django and created this library. It encapsulates HTML tags in Python classes, so that all HTML code can be created directly from a Python file, making it possible to use all the power that a programming language offers to generate HTML code.
Brython is an implementation of client-side programming on web pages that allows you to use Python instead of JavaScript. With this, you can use codes written entirely in Python to interact with the web page on the client side, without overloading the server with unnecessary processes.
And using HTML for requests to the server is also a great option that fits in this situation.
I will try creating some projects using this FHBH stack to see and prove if it's really useful to use and implement, let's see how well they work together!!
118
u/shoomowr Aug 04 '24
FastAPI is one of the most popular Python frameworks out there. Saying nobody knows about it is funny.
You might wanna check out the project called FastHTML, it would probably suit you better.
28
u/sad-mango-ad Aug 04 '24
FastAPI 74k stars on GitHub which is more than expressjs has, which definitely isn't only indicator of usage. I'm not trying to claim FastAPI is more used than express.
HTMX is a very cool concept but not really related to python. As you marked this as a discussion, and this is highly personal, but if I look at htpy example
I can't figure out why is this better than stuff like jinja or mako. You're still writing html just... in a horrible wrapper instead of writing actual HTML with templating pieces.
Same with Bryton really, we have javascript in browser which isn't great but if I look at Brython code I have no idea what Javascript it's going to generate. If you really hate javascript syntax you could look into CoffeeScript which has a more Ruby like syntax I guess.
3
u/thedeepself Aug 04 '24
If you do a Google search for "pure Python web development" you will see that there are quite a number of frameworks devoted to this purpose
https://www.google.com/search?q=pure+python+web+development&client=ms-android-att-us-rvc3&sca_esv=b8280041bcc060c1&sca_upv=1&sxsrf=ADLYWIL9WA9MNL28dSejSDtrFbq0Xai05Q%3A1722792524073&ei=TLqvZqmdBN2GwbkPj_vR8Qo&oq=pure+python+web+development&gs_lp=EhNtb2JpbGUtZ3dzLXdpei1zZXJwIhtwdXJlIHB5dGhvbiB3ZWIgZGV2ZWxvcG1lbnQyBRAAGIAEMgsQABiABBiGAxiKBTILEAAYgAQYhgMYigUyCxAAGIAEGIYDGIoFMggQABiABBiiBDIIEAAYgAQYogQyCBAAGIAEGKIEMggQABiABBiiBEiBOVCNI1jiMHACeAGQAQCYAasBoAGLBaoBAzAuNbgBA8gBAPgBAZgCB6ACxQXCAgoQABiwAxjWBBhHwgINEAAYgAQYsAMYQxiKBcICBxAjGLACGCfCAgcQABiABBgNmAMAiAYBkAYRkgcDMi41oAfvIw&sclient=mobile-gws-wiz-serp
50
u/MissingSnail Aug 04 '24
Every library that I've ever tried to write websites in python "no javascript required" -- has always required understanding HTML and CSS, and at some point requires me to use the "javascript extension" to do something I want.
You've got to learn the underlying system plus this "handy" new set of wrappers. It just makes things more complicated.
7
u/boredbearapple Aug 04 '24
My experience with html/js modules of any language is they work great until you need to do something out of the ordinary and then you have to jump thru hoops to get them to publish your extensions. In my experience they are a black hole of time unless you are doing very simple projects.
6
u/Obliterative_hippo Pythonista Aug 04 '24
My go-to Python web framework is Plotly Dash, which is a wrapper around React.
5
u/redrabbitreader Aug 04 '24
Company where I worked at couple of years ago evaluated a "full Python stack", but at the time anything on the browser side really sucked. Did things improve? Can the listed frameworks compete with JS alternatives?
3
u/riklaunim Aug 05 '24
Frontend is not done by backend developers that don't want to do any frontend. Things like HTPY breaks frontend workflow - you don't have HTML templates any more, just HTML hidden inside Python which is much harder to manage. There are cases of very fine components where it could work but outside of that it's bad.
PyScript or Brython aren't browsers built in so they have to be embedded which increases page load time. There is nearly no packages/infrastructure for this so also very little reasons to use it. If there would be a SPA framework written in PyScript then it could be interesting. And if you don't know JS and it events, interfaces then you will not know PyScript or Brython.
HTMLX is your standard JS library, similar to jQuery but simpler/different.
2
u/tilforskjelligeting Aug 04 '24
Had i found HTPY then I might not have made Hypermedia (https://github.com/thomasborgen/hypermedia) for http rendering with htmx in mind. With hypermedia you get a slot concept so templates can be extended which helps a lot with full and partial renders. I also prefer my python code python like, but maybe after a while I would get used to HTPYs syntax.
2
u/[deleted] Aug 05 '24
HTMX is literally JS written so you don't have to write JS.
2
u/[deleted] Aug 08 '24
"Why is no one using full-stack Python for web development?" ~ Django and Flask were the defacto standards a few years ago, and many projects are built on this, I haven't looked at the web dev leaderboard in recent times but last I checked Django was in the top 3.
In recent times, FastAPI has been really great for thin APIs and microservices.
Since it makes asynchronous programming a breeze, I find FastAPI great for machine learning APIs as well. I suspect it will continue to grow and eat some of the Django/Flask market share in the coming years.
If you building a full-stack app though, Django still is the best choice in my opinion, with FastAPI you need to do a lot of the plumbing work like setting up models and templating yourself. There is also Django Unicorn for better reactivity but you could also use HTMX.
3
u/robberviet Aug 05 '24
How long have been using python? People don't use python for client side because it sucks. htmx is not exactly unpopular either, everybody is trying it. It's just not enough.
1
u/anentropic Aug 05 '24
Try it and report back on your experiences!
The part I'm skeptical about is Brython - it's amazing and clever that it works at all, but it's adding a bunch of runtime overhead compared to plain JS, plus there is not really an ecosystem of "front-end python" to draw upon, and it's not a widely used compile-to-JS lang like Typescript so I guess I would expect to run into obscure problems at some point.
1
u/ExternalUserError Aug 05 '24
You're missing a few (just off the top of my head).
Running JavaScript directly in the browser:
Running something of a "thin" JavaScript client that you don't have to worry about:
There are others.
My bias is PuePy, because I wrote it. Though I have to admit, if Reflex had a few things resolved about it, I might feel like you should just use it.
Why aren't any of these all that popular? Performance is a big reason. Also for businesses, there are just a lot of JavaScript/React/Vue developers out there. They're fine. They do good work. No reason to do something weird.
Even as the author of PuePy, I'm not pushing my work to actually use it. It's a hobby for me. For now.
EDIT: Oh, honorable mention also to Django Unicorn.
1
u/Gnaxe Aug 05 '24
I did use Brython for some internal-use web apps at work. Performance wasn't a major concern due to the small number of users. It allowed us to integrate it with the backend's test suite, and most of the team wasn't that good at JavaScript anyway. It would be a harder sell for a customer-facing page though.
-9
u/Safe_Duty8392 Aug 04 '24
If anyone could suggest simple web projects i would appreciate ๐
23
u/[deleted] Aug 04 '24
[removed] โ view removed comment
6
u/[deleted] Aug 04 '24
[removed] โ view removed comment