<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="http://blogs.msdn.com/utility/FeedStylesheets/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>Developing for Developers : Software engineering</title><link>http://blogs.msdn.com/devdev/archive/tags/Software+engineering/default.aspx</link><description>Tags: Software engineering</description><dc:language>en-US</dc:language><generator>CommunityServer 2.1 SP1 (Build: 61025.2)</generator><item><title>Literate programming</title><link>http://blogs.msdn.com/devdev/archive/2006/01/23/516431.aspx</link><pubDate>Tue, 24 Jan 2006 00:53:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:516431</guid><dc:creator>dcoetzee</dc:creator><slash:comments>10</slash:comments><comments>http://blogs.msdn.com/devdev/comments/516431.aspx</comments><wfw:commentRss>http://blogs.msdn.com/devdev/commentrss.aspx?PostID=516431</wfw:commentRss><description>&lt;P&gt;&lt;A href="http://www.google.com/search?q=literate+programming"&gt;Literate programming&lt;/A&gt;, invented in 1981 by the same Donald Knuth who wrote &lt;EM&gt;The Art of Computer Programming&lt;/EM&gt; and the document language TeX, is a technique in which a program is written as a human-oriented document interspersing discussion and code. The code segments are arranged not according to execution order or the logical structure of the code, but in whatever order the author believes offers the best presentation to the reader. A tool can be used to automatically extract the code segments, put them back in the order expected by the compiler, and export them as a source file. Although it never really caught on for ordinary coding, it has the important ability to make code easier to understand for a reader, easing maintenance, transfer of ownership,&amp;nbsp;and helping to prevent future bugs.&lt;/P&gt;
&lt;P&gt;The idea is perhaps easiest to understand if we look at it not from the perspective of a coder, but from the perspective of a researcher writing a book. They write a section about an algorithm, showing first the core algorithm, then talking about issues, improvements, and variations. In each section they show a little more code.&amp;nbsp;They might show a test driver to demonstrate how it might be invoked. Taken to the logical extreme, these code samples could, taken together,&amp;nbsp;show every part of the program - all someone would need to do to run it is to copy the samples into a source file in the right order and build it. If we automate this extraction process, we now have a section of a book that simultaneously &lt;EM&gt;is&lt;/EM&gt; a real program that can be run.&lt;/P&gt;
&lt;P&gt;Some people find the idea of structuring a program in this seemingly random "presentation order" strange, but really we do it all the time. Suppose you arrive on a new team and take control of a&amp;nbsp;module from someone else. At some point, you sit down with the previous owner, who proceeds to describe how the module works. If they do this effectively, they don't take an alphabetical file listing and go through each file in order - instead, they first focus on core parts of core functionality and expand outward to more peripheral functionality. You might ask a question about a piece of code you see, and they say "Don't worry about that - I'll get to that later when I talk about X." By controlling the presentation order, they enhance your comprehension by keeping code out of the way until you have the proper background to understand its purpose.&lt;/P&gt;
&lt;P&gt;But what if this previous owner is long gone? They could have all the comments in the world, but you still won't have anything like the discussion above. Literate programming enables them to write a tutorial document that takes you through the code in the same friendly way as a sit-down with the owner, and yet never invokes redundant effort or becomes out-of-date, because it &lt;EM&gt;is&lt;/EM&gt; the code as well.&lt;/P&gt;
&lt;H2&gt;An example&lt;/H2&gt;
&lt;P&gt;But there's no better way to understand literate programming than to see some. So, right here, I'm going to discuss an implementation in C# of &lt;a href="http://blogs.msdn.com/devdev/archive/2005/08/17/452827.aspx"&gt;Bloom filters&lt;/A&gt;, the topic of my very first post (read this first if you haven't already). This implementation is based on a paper by a former of professor of mine, Panagiotis Manolios, and one of his students, Peter Dillinger, called &lt;EM&gt;&lt;A href="http://www.cc.gatech.edu/fac/Pete.Manolios/research/bloom-filters-verification.html"&gt;Bloom Filters in Probabilistic Verification&lt;/A&gt;&lt;/EM&gt;. This paper solves a frustrating implementation issue: Bloom filters require a potentially unlimited number of independent hash functions, and there's no convenient way of coming up with these hash functions on the fly. Their concept is to use only two independent hash functions to generate all of the hash values required. The insertion method below, based on Algorithm 2 in their paper, demonstrates this:&lt;/P&gt;&lt;PRE&gt;&amp;lt;&amp;lt;BloomFilter Insert method&amp;gt;&amp;gt;=
    public void Insert(TKey obj)
    {
        int h1 = obj.GetHashCode();
        int h2 = obj.GetHashCode2();
        unchecked
        {
            h1 = (int)(((uint)h1) % table.Count);
            h2 = (int)(((uint)h2) % table.Count);
        }
        &amp;lt;&amp;lt;perform insertion&amp;gt;&amp;gt;
    }
&lt;/PRE&gt;
&lt;P&gt;The syntax &lt;CODE&gt;&amp;lt;&amp;lt;perform insertion&amp;gt;&amp;gt;&lt;/CODE&gt;, used by the noweb tool, indicates a chunk of code that I haven't talked about yet. The label at the top is the name of this chunk of code. We use unchecked arithmetic for the casts because the hash code methods can return negative values, which we wish to convert to large positive values via the cast to uint. The narrowing cast back to int is safe because table.Count is in an int.&lt;/P&gt;
&lt;P&gt;Above, TKey is a generic type parameter on the class specifying the type of values stored in the Bloom filter. Keys must implement the IDoubleHashable interface, which adds a second hash function GetHashCode2() independent&amp;nbsp;from &lt;A href="http://msdn.microsoft.com/library/en-us/cpref/html/frlrfsystemobjectclassgethashcodetopic.asp"&gt;the standard GetHashCode() supplied by Object&lt;/A&gt;:&lt;/P&gt;&lt;PRE&gt;&amp;lt;&amp;lt;IDoubleHashable definition&amp;gt;&amp;gt;=
    public interface IDoubleHashable
    {
        int GetHashCode2();
    }

&amp;lt;&amp;lt;BloomFilter class definition&amp;gt;&amp;gt;=
public class BloomFilter&amp;lt;TKey&amp;gt; where TKey : IDoubleHashable
{
    &amp;lt;&amp;lt;BloomFilter implementation&amp;gt;&amp;gt;
}
&lt;/PRE&gt;
&lt;P&gt;We store the bits of the BloomFilter in a &lt;A href="http://msdn.microsoft.com/library/en-us/cpref/html/frlrfSystemCollectionsBitArrayClassTopic.asp"&gt;standard BitArray collection&lt;/A&gt;, which compactly stores the bits of the table and handles all the bit arithmetic for us:&lt;/P&gt;&lt;PRE&gt;&amp;lt;&amp;lt;BloomFilter member variables&amp;gt;&amp;gt;+=
        private BitArray table;
&lt;/PRE&gt;
&lt;P&gt;This is in the &lt;CODE&gt;System.Collections&lt;/CODE&gt; namespace, so we need a using statement:&lt;/P&gt;&lt;PRE&gt;&amp;lt;&amp;lt;BloomFilter using statements&amp;gt;&amp;gt;+=
using System.Collections;
&lt;/PRE&gt;
&lt;P&gt;The &lt;CODE&gt;+=&lt;/CODE&gt; noweb syntax above is used to add a piece of code to a code section. This is useful for sections we wish to describe sequentially a part at a time, or for elements like the above where order is unimportant.&lt;/P&gt;
&lt;P&gt;Now, we're prepared to describe the insertion. We set a number of roughly evenly spaced bits, where the first hash establishes the initial index, the second hash establishes the spacing, and the spacing is slightly increased as we go along. All arithmetic is done modulo the table size:&lt;/P&gt;&lt;PRE&gt;&amp;lt;&amp;lt;Perform insertion&amp;gt;&amp;gt;=
        for(int i=0; i&amp;lt;numHashes; i++) 
        {
            table[h1] = true;
            unchecked
            {
                h1 = (int)((uint)(h1 + h2) % table.Count);
                h2 = (int)((uint)(h2 + i) % table.Count);
            }
        }
&lt;/PRE&gt;
&lt;P&gt;The number of bits we set is determined by the fixed parameter numHashes. We'll describe how it's chosen a bit later on:&lt;/P&gt;&lt;PRE&gt;&amp;lt;&amp;lt;BloomFilter member variables&amp;gt;&amp;gt;+=
        private int numHashes;
&lt;/PRE&gt;
&lt;P&gt;The lookup procedure is analogous, checking all the same bits and returning true only if they're all set:&lt;/P&gt;&lt;PRE&gt;&amp;lt;&amp;lt;BloomFilter Contains method&amp;gt;&amp;gt;=
        public bool Contains(TKey obj)
        {
            int h1 = obj.GetHashCode();
            int h2 = obj.GetHashCode2();
            unchecked
            {
                h1 = (int)(((uint)h1) % table.Count);
                h2 = (int)(((uint)h2) % table.Count);
            }
            for (int i = 0; i &amp;lt; numHashes; i++) 
            {
                if (table[h1] == false)
                {
                    return false;
                }
                unchecked
                {
                    h1 = (int)((uint)(h1 + h2) % table.Count);
                    h2 = (int)((uint)(h2 + i) % table.Count);
                }
            }
            return true;
        }
&lt;/PRE&gt;
&lt;P&gt;The probability that this method will return true for a random value not in the set is given by:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;EM&gt;p&lt;/EM&gt; = (1 − &lt;EM&gt;e&lt;/EM&gt;&lt;SUP&gt;−&lt;EM&gt;kn/m&lt;/EM&gt;&lt;/SUP&gt;)&lt;SUP&gt;k&lt;/SUP&gt;&lt;/P&gt;
&lt;P&gt;where the variables are defined as:&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;&lt;EM&gt;k&lt;/EM&gt;: Called &lt;CODE&gt;numHashes&lt;/CODE&gt; in the code, the number of table elements set by an insertion 
&lt;LI&gt;&lt;EM&gt;m&lt;/EM&gt;: Called &lt;CODE&gt;table.Count&lt;/CODE&gt; in the code, the number of elements in the table 
&lt;LI&gt;&lt;EM&gt;n&lt;/EM&gt;: The number of distinct objects inserted so far&lt;/LI&gt;&lt;/UL&gt;
&lt;P&gt;To initialize the object, we use the following method, which needs to know &lt;EM&gt;k&lt;/EM&gt; and &lt;EM&gt;m&lt;/EM&gt;:&lt;/P&gt;&lt;PRE&gt;&amp;lt;&amp;lt;BloomFilter initialization&amp;gt;&amp;gt;+=
        private void Initialize(int tableSize, int numHashes)
        {
            this.numHashes = numHashes;
            table = new BitArray(tableSize, false);
        }
&lt;/PRE&gt;
&lt;P&gt;However, a user is unlikely to know the best values for these (which is why this isn't a constructor). Instead, we address two common use cases:&lt;/P&gt;
&lt;OL&gt;
&lt;LI&gt;In this case, the user knows &lt;EM&gt;m&lt;/EM&gt;, the desired table size in bits, and &lt;EM&gt;n&lt;/EM&gt;, an estimate of how many elements they will insert. We choose &lt;EM&gt;k&lt;/EM&gt; in a way that minimizes the false positive probability &lt;EM&gt;p&lt;/EM&gt;, using the value (ln 2)&lt;EM&gt;m&lt;/EM&gt;/&lt;EM&gt;n&lt;/EM&gt; rounded to the nearest integer: &lt;PRE&gt;&amp;lt;&amp;lt;BloomFilter initialization&amp;gt;&amp;gt;+=
        public BloomFilter(int tableSize, int numElements)
        {
            Initialize(tableSize, (int)Math.Round(ln2*numElements/tableSize));
        }
&lt;/PRE&gt;
&lt;LI&gt;In this case, the user knows&amp;nbsp;&lt;EM&gt;n&lt;/EM&gt;, an estimate of how many elements they will insert, and&amp;nbsp;&lt;EM&gt;p&lt;/EM&gt;, the desired false positive probability. Bloom filter theory states that if &lt;EM&gt;k&lt;/EM&gt; is chosen optimally (using the formula in part 1 above), we will have &lt;EM&gt;p&lt;/EM&gt; = &lt;EM&gt;α&lt;/EM&gt;&lt;SUP&gt;&lt;EM&gt;m&lt;/EM&gt;/&lt;EM&gt;n&lt;/EM&gt;&lt;/SUP&gt;, where the constant α = 1/2&lt;SUP&gt;ln 2&lt;/SUP&gt;. This means we must have &lt;EM&gt;m&lt;/EM&gt; = (log&lt;SUB&gt;&lt;EM&gt;α&lt;/EM&gt;&lt;/SUB&gt; &lt;EM&gt;p&lt;/EM&gt;)&lt;EM&gt;n&lt;/EM&gt;. I call &lt;EM&gt;α&lt;/EM&gt; &lt;CODE&gt;optimalBaseRate&lt;/CODE&gt; below: &lt;PRE&gt;&amp;lt;&amp;lt;BloomFilter initialization&amp;gt;&amp;gt;+=
    public BloomFilter(int numElements, double falsePositiveProb)
    {
        int tableSize = (int)Math.Ceiling(numElements * Math.Log(falsePositiveProb, optimalRateBase));
        Initialize(tableSize, (int)Math.Round(ln2 * tableSize / numElements));
    }&lt;/PRE&gt;&lt;/LI&gt;&lt;/OL&gt;
&lt;P&gt;The constants used above are defined at the class level (we cannot use &lt;CODE&gt;const&lt;/CODE&gt; because the &lt;CODE&gt;Math&lt;/CODE&gt; calls are considered non-constant by the compiler):&lt;/P&gt;&lt;PRE&gt;&amp;lt;&amp;lt;BloomFilter constants&amp;gt;&amp;gt;+=
    private readonly double ln2 = Math.Log(2.0);
    private readonly double optimalRateBase = 1.0/Math.Pow(2, Math.Log(2.0));
&lt;/PRE&gt;
&lt;P&gt;We need the &lt;CODE&gt;System&lt;/CODE&gt; namespace for&amp;nbsp;&lt;CODE&gt;Math&lt;/CODE&gt;:&lt;/P&gt;&lt;PRE&gt;&amp;lt;&amp;lt;BloomFilter using statements&amp;gt;&amp;gt;+=
using System;&lt;/PRE&gt;
&lt;P&gt;Finally, we put it all together to complete the implementation of &lt;CODE&gt;BloomFilter&lt;/CODE&gt;:&lt;/P&gt;&lt;PRE&gt;&amp;lt;&amp;lt;BloomFilter implementation&amp;gt;&amp;gt;=
&amp;lt;&amp;lt;BloomFilter constants&amp;gt;&amp;gt;
&amp;lt;&amp;lt;BloomFilter initialization&amp;gt;&amp;gt;
&amp;lt;&amp;lt;BloomFilter member variables&amp;gt;&amp;gt;
&amp;lt;&amp;lt;BloomFilter Insert method&amp;gt;&amp;gt;
&amp;lt;&amp;lt;BloomFilter Contains method&amp;gt;&amp;gt;
&lt;/PRE&gt;
&lt;P&gt;We structure the program as two source files, with the interface in its own file, and both entities in the &lt;CODE&gt;BloomFilters&lt;/CODE&gt; namespace:&lt;/P&gt;&lt;PRE&gt;&amp;lt;&amp;lt;BloomFilter.cs&amp;gt;&amp;gt;=
&amp;lt;&amp;lt;BloomFilter using statements&amp;gt;&amp;gt;
namespace BloomFilters {
&amp;lt;&amp;lt;BloomFilter class definition&amp;gt;&amp;gt;
}

&amp;lt;&amp;lt;IDoubleHashable.cs&amp;gt;&amp;gt;=
namespace BloomFilters {
&amp;lt;&amp;lt;IDoubleHashable definition&amp;gt;&amp;gt;
}&lt;/PRE&gt;
&lt;P&gt;Our implementation is now complete. My full version of this code includes double-hashable classes for integers and strings and a test driver, which I omit here for space. With a bit of added syntax, I could run this entire entry through the literate programming tool &lt;A href="http://www.eecs.harvard.edu/~nr/noweb/"&gt;noweb&lt;/A&gt;, and it would produce both an HTML document much like the one you're reading now, along with two C# source files which I can then build into an assembly and use.&lt;/P&gt;
&lt;H2&gt;More information&lt;/H2&gt;
&lt;P&gt;For a longer, fancier example of literate programming, take a look at &lt;A href="http://moonflare.com/code/select/index.php"&gt;my Select implementation&lt;/A&gt;, which uses the literate programming tool &lt;A href="http://www.eecs.harvard.edu/~nr/noweb/"&gt;noweb&lt;/A&gt; to write an implementation of the classical worst-case linear time selection algorithm using C++ and the document&amp;nbsp;language LaTeX. Here we gain the additional advantage of a full-fledged document language, complete with the ability to typeset mathematical expressions and diagrams, which is impossible in ordinary source code.&lt;/P&gt;
&lt;P&gt;Sometimes schemes such as Perl's pod, Javadocs, or C#'s XML comments are touted as being literate programming, but this is far from the case. These are simply isolated documentation of individual logical program units. While they are valuable and have little overhead, they do not &lt;EM&gt;present&lt;/EM&gt; the program; they only document parts of it in an isolated way.&lt;/P&gt;
&lt;P&gt;So when should you use literate programming? Certainly there is an overhead involved, but in any case where the ability to maintain a portion of a program is a critical factor, or where there is a high risk of an owner disappearing, or where code will be exposed to many external partners or customers, literate programming is a valuable tool for keeping the code accessible and easy to understand. Try rewriting a single confusing or troublesome portion of your program with it, update your build system to run the literate programming tools prior to compilation, and see if it makes a difference with your application.&lt;/P&gt;&lt;/SUP&gt;&lt;/EM&gt;&lt;/EM&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=516431" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/devdev/archive/tags/Software+engineering/default.aspx">Software engineering</category></item><item><title>Custom building and code generators in Visual Studio 2005</title><link>http://blogs.msdn.com/devdev/archive/2005/09/13/465034.aspx</link><pubDate>Tue, 13 Sep 2005 23:15:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:465034</guid><dc:creator>dcoetzee</dc:creator><slash:comments>11</slash:comments><comments>http://blogs.msdn.com/devdev/comments/465034.aspx</comments><wfw:commentRss>http://blogs.msdn.com/devdev/commentrss.aspx?PostID=465034</wfw:commentRss><description>&lt;P&gt;I'm a fervent fan of using code generator tools wherever possible to make your life easier. Although they come with issues related to effective building, diagnostics, and debugging, the amount of value they add to your application is immense: they can eliminate entire classes of potential bugs, save you a great deal of effort and time, make your module much easier to extend and maintain, and even yield runtime performance gains. Among the most frequently used code generator tools are the lexer and parser generators GNU &lt;A href="http://www.gnu.org/software/flex/"&gt;Flex&lt;/A&gt; and &lt;A href="http://www.gnu.org/software/bison/bison.html"&gt;Bison&lt;/A&gt;, based on the classic generators lex and yacc. Although I'll get into the details of how to use these tools effectively at a later time, today what I want to show you is a practical example of how to use the new custom build features of Visual Studio 2005 to effectively incorporate a code generator into your automatic build process.&lt;/P&gt;
&lt;P&gt;Here is a very simple Bison grammar for evaluating arithmetic expressions involving addition, subtraction, and multiplication:&lt;/P&gt;&lt;PRE&gt;/* example.y */
%{
#define YYSTYPE int
%}
%token PLUS MINUS STAR LPAREN RPAREN NUMBER NEWLINE
%left PLUS MINUS
%left STAR

%%
line : /* empty */
     | line expr NEWLINE      { printf("%d\n", $2); }
expr : LPAREN expr RPAREN     { $$ = $2; }
     | expr PLUS expr         { $$ = $1 + $3; }
     | expr MINUS expr        { $$ = $1 - $3; }
     | expr STAR expr         { $$ = $1 * $3; }
     | NUMBER                 { $$ = $1; }
     ;

%%

int yyerror (char const *msg) {
    printf("Error: %s\n", msg);
}

int main() {
    printf("%d\n", yyparse());
    return 0;
}&lt;/PRE&gt;
&lt;P&gt;The Flex lexer used by this parser looks like this:&lt;/P&gt;&lt;PRE&gt;/* example.lex */
%{
#include "example.parser.h"
%}
%option noyywrap

%%

[ \t]+    { /* ignore whitespace */ }
"("       { return LPAREN; }
")"       { return RPAREN; }
"+"       { return PLUS; }
"-"       { return MINUS; }
"*"       { return STAR; }
\n        { return NEWLINE; }
[0-9]+    { yylval = atoi(yytext); return NUMBER; }
.         { printf("Invalid character '%s'", yytext); }

%%&lt;/PRE&gt;
&lt;P&gt;If we were writing this parser at a UNIX command line, we might generate the source files and compile the result using this sequence of commands:&lt;/P&gt;&lt;PRE&gt;bison -v -d example.y -o example.parser.c
flex -oexample.lexer.c example.lex
gcc -o example example.lexer.c example.parser.c&lt;/PRE&gt;
&lt;P&gt;Now say you wanted to build the same application for Windows using Visual Studio 2005. The tools are available on Windows (see &lt;A href="http://gnuwin32.sourceforge.net/packages/flex.htm"&gt;flex for Win32&lt;/A&gt;, &lt;A href="http://gnuwin32.sourceforge.net/packages/bison.htm"&gt;bison for Win32&lt;/A&gt;), and you could simply run the same first two commands at the command-line and then build the resulting source files&amp;nbsp;in Visual Studio. However, this simple approach sacrifices many of the advantages that Visual Studio provides for its built-in source file types: it doesn't rebuild the generated source files as needed,&amp;nbsp;it doesn't allow you to jump to errors that occur during generation, and it doesn't allow you to configure build options using a nice GUI. Let's see how we can reclaim these advantages for Flex and Bison files.&lt;/P&gt;
&lt;H2&gt;Creating a simple custom build type&lt;/H2&gt;
&lt;P&gt;Our first goal is simply to be able to build Flex and Bison files. First, use the Flex and Bison setup binaries from the links above to install the tools. A bin directory will be created in the installation directory. Add this to your system path. You should be able to execute both flex and bison from a command prompt without specifying a path.&lt;/P&gt;
&lt;P&gt;Next, we create a new C++ console application. Uncheck the option to use precompiled headers - I'll explain how to use these with Flex and Bison later. Remove the main source file created for you by the wizard. Next, right-click the project in Solution Explorer and choose Custom Build Rules. The following dialog appears:&lt;/P&gt;&lt;IMG src="http://moonflare.com/blogfiles/devdev/CustomBuildRules.1.PNG"&gt; 
&lt;P&gt;A &lt;EM&gt;build rule &lt;/EM&gt;establishes how to build a file of a particular type. A&amp;nbsp;group of related build rules are stored in a &lt;EM&gt;build rule file&lt;/EM&gt;, which can be saved, distributed, and reused in many projects. We'll start by creating a new build rule file for our Flex and Bison rules:&lt;/P&gt;
&lt;OL&gt;
&lt;LI&gt;Click New Rule File. 
&lt;LI&gt;Enter "GNU Tools" for Display Name and File Name. 
&lt;LI&gt;Choose a suitable directory for the build rule file. If it asks you if you want to add the directory to your search path, say yes.&lt;/LI&gt;&lt;/OL&gt;
&lt;P&gt;Now we'll create a build rule for Bison files:&lt;/P&gt;
&lt;OL&gt;
&lt;LI&gt;Click Add Build Rule. 
&lt;LI&gt;Enter the following values: 
&lt;OL&gt;
&lt;LI&gt;Name: Bison 
&lt;LI&gt;File Extensions: *.y 
&lt;LI&gt;Outputs: $(InputName).parser.c;$(InputName).parser.h 
&lt;LI&gt;Command Line: bison -d [inputs] -o $(InputName).parser.c 
&lt;LI&gt;Execution Description: Generating parser...&lt;/LI&gt;&lt;/OL&gt;
&lt;LI&gt;Click OK twice, then check the box labelled&amp;nbsp;"GNU Tools" and click OK. 
&lt;LI&gt;Add the &lt;EM&gt;example.y&lt;/EM&gt; file above to your project. Right-click on the file and choose &lt;EM&gt;Compile&lt;/EM&gt;. You should receive no errors. 
&lt;LI&gt;Create a new file folder under the project called "Generated Files". Add the existing file &lt;EM&gt;example.parser.c&lt;/EM&gt; to this folder.&lt;/LI&gt;&lt;/OL&gt;&lt;IMG src="http://moonflare.com/blogfiles/devdev/CustomBuildRules.2.PNG"&gt; 
&lt;P&gt;If you build now, you should receive only an error complaining that yylex() is undefined. Now, go back to Custom Build Tools and click Modify Rule File on GNU Tools. Create a rule for Flex:&lt;/P&gt;
&lt;OL&gt;
&lt;LI&gt;Click Add Build Rule. 
&lt;LI&gt;Enter the following values: 
&lt;OL&gt;
&lt;LI&gt;Name: Flex 
&lt;LI&gt;File Extensions: *.lex 
&lt;LI&gt;Outputs: $(InputName).lexer.c 
&lt;LI&gt;Command Line: flex&amp;nbsp;-o$(InputName).lexer.c [inputs] 
&lt;LI&gt;Execution Description: Generating lexer...&lt;/LI&gt;&lt;/OL&gt;
&lt;LI&gt;Click OK three times. 
&lt;LI&gt;Add the &lt;EM&gt;example.lex&lt;/EM&gt; file above to your project. Right-click on the file and choose &lt;EM&gt;Compile&lt;/EM&gt;. You should receive no errors. 
&lt;LI&gt;Add the existing file &lt;EM&gt;example.lexer.c&lt;/EM&gt; to your project.&lt;/LI&gt;&lt;/OL&gt;
&lt;P&gt;If you build now, you should receive no errors and be able to run the application successfully. Now in any project you can simply check the "GNU Tools" box, add the .lex and .y files to your project, and build. What happens if you modify the example.y and build? It runs Bison again and recompiles example.parser.c, because it was regenerated, and example.lexer.c, because it includes a header file that was regenerated. If we modify the .lex file, Flex is rerun and example.lexer.c is recompiled, but example.parser.c is not rebuilt. If you had a larger parser, you'd appreciate how much time this incremental rebuilding saves you.&lt;/P&gt;
&lt;H2&gt;Improving diagnostic support&lt;/H2&gt;
&lt;P&gt;Delete one of the "%%" marks in the .y file and build. Unsurprisingly, Bison fails. However, the Error List tells you no more than this. It'd be more helpful if you could find out what errors the tool produced. If you look at the output window, Bison did produce some errors, but if you double click on them to visit the error location, it just takes you to the top of the file. What gives?&lt;/P&gt;
&lt;P&gt;The reason for this is that Visual Studio only recognizes one error format, that used by its own tools. Here's an example:&lt;/P&gt;&lt;PRE&gt;c:\myprojects\myproject\hello.cpp(10) : error C2065: 'i' : undeclared identifier&lt;/PRE&gt;
&lt;P&gt;Bison doesn't output errors in this format, and so they aren't parsed. Flex uses yet another different format. What to do? The simplest way to deal with this is to invoke a simple script on the output of the tools as part of the build rule which parses the output and converts it to the desired format. You can write this script in any language; I wrote&amp;nbsp;them in C# using the .NET Framework's regular expressions. Here's what I wrote inside the Main() function for the Bison converter tool (error checking and such omitted):&lt;/P&gt;&lt;PRE&gt;string line;
while ((line = Console.In.ReadLine()) != null)
{
    Match match = Regex.Match(line, "([^:]+):([0-9]+)\\.[^:]*: (.*)");
    if (match != null)
    {
        Console.WriteLine("{0}({1}): error BISON: {2}",
                          Path.GetFullPath(match.Groups[1].Value),
                          match.Groups[2].Value, match.Groups[3].Value);
    }
    else
    {
        Console.WriteLine(line);
    }
}&lt;/PRE&gt;
&lt;P&gt;I deploy the binary, say it's called BisonErrorFilter.exe,&amp;nbsp;to the same directory as bison.exe. I then change the Command Line of the Bison build rule to the following&amp;nbsp;(click the arrow in the right of the field to access a multiline text box):&lt;/P&gt;&lt;PRE&gt;bison.exe -d [inputs] -o $(InputName).parser.c &amp;gt; bison.err 2&amp;gt;&amp;amp;1
BisonErrorFilter &amp;lt; bison.err&lt;/PRE&gt;
&lt;P&gt;If you compile the .y file now, any errors should appear in the error list, as desired, and you can double-click them to visit their locations. I wrote a similar script for the lexer output. Be careful when doing this, though, because if you miss any errors, Visual Studio might look at the error return of the last command and interpret it as success. A better way to do this would be to wrap the tool in a script that passes its arguments to the tool, collects the tool's output and return code, converts and prints the output, and then returns its return code.&lt;/P&gt;
&lt;P&gt;I haven't figured out how, but I believe it's possible to also create custom help entries for each error message, then have the filter tool produce the right error code for each one. This way, users can get help for each error individually by just clicking on it and pressing F1.&lt;/P&gt;
&lt;H2&gt;Properties&lt;/H2&gt;
&lt;P&gt;Properties enable you to control how the command-line tool is executed directly from the properties page for each individual file you wish to build with it. Let's start with a simple example: a handy lexer switch is -d, which prints out an informative message each time a token is recognized. We don't want it on all the time, and certainly not in release mode, but it'd be handy to be able to turn on and off as necessary.&lt;/P&gt;
&lt;P&gt;To create a property for this, first return to the lexer build rule. Then follow these steps:&lt;/P&gt;
&lt;OL&gt;
&lt;LI&gt;Click Add Property. 
&lt;LI&gt;Choose Boolean for the User Property Type. 
&lt;LI&gt;Enter the following values: 
&lt;OL&gt;
&lt;LI&gt;Name: debug 
&lt;LI&gt;Display Name: Print debug traces 
&lt;LI&gt;Switch: -d 
&lt;LI&gt;Description: Displays an informative&amp;nbsp;message each time a token is recognized.&lt;/LI&gt;&lt;/OL&gt;
&lt;LI&gt;Click OK. Then, add [debug] right after "flex" in the Command Line field. 
&lt;LI&gt;Click OK three times. 
&lt;LI&gt;Right-click on example.lex in Solution Explorer and choose Properties. 
&lt;LI&gt;In the left pane, click the plus next to &lt;EM&gt;Flex&lt;/EM&gt;. Click General. 
&lt;LI&gt;You'll see your property. Click on it and its description will appear at the bottom. Set it to Yes. 
&lt;LI&gt;Click Command Line in the left pane. You'll see that the -d flag has been added. 
&lt;LI&gt;Click OK and build. 
&lt;LI&gt;Run the app and type an arithmetic expression. You'll see trace messages. 
&lt;LI&gt;View the project properties. You'll see that it now has a Flex node also. Here you can set the default settings for all files of that type in the project which don't have specific overriding settings set.&lt;/LI&gt;&lt;/OL&gt;&lt;IMG src="http://moonflare.com/blogfiles/devdev/CustomBuildRules.3.PNG"&gt; 
&lt;P&gt;Adding more properties is just as simple. You can go through the man page for the tool and add properties for each switch, using the Category field to group them into categories. You can use the other property types for switches accepting arguments. If you want, you can create a detailed help file with additional explanation and examples for each switch. When you're done you have an impressive looking property sheet for your files reminiscent of those for built-in types:&lt;/P&gt;&lt;IMG src="http://moonflare.com/blogfiles/devdev/CustomBuildRules.4.PNG"&gt; 
&lt;P&gt;You can also set different settings for debug and release builds. For example, for Flex, it's good to set table size to slowest and smallest for the Debug version, to speed up compilation, and to set it to the recommended full tables with equivalence classes for the Release version, which is a good tradeoff of table size and speed.&lt;/P&gt;
&lt;P&gt;Finally, once you're done adding all the properties you like, you can take the resulting .rules files and give it to everyone on your team, or distribute it on a website, so that everyone can easily integrate the tool into Visual Studio. Perhaps eventually tools like Flex and Bison will ship with a .rules file.&lt;/P&gt;
&lt;H2&gt;Conclusion&lt;/H2&gt;
&lt;P&gt;In Visual Studio 2003 you would have had to write a plug-in to come close to achieving this level of integration with a third-party tool. Although it has limitations, I hope the problems solved by these new features help encourage you to incorporate more tools and code generation into your regular development. Now that you know how to use Flex and Bison from the Visual Studio IDE, next time I'll talk about how to use the tools themselves, going through some of the development and debugging processes that a grammar developer goes through, and show you some similar tools for other .NET languages. Thanks for reading, everyone.&lt;/P&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=465034" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/devdev/archive/tags/Software+engineering/default.aspx">Software engineering</category></item><item><title>The Visitor pattern and multiple dispatch</title><link>http://blogs.msdn.com/devdev/archive/2005/08/29/457798.aspx</link><pubDate>Tue, 30 Aug 2005 04:27:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:457798</guid><dc:creator>dcoetzee</dc:creator><slash:comments>14</slash:comments><comments>http://blogs.msdn.com/devdev/comments/457798.aspx</comments><wfw:commentRss>http://blogs.msdn.com/devdev/commentrss.aspx?PostID=457798</wfw:commentRss><description>&lt;P&gt;Today I'll talk about multiple dispatch, a programming language feature that increases flexibility of method calls and eliminates the need for awkward pattern constructions, at the cost of some additional complexity in the dispatch algorithm.&lt;/P&gt;
&lt;H3&gt;The Visitor pattern&lt;/H3&gt;
&lt;P&gt;Those who have read the Gang of Four's seminal &lt;EM&gt;&lt;A href="http://www.amazon.com/exec/obidos/tg/detail/-/0201633612/"&gt;Design Patterns&lt;/A&gt;&lt;/EM&gt; may recall the &lt;A href="http://www.google.com/search?&amp;amp;q=%22visitor+pattern%22"&gt;Visitor pattern&lt;/A&gt;. Its purpose is to provide new operations on a class or set of related classes without actually altering the classes involved. &lt;EM&gt;Design Patterns&lt;/EM&gt; provides a real-world example in the document-view paradigm, but for simplicity I'll provide a simpler example here based on some &lt;A href="http://www.cs.rice.edu/~cork/book/node62.html"&gt;notes by Corky Cartwright&lt;/A&gt;.&lt;/P&gt;
&lt;P&gt;Say you wish to represent an arithmetic expression using integers and addition such as (1&amp;nbsp;+&amp;nbsp;5)&amp;nbsp;+&amp;nbsp;2. In an object-oriented language, a natural way to do this is to create an abstract base class "Expression", and then create some related subclasses:&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;ConstantExpression: Represents a constant number, like 2. 
&lt;LI&gt;SumExpression: Represents the result of adding&amp;nbsp;two Expression objects.&lt;/LI&gt;&lt;/UL&gt;
&lt;P&gt;The objects form a tree, where the leaves are ConstantExpression objects. To evaluate an expression represented in such a form, it suffices to create a virtual Evaluate() method which each subclass implements appropriately:&lt;/P&gt;&lt;PRE&gt;abstract class Expression {
    public abstract int Evaluate();
}

class ConstantExpression : Expression {
    int constant;
    public override int Evaluate() {
        return constant;
    }
}

class SumExpression : Expression {
    Expression left, right;
    public override int Evaluate() {
        return left.Evaluate() + right.Evaluate();
    }
}
&lt;/PRE&gt;
&lt;P&gt;This may solve the problem&amp;nbsp;if all you want to do is evaluate expressions, but there are all sorts of operations you can do on arithmetic expressions. Do we really want to add a virtual method for every one of them? We certainly don't want clients of the class to be forced to extend the classes just to add application-specific operations. The Visitor pattern solves this problem by replacing the Evaluate() method with an Accept() method that takes as a parameter a visitor object. The visitor object has a method for each type of expression, and Accept() invokes the appropriate one. Here's how we would evaluate expressions using the Visitor pattern:&lt;/P&gt;&lt;PRE&gt;abstract class Expression {
    public abstract object Accept(Visitor v);
}

class ConstantExpression : Expression {
    public int constant;
    public override object Accept(Visitor v) {
        return v.VisitConstant(this);
    }
}

class SumExpression : Expression {
    public Expression left, right;
    public override object Accept(Visitor v) {
        return v.VisitSum(this);
    }
}

interface Visitor {
    object VisitConstant(ConstantExpression e);
    object VisitSum(SumExpression e);
}

class EvaluateVisitor : Visitor {
    public object VisitConstant(ConstantExpression e) {
        return e.constant;
    }
    public object VisitSum(SumExpression e) {
        return (int)e.left.Accept(this) + (int)e.right.Accept(this);
    }
}&lt;/PRE&gt;
&lt;P&gt;We evaluate an expression &lt;CODE&gt;e&lt;/CODE&gt; using &lt;CODE&gt;(int)e.Accept(new EvaluateVisitor())&lt;/CODE&gt;, and adding new operations is easy; we just create new implementors of Visitor. Clients can create application-specific algorithms without touching the original classes. As an added benefit, the visitor class can keep state internal to the algorithm; for example, this visitor counts and stores the number of constants in an expression:&lt;/P&gt;&lt;PRE&gt;class CountConstantsVisitor : Visitor {
    public int Count;
    public object VisitConstant(ConstantExpression e) {
        Count++;
        return null;
    }
    public object VisitSum(SumExpression e) {
        e.left.Accept(this);
        e.right.Accept(this);
        return null;
    }
}
&lt;/PRE&gt;
&lt;P&gt;But the wary designer will note that there is a maintainance problem here: if we add a new subclass of Expression, like ProductExpression, the Visitor interface and all classes implementing it have to be updated. If the Expression class rarely changes, this is fine, and may even be good: it forces the visitor classes to consider the new cases. If it's rapidly changing, however, we definitely have a problem.&lt;/P&gt;
&lt;H3&gt;Double dispatch&lt;/H3&gt;
&lt;P&gt;At this point we take a slight detour and consider another simple example. &lt;EM&gt;Polymorphism &lt;/EM&gt;is the critical ability of an object-oriented method call to invoke different methods at runtime based on the type of the object, like Evaluate() in our first example. If you've ever dealt with operator overloading in C++ or C#, though, you may come up against the limits of polymorphism. If I write an &lt;CODE&gt;operator+&lt;/CODE&gt; for a class Complex for complex numbers, subclasses can override it in a polymorphic way - but only if the complex number is on the &lt;I&gt;left&lt;/I&gt;. If the Complex object is on the right-hand side, there is no way to ensure the correct method is invoked polymorphically short of testing the type and invoking it yourself.&lt;/P&gt;
&lt;P&gt;How cruel we are to the unprivileged right-hand sides! The built-in C operator + produces different types depending on both the type of its left and right argument; both a double plus a float and a float plus a double produce doubles. We want something similar for our own operators, the ability to polymorphically choose a method based on both the type of its left argument and its right argument. Then we could write code like this:&lt;/P&gt;&lt;PRE&gt;Complex operator+(Complex c, int i) { ... }
Complex operator+(ComplexSubclass c, int i) { ... }
Complex operator+(int i, Complex c) { ... }
Complex operator+(int i, ComplexSubclass c) { ... }
&lt;/PRE&gt;
&lt;P&gt;The right method will be chosen at runtime based on the types of both sides; the most specific (most derived) type is always chosen. This is called &lt;EM&gt;double dispatch&lt;/EM&gt;, because we select the method ("dispatch" the message) based on the type of two arguments.&lt;/P&gt;
&lt;P&gt;Unfortunately, this new flexibility also introduces some new problems. Suppose we have these two methods:&lt;/P&gt;&lt;PRE&gt;Complex operator+(ComplexSubclass s, Complex c) { ... }
Complex operator+(Complex c, ComplexSubclass s) { ... }
&lt;/PRE&gt;
&lt;P&gt;Now, suppose we try to add two objects of type &lt;CODE&gt;ComplexSubclass&lt;/CODE&gt;. Neither of the above looks more appropriate than the other. There are various ways of dealing with this; for example, we can give the first argument precedence over the others, we can throw an error at runtime, or we can make the compiler require us to implement a method taking two &lt;CODE&gt;ComplexSubclass&lt;/CODE&gt; objects. For this article, we'll sidestep the issue by saying we won't write any code that will invoke this dilemma.&lt;/P&gt;
&lt;P&gt;Now, I'm sure you're wondering what any of this has to do with the Visitor pattern. The answer is that this feature allows us to drastically simplify our Visitor pattern example while retaining all of its benefits:&lt;/P&gt;&lt;PRE&gt;abstract class Expression { }

class ConstantExpression : Expression {
    public int constant;
}

class SumExpression : Expression {
    public Expression left, right;
}

class EvaluateVisitor {
    public int Visit(ConstantExpression e) {
        return e.constant;
    }
    public int Visit(SumExpression e) {
        return Visit(e.left) + Visit(e.right);
    }
}
&lt;/PRE&gt;
&lt;P&gt;Now, this isn't valid C# of course, since C# doesn't support double dispatch, but you can see the effect it would have if it did: the Visitor interface is gone, the Accept() method is gone, and the calls in the last Visit() method are simplified. Best of all, it solves our dilemma of a rapidly changing Expression class hierarchy, because we can add a "default case" method that deals with any expression types we're not familiar with: &lt;PRE&gt;    public int Visit(Expression e) {
        throw new Exception("Unsupported type of expression"); // or whatever
    }
&lt;/PRE&gt;
&lt;P&gt;One handy trick you can do in Java and .NET languages is to have a method that examines the type of its argument and then uses reflection to pass it on to the correct overload, simulating polymorphism. This is much slower than native double dispatch support, but achieves much of the same effect.&lt;/P&gt;
&lt;P&gt;If you've studied how polymorphic methods are dispatched, you're probably most familiar with the "vptr" and "vtable" model, where each object includes a reference to a type descriptor, which in turn contains a table of function pointers giving the right function to invoke for each method for an object of that type. With double dispatch this becomes trickier. One of the simplest strategies, and an effective one in practice, is to have the initial vtable dispatch the method to a "stub" method, whose job is to perform another vtable dispatch on the second argument. Because most methods don't require double dispatch, this avoids imposing a penalty on ordinary single dispatch methods.&lt;/P&gt;
&lt;H3&gt;Multiple dispatch&lt;/H3&gt;
&lt;P&gt;But why stop at two arguments? Why not choose the method based on &lt;I&gt;all&lt;/I&gt; the arguments? Although increasingly less useful, there are legitimate applications of methods that dispatch on 3, 4, or more arguments. This form of dispatch, called &lt;EM&gt;multiple dispatch&lt;/EM&gt;,&amp;nbsp;is directly supported by languages such as &lt;A href="http://gauss.gwydiondylan.org/"&gt;Dylan&lt;/A&gt;, &lt;A href="http://www.cs.washington.edu/research/projects/cecil/"&gt;Cecil&lt;/A&gt;, and &lt;A href="http://www.apl.jhu.edu/~hall/AI-Programming/CLOS.html"&gt;CLOS&lt;/A&gt; (the Common Lisp Object System).&amp;nbsp;Not only does this feature ease design of an initial&amp;nbsp;system, but&amp;nbsp;it also greatly increase the ability to extend it in multiple directions in an object-oriented way. Try experimenting with some of them and going through their tutorials; even in languages that don't directly support multiple dispatch, it helps to be able to recognise a situation where it would apply and simulate it. 
&lt;P&gt;Thanks for reading, everyone.&lt;/P&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=457798" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/devdev/archive/tags/Software+engineering/default.aspx">Software engineering</category><category domain="http://blogs.msdn.com/devdev/archive/tags/Programming+languages/default.aspx">Programming languages</category></item><item><title>Stop writing header files</title><link>http://blogs.msdn.com/devdev/archive/2005/08/19/453891.aspx</link><pubDate>Sat, 20 Aug 2005 02:05:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:453891</guid><dc:creator>dcoetzee</dc:creator><slash:comments>5</slash:comments><comments>http://blogs.msdn.com/devdev/comments/453891.aspx</comments><wfw:commentRss>http://blogs.msdn.com/devdev/commentrss.aspx?PostID=453891</wfw:commentRss><description>&lt;P&gt;Although one of my favorite languages, C++ has a number of issues that make it difficult to write and maintain. One of the worst is its compilation model: you import declarations using fragile literal text inclusion (&lt;CODE&gt;#include&lt;/CODE&gt;), and you have to waste your time keeping these declarations&amp;nbsp;redundantly in sync with the source files.&amp;nbsp;Templated function definitions require even more redundancy. The same information is really in both places - this violates &lt;EM&gt;&lt;A href="http://www.amazon.com/exec/obidos/tg/detail/-/020161622X/"&gt;The Pragmatic Programmer&lt;/A&gt;&lt;/EM&gt;'s oft-repeated tip&amp;nbsp;11, DRY (&lt;EM&gt;Don't Repeat Yourself&lt;/EM&gt;).&lt;/P&gt;
&lt;P&gt;Worse yet, the line between what goes in the header file and source file looks like it was drawn by a drunkard. You have an inline function? Put it in the header file. You want to make it not inline anymore? Put it in the source file. You want to template it? Back in the header file it goes. In C there are additional issues, since a function definition that is out of sync with its prototype results not in a compile-time error but an implicit declaration and a mysterious link error.&lt;/P&gt;
&lt;P&gt;So what's the solution? The best solution is to simply &lt;STRONG&gt;stop writing header files&lt;/STRONG&gt;. Instead, write the source file, mark the nonredundant information that needs to go into the header, and then use a&amp;nbsp;build tool to generate your header based on this information prior to compilation. The header can never be out of sync, you can make changes more quickly, you drop the number of lines of code you have to actively maintain, and everybody is happier.&lt;/P&gt;
&lt;P&gt;Of course, that sounds like a lot of work - especially the part that involves writing a tool that has to parse a nontrivial subset of C++. Luckily, some fellow victims out there have already produced tools that do this. The best one I've come across so far is &lt;A href="http://www.lazycplusplus.com/"&gt;Lzz: The Lazy C++ Programmer's Tool&lt;/A&gt;, a tool that allows you to lay out function definitions in C++ code in much the same way as Java or C# (within the class), and then it produces both the header and source files. Here's a sample:&lt;/P&gt;&lt;PRE&gt;&lt;FONT size=4&gt;&lt;FONT size=2&gt;class A {
  public:
    inline void f (int i) {
        if (i &amp;lt;= 0)
            g();
        else
            g(i);
    }

  private:
    void g (int j = 0) {
        if (j &amp;gt; 0)
            g(j - 1);
    }
};&lt;/FONT&gt;
&lt;/FONT&gt;&lt;/PRE&gt;
&lt;P&gt;The function &lt;CODE&gt;f&lt;/CODE&gt; ends up in the header file and &lt;CODE&gt;g&lt;/CODE&gt; in the source file. If I remove the "inline" keyword, however, &lt;CODE&gt;f&lt;/CODE&gt; gets moved to the source file. Don't have to worry about it.&lt;/P&gt;
&lt;P&gt;Lzz&amp;nbsp;has some limitations though, so make sure you read the documentation.&amp;nbsp; It also includes a couple interesting extensions called Lazy classes and Lazy functors that I won't get into here. Try it out and see if you're willing to kiss your header files goodbye.&lt;/P&gt;
&lt;P&gt;Derrick Coetzee&lt;BR&gt;&lt;I&gt;&lt;FONT size=2&gt;This posting is provided "AS IS" with no warranties, and confers no rights.&lt;/FONT&gt;&lt;/I&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face=Arial size=2&gt;P.S. For those of you waiting on the Bloom filter code, I've got something written and I'm just waiting for approval from the powers that be. Hang in there.&lt;/FONT&gt;&lt;/P&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=453891" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/devdev/archive/tags/Software+engineering/default.aspx">Software engineering</category><category domain="http://blogs.msdn.com/devdev/archive/tags/Programming+languages/default.aspx">Programming languages</category></item></channel></rss>