From C# going to c++

O

OD

Our friend choice was between unmanaged/managed environments. You're
speaking about java/c# choice, two managed environment. It's clear
differences are not so big in this case.
But meanwhile, you're saying "I prefer .net", so as you're not silly,
you're thinking .net is "best than" java.
Hard to "prefer" without saying "it's best"...
 
H

herr

I read on the internet that only %4 of Windows vista is written in .Net . Is
this really how MS makes use of its own technology, or should we be happy
because there is something like Paint.Net out there?!

IMHO Paint.Net is a nice demonstration of what we can do with .net, but
again, in terms of overall performance, it can't beat PhotoShop or
CorelDraw.
 
C

Carl Daniel [VC++ MVP]

herr said:
I read on the internet that only %4 of Windows vista is written in
.Net . Is this really how MS makes use of its own technology, or
should we be happy because there is something like Paint.Net out
there?!

Keep in mind - Vista is 90% (or more ) the same as XP. Surely no one would
expect that Vista was written from scratch.

On the performance side though, I have to agree with most of the respondents
here: Performance is a result of good design, not micro-optimization. My
company produces a desktop app that's a very specialized text editor. It's
written entirely in C# (2.0) and has performance that rivals Notepad (which
is written in C to the win32 API). Our editor kicks the pants off of the
Visual Studio editor performance wise - and that editor is written in native
C++.

If you're having performance problems, learn the nature of the problems and
look for solutions to those problems. Simply jumping head first into an
entirely different programming environment is unlikely to solve the problems
for you.

-cd
 
G

Guest

I "prefer" both, depending on the requirements of the project. For one
project we need to interface with CORBA objects, so java is prefered. For
one project, we are required to interface with relational databases, so
csharp is preferred.
 
M

MikeJ

heck we have programmers at my office that has programmed for years, when i
was hired i saw how slow there services were....after going through the
code...i find
things like the below
most of there looping looks like this

while true
if (somevalue=somevalue)
{
obj=new business1();
obj.method1();
}
elseif (somevalue=somvalue)
{
obj = new business1();
obj.Method2();
}
} // end while
notice the same object being created each loop
instead of being created once outside the loop
the exec the methods
go through 30000 iterations and thats 30000 new instances
of the same object instead of 1.

there excuse was it works..
funny how lots of people think
MJ
 
P

Peter Duniho

heck we have programmers at my office that has programmed for years,
when i
was hired i saw how slow there services were....

True enough. Time spent programming is no guarantee of quality. A person
can do the same thing wrong for years without ever figuring it out.
[...]
notice the same object being created each loop
instead of being created once outside the loop
the exec the methods
go through 30000 iterations and thats 30000 new instances
of the same object instead of 1.

Of course, it begs the question: what sort of design requires that you
instantiate an object just to call a single method? I can think of
exceptions to the rule, but generally speaking that's the sort of thing
that is better handled by static methods, or in some cases a singleton
class.

That said, my understanding is that instantiating objects over and over in
..NET isn't really all that expensive, relatively speaking. In that loop
you posted, even if you move the instantiation of that one object out of
the loop, there's no reason to believe that calling the methods doesn't
also instantiate new objects as well. So you save one instantiation of
what could be several or even dozens.

Also, I gather that the framework has optimized for this case, caching the
memory blocks needed for objects that are reused frequently. Of course,
that doesn't help with the actual initialization, but objects should
generally be designed so that initialization isn't expensive, and again
those methods could be instantiating plenty of new objects each time as
well.

I agree that the code could be cleaner, but there seem to be greater
things wrong with the design there than where the object gets
instantiated, and there _is_ something to be said for not worrying too
much about performance until there's a proveably slow area of code.

Pete
 
M

MikeJ

I agree...ive since re wrote all that code...and
its like 100 times faster...and in this case
there static now

MJ

Peter Duniho said:
heck we have programmers at my office that has programmed for years,
when i
was hired i saw how slow there services were....

True enough. Time spent programming is no guarantee of quality. A person
can do the same thing wrong for years without ever figuring it out.
[...]
notice the same object being created each loop
instead of being created once outside the loop
the exec the methods
go through 30000 iterations and thats 30000 new instances
of the same object instead of 1.

Of course, it begs the question: what sort of design requires that you
instantiate an object just to call a single method? I can think of
exceptions to the rule, but generally speaking that's the sort of thing
that is better handled by static methods, or in some cases a singleton
class.

That said, my understanding is that instantiating objects over and over in
.NET isn't really all that expensive, relatively speaking. In that loop
you posted, even if you move the instantiation of that one object out of
the loop, there's no reason to believe that calling the methods doesn't
also instantiate new objects as well. So you save one instantiation of
what could be several or even dozens.

Also, I gather that the framework has optimized for this case, caching the
memory blocks needed for objects that are reused frequently. Of course,
that doesn't help with the actual initialization, but objects should
generally be designed so that initialization isn't expensive, and again
those methods could be instantiating plenty of new objects each time as
well.

I agree that the code could be cleaner, but there seem to be greater
things wrong with the design there than where the object gets
instantiated, and there _is_ something to be said for not worrying too
much about performance until there's a proveably slow area of code.

Pete
 
G

Guest

ModelBuilder said:
I "prefer" both, depending on the requirements of the project. For one
project we need to interface with CORBA objects, so java is prefered. For
one project, we are required to interface with relational databases, so
csharp is preferred.

It may surprise you, but Java actually do have support for
relational databases.

Arne
 
?

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

herr said:
I read on the internet that only %4 of Windows vista is written in .Net . Is
this really how MS makes use of its own technology, or should we be happy
because there is something like Paint.Net out there?!

IMHO Paint.Net is a nice demonstration of what we can do with .net, but
again, in terms of overall performance, it can't beat PhotoShop or
CorelDraw.

I don't think MS has official mentioned the numbers, but let
us assume:
XP - 40 MLOC
Vista - 50 MLOC

1) It would require a lot of money (even for MS) to port 40 MLOC
from C++ to .NET.

2) Vista for obvious reasons still have to support Win32 API. It is
much easier to have .NET code call Win32 code than the other way
around.

3) Some of the low level stuff is not suited for managed code.

Arne

PS: I thought Paint.Net was an paint program like PhotoShop in the
same way as WordPad is an editor like Visual Studio ... :)
 
C

Chris Mullins [MVP]

Saying I prefer .Net over Java, doesn't come anywhere close to saying .Net
is better than Java. Especially in the context that post, where I explicitly
said Java & .Net are pretty similar.

I prefer English over Spanish, but that doesn't mean English is the best
language. It just happens to be the one I know very well.

Now, Managed Vs. UnManaged for a user application - that's a no brainer.
 
G

Gaz

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.

Technologies are continuously being made that abstract programmers further
and further away from 'the machine'. Long gone are the days where you could
buy 'Advanced Reference Manuals' detailing all the memory address space,
every OS call and all the hardware interrupts and vectors that you could
handle and intercept yourself etc etc. Writing in assembly language was a
pleasure and the whole machine was yours to program as you wish.

But Microsoft have done their damnest to protect 'their' OS and stop
programmers getting within a barge pole of the kernel, you can't easily do
it any more, there isn't even a single tasking 'CLI' mode. .NET is one of
these high level technologies and comes with a complete online programmers
reference library, everyone uses them and you're forced to move along, but
the original Win32 programmers are not. Why program with added layers of
abstraction, once you have the whole Win32 in your head there's no reason to
move on IMO.
 
G

Guest

Yes, I realize you can use both languages for both requriements. I just
prefer each for the uses that I stated. Probably my java db aversion is a
few years old and needs a revisit though...
 
C

Chris Mullins [MVP]

Gaz said:
Why program with added layers of abstraction, once you have the whole
Win32 in your head there's no reason to move on IMO.

I can't decide if you really mean this, or are being sarcastic. At the risk
of looking foolish, I'll go with "really mean it" for $200.

The reason is that most people can do more in 15 minutes with WinForms and
..Net than they could in several days worth of Win32 programming (or even
Java and a good GUI toolkit, or, heck VB6). .Net has taken all the really
common use cases for development and made them very easy to use.This
evolution has taken place over 10+ years, and is very far along.

There's a reason application like VB (3,4,5,6), Delphi, C++ Builder, and MFC
all did so well - it's because Win32 is a slow and painful environment to
work in. Why anyone would choose to code against a "C" API in this day and
age is a mystery to me.

Creating fancy windows? Adding Skins to an application? Click-Once
Deployment? Adding Menu's and Toolbars? Adding a Office Style Ribbon? MDI?
SDI? Animations? Office Automation? File I/O? Socket I/O? Windows Services?
Database Access? All of these are much easier to code in .Net over Win32.
The difference is so vast between the two, that coding in Win32 is no longer
cost effective.

Yes, there are tasks bests suited to pure Win32, but they're few and far
between and the numbers are shrinking.

Before you ask, yes, I spent years building Win32 applications in C++, and
was (at least at one point) very good at it. I'm also very good at building
apps in .Net, and I can say there's no comparison for any of the major use
cases.
 
H

herr

It is now 6 years after the time .Net first came out.

I still wait, but you know, all major companies, like Sony, canon, Philips,
Nokia and many others still write software for their products in
c++/MFC/win32 , although there are no legacy codes there for many of their
new applications and their only target platforms is mainly Win XP (was not
..net platform free?!)

You think Google would code its Google Earth, Google Talk, Picasa, Google
Desktop and other products in C# if .Net Framework was preinstalled on
Windows XP ?

I am so Cynic on this issue. I don't think any of these big companies will
ever write their commercial products in .net ( except for some small
utilities list "Disk-to-Phone) by SonyEricsson)
 
P

Peter Duniho

It is now 6 years after the time .Net first came out.

I still wait, but you know, all major companies, like Sony, canon,
Philips,
Nokia and many others still write software for their products in
c++/MFC/win32 , although there are no legacy codes there for many of
their
new applications and their only target platforms is mainly Win XP (was
not
.net platform free?!)

What makes you think there is no legacy code for their applications? For
that matter, what makes you think that none of them are using .NET? I
certainly have seen consumer-electronics support utilities built in .NET.
For that matter, ATI uses .NET for their video adapter control panel now,
and Neverwinter Nights 2 uses .NET for the version of the game design
toolset that comes with that game.

In any case, what in the world do you care whether those companies are
using .NET? As if Sony (for example) is some epitome of good programming
practices. Hah!
You think Google would code its Google Earth, Google Talk, Picasa, Google
Desktop and other products in C# if .Net Framework was preinstalled on
Windows XP ?

Who knows. However, for Google to _not_ use .NET offers absolutely no
insight as to whether .NET is a viable platform or not. It does, however,
say a lot about Google's own internal policies and how they view Microsoft
as a competitor.
I am so Cynic on this issue. I don't think any of these big companies
will
ever write their commercial products in .net ( except for some small
utilities list "Disk-to-Phone) by SonyEricsson)

Again. Who cares? The worth of .NET is not proven or disproven by the
decision of "big companies" to use it or not.

Pete
 
H

herr

Again. Who cares? The worth of .NET is not proven or disproven by the
decision of "big companies" to use it or not.

And who were the main targets of this technology?
 
M

Markus

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

Don't know exactly, but at least MS BizTalk Server is not the smallest
application that is based 100% on .NET (I am not sure, but I think v2002
was still legacy code, for version 2004 they made the big switch...).

Markus
 
B

Bob Johnson

If you are so convinced and cynical (as you describe yourself) that .NET is
NOT the "best" (whatever that means) for you, then why are you posting here.
Why don't you go to whoever you perceive to be experts in C++ and Win32 API
programming and ask THEM for advice?

Please comment.
 

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