Re: [web2py] Re: RESTful vs JSONRPC

2013-03-02 Thread Phyo Arkar
Thank you very much for very detailed explanation niphlod. Amazing.

For me , JSONRPC is more useful in current projects (which do not need CURD
, just Update and Read is mostly done ).

For my case it is mostly Machine learning , parsing files , indexing ,
producing Network diagrams , etc.
so that fit this cases :

> You don't need a service but some means of communication by a server
> written by you and a client that only you use ?


I will stick with JSONRPC.
On Sat, Mar 2, 2013 at 8:02 PM, Niphlod  wrote:

> it's merely a question about "angles"
>
> suppose you want to give access only to one table, e.g., products. only
> search by name and return just the quantity in stock in addition to the
> name.
>
> with jsonrpc you need to code a function that searches through your
> products and returns a list of tuples (or a dictionary) holding "name,
> stock" values.
>
> Now, suppose you want to add the possibility to order a product, or
> multiple ones.
>
> again, with jsonrpc you need to code a function that searches through your
> products and returns a list of tuples holding "name, ordered_qty" values.
>
> Now, suppose you want to give the ability to search through product tags,
> and order products
>
> you need to come up with a representation of your model, code a function
> that searches through tags, links them through products, and then again
> return the result.
>
> In all of this, you need to figure out a result that carries all the info
> needed for an API to be used (such as, e.g., returning tags in the 1st
> function anyway if they are handy, etc etc etc).
>
> When you add more and more functionality, or "features", you need to be
> consistent in what you return, else your API becomes more and more bloated
> and patched and disconnetted from piece to piece. JSONRPC doesn't define
> the state of your products, unless you come up with that. You have to tell
> your users that order_product method returns "name, ordered_qty" , come up
> with an error when they can't order something, tell them that a product can
> be searched also by tags with the search_by_tag method, etc etc etc.
>
> At any given point in time, clients need to know what feature you expose
> and what to expect back.
>
> On the other side, REST uses urls, response codes http verbs (HEAD, GET,
> POST, PUT, DELETE) and headers to describe both your returned format and
> your model. They know when an operation change something, if they can cache
> the result, etc etc.
>
> In richer and standards conformant APIs you get back with the results also
> links to access connected resources (i.e. the details about the tag of the
> product). Clients can ask xml or json just changing headers, and generally
> must be informed of your model only  they know already (if your API is
> totally REST "certified") that they should use x to achieve y.
>
> tl;dr: In general, a REST API feels more "open" but yes, more complicated
> because it involves several base concepts on how the web works.
> JSONRPC on the other end feels more "explicit". JSONRPC in an APIs exposes
> more "how to work with" while REST "what to work with".
>
> So, suppose you want to expose an api to access your online store I'd
> go for REST hands down.
> You need instead to expose a service that returns the avatar picture
> location given an email ? JSONRPC.
> You need to expose a service that crops pictures sent by users ? .
> neither (binary formats don't play well with both JSONRPC or REST)
> You don't need a service but some means of communication by a server
> written by you and a client that only you use ? JSONRPC will be more
> productive in a short term and if you have all the detailed implementation
> planned, but on the long run REST may be more appropriate.
>
>  --
>
> ---
> You received this message because you are subscribed to the Google Groups
> "web2py-users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to web2py+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>
>

-- 

--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




Re: [web2py] Re: RESTful vs JSONRPC

2013-03-02 Thread Niphlod
it's merely a question about "angles"

suppose you want to give access only to one table, e.g., products. only 
search by name and return just the quantity in stock in addition to the 
name.

with jsonrpc you need to code a function that searches through your 
products and returns a list of tuples (or a dictionary) holding "name, 
stock" values.

Now, suppose you want to add the possibility to order a product, or 
multiple ones.

again, with jsonrpc you need to code a function that searches through your 
products and returns a list of tuples holding "name, ordered_qty" values.

Now, suppose you want to give the ability to search through product tags, 
and order products

you need to come up with a representation of your model, code a function 
that searches through tags, links them through products, and then again 
return the result.

In all of this, you need to figure out a result that carries all the info 
needed for an API to be used (such as, e.g., returning tags in the 1st 
function anyway if they are handy, etc etc etc). 

When you add more and more functionality, or "features", you need to be 
consistent in what you return, else your API becomes more and more bloated 
and patched and disconnetted from piece to piece. JSONRPC doesn't define 
the state of your products, unless you come up with that. You have to tell 
your users that order_product method returns "name, ordered_qty" , come up 
with an error when they can't order something, tell them that a product can 
be searched also by tags with the search_by_tag method, etc etc etc.

At any given point in time, clients need to know what feature you expose 
and what to expect back.

On the other side, REST uses urls, response codes http verbs (HEAD, GET, 
POST, PUT, DELETE) and headers to describe both your returned format and 
your model. They know when an operation change something, if they can cache 
the result, etc etc. 

In richer and standards conformant APIs you get back with the results also 
links to access connected resources (i.e. the details about the tag of the 
product). Clients can ask xml or json just changing headers, and generally 
must be informed of your model only  they know already (if your API is 
totally REST "certified") that they should use x to achieve y. 

tl;dr: In general, a REST API feels more "open" but yes, more complicated 
because it involves several base concepts on how the web works. 
JSONRPC on the other end feels more "explicit". JSONRPC in an APIs exposes 
more "how to work with" while REST "what to work with".

So, suppose you want to expose an api to access your online store I'd 
go for REST hands down. 
You need instead to expose a service that returns the avatar picture 
location given an email ? JSONRPC. 
You need to expose a service that crops pictures sent by users ? . 
neither (binary formats don't play well with both JSONRPC or REST)
You don't need a service but some means of communication by a server 
written by you and a client that only you use ? JSONRPC will be more 
productive in a short term and if you have all the detailed implementation 
planned, but on the long run REST may be more appropriate.

-- 

--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




Re: [web2py] Re: RESTful vs JSONRPC

2013-03-02 Thread Alec Taylor
Can you expand a little on "features"?

Would be interested in a more concrete example of when to use JSONRPC over REST

On Sat, Mar 2, 2013 at 11:53 PM, Niphlod  wrote:
> JSONRPC is a method to invoke functions that is standardized. REST is a
> standardized method to represent something.
>
> Standards are constructed on different things: JSONRPC standardizes the
> transport method and the returned values, while REST standardizes how you
> should represent a given "entity" and how you should interact with the
> entity itself (not the format itself).
>
> That being said, there's no standards on how to implement a particular
> functionality: REST is useful to interact with models, hence it's more
> geared towards representing your "objects", and if your objects are db
> records, REST methods map very well to the usual CRUD operations.
>
> JSONRPC instead is more keen to map to the "functional" side of things: you
> need to code interactions with the model in your functions.
>
> That's why you can find largely on the internet both of them, but when the
> exposed API is something that needs to give access to a wide interlinked
> model the preferred method is REST, while if it exposes only "features" you
> find JSONRPC as the standard.
>
>
> On Saturday, March 2, 2013 9:45:35 AM UTC+1, Phyo Arkar wrote:
>>
>> From what it seems, RESTFUL seems a bit more complex vs JSONRPC.
>>
>> What are the advantages for using REST, when using full AJAX Framework
>> like qooxdoo?
>>
>>
> --
>
> ---
> You received this message because you are subscribed to the Google Groups
> "web2py-users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to web2py+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>

-- 

--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




[web2py] Re: RESTful vs JSONRPC

2013-03-02 Thread Niphlod
JSONRPC is a method to invoke functions that is standardized. REST is a 
standardized method to represent something.

Standards are constructed on different things: JSONRPC standardizes the 
transport method and the returned values, while REST standardizes how you 
should represent a given "entity" and how you should interact with the 
entity itself (not the format itself).

That being said, there's no standards on how to implement a particular 
functionality: REST is useful to interact with models, hence it's more 
geared towards representing your "objects", and if your objects are db 
records, REST methods map very well to the usual CRUD operations. 

JSONRPC instead is more keen to map to the "functional" side of things: you 
need to code interactions with the model in your functions.  

That's why you can find largely on the internet both of them, but when the 
exposed API is something that needs to give access to a wide interlinked 
model the preferred method is REST, while if it exposes only "features" you 
find JSONRPC as the standard.

On Saturday, March 2, 2013 9:45:35 AM UTC+1, Phyo Arkar wrote:
>
> From what it seems, RESTFUL seems a bit more complex vs JSONRPC.
>
> What are the advantages for using REST, when using full 
> AJAX Framework like qooxdoo?
>
>
>

-- 

--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.