News for hackers. Stuff that matters.
Re:WebSockets versus REST? by DougWebb on Sunday February 26, 2012 @07:18PM (#3637271)
I think what lots of people are missing is that Websockets doesn't compete with REST or SOAP, it competes with HTTP. Until now, programs written in Javascript could only use one internet protocol: HTTP. Websockets brings low-level TCP socket programming to Javascript, enabling the use of any TCP-level protocol.

Of course, this happens within a sandbox that involves initiating the connection over HTTP and tunneling the protocol through a server over port 80. But that server can be a proxy that forwards the stream to any TCP service, on any TCP port. We're back to the days when anyone could and did develop their own protocols, and many of those became standards.

I suspect that we're going to see that kind of development again: people will initially create their own protocols to use over Websockets, then they'll recognize the benefit of tunneling existing standard TCP protocols to their Javascript programs (how about an IMAP client written in Javascript?) then finally someone will develop an HTTP client in Javascript.

Re:WebSockets versus REST? by pmboyd on Sunday February 26, 2012 @08:54PM (#3637469)
The bigger picture is that WebSockets increases what's possible via the web. In theory REST isn't tied to HTTP although practically speaking, the two do go hand in hand. The natural REST application is also somewhat different from the natural WebSocket application.
Re:WebSockets versus REST? by ypcx on Monday February 27, 2012 @04:22AM (#3638353)
I think it does compete with REST. I want my framework as simple as possible (and real-time as possible, of course), and I know that to reach 100% of the audience plus have a good SEO, I will certainly have to have 2 versions of my website: One low-tech, no-javascript, pure HTML 4. The other, thanks to the first one, can shoot very high. So I will get rid of REST, and have all my data being synchronized via WebSocket. Function calls will be RPC over WebSocket. The much-less-than 1% users without WebSocket or Flash support (which implements a fallback WebSocket client), or with a Flash or WebSocket behind a Proxy that won't let these through, will be defaulted to the low-level website, which has to be there anyway, because dynamic content is very badly indexable by search engines. I think I will be working on a Node.js micro-framework to accomplish this very soon. This of course will have to be backed by a fast in-memory database with pub-sub, like Redis. The other fallback transports for WebSocket, like JSONP or other hacks, aren't in my opinion worth it at all, given the proliferation of Flash and WebSocket-supporting browsers.

Time for a plug too: my https://github.com/ypocat/ws-rpc and https://github.com/ypocat/ws-flash-client extensions for the mean and lean "ws" Node.js WebSocket server. (Reason for creating both of these was very simple - socket.io did not work out for me.)

Re:WebSockets versus REST? by k_bx on Monday February 27, 2012 @11:47AM (#3639553)
Yes, ok, you will use WebSockets for your API. But what will it look like to book a ticket on your API? "{'action': 'book', 'from': 'Chicago', 'to': 'Moscow'}"? It's still junk without REST style.

The point of REST is operating with resources as building bricks of your API, and using only four CRUD operations on them (or on their collection). Besides, for testing purposes it is good to still have REST API to test it with curl or some web client in your code.

So what I'd suggest is to continue building REST API, but create a smooth REST2WebSocket layer to make your REST requests through WebSockets. Like "{'method': 'PUT', 'resource': '/api/users/john', 'data': '\{\'name\': \'Paul\'...".

Re:WebSockets versus REST? by k_bx on Monday February 27, 2012 @11:53AM (#3639574)
(maybe the examples I provided are not ugly enough to show difference, so I'll try to do that here)

On non-rest API you can get in trouble mixing actions and resources, so you can get things like {'action': 'list_users'}, {'action': 'rename_user'}, {'action': 'user_ban'}, {'action': 'rename_user_and_email'}, {'action': 'list_active_users'}

While on REST API you are at least consistent that user-resource is /users/, that concrete user is /users/<user_id> and that only operations are CRUD on either all users -> /users/ or on concrete user /users/<user_id>. That gives so much more clarity (+ caching reads, + only open transactions on POST/PUT/DELETE).

Re:WebSockets versus REST? by riobard on Monday February 27, 2012 @12:02AM (#3637839)
No, WebSockets doesn't complete with HTTP. It complements HTTP.

SPDY competes with HTTP.

Re:WebSockets versus REST? by beaumartinez on Monday February 27, 2012 @05:08AM (#3638438)
No, SPDY competes with TCP[1].

[1] http://www.chromium.org/spdy/spdy-whitepaper

Re:WebSockets versus REST? by javascriptlol on Monday February 27, 2012 @03:11AM (#3638182)
Unfortunately, there will be no UDP protocols. So we're not quite back to where we were in 1970 yet.
Re:WebSockets versus REST? by aapl on Monday February 27, 2012 @09:05AM (#3638974)
UDP will be coming as a part of the WebRTC effort. The current spec draft and prototypes don't include arbitary data channels, but they are currently being specced on the mailing list.
Re:WebSockets versus REST? by javascriptlol on Monday February 27, 2012 @02:13PM (#3640184)
Excellent. Someone else pointed this out. This is good news.
Re:WebSockets versus REST? by cenuij on Sunday February 26, 2012 @09:09PM (#3637507)
I think you have missed the mark by such a wide margin that I need to call you on your bullshit.

> I think what lots of people are missing is that Websockets doesn't compete with REST or SOAP, it competes with HTTP.

Websockets of any reference are implentations of HTTP, your lack of knowledge is not a badge of authority.

"Of course, this happens within a sandbox that involves initiating the connection over HTTP and tunneling the protocol through a server over port 80."

I am sure that you have no clue about what your talking about, I will bring this forward with the following statement:

"We're back to the days when anyone could and did develop their own protocols, and many of those became standards."

Your name is not on any IETF bodies or standards, who are you exactly?

Re:WebSockets versus REST? by icebraining on Sunday February 26, 2012 @09:51PM (#3637595)
Websockets of any reference are implentations of HTTP

As parent said, they only implement HTTP for handshaking. Then you switch to the websocket protocol.

To quote websocket.org:

    The protocol switch from HTTP to WebSocket is referred to as
    a the WebSocket handshake. (...) The browser sends a request
    to the server, indicating that it wants to switch protocols from
    HTTP to WebSocket. (...) At this point the HTTP connection breaks
    down and is replaced by the WebSocket connection over the
    same underlying TCP/IP connection.
The rest of your post is just argument-free personal attacks, therefore I'll refrain from replying to it.
Re:WebSockets versus REST? by mahmud on Sunday February 26, 2012 @09:15PM (#3637521)
I think you have missed the mark by such a wide margin that I need to call you on your bullshit.

Not a good start :-|

Re:WebSockets versus REST? by cenuij on Sunday February 26, 2012 @09:20PM (#3637530)
yeah, it's a bad thing when tech beats bullshit :(
Re:WebSockets versus REST? by danssig on Monday February 27, 2012 @05:13AM (#3638445)
He was right. Who are you exactly?