Saturday, September 12, 2009

XML-RPC in Lisp

Here is how to get a xml-rpc client working in SBCL.

You will need to install s-xml,s-xml-rpc using asdf

[sourcecode lang='bash']
(require 'asdf)
(require 'asdf-install)
(asdf-install:install 's-xml)
(asdf-install:install 's-xml-rpc)
[/sourcecode]

Next to use the libraries you will use the following commands.

[sourcecode lang='bash']
(require 'asdf)
(asdf:oos 'asdf:load-op 's-xml)
(asdf:oos 'asdf:load-op 's-xml-rpc)
(use-package :s-xml-rpc)
;(use-package :commuse-lisp-user)

(xml-rpc-call
(encode-xml-rpc-call "math.SumAndDifference" 5 2)
:host "www.cookcomputing.com"
:url "/xmlrpcsamples/math.rem")
[/sourcecode]
Links

cookcomputing rpc page

XML-RPC in Lisp

XML-RPC project page

Thursday, September 10, 2009

What are Immutable Object

I think every programmer should seriously try to understand what immutable objects/persistent data structures are about and how they can simplify and solve certain problems especially when they have to deal with threading/concurrency since they are inherently thread safe.

This is probably the simplest definition that I found.

immutable
adj. 1. (of an object) Having components that cannot be modified once the object has been created. 2. (of a class) An immutable class is a class all of whose objects are immutable. [annotate]
So what does that mean in code ?

It means that when you do something like

A=(1 2 3) ; where (1 2 3) is an imutable list of integers 1, 2 and 3

We can't say swap the element 2 for a 4 because it is imutable. Some languages allow you to replace the list like

A=(4 5 6), In Erlang you can't once it is assigned you can't change it.

Links:

Java theory and practice - To mutate or not to mutate

Immutable object

Tuesday, September 8, 2009

Using JMeter to look at data transmitted

JMeter beside looking at how your website performs, you can also use the data to look at how much data is actually sent to the browser and the effects of caching.

Many web projects use some javascript/Ajax library for doing UI, and these javascript files usually come in a debug or minified version. And the javascript files are big for example we were using ExtJS 2.2 and the debug version is almost a meg big, the minified version of about 527kb, but there might exists other javascript files that your webpages may call and it is probably quite a pain to look for each file and count the size.

In my case we wanted to see how much data is actually sent over with each call to a web page, and how web browser caching during subsequent calls to other webpages affects the data transmitted. Using JMeter allows you to see how much data is transmitted with each call including what files are being transmitted with each call and their sizes.