News for hackers. Stuff that matters.
Re:Two Approaches to Decoupling by dack on Monday May 01, 2023 @11:25PM (#35782950)
I am probably misunderstanding the article, but as far as I can tell, the two ways discussed are "JSON API like almost everybody does" and "do server-side rendering and call it the API".

Not to say it's wrong to do server-side rendering of the frontend, but I got the impression that the article wanted to make a distinction that I'm not seeing.

Re:Two Approaches to Decoupling by recursivedoubts on Monday May 01, 2023 @11:29PM (#35782991)
server side rendering (that is, returning HTML) is an API, it's just that it's a hypermedia API (poor hypermedia, can't get no respect) rather than a data API, intended to be consumed by a hypermedia client (e.g. a web browser) and revealing/affording further API navigation via hypermedia controls (e.g. links)

hypermedia APIs have not proven to be good data APIs, but they have proven to be excellent at surviving change within a larger hypermedia system (like the web)

in this article I'm trying to show why, despite the promise of decoupling that comes with a generic JSON Data API, it is hypermedia APIs (with tight server/front end coupling) that survive change better, due to the uniform interface of REST

Re:Two Approaches to Decoupling by jsyolo on Tuesday May 02, 2023 @12:41AM (#35783437)
and revealing/affording further API navigation via hypermedia controls (e.g. links)

I haven't a hard time understanding the utility of this, the article gives an example (removing ability of transfers), but why would a webpage need those hypermedia controls in the response if they are already encoded in the API of the business logic? for ex: The business logic tells the presentation layer, "if X field is true, disable transfers button".

Re:Two Approaches to Decoupling by recursivedoubts on Tuesday May 02, 2023 @09:29AM (#35787128)
The presentation layer needs to interpret the business layer information in your example. This couples the two together if, for example, the form of the business data changes.

This is in contrast to hypermedia where the client (a browser) simply sees the new hypermedia and renders it. In this case, the client is decoupled from the particulars of the business logic.

This is due to the uniform interface of REST. See https://htmx.org/essays/hateoas/

Re:Two Approaches to Decoupling by wpietri on Tuesday May 02, 2023 @12:56AM (#35783527)
Thanks so much for this article. I have something that I want to try out HTMX on and this really clarified some things for me.

I particularly liked the bit about the way that the JSON approach, decoupled in theory, often ends up being tightly coupled in practice, such that you keep having to change both at once. And many places are structured such that you need two people or even two teams to make a single change. That doesn't sound decoupled at all!

I'm excited to see how it is to give on that in-practice-imaginary decoupling and try for HATOEAS at the fractions-of-a-page level that HTMX looks to enable.

Re:Two Approaches to Decoupling by culturedsystems on Tuesday May 02, 2023 @07:00AM (#35785725)
It's an API for a specific hypermedia client, i.e, a web browser. It's not obvious that it's the best hypermedia API for a different client, for example, a JavaScript application that happens to be running in a web browser.
Re:Two Approaches to Decoupling by recursivedoubts on Tuesday May 02, 2023 @09:27AM (#35787107)
well, if you are building a hypermedia client, good luck to you

https://www.oreilly.com/library/view/restful-web-clients/978...

it's not a trivial task though