Is REST a good choice for GUI web applications?
Asked Answered
C

3

6

GUI based web applications could be build upon a GUI component, stateful framework like Wicket or they could build in a RESTful, stateless way with GUI status only on the client.

From a technical point of view REST looks like the right way since it leverages the full power of http and leads to highly scalable applications. But that comes at a price. Complex GUIs will require a JavaScript application on the client in many cases. You have to stay on the same page and reload only parts, if state should be maintained on the client. Or you have to use tricks with hidden iframes. Sometimes there are pseudo resource like shopping carts on the server, to enable a RESTful design. You have to maintain intermediate state of multi step dialogues and so on ...

If I look around there are very few RESTful GUI webapplications. Is this because of historical reasons or is a RESTful design unproductive in common scenarios?

Chrysoprase answered 3/2, 2010 at 7:14 Comment(4)
What is your definition of a "GUI web application"? Yahoo.com? Stackoverflow? Google Maps? eyeos.org?Tews
Or to turn @deceze's comment around: when is it NOT GUI?Abbott
GUI is an application for direct interaction with humans, whereas a service is one side of a machine to machine communication.Chrysoprase
So... a web page then? Does it count if it's [mostly] static, or does it need to "do something"?Tews
A
9

If I look around there are very few RESTful GUI webapplications. Is this because of historical reasons or is a RESTful design unproductive in common scenarios?

My answer is subjective, but in my opinion, two major hurdles hinder RESTful development:

  1. Change - it very different from the way sites are traditionally designed
  2. Challenge - designing a pure RESTful server API and a corresponding rich, robust client UI isn't easy

Complex GUIs will require a JavaScript application on the client in many cases.

In my opinion, a complex, a rich client-side experience is going to require some in-depth JavaScript, regardless of the server-side implementation.

You have to stay on the same page and reload only parts,

This is a very different design from the traditional request/response full-page-to-full-page design. Each design has its own trade offs. REST designs work particularly well with AJAX calls, but the client-side code requires careful design to be maintainable and robust.

A RESTful server with a thick-client:

  • scales well: session information for every user isn't stored in scarce server memory
  • less request/response data over the wire: not sending every page in full, not sending session IDs or ViewStates
  • clean reusable URLs: provide a clean, decoupled server API that can support multiple UIs
  • pure: strict adherence to the HTTP specification (GETs cause no side effects, etc.)
  • client experience: richer, more responsive with asynchronous transactions

However, as you mentioned thick-clients have drawbacks:

  • more vulnerable to XSS attacks, RESTful URLs really need careful security
  • complex JavaScript can be challenging to develop, maintain, and debug (using OO JavaScript can help mediate this)
  • there is a need to indicate to the user that asynchronous requests are processing in the background
  • more client-side failure-handling logic is required
  • frameworks and IDE tools have been traditionally weaker for client-side development, compared to server-side (this is slowly getting better)
Aphanite answered 3/2, 2010 at 23:53 Comment(0)
D
1

RESTful GUI designs are very productive, IMHO. You can leverage a lot of functionality without extra work to support the corner cases, such as the user resubmitting information, browser history (back and forward) multiple tabs and windows. If I'm not mistaken this site uses a RESTful UI.

Duodecimo answered 3/2, 2010 at 7:24 Comment(0)
M
0

REST was defined by observing characteristic of successful web applications, both GUI and M2M. Therefore by definition it should be appropriate for these cases.

I also noticed you asked a question regarding desktop versus web applications. You may be interested to know that REST is an excellent architecture for building desktop client applications too. I have written a few desktop clients that get all of their data from a REST server.

Mealtime answered 3/2, 2010 at 12:16 Comment(2)
I can imagine that REST is a fine back end for a desktop application, but it is easy to manage state in such an application. Whereas state management in browser is not trivial today. (PS: I didn't ask the mentioned question)Chrysoprase
My apologies, I got confused between you and Dimitre.Mealtime

© 2022 - 2024 — McMap. All rights reserved.