Sunday, September 30, 2007

Narcissus.py

Today I finished porting of Rbnarcissus to Python.

I managed to finish the porting in a total of 7 days, spending approximately
2-3 hours per day. The test parse script has also been ported. With this
I managed to produce the JS parse tree for the following simple Javascript
function.


function test()
{
var a = 10
var b = 20
var c = a + b
}


As a result of parsing, the following function dictionary was printed.


{test: []}


This library will be made available as part of HarvestMan and the EIAO projects.
This is perhaps going to be the first open source pure Python parser for Javascript.

I need to do a bit more of testing on more complex Javascript code before I make the code publicly available. This might take another week or so, depending upon how much time I get to spend on this in the coming days...

Tuesday, September 18, 2007

Rbnarcissus Porting - Day 2

In the second marathon day of Rbnarcissus porting I completed porting of another 5 functions in the Parser.rb module. What is pending are two huge functions which parses statements and expressions. That should be taken care by another day or two of hectic hacking...

Monday, September 17, 2007

BangPypers move in to python.org

The entire Python family of BangPypers moved enmasse to their new home at the python.org website three days back, on Sep 14 2007.

Jeff Rush of Python Advocacy Blog was instrumental in creating the new mailing list hosted at python.org, after I sent him a request regarding the same. Jeff was immensely kind and helpful during the whole process, which got completed by end of the day. Thanks a lot Jeff!

The move came after a slew of discussions which started with this thread in early August by Anand. C (strandpyper). Quickly a kind of agreement was reached among the participants of the thread about moving out to a better place from the existing Y! group, preferably at the python.org website itself.

A lot of people participated in the discussion, giving valuable suggestions, which finally helped to reach an agreement and making the task of moving the members to the new list a painless process.

The new mailing list is public and open to anyone. This should hopefully expose the BangPypers members to the larger Python community in the international scene and give the group more visibility. It will be nice to see if any kind of larger group activities can be arranged as a part of such an exposure.

The group still lacks a coherent theme, which needs to be painted into so that it functions as a rather tight group with shared interests, than the current fragmented one. One way of doing this is to execute open source Python projects as a group, by forming small interest groups inside the larger group, which can then focus on a particular project. The monthly meetings also need to be revived, which can bring more thought into what can be done in the coming months.

If you are interested in Python and/or the BangPypers group, feel free to comment with your thoughts.

Rbnarcissus Porting - Day 1

Today I completed almost 40% of the the porting of Rbnarcissus to Python. All the data structures and regular expressions have been ported along with the "Tokenizer" class.
There still remains around 13 classes to be ported which forms the bulk (60%) of the code.

If I keep up the same pace, I should be done with this in another 3-4 days. This could become a useful tool for Python programmers, having a pure Python parser for Javascript.

Watch this space for more updates.

Saturday, September 08, 2007

The Ruby Way - A Python programmer learns Ruby

Ruby is the language I am always putting off to learning the next day. I came across Ruby almost at the same time I started learning Python. However due to its similarities with Perl, I was never able to take an affinity towards the language.

I knew Ruby needed to be in my toolbox of languages and it was only a matter of time before I got to it. This happened last week, trying to solve a very practical programming problem.

I was trying to develop a Javascript parser/tokenizer for HarvestMan so that HarvestMan can crawl pages which defines the DOM dynamically using Javascript. I have been at this problem for some time now, but never came across a pure Python or even a C/C++ extension Javascript parser I could use. Last week I came across Rbnarcissus, a pure Ruby port of Narcissus, the open source Javascript engine written in Javascript.

I have set upon myself the task of porting this code to pure Python. I figured I knew enough Ruby to do this without any additional help, but one look at the code and I realized I needed help. I bought Hal Fulton's excellent Ruby book The Ruby Way from a book shop. (The book is a bit pricey for a low priced Indian edition, but it is worth the money.)

I have been spending the last two days with the book. I have realized a few things about the The Ruby Way when compared to the Zen of Python.

1. Ruby follows the Perl paradigm of There is more than one obvious way to do it, when compared to the Pythonic There should be one-- and preferably only one --obvious way to do it. (An import this in a Python interpreter prompt gives you the Zen of Python).

2. Ruby is a more complete object oriented language than Python and empowers its types and objects much more than Python does. However this also makes Ruby slightly more harder to learn than Python.

I feel Python is still the ideal language for a newbie who wants to learn a very high level programming language. However Ruby is much more powerful and suited for the expert programmer who expects more power out of his objects and types.

I have not got completely into the Ruby Way yet, but I am on my way. I am hoping that combining the Ruby Way with the Zen of Python will lead me to the Tao of Programming...