Friday, October 10, 2008

Google Chrome, Looking Good

It seems almost everybody is taking a strong liking into Google Chrome these days and almost everybody who has downloaded it seems to be appreciating it a lot. So I myself thought of giving Google Chrome a trial run. 

However I have to say that my first impression on Google Chrome was not a very good one mainly due to the fact that it’s only available for the Windows platform at the moment. I’m an open source fan and that makes me naturally dislike anything that won’t run on Linux out of the box. However I think I can forgive Google for that. I believe they just wanted to keep the things simple by focusing on one target platform since this is only a beta release. Also they probably wanted to get the maximum possible test coverage out of this release. In that case Windows is the only logical solution since whether we like it or not Windows still dominates the client side system software market. (and it will probably remain that way for a long time :-( )

Other than the above mentioned glitch my experience with Google Chrome has been a fairly good one. It’s easy to install and configure. I really like the wording and labeling convention used in Chrome. It’s simple and casual English that anybody can understand. Not a single technical word is used so that even someone who is browsing the Internet for the first time can easily get used to Google Chrome. Even the buttons that are usually rendered as ‘browse’ buttons in other browsers will be rendered as ‘choose file’ buttons. 

The user interfaces are pretty cool too. Chrome UI designers have clearly dumped the approaches taken by IE developers and Firefox developers to come up with their own style. It has no menu bars and no tool bars. All it has is the address bar with few more additional controls embedded into it. The address bar can be used to type in both URLs and search queries. One advantage of this organization is that it makes the browser’s main Window large so that the user can see more content without having to scroll much. But the problem is for someone who is so used to IE or Firefox, figuring out how to control the browser is going to be a bit of a pain.

In my opinion it has slightly better performance compared to Firefox-3 and IE-7. (well at least I feel that way) I have experienced frequent browser crashes with both IE-7 and Firefox-3. But I’m yet to experience that in Chrome. 

Perhaps the most enticing feature of Chrome is that every time a new tab is opened a new process is forked off by the browser. This way each tab gets its own set of resources. This will hopefully rectify most of the memory related issues experienced by other browsers. If you are a regular Firefox user you know that as we continue to open new tabs in Firefox the overall performance of the browser degrades significantly. This is because all the tabs have to share the same set of resource (memory in particular). By dedicating a separate process for each tab Google Chrome effectively deals with this issue.

I will continue to test Google Chrome in the days to come. I just started with Chrome and I will be in a better position to give a comprehensive feedback after another couple of weeks. Until then ‘good job Google’!

Wednesday, October 8, 2008

Lex It! Yacc It!

Lately I have been working a lot with the two legendary parser generator tools, ‘Lex’ and ‘Yacc’. (Well it’s actually ‘Flex’ and ‘Bison’ to be precise) To be honest I didn’t have any experience with Lex and Yacc two weeks back. But the two applications are so easy to learn and master that anyone could become an expert compiler developer in no time. Practically speaking one could start developing parsers and compilers without any prior knowledge on compiler theory or language parsing. All you need to get started is some experience in C programming. However I have to admit that some knowledge on regular expressions, context free grammars and push down automatons can make your life lot easier since that would help you better understand the syntax of the two configuration languages used by Lex and Yacc. 

Lex (or Flex) generates a C function called yylex which is capable of scanning and tokenizing a given input. The input to Lex primarily consists of regular expressions and C code segments to be executed on detection of strings that match the regular expression definitions. Yacc (or Bison) generates a C function called yyparse which accepts a sequence of tokens from yylex and parses them. The YACC input would include the productions of the language grammar and C code segments to be executed on application of the productions. 

It’s truly amazing how easy to develop parsers to accept complex languages with Lex and Yacc. The more I use it more I like it. The syntax of the configuration files are well structured and so easy to understand. I was so inspired by these two applications that I started developing my own command-line mathematics package for Unix/Linux systems. My plan is to develop something which is similar to the command interpreter that comes with MATLAB. I have already implemented support for executing simple mathematical expressions, trigonometric functions, logarithms and variables. I’m currently trying to implement the support for user defined functions. Once that is done I intend to implement support for matrix algebra and simple statistics.

The above sounds like a lot of work but thanks to Lex and Yacc I have to write only a very small amount of code. The two magic tools do the job by generating hundreds of lines of C code for me. Of course needless to say that developing something similar from the scratch would surely take months.

I’ve always wondered how come there are so many programming languages. But now I think I know the answer. It’s so freaking easy to develop parsers and compilers for a language with tools like Lex and Yacc. Once you have a language expressed in terms of a set of productions it takes only a few minutes to develop a fully functional compiler. So anyone can come up with an idea for a new language and turn it into reality in a flash. In fact I’m thinking about doing the same in the near future :-)

If you are like me and want to learn and master Lex and Yacc here is a cool reference guide. It helped me out a lot and I’m sure it will do the same for you.

Monday, September 1, 2008

GSoC 2008 ....... Done

You may have noticed that my blog has gone rather silent in the last couple of months. Well, the reason was my Google Summer of Code (GSoC) project. The final deadline was on 18th of August so I worked really hard to deliver the goods on time and finally I can proudly state that I managed to successfully complete my project on time.

The objective of my GSoC project was to implement XML schema type alternatives support for Apache Xerces2/J, the legendary open source XML parser for Java applications. Type alternatives is the answer from W3C XML schema working group, for conditional type assignment problem. This feature was first introduced in the XML schema 1.1 structures specification. Type alternatives allow a type to be assigned to an element dynamically at validation time based on one or more conditions. Conditions are expressed as XPath 2.0 expressions. Here is an example element declaration which uses XML schema type alternatives.

As stated in the above code snippet the declared type of the message element is the complex type called messageType. However the element declaration also contains a few type alternatives. These type alternatives allow the type of the message elements to be determined at the validation time. Based on the conditions stated as the test attribute values the schema validator will assign a type for the message element prior to validating its content. The expressions '@kind' and '@code' refer to two attributes of the message element. The first type alternative will assign the type called messageTypeString if the kind attribute has the value 'string' and the code attribute has a value greater than 1000.

When the schema validator encounters an element declaration with one or more type alternatives it will evaluate the test expressions one by one until an expression which evaluates to true is found. When such a matching type alternative is found the corresponding type will be assigned to the element. If none of the type alternatives match then a default type will be assigned.

My project mainly consisted of two main sections. First section of the project was to implement the type alternatives traversal support so that Xerces2/J can properly traverse an XML schema document which contains type alternatives and add the corresponding information to the schema grammar. Implementing this was fairly easy and I managed to complete it prior to th GSoC mid term evaluations. The second part of the project was to implement type alternatives validation. This was fairly difficult since I had to develop a bare minimal XPath 2.0 implementation for Xerces2/J. Developing the XPath processor actually covered a significant portion of the entire project.

My workings will be fully available in the Xerces2/J code base (even now the code related to traversal part is in one of the SVN branches) very soon. All in all it was a great learning experience as it was a great opportunity for me to learn a whole bunch of cool technologies like XML, XML schema, and XPath 2.0. I also got the opportunity to put some of my knowledge on theory of computing into action and sharpen my programming skills. I would like to give my heartiest gratitude to the Google, the Apache community and very specially to my mentor Khaled Noaman for being a very supportive guide right from the start of my project.

Tuesday, August 19, 2008

Financial Applications with WSO2 ESB

It's getting better and better folks. FIX protocol support in WSO2 ESB is evolving in a blistering rate. This article by Asanka Abeysinghe shows how an entire broker trading platform can be re-engineered using WSO2 ESB. It combines a set of well known usecases of the FIX transport of WSO2 ESB and demonstrates how the ESB can be used to build complete financial applications.

However when looking back at the way things have gone this is nothing to be surprised of. Few months back Paul Fremantle, CTO of WSO2, infact predicted that FIX protocol support in WSO2 ESB will soon evolve to this stage.


Sunday, August 10, 2008

FIX Support in WSO2 ESB

WSO2 ESB is an ultra fast, lightweight, open source ESB based on Apache Synapse. The FIX transport implementation of Apache Synapse is fully operational in WSO2 ESB 1.7. Asanka Abeysinghe from WSO2 has recently published a comprehensive article on using the FIX transport in WSO2 ESB. He starts by giving a short introduction to the FIX protocol and goes onto explaining a number of interesting usecases for the FIX transport in WSO2 ESB.

If you are looking for a powerful SOA based solution to deal with your FIX transactions, this is a must read for you. While you are at it don't forget to take a peek at the article titled 'Apache Synapse FIX'ed', and article I wrote few months back introducing the FIX transport implementation of Apache Synapse.

Saturday, August 9, 2008

Fixing the FIX Transport

The 1.2 version of Apache Synapse, the open source lightweight ESB was released on June 2008. One of the most striking features of this release was the FIX transport implementation, mainly due to the fact that most ESBs in the world still do not support the FIX protocol. The Synapse FIX transport implementation which is only two months old at the moment has already made a lot of hype in the world of Software Engineering and SOA. It seems we already got a few interested people (potential clients?) who are at the moment testing and playing with the transport.

Synapse 1.2 ships with two samples that demonstrate the FIX transport module. One of them demonstrates how two FIX endpoints can be bridged using Apache Synapse. The other samples shows how to bridge an HTTP client with a FIX endpoint. Over the last couple of months the Synapse community has worked really hard to further improve the FIX transport implementation and also to identify more exciting usecases for the transport module. As a result we managed to add four new samples demonstrating the FIX transport to the Synapse documentation. These samples are currently available in the Apache Synapse Snapshot and will be most likely included in the next release.

The first of the four newly added samples (sample 259) shows how to bridge a FIX client with an HTTP endpoint. The sample effectively demonstrates how Banzai, the sample FIX blotter that ships with Quickfix/J can be used to send order requests via Synapse to a service listening on HTTP. The sample uses the XSLT mediator to convert the FIX messages into a SOAP messages.

The second of the new samples (sample 260) shows how Synapse can be used to bridge a FIX endpoint with an AMQP endpoint. Here once the FIX message is converted into XML it will be bound to a JMS payload and sent to an AMQP consumer. Since AMQP is used widely in business applications, I believe that this sample will open up the door way to a ton of really cool usecases.

The third sample (sample 261) demonstrates how Synapse can be used to switch between FIX sessions with different versions (BeginString values). The sample successfully bridges a FIX 4.0 session with a FIX 4.1 session but the underlying concepts can be used to bridge virtually any two FIX sessions. One thing worth mentioning here is that the FIX transport implementation of Synapse initially did not support bridging FIX sessions of different versions. But considering the potential usecases, we implemented that feature very recently.

The fourth newly added sample (sample 262) demonstrates how CBR (Content Based Routing) can be done with FIX messages using Apache Synapse. The sample configuration causes Synapse to accept FIX messages over a session, read a certain symbol in the messages and based on the symbol value route the messages to different endpoints.

We also added namespace support to the FIX transport module so that it can properly parse and validate XML based FIX messages with namespaces. Another recent feature addition was improving the way FIX sessions are initialized in Synapse. The initial implementation lazy initializes all the FIX sessions for outgoing FIX messages. That means an outgoing session will not be created until a message arrives for that particular session. However since this leads to fairly large delays we improved the transport module so that the outgoing sessions are also initialized at the startup along with the incoming sessions. (the old way of initializing sessions is also supported)

Currently we are working on adding support for FIX repeated groups. (we already have a feature request for this on the JIRA from one of our users) All in all it seems that the FIX transport module for Synapse is increasingly becoming a very powerful and matured piece of software in a blistering rate.