News for hackers. Stuff that matters.
Re:Textual: Rapid Application Development Framework for Python by JonathanBeuys on Friday August 18, 2023 @10:28AM (#37176130)
After a few decades of developing applications, I am convinced that frameworks are the wrong approach.

You gain development speed in the beginning, but you lose it later on when the framework introduces breaking changes and you have to keep working around a changing stack. Or the framework gets abandoned and it would be too much work to maintain it. Because it has so much bells and whistles you don't need. This one for example contains 1298 files without dependencies.

Both, coding everything yourself or using lean libraries are better. There are very few lean libraries unfortunately. Keeping code elegant and simple is a rare skill.

When there is a lean, well done library for my use case, I use it. Because if shit hits the fan, I can maintain the library myself.

Re:Textual: Rapid Application Development Framework for Python by anonzzzies on Friday August 18, 2023 @10:39AM (#37176277)
> There are very few lean libraries unfortunately. Keeping code elegant and simple is a rare skill.

So... You are saying 'you should write everything yourself with libraries that basically don't exist'? I agree with you somewhat, but it's not very realistic; it's so much faster to use something that gets you 80% of the way with minimum work. And you know it'll break in a bit but that's life.

Also, thinks like Django or ASP.NET have been pretty stable for a very long time. We have large Django projects from 10 years and updating those was a breeze.

Re:Textual: Rapid Application Development Framework for Python by TekMol on Friday August 18, 2023 @10:52AM (#37176480)

    it's not very realistic
It is totally realistic. I have multiple projects running that do not use any external code. With millions of users.

Those projects are PHP though. PHP has a lot of bells and whistles on board. Unfortunately with PHP 8, they started introducing a lot of breaking changes. So they lost my trust and I will use Python for new projects.

Not sure yet if I will use Django (As you said, it seems pretty stable) or do the good old CGI approach. If I do the latter, I will probably write a new CGI library for it, because in the Python ecosystem it is all about long running processes nowadays and I think that is the wrong approach.

Re:Textual: Rapid Application Development Framework for Python by VectorLock on Friday August 18, 2023 @11:56AM (#37177478)
There are some good reasons that everything, PHP and Python included, moved away from CGI to long-running processes.
Re:Textual: Rapid Application Development Framework for Python by miahwilde on Friday August 18, 2023 @12:31PM (#37178086)
Long-running processes have their uses but they are not the only tool or the end of the evolution. "Serverless lambda" is one example of how moving back to one-off processes provides a different kind of value.
Re:Textual: Rapid Application Development Framework for Python by TekMol on Friday August 18, 2023 @12:30PM (#37178073)
Name one.
Re:Textual: Rapid Application Development Framework for Python by eesmith on Friday August 18, 2023 @01:03PM (#37178631)
In general, startup takes time - import dependencies, read config files, make a database connection, and so on. That time can be noticeable.

Years ago I had to deploy on a network file system which was very slow for file stats. (It was designed for HPC and bandwidth.)

Python startup (by default) requires a large number of stat calls. It took our CGI app over a second just to start.

I was able to improve it by packaging the Python std lib as a zipfile, and our app as another, since zipimports avoid a lot of stat calls.

TurboGears had just come out. I did a prototype using it. Its was so much faster!

For organizational reasons were were not able to switch. IT took over and, after several years, replaced it all with a Java version.

Re:Textual: Rapid Application Development Framework for Python by TekMol on Friday August 18, 2023 @01:33PM (#37179179)
What is your problem with startup time? Have you timed it? How long does it take?

PHP starts up from scratch on every request, yet it blows Python out of the water performance wise.

Re:Textual: Rapid Application Development Framework for Python by Thews on Friday August 18, 2023 @02:44PM (#37180257)
It's been a while since I've seen anyone brag about PHP's speed.

PHP is quite slow at encoding and decoding JSON, very slow at any kind of tree data structure, and has among the highest memory usage of any language at printing a string of text to a console or otherwise.

Python is faster at all of those things and it's quite slow. Those are kind of web related tasks, and the web benchmarks for say django vs laravel don't show that PHP is any kind of winner.

Re:Textual: Rapid Application Development Framework for Python by VectorLock on Friday August 18, 2023 @03:05PM (#37180545)
If he think's CGI startup time is acceptable then I guess maybe PHP seems fast then?
Re:Textual: Rapid Application Development Framework for Python by Thews on Friday August 18, 2023 @03:19PM (#37180728)
My bigger issue with the CGI model is the lack of handling connections as streaming. You can't parse a file while it's still being uploaded, and that can eat up a lot of memory on larger files.

I know startup times can take a toll like establishing db connections, cache checking (like redis), file imports, etc. If you are using something that starts up for every request, then you have to be aware of those kinds of things and design around them.

Re:Textual: Rapid Application Development Framework for Python by aidos on Friday August 18, 2023 @02:57PM (#37180445)
By the time everything is imported and running you can be into the territory of really not wanting to do it on every request. I’ve not timed it in my case for a while but you’re definitely looking at 100s or 1000s of ms.
Re:Textual: Rapid Application Development Framework for Python by eesmith on Friday August 18, 2023 @03:37PM (#37181003)
> Have you timed it?

I literally gave a timing number in my comment.

The >1 second time was for a very unusual circumstance. Unless you timed PHP startup time using straight CGI (not mod_cgi, nor FastCGI) on a Lustre file system about 15 years ago, with the appropriate set of extensions enabled for what our application needed, you can't really compare the two.

> PHP starts up from scratch on every request

Congratulations.

Now getting back to your request to "Name one", the PHP documentation at https://www.php.net/manual/en/install.unix.commandline.php gives essentially the same answer as I did:

"By default, PHP is built as both a CLI and CGI program, which can be used for CGI processing. If you are running a web server that PHP has module support for, you should generally go for that solution for performance reasons."

Re:Textual: Rapid Application Development Framework for Python by VectorLock on Friday August 18, 2023 @11:13PM (#37185115)
Even to execute the most minimal binary fork/execve takes a not insignificant amount of time. Thats one of the reasons why CGI fell by the wayside.
Re:Textual: Rapid Application Development Framework for Python by paulddraper on Friday August 18, 2023 @02:17PM (#37179865)
Perf
Re:Textual: Rapid Application Development Framework for Python by thewataccount on Friday August 18, 2023 @03:08PM (#37180586)
Long running processes only need to load their imports, configuration, database connections, etc. once, and don't incur overhead for each request. On top of this, things like imports get to be cached, and there's less need for a database connection pooler to broker connections.

Particularly async runtimes have become more popular - where you can have a single process handling concurrent requests and awaiting/yielding in between their api/db calls. Instead of having many processes that don't share resources that might be waiting 10ms/100ms for api/db calls.

For applications that make large numbers of api/db calls - especially slower ones, may prefer async runtimes over individual processes per request.

I'm not at all saying CGI is a bad option, just that there are real benefits to reusing, pooling and caching resources.

Re:Textual: Rapid Application Development Framework for Python by haswell on Friday August 18, 2023 @10:46AM (#37176379)
I think this really depends on the kind of applications you’re developing, and how you use frameworks during the development process.

Frameworks really shine at quickly proving out concepts. They enable prototypes that would have otherwise been too costly to produce, which is often the difference between a project moving forward or not.

The problem is often what comes next: teams fall for the productivity boost and carry the rapid design forward expecting similar gains throughout the rest of the project.

I use frameworks when I want to get ideas out of my head. I tend to throw framework code away if I take the project further, and I’m in a better position to implement from scratch knowing what I’d do differently.

YMMV, the environment you work in makes a big difference, the kind of thing you’re building makes a big difference, etc.

Re:Textual: Rapid Application Development Framework for Python by kbrannigan on Friday August 18, 2023 @01:01PM (#37178602)
this is developer's gospel for me So I don't have to always to use the framework's feature all the time ??!!!

When I face an issue with the framework, I tend to question my ability as a programmer, even though i could code it myself.

Like a non trivial django form, I could have just manually coded the form, then just pass the data to the view, validate it manually. Instead of fighting

Re:Textual: Rapid Application Development Framework for Python by DenisM on Friday August 18, 2023 @04:42PM (#37181826)
This very insightful, thank you.

A great example of finding a way out of clutches of a dichotomy.

Re:Textual: Rapid Application Development Framework for Python by PurpleRamen on Friday August 18, 2023 @10:50AM (#37176467)
Frameworks exist, because you can't code everything yourself. And libs are pointless if you need interconnected gears, which UIs are very heavy users of. Frameworks exist, and remain to exist, because there is demand and they solve problems. But yes, not every framework is good.
Re:Textual: Rapid Application Development Framework for Python by dclowd9901 on Friday August 18, 2023 @10:52AM (#37176485)
I’m inclined to agree. Unless the framework implements a lot of opinionated behavior that aligns with your product goals, you almost invariably end up fighting it. And on a long enough time line, that tends to happen anyway.

But that’s not why we adopt frameworks. We do it so that engineers are fungible commodities. It makes it easier to find, hire and onboard additional resources. Also requires fewer resources since you don’t need folks on your team dedicated to maintaining your house-built framework.

So, while I agree that building something in house is better for getting exactly what you want from a framework, it isn’t very practical from a business standpoint.

Re:Textual: Rapid Application Development Framework for Python by mrits on Friday August 18, 2023 @11:08AM (#37176723)
If your app lives in a vacuum I don't see why you'd ever need to upgrade the framework.

If it doesn't then the code you wrote yourself will eventually break as the rest of the world advances their APIs and standards.

Even a website written in pure HTML and put up on a small linux server a decade ago would have rendering issues as well as probably not allowed past browsers or corporate firewalls due to older SSL libraries.

Re:Textual: Rapid Application Development Framework for Python by unoti on Friday August 18, 2023 @12:09PM (#37177697)
> If your app lives in a vacuum I don't see why you'd ever need to upgrade the framework.

Unfortunately the only apps that live in a vacuum are embedded apps not connected to the internet. We should all be monitoring our dependencies for security upgrades. Eventually even a stable framework like Django goes out of long term support. I wrote a Django app in 2008 that is still in heavy use today and at some point had to go through and upgrade to a new major version. It wasn’t a breeze, it took me a few weeks. To leave the app live on that 10 year old version would have been irresponsible for security reasons. The only apps that live in a vacuum are embedded apps, like the one in a vacuum cleaner.

Re:Textual: Rapid Application Development Framework for Python by mrits on Friday August 18, 2023 @03:57PM (#37181257)
The vacuum gets power from an electrical network that is also fully capable of transferring structured digital information as well. My point is that your own code will also break if you don't keep it maintained for all practical purposes.
Re:Textual: Rapid Application Development Framework for Python by dalke on Friday August 18, 2023 @01:23PM (#37178992)
My static pure HTML+CSS site is nearly 20 years old and renders just fine in modern browsers.

It's so old it has no https interface.

I do depend on my hosting provider to keep Apache and FreeBSD up to date, if only for security reasons.

Re:Textual: Rapid Application Development Framework for Python by mrits on Friday August 18, 2023 @03:58PM (#37181261)
Yeah, that was my point. You couldn't get to non https sites in a lot of situations
Re:Textual: Rapid Application Development Framework for Python by ye-olde-sysrq on Friday August 18, 2023 @11:11AM (#37176771)
You could also just use some known, boring technology. I was using Java Swing in 2016. It was rock-solid and unchanging. It will outlive me. Nobody is going to touch it again (all the churn is now in JavaFX). And yet! It even got HiDPI support somewhere around Java 8 or 9 (or at least, whatever they did, Swing apps now respect display scaling when at one point they definitely did not).
Re:Textual: Rapid Application Development Framework for Python by VectorLock on Friday August 18, 2023 @11:55AM (#37177454)
Compare and contrast your operating system, and how many files and breaking updates that gets.
Re:Textual: Rapid Application Development Framework for Python by paulddraper on Friday August 18, 2023 @12:24PM (#37177953)
> I am convinced that frameworks are the wrong approach

Frameworks are always eventually the wrong approach.

But so many projects need a 1.0 without breaking the bank.

Re:Textual: Rapid Application Development Framework for Python by miahwilde on Friday August 18, 2023 @12:33PM (#37178118)
Do you perchance maintain a short list of clean and lean libraries?
Re:Textual: Rapid Application Development Framework for Python by IKantRead on Friday August 18, 2023 @12:53PM (#37178467)
I really want to agree with this, but the trouble is that an unstated prerequisite is that you need a team of developers that have a strong sense of software design. A sensibility I've come to believe is drastically in decline in more junior software engineers (though don't mistake this for a statement that the quality of these devs appears any less).

Just take Ruby on Rails, which is probably a great example of a framework that runs into the problems you're describing. My experience with more contemporary, generally more junior, dev teams is that the "Rails" part of the framework is essential for these developers to maintain any loose semblance of adherence to any kind of architecture or design principles.

Earlier in my career I remember, even junior devs, spending a fair amount of time thinking about about the abstractions they were using, making design decisions, and often times being more guilty than not of over thinking abstractions.

Today I've seen so many very bright and talented engineers whose sole view of good software is minimizing the time from request to PR (and code reviews that strong favor minimizing the time from PR -> prod).

If you have a bunch of senior engineers (not SV "senior", but truly experienced), and they're the type that still pick up SICP form time to time, or spend a Saturday reading a section of TAOCP, then sure I think the framework-free approach is best. But you also don't need to tell that to a team of engineers like that.

Otherwise, frameworks and even languages that do the most handholding when it comes to design decisions are going to remain essential.

Re:Textual: Rapid Application Development Framework for Python by kanbara on Saturday August 19, 2023 @01:12AM (#37185734)
what’s with the jab about SV “senior”? where i am, senior engineers are properly senior. and nobody even knows what levels and titles people have. ¯\_(ツ)_/¯
Re:Textual: Rapid Application Development Framework for Python by pbreit on Friday August 18, 2023 @01:18PM (#37178924)
Any suggestions for lean Python libraries besides Flask?
Re:Textual: Rapid Application Development Framework for Python by datadrivenangel on Friday August 18, 2023 @02:44PM (#37180262)
Fast API is very lightweight.
Re:Textual: Rapid Application Development Framework for Python by billowycoat on Friday August 18, 2023 @01:21PM (#37178973)
For a TUI though? A plain old terminal gives you next to nothing. Not even buttons or scroll bars.

A lean library will turn in to a framework if you decide to build anything more than a minimally complex app.

The widgets are conditional imports. If you don’t use the tree widget, it is never imported.

Re:Textual: Rapid Application Development Framework for Python by codegeek on Friday August 18, 2023 @01:26PM (#37179069)
Most code is written to make money. Frameworks make it easy to not only start a project but run it for a long time with fast time to market. I agree that if it was just about writing nice code, libraries are good but if you want to make money writing code, frameworks help do it much faster.

You could argue that you can make money writing without frameworks but at what cost and how many teams can successfully do that ? Framework gives any team (even average ones) the headstart they need to continue to actually do something that makes money.

Re:Textual: Rapid Application Development Framework for Python by baq on Friday August 18, 2023 @02:17PM (#37179868)
Nail on the head.

Too many devs care way too much about having a pretty solution instead of a cost-efficient one. The solutions space usually has a middle ground somewhere (affectionately called 'horrible hack' every once in a while). It's what makes a difference between a software engineer and a programmer.

To paraphrase, anyone can build good software, but it takes an engineer to build good software quickly.

Re:Textual: Rapid Application Development Framework for Python by sharts on Friday August 18, 2023 @08:58PM (#37184284)
Nothing is stopping one from versioning and packaging their dependencies. Then there is no work to maintain anything and you can address any other changes with your own code if you like.

Libraries can change as well. Frameworks are just that, a bunch of libraries.