News for hackers. Stuff that matters.
Re:PostgREST: Providing HTML Content Using Htmx by kreetx on Monday December 18, 2023 @05:33PM (#38689349)
What a neat web development stack, just html & database! No back-end and no front-end required.
Re:PostgREST: Providing HTML Content Using Htmx by markbnj on Monday December 18, 2023 @05:40PM (#38689424)
Years ago, mid-90's, I visited Compuserve in Ohio. The web was just getting going and one of the engineers I met there showed off a music store he was building by returning html from SQL stored procedures :).
Re:PostgREST: Providing HTML Content Using Htmx by bsdpufferfish on Monday December 18, 2023 @05:44PM (#38689468)
The quality of open source databases with views, partitions, etc as well as improvements in server hardware have made this approach much more appealing.
Re:PostgREST: Providing HTML Content Using Htmx by est on Monday December 18, 2023 @10:01PM (#38691273)
if you think about it, serverless lambdas are just stored procedures with bells and wistles.
Re:PostgREST: Providing HTML Content Using Htmx by icedchai on Monday December 18, 2023 @10:46PM (#38691575)
Lambdas feel more like CGI scripts. Too bad they didn't just use the CGI standard instead of something proprietary.
Re:PostgREST: Providing HTML Content Using Htmx by lemper on Monday December 18, 2023 @11:41PM (#38691904)
if you think about it, php is just stored procedure with bells and whistles.
Re:PostgREST: Providing HTML Content Using Htmx by est on Tuesday December 19, 2023 @12:25AM (#38692176)
nah you have to worry about deployments of where .php were placed and mod_php and php-fpm stuff. DB can scale and you don't have to worry where SP were executed.
Re:PostgREST: Providing HTML Content Using Htmx by agumonkey on Monday December 18, 2023 @07:57PM (#38690478)
I have a huge feeling there will be a compressive period after the sort of cambrian explosion we've seen in the last decade.. everybody do very similar things, spread across N layers just so you can modify a bunch of rows in db. Mind boggling.
Re:PostgREST: Providing HTML Content Using Htmx by j-a-a-p on Tuesday December 19, 2023 @07:50AM (#38694885)
Yes, we had that at Oracle as a product. SQL + PL/SQL = HTML. It also had a built in versioning that if two users would change the same record it would moan.
Re:PostgREST: Providing HTML Content Using Htmx by cpursley on Monday December 18, 2023 @06:12PM (#38689712)
If you think that's cool, you might also want to check out Omnigres:

https://github.com/omnigres/omnigres

Re:PostgREST: Providing HTML Content Using Htmx by indigo945 on Tuesday December 19, 2023 @12:54AM (#38692333)
I don't really understand what this project is designed to do. I see a lot of reinvented square wheels, that other Postgres extensions already do better. Another (synchronous) HTTP client library, why? What does the "completed" JSON module even do, what are its aims? Maybe I just don't see the forest for the trees, but I can't figure out the value-add here.
Re:PostgREST: Providing HTML Content Using Htmx by akoboldfrying on Tuesday December 19, 2023 @02:55AM (#38693009)
I think the main value proposition is its HTTP server, which AFAICT lets you serve web requests from inside the PostgreSQL DB process.

(I'm not sure whether PostgREST also serves requests from inside the process, but another comment mentioned that it's a separate server process. I can see advantages to both ways.)

Re:PostgREST: Providing HTML Content Using Htmx by turtlebits on Monday December 18, 2023 @05:42PM (#38689449)
You still need to run PostgREST, so still 3 servers. (web/app/db)
Re:PostgREST: Providing HTML Content Using Htmx by danielheath on Monday December 18, 2023 @06:59PM (#38690068)
I can't imagine I'd put the database on a separate host from postgREST - the overheads are so low as to not meaningfully exist.

I _might_ introduce a load balancer to support migrating between servers with only 1-2 seconds downtime, but probably only for the duration of the move.

Re:PostgREST: Providing HTML Content Using Htmx by colecut on Monday December 18, 2023 @05:59PM (#38689606)
Isn't this example just web + db ?
Re:PostgREST: Providing HTML Content Using Htmx by lgas on Monday December 18, 2023 @07:02PM (#38690092)
PostgREST is an app that turns the db into an API. This takes the place of a traditional app server, but it's still an app server.
Re:PostgREST: Providing HTML Content Using Htmx by colecut on Monday December 18, 2023 @09:42PM (#38691153)
Thanks for the clarification
Re:PostgREST: Providing HTML Content Using Htmx by colordrops on Monday December 18, 2023 @06:15PM (#38689733)
Am I trippin or is htmx not a JS library?
Re:PostgREST: Providing HTML Content Using Htmx by arcanemachiner on Monday December 18, 2023 @06:46PM (#38689965)
Yes, it is. People often talk about how HTMX allows for interactive websites without any JS. Well, there is JS, it's just that it was written by the developer of HTMX, not the developer making their web app.
Re:PostgREST: Providing HTML Content Using Htmx by chii on Monday December 18, 2023 @07:46PM (#38690396)
presumably the implication of a "js library" is that your frontend is written by you using js, rather than declaratively via html(x).
Re:PostgREST: Providing HTML Content Using Htmx by jonahx on Monday December 18, 2023 @09:57PM (#38691245)
This is true, but htmx is targeting developer experience and simplicity, not solving <noscript> user case. For this perspective "interactive websites without any JS" is accurate.
Re:PostgREST: Providing HTML Content Using Htmx by threatofrain on Tuesday December 19, 2023 @12:05AM (#38692046)
I wouldn't say that's accurate because Astro is a better fit for that description.
Re:PostgREST: Providing HTML Content Using Htmx by intrasight on Monday December 18, 2023 @06:22PM (#38689784)
Not really. It just augments the hypermedia capabilities of HTML. Adds the missing semantics. You don't invoke library functions.
Re:PostgREST: Providing HTML Content Using Htmx by promiseofbeans on Monday December 18, 2023 @07:05PM (#38690112)
It still needs JS to work though
Re:PostgREST: Providing HTML Content Using Htmx by evilduck on Monday December 18, 2023 @10:51PM (#38691602)
Look up nontrivial examples on their own docs.

“Simple” form validation is a clusterfuck and that’s what they’re leading with.

Re:PostgREST: Providing HTML Content Using Htmx by sesm on Tuesday December 19, 2023 @07:35AM (#38694783)
Why HTMX advocates say 'augments the hypermedia capabilities of HTML' instead of 'another implementation of HTML-over-the-wire approach'? Placing hidden meaning into common words sounds very cult-ish.
Re:PostgREST: Providing HTML Content Using Htmx by recursivedoubts on Tuesday December 19, 2023 @01:53PM (#38699829)
we say this, because, more than other HTML-over-the-wire libraries, htmx focuses on generalizing the two core hypermedia controls, anchors and forms

i discuss this extensively in chapter 4 of our book:

https://hypermedia.systems/extending-html-as-hypermedia/

the tldr is that htmx generalizes:

- the event that triggers an HTTP request

- the element that triggers an HTTP request

- the type of the HTTP request

- the placement of the hypermedia response to that HTTP request

In this sense, htmx adds functionality to (or, more dramatically, "completes") HTML.

This is in contrast with, for example, https://unpoly.com, which also uses HTML-over-the-wire, but provides higher level concepts (e.g. layers) and isn't as focused on generalizing hypermedia controls. This has advantages, unpoly gives you more functionality out of the box, but puts it further way from being a pure conceptual HTML extension.

Re:PostgREST: Providing HTML Content Using Htmx by aragonite on Monday December 18, 2023 @06:38PM (#38689907)
It's more like a polyfill for a proposed/nonstandard version of HTML.
Re:PostgREST: Providing HTML Content Using Htmx by arcanemachiner on Monday December 18, 2023 @06:46PM (#38689969)
Written in JavaScript, if you can believe it.
Re:PostgREST: Providing HTML Content Using Htmx by aragonite on Monday December 18, 2023 @07:02PM (#38690087)
Yes but I'd argue that this is a case that shows the construction "JavaScript library" to be non-intersective :)

My colleague James is tall and he's a basketball player. But, in one pretty straightforward sense at least, he's not a tall basketball player.

Edit: I thought of a better analogy. Compare Lodash and uBlock. Lodash is clearly a "JavaScript library", uBlock is clearly not. Why not, given that like Lodash it's just so much JavaScript? Because uBlocks' intended users don't use it as a JavaScript library. They use it to modify the default behavior of the chrome browser to something more to their liking, not as a tool for more easily expressing themselves when writing JavaScript code. I'd argue the relation of htmx to HTML is very much like that of a Chrome/VSCode extension to Chrome/VSCode: its purpose is to change the built-in behavior of some tool (HTML) used by the user, whereas a library at bottom serves an expressive purpose.

Re:PostgREST: Providing HTML Content Using Htmx by kreetx on Tuesday December 19, 2023 @07:56AM (#38694941)
htmx's angle is that the developer don't interact with the javascript, so it's not a javascript library. Otherwise one could say that html is a C++ library because the markup is interpreted and run by the browser (written in C++).
Re:PostgREST: Providing HTML Content Using Htmx by quickthrower2 on Monday December 18, 2023 @11:28PM (#38691816)
The other option being… webassembly? convince WHATWG members to change their browsers?
Re:PostgREST: Providing HTML Content Using Htmx by yawaramin on Monday December 18, 2023 @11:50PM (#38691952)
It would be harder to believe something running dynamically in the browser is not written in JavaScript.
Re:PostgREST: Providing HTML Content Using Htmx by djbusby on Monday December 18, 2023 @06:21PM (#38689778)
It is a JavaScript library
Re:PostgREST: Providing HTML Content Using Htmx by smegsicle on Monday December 18, 2023 @05:37PM (#38689409)
crud without the cruft
Re:PostgREST: Providing HTML Content Using Htmx by marktangotango on Monday December 18, 2023 @08:37PM (#38690762)
How is authentication/authorization handled with this stack? Or sign up with email validation and password reset?
Re:PostgREST: Providing HTML Content Using Htmx by hasty_pudding on Monday December 18, 2023 @10:25PM (#38691429)
It's a little bit involved but doable.

https://postgrest.org/en/stable/references/auth.html

Re:PostgREST: Providing HTML Content Using Htmx by bigEnotation on Tuesday December 19, 2023 @12:05AM (#38692042)
So where is the secret key stored for signing the JWT? In the front end as well?
Re:PostgREST: Providing HTML Content Using Htmx by est on Monday December 18, 2023 @10:03PM (#38691281)
RDBMS auth and roles are a thing. They even support mTLS.
Re:PostgREST: Providing HTML Content Using Htmx by horusthegame on Monday December 18, 2023 @08:38PM (#38690767)
We've been down this road before. It's neat but not for long term maintenance, support or training as soon as HTMX loses its luster and the, then manager, has to concede the whole thing has to be re-written from scratch.
Re:PostgREST: Providing HTML Content Using Htmx by haolez on Monday December 18, 2023 @08:43PM (#38690801)
I've gone down this road before and that's not what I would criticize.

Where things went south for me:

- hard to hire developers that know how to work with this or that are willing to learn

- very hard to debug performance issues

- version control gets weird, since migrations are not really meant for functions and procedures (although Pyrseas[0] helped a lot)

[0] https://pyrseas.readthedocs.io/en/latest/

Re:PostgREST: Providing HTML Content Using Htmx by jonahx on Monday December 18, 2023 @09:51PM (#38691212)
Is it possible to capture changes in git somehow? If not what did you do?
Re:PostgREST: Providing HTML Content Using Htmx by akoboldfrying on Tuesday December 19, 2023 @02:57AM (#38693020)
I smell a startup opportunity.
Re:PostgREST: Providing HTML Content Using Htmx by haolez on Tuesday December 19, 2023 @06:50AM (#38694462)
I think using Postgres as a runtime would feel like a PaaS runtime not much different from other offerings in the market. But, for something self-hosted, it feels like super powers in the beginning.
Re:PostgREST: Providing HTML Content Using Htmx by haolez on Tuesday December 19, 2023 @06:50AM (#38694469)
I've used git as usual to evolve my SQL functions and procedures and my CI/CD pipeline used Pyrseas to sync code with database.
Re:PostgREST: Providing HTML Content Using Htmx by yen223 on Monday December 18, 2023 @10:06PM (#38691309)
I am starting to believe that "system has to be rewritten from scratch in the future" is not nearly the dealbreaker people make it out to be. Especially if it didn't take that much work building the v0 version.

You should almost always rewrite the system in the future, that's just the nature of growth and systems evolution.

Re:PostgREST: Providing HTML Content Using Htmx by potamic on Tuesday December 19, 2023 @12:05AM (#38692045)
Re:PostgREST: Providing HTML Content Using Htmx by cpursley on Tuesday December 19, 2023 @05:08AM (#38693838)
So like nearly every JavaScript framework that comes along?
Re:PostgREST: Providing HTML Content Using Htmx by est on Monday December 18, 2023 @10:00PM (#38691261)
... we are back with mainframes but this time browsers as terminals
Re:PostgREST: Providing HTML Content Using Htmx by quickthrower2 on Monday December 18, 2023 @11:24PM (#38691793)
Now deploy a DB per customer and you have scaling sorted.
Re:PostgREST: Providing HTML Content Using Htmx by cpursley on Tuesday December 19, 2023 @05:09AM (#38693848)
Yep, and that’s easier than ever now with neon, fly.io and similar.
Re:PostgREST: Providing HTML Content Using Htmx by weird-eye-issue on Tuesday December 19, 2023 @03:49AM (#38693311)
The backend and frontend are still there... Just all tangled directly into database code
Re:PostgREST: Providing HTML Content Using Htmx by paulddraper on Tuesday December 19, 2023 @04:34AM (#38693602)
It's all a shell game.
Re:PostgREST: Providing HTML Content Using Htmx by kreetx on Tuesday December 19, 2023 @07:39AM (#38694816)
Yeah, I exaggerated a bit. It's just that where it used to be postgres + node + react + html, then the middle two have been cut.

And I'm actually not contesting the value of a regular back-end and a front-end framework: postgrest and htmx make it easy to achieve more with configuration, but this only works up to a degree. After that point the benefits of a custom application start to overweight its absence.