From C# going to c++

H

herr

Hi all,

For some reasons, I am moving away from managed c# (after using it for 3
years) and want to code my windows application in native C++ (perfomance
issues mainly). I already have a small knowledge of c++, but don't really
know what to read to learn writing advanced windows applications with it.
Any one can help me on my way to mastering c++ windows software writing?
I need some books, tutorials, online communities or what ever you guys just
know tell me.

Thanks for you help anyway!
 
B

Ben Voigt [C++ MVP]

herr said:
Hi all,

For some reasons, I am moving away from managed c# (after using it for 3
years) and want to code my windows application in native C++ (perfomance
issues mainly). I already have a small knowledge of c++, but don't really

Probably not a good idea to rewrite the whole thing. Use a profiler, find
out what portions of the code have performance problems, and rewrite just
those.
 
?

=?ISO-8859-1?Q?Arne_Vajh=F8j?=

herr said:
For some reasons, I am moving away from managed c# (after using it for 3
years) and want to code my windows application in native C++ (perfomance
issues mainly).

I am very skeptical on whether you will see significant
performance improvements by that change.
I already have a small knowledge of c++, but don't really
know what to read to learn writing advanced windows applications with it.
Any one can help me on my way to mastering c++ windows software writing?
I need some books, tutorials, online communities or what ever you guys just
know tell me.

What GUI library do you want to code against ? Win32 API ? MFC ?
wxWidgets ? Qt ?

Arne
 
H

herr

I am very skeptical on whether you will see significant
performance improvements by that change.

Then why is it that .net is not used by big software companies like Adobe,
Yahoo, Google and even Microsoft (even in Vista) ? I mean in Desktop
applications.

What GUI library do you want to code against ? Win32 API ? MFC ?
wxWidgets ? Qt ?

I don't know! What is the most used GUI library in the market? The best for
windows XP / Vista platforms.
 
?

=?ISO-8859-1?Q?Arne_Vajh=F8j?=

herr said:
Then why is it that .net is not used by big software companies like Adobe,
Yahoo, Google and even Microsoft (even in Vista) ? I mean in Desktop
applications.

I was not aware that Google and Yahoo made desktop apps.

I am very sure that more and more of MS desktop apps will be
coded using .NET (and Adobe also unless they have cross platform
requirements that prevent them from doing so).

The reason they are not already has probably more to do with the cost
of rewriting millions and millions of lines of code than for
performance reasons.
I don't know! What is the most used GUI library in the market? The best for
windows XP / Vista platforms.

There are a lot MFC code out there.

But I would consider .NET and WPF a much more future proof
route than MFC.

Arne
 
P

Peter Duniho

Then why is it that .net is not used by big software companies like
Adobe,
Yahoo, Google and even Microsoft (even in Vista) ? I mean in Desktop
applications.

For a variety of reasons, none of which have anything to do with
performance.

Also, I doubt it's true that the companies you mentioned don't use .NET in
any of their applications. For sure, it's not true for Microsoft, though
as is also the case for Adobe, the major desktop applications (e.g.
Microsoft Office programs) aren't going to be in .NET because .NET wasn't
around when the bulk of the code for those applications was written.
I don't know! What is the most used GUI library in the market? The best
for
windows XP / Vista platforms.

..NET is IMHO the best GUI library to use on Windows.

If you're not going to use .NET, then you might as well learn the native
Win32 API and stick with that.

Personally, I think the business of "performance issues mainly" is
invalid. Only certain specialized applications would have "performance
issues", and even in those cases that's no reason to abandon .NET
altogether. It _is_ a reason to identify the elements of the application
that are not performing well and do something about it.

But most of your performance problems will turn out to be algorithm design
errors, rather than something inherently slow about .NET, and for the tiny
fraction of things that really are a limitation of .NET, you can implement
those in some other language in a separate module and then call that from
your .NET code. That will allow you to take full advantage of the
services .NET offers without sacrificing performance.

You should, of course, feel free to redevelop your code however you like.
If you want to stop using .NET, that's your perogative. But if you
believe that you will see significant performance gains doing so, I
suspect you are in for some disappointment.

Pete
 
B

Ben Rush

"Any one can help me on my way to mastering c++ windows software writing?"

Start fixing your problem by identifying exactly what is poor in your C#
application and fixing it one by one. If you have to ask how to write
advanced windows applications in C++ you're not going to get the performance
gain you expect out of doing something in C++; an application can suck no
matter what language you write it in.

--
~~~~~~~~~~~~~~~~~~~~~~~~~~
Ben Rush
Microsoft .NET Consultant
http://www.ben-rush.net/blog
http://www.sideshowsystems.com
 
O

OD

Like some others in this thread I'm not sure you will see a big
difference about performances..

I recently wrote a complete test between C# and Delphi 2006, a kind of
benchmark.
Each code does exactly the same thing, one built on BDS 2006, the other
on VS 2005. Each code has been written to respect each language (no
unfair trick to give advantage to one language).
Results are that the C# version is about 25 to 40 % faster than the
Delphi 2006 one (depending on the computer, Intel processors giving
best C# results than AMD ones, but always C# faster than Delphi).

Memory management, strings, maths, file IO, I tested what most
applications are supposed to do when they're working.

So, as I'm knowing C++ is very near Delphi on the performance side (I
tested this a couple of years ago), I think switching to C++ will
decrease the overall performances of your application. And you'll lose
all the benefit of the CLR and the object API of the framework. Win32
API is a mess...
 
H

herr

Thanks guys for your valuable help.

I have one other questions. What is the largest application written in .net?
(except for the Framework itself).
 
C

Chris Mullins [MVP]

If you're moving away from .Net, you need to decide what technology you want
to use.

There are several options that come to mind for Windows Forms development:

- You can write a pure C / C++ Win32 application. This is a major pain in
the ass, but is certainly possible. For this, go buy Charles Petzold's book,
"Programming Windows". It's circa 1998 or so - be sure you get the Win32
version, and not the newer C# versions. You'll probably need to end up
buying this book anyway, regardless of which choice you end up making.

- MFC is a good, and very popular choice. There are tons of books out there
on this.

- ATL is probably not the right choice these days - but I don't know the
current status of this technology though, or where it sits in relationship
to MFC.

- You could go with an older Borland product (Delphi or C++ Builder). These
both produce native code - no CLR requried.

- You can use VB6, depending on what you're needing to do.

- There are also a number of libraries out there for C++ you may want to
look at. I've heard good things about qt, although I've never used it.

It's all going to depend on what you're needing to do...
 
I

Ian Semmel

Learning to write C++ native windows apps won't do your career prospects any
harm, as there are zillions of apps out there that will need maintenance and
development for many years to come (COBOL programmers are still in demand).

That said, be prepared for a rather steep learning curve.

If you are going to write windows apps in C++, MFC is really your only
choice in my opinion. MFC is a fairly thin C++ wrapper around the Windows
API (which is 'C').

C# does a lot of things for you that MFC doesn't (like garbage collect) and
you are programming at a lower level.

As far as learning MFC, go through the documentation before you go out and
buy a book. There are lots of examples there.
 
C

Chris Mullins [MVP]

herr said:
Then why is it that .net is not used by big software companies like Adobe,
Yahoo, Google and even Microsoft (even in Vista) ? I mean in Desktop
applications.

I agree with Peter on this one.

There are lots of reasons to not use .Net, but in most cases, performance
isn't one of them. The number of apps in which "performance" is even an
issue are really pretty few and far between these days.

I don't know! What is the most used GUI library in the market? The best
for
windows XP / Vista platforms.

If I were to guess, I would say the most popular, in terms of number of apps
deployed, are (in order):
- Pure Win32
- MFC
- VB6
- .Net Windows Forms
 
G

Guest

The size of an application can be determined many ways. You can write an app
in a handful of lines that declares a huge array, or one with many lines,
that uses little memory. We have a couple of systems that are in the 10K to
50K code line range each that are extensions to a commercial GIS product.
 
C

Chris Mullins [MVP]

herr said:
I have one other questions. What is the largest application written in
.net? (except for the Framework itself).

Your decision to use or not use the .Net framework should NOT be based on
what people in this group tell you.

Figure out the requirements you need from a development platform, the look
at the available platforms. This is how you should make your choice.

For 95% (or more!) of applications today, .Net and/or Java are the right
choice. These two offer a good balance of developer productivity, perfomant
and reliable code, and a large talent pool to choose from for staffing and
maintenance purposes. I personaly perfer .Net over Java, but if anyone
starts telling you one is clearly better than the other, then they're just
being silly.

If you have specialized requirements, you may need a more specialized
development environment. Evaluate your requirements, then choose a platform.
 
?

=?ISO-8859-1?Q?Arne_Vajh=F8j?=

Chris said:
The number of apps in which "performance" is even an
issue are really pretty few and far between these days.

There a lot of apps with performance problems.

But I agree that there are probably few apps where classic
micro optimizing (like the compilers ability to optimize
a certain for loop) is an issue.

Arne
 
C

Chris Mullins [MVP]

Performance problems that I run into today tend to be related to:
- Architectural Flaws
- Alrorithm Flaws

It's almost never due to "C++ executes 1.2% faster than C# or Java".

The problems tend to be:
- "We're making 1500+ PLSQL calls, and we should be making 1".
- "We're calling web services synchronously, and making the user wait."
- "We're using distributed Transactions, and one of the participants is a
State Agency running over a 14.4k modem, and they refuse to upgrade."

It's really much more about design and engineering than actualy
knitty-gritty code tuning ...
 
?

=?ISO-8859-1?Q?Arne_Vajh=F8j?=

Chris said:
Performance problems that I run into today tend to be related to:
- Architectural Flaws
- Alrorithm Flaws

It's almost never due to "C++ executes 1.2% faster than C# or Java".

The problems tend to be:
- "We're making 1500+ PLSQL calls, and we should be making 1".
- "We're calling web services synchronously, and making the user wait."
- "We're using distributed Transactions, and one of the participants is a
State Agency running over a 14.4k modem, and they refuse to upgrade."

It's really much more about design and engineering than actualy
knitty-gritty code tuning ...

Yep.

Arne
 
C

count0

herr said:
Hi all,

For some reasons, I am moving away from managed c# (after using it for 3
years) and want to code my windows application in native C++ (perfomance
issues mainly). I already have a small knowledge of c++, but don't really
know what to read to learn writing advanced windows applications with it.
Any one can help me on my way to mastering c++ windows software writing?
I need some books, tutorials, online communities or what ever you guys just
know tell me.

Beside C# and native C++, there is a third way: C++/CLI, it has the
best of both world. You can use Windows Forms for UI, and native code
for algorithms, and use libraries like boost.
 
R

Rad [Visual C# MVP]

Then why is it that .net is not used by big software companies like Adobe,
Yahoo, Google and even Microsoft (even in Vista) ? I mean in Desktop
applications.

A couple of reasons
1) They have a large library of perfectly functional code that has
been tested for server al years, sometimes decades (like Adobe). There
would be nothing to be gained in doing it from scratch
2) Writing an application in .NET places a requirement for the
customer to have the .NET framework. Forcing a customer to get this
might not be something you want to do, especially if your software is
a small utility
3) Microsoft DO use .NET in their commercial products. Look at
Microsoft CRM or Microsoft SQL Server 2005. Although, truth be told,
SQL Server Management Studio is a *HOWLING DOG*
 
T

Tom Spink

herr said:
Hi all,

For some reasons, I am moving away from managed c# (after using it for 3
years) and want to code my windows application in native C++ (perfomance
issues mainly). I already have a small knowledge of c++, but don't really
know what to read to learn writing advanced windows applications with it.
Any one can help me on my way to mastering c++ windows software writing?
I need some books, tutorials, online communities or what ever you guys
just know tell me.

Thanks for you help anyway!

Hi,

IMHO, if you move to C++, you'll *lose* performance. This is because your
code will become a lot more complex, it'll take longer to write, you'll
discover a LOT more bugs and it will be hard to maintain.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top