STRPC progress
May 8th, 2008
Image via WikipediaI was just making STRPC server in Factor because I need it for something I hope I will be able to release (very early version) soon. I made it work, but it’s still patchy at certain places. I have to write the Htmlize serialization and de-serialization in Factor, and add error reporting and input type checking and then it’s done.
STRPC itself is still very experimental (read crappy) right now, I used it at 5 projects but nobody else used it otherwise. And it does not surprise me. Who would use a nightly brain-dump of a XMLRPC frustrated coder that writes and changes it as he goes…
Well, I think I got the clearer idea of what exactly I want STRPC to offer now and I will update the spec, examples and libraries when I find some time. I have used it from PHP, JavaScript, Haxe, AS3 and Factor now.
The biggest change will be that it will now be serialization independent so the server could support any serialization (or many of them). Every server will have to support Htmlize serialization so if you write a client you can be sure that this one is supported. But besides it it can also support any number of other types. For example, why not use python’s (or php’s) native serialization if you have server and client written in python. The other example is Flash. AMF binary serialization is said to be much faster for flash and is natively supported so why use something that you have to parse by yourself in AS3. The same with JavaScript and JSON. Each server will be able to provide their clients with a list of supported serializations so client can programmatically choose the most suitable method…
Posts are boring if I don’t add some code so here is how you make a STRPC server in Factor now. This one adds and substracts two numbers and returns the result.
: strpc ( -- return )
request -> query>>
{
{
"math" "sum"
{ { "a" number }
{ "b" number } }
number
[ + ]
} {
"math" "sub"
{ { "a" number }
{ "b" number } }
number
[ - ]
}
} serve-strpc ;
: start-server ( -- )
[ drop strpc ] fuj-def-responder set-global
You will put the words you want called instead of “+” and “-” . These words (functions) have NO rpc specific code and are totally general words.

