Fog Creek Software
Discussion Board

Welcome! and rules

Joel on Software

C# vs Perl text processing performance

I've been comparing C# with Perl for a high volume intensive text processing application: take a list of phrases, and for each one exclude noise words, stem individual words back to root forms, and write all combinations of words from each phrase (sorted alphabetically) to a text file. This is textbook Perl stuff, but to my surprise I found that the C# version of my code ran about 20% faster than the Perl version. They do essentially the same thing, and generate identical output files.

Has anyone else found similar suprises where C# can outperform Perl on it's home turf?

Mark B
Friday, April 30, 2004

I'm not at all surprised by this.  PERL is insanely dynamic language and C# is reality static.  PERL is interpreted.  C# is compiled at runtime (from byte-codes to native code).  C# has proper string handling unlike it's cousins C and C++ to which PERL's text processoring is often favourably compared with.

Almost Anonymous
Friday, April 30, 2004

I dunno, I think this is actually an endorsement for Perl.

Li-fan Chen
Friday, April 30, 2004

> C# has proper string handling unlike it's cousins C and C++

What's wrong with C++'s std::string?

Michael Eisenberg
Tuesday, May 4, 2004

Whoa.  Which perl were you using?

perl on cygwin is going to be slower because it's going through several layers of emulation.  And if you're doing File IO, the UNIX->Windows->NTFS layers are gonna add up really quicklky against anything running under cygwin.

at least test with perl on SFU or perl on linux on the same machine.

Richard P
Wednesday, June 2, 2004

*  Recent Topics

*  Fog Creek Home