by recursivedoubts · 4y ago · 0 comments
infuriatingly, if HTML had just a bit more oomph, we could make a lot better websites with it, but they haven't been moving HTML forward as a hypermedia for decades now (see https://htmx.org for what I mean, they could implement this concept in the browser in a week, and it would change web development dramatically)
the upcoming view transitions API will help:
https://github.com/WICG/view-transitions
but, still, there are some really obvious and simple things that could be done to make HTML much more compelling (maybe let's start by making PUT, PATCH and DELETE available in HTML!)
Well, at least it's no trouble to include these two libraries and bring your clients into the 21st century of hypertext. But doing so without JS would be amazing.
If anything I'd associate javascript with clunkyness.
I have done a few Angular and React apps to keep the skills sharp. The imposed workflow for the power is an interesting set of tradeoffs, never mind the magic and amount of decisions you need to make to use both.
Add on top of that the rest of npm, nvm, css compilers, the various css toolkits for layout, and the rest and it just feels so complicated, even for the most basic page which needs to pull in some data over an api.
It doesn't seem to be getting any simpler.
I agree with you to an extent: I've had some very bad experiences with javascript applications as well, but the general sentiment is (reasonably, in my opinion) that a well done SPA will feel smoother than a well done MPA
W/ htmx or similar libraries like unpoly or hotwire, you can close this gap. The big difference is the ability to update partial bits of HTML, rather than needing to do a full page refresh.
Lets say you want to sort all your posts by date and paginate the results (say, 20 results per page or something), as per typical blogging patterns. That's a lot of HTML cruft you gotta make for this to happen. Meanwhile, Wordpress / Jekyll / Hugo (etc. etc.) do this all automatically for you.
Personally, I prefer html with a little embedded css. It works, it's quick, it's all in one place, and it lets me produce suitably elegant pages.
Yes. Has anyone ever purpose it?
hopefully at some point someone will notice it
Is this really that much better than POST http://www.mysite.com/thing/100/delete ?
GET and POST have actual client-side implementation differences. The rest is simply semantics.
I love REST but these extra verbs seem redundant.
PUT and DELETE correspond with U and D, so they make sense to include. PATCH is a little less obviously useful (partial update vs. a full update w/ a PUT.)
Regardless of our feelings about them, they are there in HTTP, the HyperText Transfer Protocol. So maybe we should make them accessible through the HyperText we are transferring.
It is a huge shortcut to map CRUD operations to HTTP verbs POST, GET, PUT, DELETE. By the way, the definition of HTTP verbs defined in the HTTP RFCs (from RFC 1945 to RFC 7231) and the original thesis from Roy Fielding about REST (which is defining REST principles as an architectural style) never talk about one-to-one relationship between CRUD and PUT-GET-POST-DELETE.
While I understand that it might be confusing without deep-diving in long-long-lectures, the last RFC explains clearly what is the purpose of each HTTP verb including the difference between PUT and POST:
The fundamental difference between the POST and PUT methods is
highlighted by the different intent for the enclosed representation.
The target resource in a POST request is intended to handle the
enclosed representation according to the resource's own semantics,
whereas the enclosed representation in a PUT request is defined as
replacing the state of the target resource. Hence, the intent of PUT
is idempotent and visible to intermediaries, even though the exact
effect is only known by the origin server.
Therefore it would be perfectly valid to "create" a resource with both PUT and POST methods as well as "update" another one with, also, PUT and POST. It is actually even clearly stated with a few examples in the RFC. For instance in POST definition: Appending data to a resource's existing representation(s).
I used to defined PUT and POST requests according their characteristics: the first one is idempotent, the second is not ... but could be.
Therefore, in my understanding, it is perfectly valid to perform an "upsert" (insert or update) to a resource which doesn't exist yet but for which you already know the URL, it is indeed idempotent. For instance: PUT /resources/xyz
A last piece of evidence is the first line of PUT section in RFC 7231: The PUT method requests that the state of the target resource be
created or replaced with the state defined by the representation
enclosed in the request message payload.
I hope it helps to clarify a little bit the topic.The extra verbs make your URLs less redundant!