Fog Creek Software
Discussion Board




Welcome! and rules

Joel on Software

.NET programs slowness

Hello.

First of all I would like to state that this is not a troll or an attempt to generate lots of useless discussions. I'd also like to tell you that English is not my native language, so please bear with a few minor language problems.

I am an experienced Delphi and C++ developer. Because Delphi jobs are in short supply, I decided to make the jump to C# and .NET.

The C# programming language is wonderful, and in my humble opinion it is "Java done right".

When Sun made Java, they removed way too many features from C++, so Java feels (to me) like a very small car - it gets you there, but you have to struggle to fit in a small space.

C# is the language where the right ballance has been reached - cut enough from C++ so it is a lot harder to make mistakes, but leave enough so it is easy to program.

A few days ago I have started to develop an application in C#. Nothing fancy - just a few forms with controls on them, a moderate ammount of code :-), etc.

Before this I had developed a C# grid control, and also did a lot of tests (played with WinForms, etc).

My app worked very slowly - it was almost unacceptably slow.

I checked the code for things which could degrade performance. There was none.

Then I rewrote in Delphi. The app is now snappy and fast - A LOT FASTER than the C# version.

I'm very upset about this. C# is the right language, but the run-time performance is simply disappointing.

George Nicolescu
Monday, April 14, 2003

>A few days ago I have started to develop an application in C#. Nothing fancy - just a few forms with controls on them, a moderate ammount of code :-), etc.

Ok, what does this 'moderate amount of code' do?

>Then I rewrote in Delphi. The app is now snappy and fast - A LOT FASTER than the C# version.

As you said, you're an experienced Delphi developer, you picked up C#/.NET Framework how long ago?

This isn't a flame - please describe what your code does (or post it somewhere) so we can help you if possible.  And .NET is (or may be) going to be somewhat slower than native code in many cases.

GiorgioG
Monday, April 14, 2003

In everything I've written, .NET is indistinguishable from C++ in speed. Without knowing the specifics of what was slow, and what exactly the code was doing, it's hard to tell why something was slow. There are clearly ways even in native C++ that you can make painfully slow Win32 GUIs, so it's not necessarily the language you choose.

Brad (dotnetguy.techieswithcats.com)
Monday, April 14, 2003

Run your code through Compuware DevPartner Profiler:
http://www.compuware.com/products/devpartner/profiler/

or nprof: http://nprof.sourceforge.net/

Duncan Smart
Tuesday, April 15, 2003

Thank you for your interesting replies.

The C# program's interface was really slow.

After writing the program in C#, I rewrote it in Delphi almost 1:1 - that is, I simply translated the code to Delphi without making algorithm changes.

I have got an impressive speed boost.

I think that this speaks for itself.

If my algorithm had been at fault, then the Delphi program (the Delphi translation of the C# program) should have been slow, too.

It is not the first time I notice slowness in a C# program - I also developed a grid control in C#, and it was slow (I can estimate when something is slow because of the algorithm or because of the library and inefficient compilation).

George Nicolescu
Tuesday, April 15, 2003

The interface was slow? What kind of interface were you using? There are definitely ways you can get "slow paint syndrome" in Win32, and it's true for Windows Forms as well. What happens if you forego the UI, and instead write a very small amount of information to the console instead?

Brad Wilson (dotnetguy.techieswithcats.com)
Tuesday, April 15, 2003

That is an excellent suggestion, and I'll try it out when I'll have the time.

George Nicolescu
Wednesday, April 16, 2003

Get VS.NET 2003. You'll definately see a speed boost.

Pierre
Wednesday, April 16, 2003

Also make sure to test it when built with the "Release" configuration chosen.

Debug information seriously slows it down.  My guess is that debug info in .NET (or any interpreted/bytecoded environment) is giong to be even more of a perf hit than in native code.

Richard Ponton
Wednesday, April 16, 2003

I have tried building the release version. The diference in speed is minimal - I can certainly notice it, but it's not very significant.

George Nicolescu
Thursday, April 17, 2003

A .NET app will definitely use more memory than a Delphi app.  If your machine is running close to the memory limit, then this would push the .NET app into using Virtual Memory, which will noticeably slow things down.  Just a possibility.

Delphi is a much more mature RAD tool and has always been very good about generating snappy UIs (barring stupid programmer mistakes).  I love Delphi.  I worked for Borland for a year doing tech support for Delphi.  But I also work with .NET now and I know it's no slouch either.  If your app is horribly slow with .NET, there's something wrong.

Richard Ponton
Friday, April 18, 2003

"...then this would push the .NET app into using Virtual Memory"

(Going off topic and pedantic :-) ) -- *All* are programs *always* using Virtual Memory. You should have said: "push the OS into using the Pagefile"

Duncan Smart
Saturday, April 26, 2003

*  Recent Topics

*  Fog Creek Home