I’m trying to dig into C# a little more at work, so I decided to do something really easy and write a little code to grab an RSS feed and pull the enclosure data out of it. Before you look at the code, let me say that I don’t have an objective point to make with this. I’m not trying to make sweeping judgments based on number of lines of code or anything else. I do have some subjective remarks to make at the end, however.

Here is the C# code:

using System;
using System.Xml;

namespace RssGrabber
{
    class MainClass
    {
        public static void Main(string[] args)
        {
            string rssUrl = "http://geekmuse.dreamhosters.com/wp/?feed=rss2";
            XmlTextReader reader = new XmlTextReader(rssUrl);
            while(reader.Read())
            {
                if ((reader.IsStartElement()) && (reader.Name == "enclosure"))
                {
                    while (reader.MoveToNextAttribute())
                    {
                        System.Console.WriteLine("{0} => {1}", reader.Name, reader.Value);
                    }
                }
            }
        }
    }
}

Here is the Python code:

from elementtree import ElementTree as ET
import StringIO
import urllib

rssUrl = "http://geekmuse.dreamhosters.com/wp/?feed=rss2"

et = ET.parse(StringIO.StringIO(urllib.urlopen(rssUrl).read()))
for elem in et.findall("//enclosure"):
    for items in  elem.attrib.items():
        print "%s => %s" % items

Now, on to the subjective. Python just feels more manageable than C#. It feels friendlier. It didn’t feel tedious to try to get data out of. That’s it. That’s my point. If your opinion varies from that, then that’s OK. I’m not here to change your mind. And I’m definitely not here to try to offer up comprehensive language comparisons. I’m just expressing a little piece of an experience I just had which I thought was worth noting.