<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>noor - نور &#187; General</title>
	<atom:link href="http://noor.ojuba.org/category/general/feed/" rel="self" type="application/rss+xml" />
	<link>http://noor.ojuba.org</link>
	<description>Kefah Issa weblog - مدونة كفاح عيسى</description>
	<lastBuildDate>Thu, 17 Dec 2009 07:52:24 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.6</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>A ride with hessian</title>
		<link>http://noor.ojuba.org/2008/11/a-ride-with-hessian/</link>
		<comments>http://noor.ojuba.org/2008/11/a-ride-with-hessian/#comments</comments>
		<pubDate>Sun, 30 Nov 2008 20:54:02 +0000</pubDate>
		<dc:creator>Kefah Issa</dc:creator>
				<category><![CDATA[General]]></category>
		<category><![CDATA[Grails]]></category>
		<category><![CDATA[c++]]></category>
		<category><![CDATA[groovy]]></category>
		<category><![CDATA[java]]></category>

		<guid isPermaLink="false">http://noor.ojuba.org/?p=31</guid>
		<description><![CDATA[Today, I came across what I call a deep-sea pearl. I came to know Hessian, the binary web service protocol.
Some time ago I blogged about the same idea Predictable Binary Representation (PBR)
 , naively thinking that no one has done this before.
With the help of few friends, and some googling there turned out to be [...]]]></description>
			<content:encoded><![CDATA[<p>Today, I came across what I call a deep-sea pearl. I came to know Hessian, the binary web service protocol.</p>
<p>Some time ago I blogged about the same idea <a href="http://noor.ojuba.org/2008/9/predictable-binary-representation-pbr">Predictable Binary Representation (PBR)</a><br />
 </a>, naively thinking that no one has done this before.</p>
<p>With the help of few friends, and some googling there turned out to be a zillion solutions that attempt to address that very problem; the etch has been really scratched by many, and the need for a compact, and predictable binary protocol is a must, no matter how fast the internet is or will become.<br/></p>
<p><span id="more-31"></span></p>
<p>Parsing JSON, despite the fact that its among the most elegant human-readable text-protocols, would consume CPU cycles, and would be susceptible to errors more likely than not.</p>
<p>With a Binary protocol, you could &#8230;</p>
<ul>
<li>Know the total size of a message (aka packet) before hand</li>
<li>Have its checksum that you can verify</li>
<li>For every single data entry, you would exactly know what size in bytes to expect next and what the type of data is, as opposed to checking for special marking characters to tell when an end of that item is reached.</li>
<li>No need to escape any special characters, should they occur plainly within the data. The problems JSON and XML have because of this deficiency are huge. Why all that hassle?! A question that puzzled me for years. </li>
<li>Far more compact in size, even without compression. There are no xml tags repeating for every node. In hessian, a dictionary of entry-names is only defined once at the header, then corresponding id&#8217;s are used across the message.
</ul>
<p>From the technical perspective, when we talk about web services, we are talking about software-to-software communication. As such Human-readable protocols are mere overhead to say the least. We should focus more on optimizing software-to-software protocol than making it look good to the human eyes.</p>
<p>Forget about XML, JSON or anything similar; and consider the beauty, performance, and optimization of binary protocols.</p>
<p>Despite the competition from Thrift (by facebook), Protocol Buffers (by google), and ASN.1 (older standard), along many others, <a href="http://hessian.caucho.com/">Hessian (by Caucho)</a> stands out from the crowd &#8230;</p>
<p>Let me tell you why I quickly fell in love with Hessian,<br/></p>
<ul>
<li>Dead-simple to use, both server-side and client-side.</li>
<li>Can be equally used on Java, C/C++, .Net, Ruby, PHP, Flash and so forth.</li>
<li>Saves tons of bandwidth, cpu cycles and increases reliability</li>
<li>Runs via the firewall-friendly http-protocol</li>
</ul>
<p>It was intriguing when reading the features and specifications. Being the hands-on person I am, I only believe what I can do &#8230;</p>
<p>So, lets roll up our sleeves and get in a quick practical session with Hessian &#8230;.</p>
<p><b>Hessian  and Java </b></p>
<p>Preparations </p>
<p>Create few folders to host our samples</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">mkdir</span> <span style="color: #660033;">-p</span> hessian<span style="color: #000000; font-weight: bold;">/</span>lib
<span style="color: #7a0874; font-weight: bold;">cd</span> hessian</pre></div></div>

<p>I downloaded the latest <a href="http://hessian.caucho.com/download/hessian-3.2.0.jar">hessian library jar file</a> to my local lib folder.</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">wget</span> <span style="color: #ff0000;">'http://hessian.caucho.com/download/hessian-3.2.0.jar'</span>
<span style="color: #c20cb9; font-weight: bold;">mv</span> hessian-3.2.0.jar lib</pre></div></div>

<p>Using jetty 6.1.x or 7.x would do equally well,</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">wget</span> <span style="color: #ff0000;">'http://dist.codehaus.org/jetty/jetty-6.1.12/jetty-6.1.12.zip'</span></pre></div></div>

<p>Unpack</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"> <span style="color: #c20cb9; font-weight: bold;">unzip</span> jetty-6.1.12.zip</pre></div></div>

<p>we only need three jars, as we are going to use the compact embeddable jetty jars.</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">mv</span> jetty-6.1.12<span style="color: #000000; font-weight: bold;">/</span>lib<span style="color: #000000; font-weight: bold;">/</span>jetty-<span style="color: #000000; font-weight: bold;">*</span> jetty-6.1.12<span style="color: #000000; font-weight: bold;">/</span>lib<span style="color: #000000; font-weight: bold;">/</span>servlet-api-<span style="color: #000000;">2.5</span>-6.1.12.jar lib<span style="color: #000000; font-weight: bold;">/</span>
<span style="color: #c20cb9; font-weight: bold;">rm</span> <span style="color: #660033;">-rf</span> jetty-6.1.12</pre></div></div>

<p>Make sure to define CLASSPATH environment variable that would properly point to all the jars in our lib folder. for that I use the following setenv.sh script that can be sourced every time needed.</p>
<p><em>setenv.sh</em></p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">#!/bin/bash</span>
<span style="color: #007800;">CLASSPATH</span>=<span style="color: #ff0000;">&quot;.&quot;</span>
<span style="color: #000000; font-weight: bold;">for</span> myjar <span style="color: #000000; font-weight: bold;">in</span> $<span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #c20cb9; font-weight: bold;">find</span> <span style="color: #007800;">$PWD</span><span style="color: #000000; font-weight: bold;">/</span>lib <span style="color: #660033;">-iname</span> <span style="color: #ff0000;">'*.jar'</span><span style="color: #7a0874; font-weight: bold;">&#41;</span>; <span style="color: #000000; font-weight: bold;">do</span> <span style="color: #007800;">CLASSPATH</span>=<span style="color: #007800;">$CLASSPATH</span>:<span style="color: #007800;">$myjar</span>; <span style="color: #000000; font-weight: bold;">done</span>;
<span style="color: #7a0874; font-weight: bold;">export</span> CLASSPATH</pre></div></div>

<p>Then you can source it like this</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #7a0874; font-weight: bold;">source</span> setenv.sh</pre></div></div>

<p>Define (create) our API interface using POJO<br/></p>
<p><em>BasicAPI.java</em></p>

<div class="wp_syntax"><div class="code"><pre class="java" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">interface</span> BasicAPI <span style="color: #009900;">&#123;</span>
	<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #003399;">String</span> hello <span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>Create the service API implementation and expose via an embeddable servlet container<br/><br />
<em>BasicService.java</em></p>

<div class="wp_syntax"><div class="code"><pre class="java" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">org.mortbay.jetty.servlet.Context</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">org.mortbay.jetty.Server</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">com.caucho.hessian.server.HessianServlet</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">class</span> BasicService <span style="color: #000000; font-weight: bold;">extends</span> HessianServlet <span style="color: #000000; font-weight: bold;">implements</span> BasicAPI <span style="color: #009900;">&#123;</span>
	<span style="color: #000000; font-weight: bold;">private</span> <span style="color: #003399;">String</span> _greeting <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;Hello, world&quot;</span><span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000066; font-weight: bold;">void</span> setGreeting<span style="color: #009900;">&#40;</span><span style="color: #003399;">String</span> greeting<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		_greeting <span style="color: #339933;">=</span> greeting<span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
&nbsp;
	<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #003399;">String</span> hello<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		<span style="color: #000000; font-weight: bold;">return</span> _greeting<span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
&nbsp;
	<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">static</span> <span style="color: #000066; font-weight: bold;">void</span> main <span style="color: #009900;">&#40;</span><span style="color: #003399;">String</span> <span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span> args<span style="color: #009900;">&#41;</span> <span style="color: #000000; font-weight: bold;">throws</span> <span style="color: #003399;">Exception</span> <span style="color: #009900;">&#123;</span>
		Server server <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> Server<span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">8080</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>  
		<span style="color: #003399;">Context</span> context <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> <span style="color: #003399;">Context</span><span style="color: #009900;">&#40;</span>server, <span style="color: #0000ff;">&quot;/&quot;</span>, <span style="color: #003399;">Context</span>.<span style="color: #006633;">SESSIONS</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		context.<span style="color: #006633;">addServlet</span><span style="color: #009900;">&#40;</span>BasicService.<span style="color: #000000; font-weight: bold;">class</span>, <span style="color: #0000ff;">&quot;/basic&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		server.<span style="color: #006633;">start</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>Compile the Java Server API and Interface and start our service<br/></p>

<div class="wp_syntax"><div class="code"><pre class="java" style="font-family:monospace;">javac BasicService.<span style="color: #006633;">java</span> 
java BasicService</pre></div></div>

<p>Create the Client app<br/><br />
<em>Client.java</em></p>

<div class="wp_syntax"><div class="code"><pre class="java" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">com.caucho.hessian.client.*</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">class</span> Client <span style="color: #009900;">&#123;</span>
	<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">static</span> <span style="color: #000066; font-weight: bold;">void</span> main <span style="color: #009900;">&#40;</span><span style="color: #003399;">String</span> <span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span> args<span style="color: #009900;">&#41;</span> <span style="color: #000000; font-weight: bold;">throws</span> <span style="color: #003399;">Exception</span> <span style="color: #009900;">&#123;</span>
		<span style="color: #003399;">String</span> url <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;http://localhost:8080/basic&quot;</span><span style="color: #339933;">;</span>
		HessianProxyFactory factory <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> HessianProxyFactory<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		BasicAPI basic <span style="color: #339933;">=</span> <span style="color: #009900;">&#40;</span>BasicAPI<span style="color: #009900;">&#41;</span> factory.<span style="color: #006633;">create</span><span style="color: #009900;">&#40;</span>BasicAPI.<span style="color: #000000; font-weight: bold;">class</span>, url<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #003399;">System</span>.<span style="color: #006633;">out</span>.<span style="color: #006633;">println</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;basic.hello() said : &quot;</span> <span style="color: #339933;">+</span> basic.<span style="color: #006633;">hello</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>Compile and run the client<br/></p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">javac Client.java
java Client</pre></div></div>

<p>C&#8217;est tout! (Thats all). Your java-based client-server hessian binary protocol web service system is up and running. Wow!</p>
<p><b>Hessian in Ruby</b><br/></p>
<p>After download and unpacking <a href="http://hessian.rubyforge.org/">hessian library for ruby</a> it only takes three lines of code to connect to our java web service</p>

<div class="wp_syntax"><div class="code"><pre class="ruby" style="font-family:monospace;"><span style="color:#CC0066; font-weight:bold;">require</span> <span style="color:#996600;">&quot;lib/hessian.rb&quot;</span>
client = <span style="color:#6666ff; font-weight:bold;">Hessian::HessianClient</span>.<span style="color:#9900CC;">new</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#996600;">'http://localhost:8080/basic'</span><span style="color:#006600; font-weight:bold;">&#41;</span>
<span style="color:#CC0066; font-weight:bold;">print</span> client.<span style="color:#9900CC;">hello</span></pre></div></div>

<p>It seems that you can also easily create hessian-based services via ruby, but i didn&#8217;t dig into it.</p>
<p><b> Hessian in PHP </b><br />
Download, unpack and make accessible via apache <a href="http://hessianphp.sourceforge.net/">the php library of hessian</a>. There is a minor glitch in Hessian PHP in which the DateTime class conflicts with Php 5.2 pre-defined DateTime class. Simply re-touch the library code and rename that class.</p>
<p><em>php_hessian_client.php</em></p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?</span>
<span style="color: #b1b100;">include_once</span> <span style="color: #0000ff;">'HessianClient.php'</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$proxy</span> <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">&amp;new</span> HessianClient<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'http://localhost:8080/basic'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #b1b100;">echo</span> <span style="color: #000088;">$proxy</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">hello</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> 
<span style="color: #000000; font-weight: bold;">?&gt;</span></pre></div></div>

<p>You can also write a simple hessian web service api provider &#8230;<br />
<em>php_hessian_service.php</em></p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?</span>
<span style="color: #000000; font-weight: bold;">class</span> Math<span style="color: #009900;">&#123;</span>    
  <span style="color: #000000; font-weight: bold;">function</span> add<span style="color: #009900;">&#40;</span><span style="color: #000088;">$n1</span><span style="color: #339933;">,</span><span style="color: #000088;">$n2</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>        
    <span style="color: #b1b100;">return</span> <span style="color: #000088;">$n1</span><span style="color: #339933;">+</span><span style="color: #000088;">$n2</span><span style="color: #339933;">;</span>    
  <span style="color: #009900;">&#125;</span>    
  <span style="color: #000000; font-weight: bold;">function</span> sub<span style="color: #009900;">&#40;</span><span style="color: #000088;">$n1</span><span style="color: #339933;">,</span><span style="color: #000088;">$n2</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>        
    <span style="color: #b1b100;">return</span> <span style="color: #000088;">$n1</span><span style="color: #339933;">-</span><span style="color: #000088;">$n2</span><span style="color: #339933;">;</span>    
  <span style="color: #009900;">&#125;</span>    
  <span style="color: #000000; font-weight: bold;">function</span> mul<span style="color: #009900;">&#40;</span><span style="color: #000088;">$n1</span><span style="color: #339933;">,</span><span style="color: #000088;">$n2</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>        
    <span style="color: #b1b100;">return</span> <span style="color: #000088;">$n1</span><span style="color: #339933;">*</span><span style="color: #000088;">$n2</span><span style="color: #339933;">;</span>    
  <span style="color: #009900;">&#125;</span>    
  <span style="color: #000000; font-weight: bold;">function</span> div<span style="color: #009900;">&#40;</span><span style="color: #000088;">$n1</span><span style="color: #339933;">,</span><span style="color: #000088;">$n2</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>        
    <span style="color: #b1b100;">return</span> <span style="color: #000088;">$n1</span><span style="color: #339933;">/</span><span style="color: #000088;">$n2</span><span style="color: #339933;">;</span>    
  <span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span>
<span style="color: #b1b100;">include_once</span> <span style="color: #0000ff;">'HessianService.php'</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$wrapper</span> <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">&amp;new</span> HessianService<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$wrapper</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">registerObject</span><span style="color: #009900;">&#40;</span><span style="color: #000000; font-weight: bold;">new</span> Math<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$wrapper</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">service</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">?&gt;</span></pre></div></div>

<p><b> More! </b><br />
Wait, there is more! </p>
<ul>
<li> <b>Lanuages Support </b>Hessian is supported on Grails via <a href="http://grails.org/Remoting+Plugin">the remoting plugin</a>, I didn&#8217;t try the rest of the languages supported by hessian yet, but it looks that they would be fine.</li>
<li><b>Authentication and Http Proxy</b><br />
You can also make use of Http Authentication to add a security layer on top of your api&#8217;s, and proxy-by-pass in case there is a proxy in the way. </li>
<li><b>Additional Services built on top of Hessian </b><br />
There are also two interesting technologies by Caucho built on top of hessian, viz <a href="http://caucho.com/resin/doc/bam.xtp">BAM</a> and <a href="http://caucho.com/resin/doc/resin-comet.xtp"> comet </a>. </li>
<li><b>Performance benchmarks</b><br />
This is an <a href="http://daniel.gredler.net/2008/01/07/java-remoting-protocol-benchmarks/">interesting benchmark</a>, demonstrating how hessian perform against classical text and binary protocols.</li>
</ul>
<p><b> Gotcha&#8217;s </b><br />
I can see a couple of minor gotcha&#8217;s in Hessian library that can be addressed &#8230;</p>
<p>A. The language-support projects seem not to be updated for a long time, some more than a year. Those projects only support hessian protocol version 1.0.x and don&#8217;t support the latest hessian 2 protocol.</p>
<p>B. The thing I really missed is a JavaScript library that connects me to a hessian service directly. That alone will immediately offer a great value to AJAX applications.  I don&#8217;t see that far from possible, given the fact that there is already an ActionScript implementation for Flash. I hope someone will dedicate the effort to make that a reality.</p>
<p><b>Conclusion</b><br />
The Internet is coming back to its senses <img src='http://noor.ojuba.org/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> , using Binary-based communication protocols might sound 30-year old concept, but it brings a lot on the table that current text-based human-readable protocols don&#8217;t.<br />
I am all forward for making use of such protocols in SaaS / SOA setups. Simply Binary Protocols such as hessian, could provide an alternative communication option for today&#8217;s SOAP/XML-RPC/JSON ones.</p>
]]></content:encoded>
			<wfw:commentRss>http://noor.ojuba.org/2008/11/a-ride-with-hessian/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Predictable Binary Representation  (PBR)</title>
		<link>http://noor.ojuba.org/2008/09/predictable-binary-representation-pbr/</link>
		<comments>http://noor.ojuba.org/2008/09/predictable-binary-representation-pbr/#comments</comments>
		<pubDate>Mon, 01 Sep 2008 10:30:56 +0000</pubDate>
		<dc:creator>Kefah Issa</dc:creator>
				<category><![CDATA[General]]></category>

		<guid isPermaLink="false">http://noor.ojuba.org/?p=20</guid>
		<description><![CDATA[XML is nice, YAML and JSON are cool, proprietary formats for binary encapsulation are not good; those are all facts that many people agree to.
But they all the good solutions remain sub-optimal when it comes to network bandwidth overhead and cpu usage needed to parse the blob every time.
This might have, and should have been [...]]]></description>
			<content:encoded><![CDATA[<p>XML is nice, YAML and JSON are cool, proprietary formats for binary encapsulation are not good; those are all facts that many people agree to.</p>
<p>But they all the good solutions remain sub-optimal when it comes to network bandwidth overhead and cpu usage needed to parse the blob every time.</p>
<p>This might have, and should have been considered long time ago. I didn&#8217;t find any open format to cover it however, hence I&#8217;m suggesting one&#8230;</p>
<p><strong>Features</strong></p>
<p>The following needs are not addressed by those data representation formats, but are by PBR :</p>
<p>1. Supporting Binary content. You need to revert to Base64 or the like to do this. but its not natively supported.<br />
2. Completly Predictable (so no guess work in parsing). I don&#8217;t want to waste cpu cycles and logic to parse the content in an unpredicable manner. I want to be able to exactly tell what the next step a head and how much data I need to manage.<br />
3. No escaping. I really don&#8217;t like escaping. I want to be able to put my content AS IS &#8482;.<br />
4. Reliable : Checksum. Thats a cool addition that will make me confident of my data.</p>
<p><span id="more-20"></span></p>
<p>Here I outline the details of PBR (pronoucde  Pe.be.r) along with reference implementation (TBD) :</p>
<p>The data is represented in a message.</p>
<p>Each message is made of envelope header and body.</p>
<p>The Data elements (Entries) are organized in Entry-Name/Entry-Value pairs.</p>
<p>The body is simple a list of Entries (aka root node).</p>
<p><strong>Supported Data Types</strong></p>
<p>Just like JSON PBR does support the basic and most used data types that cover most of today&#8217;s modern needs</p>
<ol>
<li><strong>Boolean</strong></li>
<li><strong>String </strong>(UTF-8)<strong><br />
</strong></li>
<li><strong>Binary</strong></li>
<li><strong>Integer</strong></li>
<li><strong>Double</strong></li>
<li><strong>Date</strong></li>
<li><strong>Map </strong>(List is just a map with unnamed entries)<strong><br />
</strong></li>
</ol>
<p>- Depth or number of entries is unlimited.<br />
- Content-size limit it 2^31 (2GB).</p>
<p>PBR is not human readable, but using a binary editor or in the future a simple PBR reader would allow to easily read and manually manipulate the data.</p>
<p><strong>Envelope Header </strong></p>
<ul>
<li><strong>PBR Version</strong> (2 Bytes, signed short)</li>
<li><strong>MD5 Checksum</strong> of the body (16 Bytes)</li>
<li><strong>Total Message Size</strong> exclusive of the envelope header  in Bytes(4 Bytes, signed long)</li>
<li><strong>Number of Level-One Entries </strong>(4 Bytes, signed long)</li>
</ul>
<p>Total Envelop Header size is 26 bytes</p>
<p>The Message Body is a list of data entries. The number of those data entries (1st-level) is as defined in the header above.</p>
<p><strong>Data Entry </strong></p>
<ul>
<li><strong>Entry Type</strong> (1 Byte, signed byte) : The type id of the entry, 1..7 as per the types list above.</li>
<li><strong>Entry Name Size</strong> (1 Byte, signed byte) : The Size of the Name of the entry.  can be set to 0.</li>
<li><strong>Entry Name Value</strong> (0..127 Bytes) : The entry name in UTF-8.</li>
<li><strong>Number of Children</strong> (4 Bytes, signed long)</li>
<li><strong>Value Size</strong> : (4 Bytes, signed long) : The size in bytes of the value of this entry.</li>
<li><strong>Value</strong> : ( 1 .. 2^31)</li>
</ul>
<p>Any entry can have children, just like XML node.</p>
<p>However it can only either have children or a value (i.e. Number of Children ==0).</p>
<p>If Number of Children &gt; 0, then the value contains an aggregation of a list of other entries that need to be read.</p>
]]></content:encoded>
			<wfw:commentRss>http://noor.ojuba.org/2008/09/predictable-binary-representation-pbr/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>QT for GNOME</title>
		<link>http://noor.ojuba.org/2008/07/qt-for-gnome/</link>
		<comments>http://noor.ojuba.org/2008/07/qt-for-gnome/#comments</comments>
		<pubDate>Tue, 15 Jul 2008 21:23:34 +0000</pubDate>
		<dc:creator>Kefah Issa</dc:creator>
				<category><![CDATA[Fedora 9]]></category>
		<category><![CDATA[General]]></category>

		<guid isPermaLink="false">http://noor.ojuba.org/?p=18</guid>
		<description><![CDATA[I feel very strongly about the historical opportunity for the GNOME community to switch their tool kit over to QT 4.x. GNOME was originally a fork of effort from KDE back in the old days when QT was not GPL-enabled.

Now it is &#8212; and so for many years &#8212; I can see no reason why [...]]]></description>
			<content:encoded><![CDATA[<p>I feel very strongly about the historical opportunity for the GNOME community to switch their tool kit over to QT 4.x. GNOME was originally a fork of effort from KDE back in the old days when QT was not GPL-enabled.</p>
<p><span id="more-18"></span></p>
<p>Now it is &#8212; and so for many years &#8212; I can see no reason why GNOME can&#8217;t do the switch.</p>
<p>This will be a major effort of course, and there will be two types of opponents in the GNOME community :<br />
A. C-Lovers : Those who like C-language (not C++) as GTK and GNOME in general is more C-Lang than C++.<br />
B. Mono-lovers : Those who are after mono, which is not a very successful imitation for Microsot .NET.</p>
<p>Lets put that a side for a minute and lets give it a hard look, GNOME development has been stalled due to many technology limitation. Even with the latest GUADEC and talk about tab-enabling (which i still think is a joke).</p>
<p>So, despite our love and hate, at the end of the day QT is THE most mature toolkit in the FLOSS world. It deserves all the blessings it can get &#8230; and very well deserves to be considered as an excellent candidate for the GNOME project, especially after what happened with KDE4 and their move into directions that are far from the users and community. The failure in KDE4 was a result of the people who assumed its leader ship in the last two years, and its not in any way related to QT.</p>
]]></content:encoded>
			<wfw:commentRss>http://noor.ojuba.org/2008/07/qt-for-gnome/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>My search for a web-development framework</title>
		<link>http://noor.ojuba.org/2008/06/my-search-for-a-web-development-framework/</link>
		<comments>http://noor.ojuba.org/2008/06/my-search-for-a-web-development-framework/#comments</comments>
		<pubDate>Sat, 14 Jun 2008 05:01:29 +0000</pubDate>
		<dc:creator>Kefah Issa</dc:creator>
				<category><![CDATA[General]]></category>
		<category><![CDATA[web-framework]]></category>

		<guid isPermaLink="false">http://ojuba.org/kefahblog/?p=3</guid>
		<description><![CDATA[Would the debate on the best Web-development framework evern end? probably not, becuase debate reflects the very nature of us humans. We see things from different angles, and apply them to different cases &#8230;
Nevertheless, for the yours truly this does not have to be the case&#8230; here is my angle &#8230;

The need and demand to [...]]]></description>
			<content:encoded><![CDATA[<p>Would the debate on the best Web-development framework evern end? probably not, becuase debate reflects the very nature of us humans. We see things from different angles, and apply them to different cases &#8230;</p>
<p>Nevertheless, for the yours truly this does not have to be the case&#8230; here is my angle &#8230;</p>
<p><span id="more-3"></span></p>
<p>The need and demand to build content-oriented websites have been knocking my door for that last 10 years. I built several solutions, using ASP, PHP, Cocoon, Lenya, Ruby on Rails, Java Servlets &#8230; along few others. Each of them had its own shortcomings that made me not to choose again in my next project.</p>
<p>I spent good portion of my time just searching for a better alternative &#8230;</p>
<p>Ruby on Rails (RoR): My experience with Rails has started around two years ago. Rails was a cool technology. However it didn&#8217;t live up to the expectations. I think both Ruby and the Rails framework has fundamental implementation issues that should have been solved two years ago, but nothing was done about it. so, after the huge hype and promotion, its cooling down slowly. Now, as they say &#8220;Good things never go away&#8221; Ruby on Rails made every one think again about how to write web-frame works and how to make it easy and sensible. Java and PHP communities among many others made the move and benefited from the wonderful approach that Rails has offered to web-development.</p>
<p>That being said, RoR has become more like a reference to an original concept.</p>
<p>But what are the limitations of RoR? one may ask, the answer is simple : Performance and Scalability.</p>
<p>Should Ruby 2.0 have been released two years ago, RoR would probably have been the preferred choice. but any advancement in Ruby has been staggering for too too long.</p>
<p>I would never blame any one for that, things are what they are. I&#8217;m sure the ruby-developer-community have their reasons. but for me, it means that i have to find my way again in my search for a web-development framework. That was around the beginning of this year.</p>
<p>Lenya 2.0 :A well-architected option that simply has major problems in running up to its advertised features. its very hard to get things working, and if you come up with any specific need that wasn&#8217;t previously thought of it would also be super hard to implement. I know that my comments on Lenya might sound too subjective, but they are not; they are based on months of trying and digging and learning without any avail.</p>
<p>PHP (CakePHP, codeIginator, Symphony) : I never got into PHP really. I know that the computer language is but a tool, but I think PHP being made very easy by design made it too difficult for someone like myself. <img src='http://noor.ojuba.org/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> </p>
<p>Groovy and Grails : Although I heard about it couple of years, it never really caught my attention. &#8220;what would just-another-ruby-on-rails replica bring to the world!?&#8221; I asked by then.<br />
Things have changed, though. For the last four weeks, I have got my hands dirty and my feet wet with Groovy and Grails&#8230; and I must say that I am amazed.</p>
<p>What I found so cool about it &#8230;</p>
<ol>
<li>Compiled and not interpreted. So its not an interpreter on top a virtual machine.</li>
<li>Full Java interchangeability, even the syntax pretty much overlaps. to the degree that if you change the extension of a java file to groovy it would probably work with minimal changes. which means that you can inter-mingle java code and libraries with groovy ones.</li>
<li>Grails builds on top of industrial-strength components such as Hibernate and Spring. Hence you will find your most demanding needs covered.</li>
</ol>
<p>The one shortcoming would be performance (but not scalability). That is grails is multi-threaded (unlike Rails that is single threaded, even on JRuby, rails remain to be single threaded).</p>
<p>But performance is improving, groovy 1.6 promises to bring it closer.</p>
<p>On the grails website, they say &#8220;The search is over&#8221; I started to realize and believe in that &#8230; hope my search will be over at least for the next few years.<br />
more to come &#8230;</p>
]]></content:encoded>
			<wfw:commentRss>http://noor.ojuba.org/2008/06/my-search-for-a-web-development-framework/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Hello world!</title>
		<link>http://noor.ojuba.org/2008/06/hello-world/</link>
		<comments>http://noor.ojuba.org/2008/06/hello-world/#comments</comments>
		<pubDate>Sat, 14 Jun 2008 04:20:40 +0000</pubDate>
		<dc:creator>Kefah Issa</dc:creator>
				<category><![CDATA[General]]></category>

		<guid isPermaLink="false">http://ojuba.org/kefahblog/?p=1</guid>
		<description><![CDATA[I never thought that I would have a blog, I am not a talking-kind-of-person. But now I started to see it as a good method to keep my notes in one place and make them availalbe. Just a 2 cents kind of stuff.
]]></description>
			<content:encoded><![CDATA[<p>I never thought that I would have a blog, I am not a talking-kind-of-person. But now I started to see it as a good method to keep my notes in one place and make them availalbe. Just a 2 cents kind of stuff.</p>
]]></content:encoded>
			<wfw:commentRss>http://noor.ojuba.org/2008/06/hello-world/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
