C# vs. C++

A

Arne Vajhøj

Daniel said:
* C# is a virtual machine - a little like java and VB already - at
run-time your program is interpreted by another program called the
CLR.

Try google "JIT compiler".

Arne
 
A

Arne Vajhøj

Nick said:
Curious. I wouldn't see C# as fundamentally better for writing
Object-oriented code. I see the two languages as essentially the same
but C# has removed the need for explicit memory management and a few
other house keeping issues

More access levels, interfaces and delegates seems
to me to be features that makes good OOP easier.

Arne
 
A

Arne Vajhøj

Michael said:
Huh? Our entire telecommunications industry is written in C and C++ and
C++ is still the way to go for embedded systems.

And a lot of other stuff.

Most of the OLE/COM stuff in Windows and Office is C++.

Lots of Windows apps out there are also build using MFC.

And I would not call C++ experimental. It is used in a lot
of production code.

Of course things has progressed since the mid 1980's. Java
learned from and improved from C++. And C# learned from and
improved from Java.

For a typical business application I will absolutely
recommend Java or C# over C++.

But C++ will live on for many years. Because of the bazillions
of lines of code that exist. And because of special requirements
for hardware access or real time characteristics that Java and C#
can not meet.

Arne
 
C

Cholo Lennon

Arne Vajhøj said:
More access levels, interfaces and delegates seems
to me to be features that makes good OOP easier.

Just some clarification: In C++ you have interfaces (abstract classes) and
delegates (std::tr1::function or boost::function)

Regards
 
F

Fernando Gómez

Giovanni said:
I agree with you, RFOG.

Only one point: Linux (the kernel) is built in pure C (not C++).



You're right.

Moreover, I doubt that very big and successfull apps (like Microsoft Office,
or Visual Studio, or even non-Microsoft apps like Photoshop) could be built
using C# (or Java...). Or, if they would be built with C# or some other
"managed" language, what would be the memory occupation and would they be as
snappy as the C++ versions?

He. Try SQL Server 2005 Management Studio. It really sucks.
 
R

RFOG

En 21/06/2008 22:24:33 said:
There are cases (embedded or kernel) where you want very tight control
over the generated code. In which case you will either pick C or
pick C++ and only use a subset of C++ (that likely will look
relative similar to C).

Arne

Yes, I agree with that. But you suppose a world centered in x86 arch...
For one PC there are a zillion of other devices that run other
microprocessors and some C++ compilers (CodeWarrior for ColdFire, one that
I know, for example) are very very agressive optimizing and restructures
code avoiding in most cases vtables and so, making more compact code than
a person can do.

But, of course, in most cases in embedded scenarios developers only uses
C++ as a "better C". It is, for example, very absurd to instantiate a
polimorphic class with ten levels of abstraction into a high precision
timer interrupt and deallocate in each interrupt finishing.

--
Microsoft Visual C++ MVP
========================
Mi blog sobre programación: http://geeks.ms/blogs/rfog
Momentos Leves: http://momentosleves.blogspot.com/
Cosas mías: http://rfog.blogsome.com/
Libros, ciencia ficción y programación
========================================
Debemos vivir y trabajar, en cada momento, como si tuviésemos la eternidad
ante nosotros.
-- Gabriel Marcel.
 
R

Rudy Velthuis

Alvin said:
There's no such thing. That's why they are smart, they handle it for
you.

That doesn't mean they can't use reference counting as a mechanism, and
if they do, they are reference counted.
 
H

Hendrik Schober

MC said:
Peter Duniho said:
C++ is a dying language. [...]

Huh? Our entire telecommunications industry is written in C and C++ and
C++ is still the way to go for embedded systems.


http://www.research.att.com/~bs/applications.html
http://www.lextrait.com/vincent/implementations.html

(And look at the first line on that second link. said:
Right. C++ is no longer taught to computer science students, at least not as one of their fundamental skills -- Java dominates
academia now, and C# is catching on.

I have been teaching C++ to CS students for years. And,
yes, they're taught Java first, because it's considered
easier to learn. But, no, there's no C# at all in their
curriculum.
And I think you'll find that in embedded systems, what is actually written is closer to C than to C++. [...]

Look at the above links.
[...]
Back to the original poster -- One BIG point is that the transition

Visual Basic --> Visual Basic .NET --> C# --> C or C++

is a LOT easier to make than if you do the last steps in the reverse order.

From my experience (see above) I think this, while it
seems "obviously right", is wrong. My students, having
been taught Java first, have a lot of trouble learning
to pay attention to details like memory, passing strings
per (const) reference etc., because they aren't used to
it. Some told me that only after my course they started
to understand many things in Java.
C++ programmers, OTOH, have no problem picking up Java
or C#.

Schobi
 
H

Hendrik Schober

MC said:
[...]
That is a good point. Object-oriented programming wasn't mature when C++ came into use. There is a lot of bad C++ code in the
world, and C++ makes it easy to write bad code and create programs that crash.

I think C will outlive C++. C is going to continue to be a good language for small routines where performance is paramount. For
such things, I find myself writing "C-barely-plus-plus," which is C with slight use of the C++ extensions. [...]


IMO these to paragraphs contradict each other. C makes it a lot
easier to write bad, crashing code, than C++ does.

Schobi
 
A

Alvin Bruney [ASP.NET MVP]

C# can also give you some of that, but C++ is more
flexible and powerful,
Why is it more powerful and more flexible? I thought you could write
'unsafe' code in C#. Doesn't that make it as powerful and as flexible. Or
perhaps unsafe code was removed from C#, if so then I stand corrected.

--

Regards,
Alvin Bruney [MVP ASP.NET]

[Shameless Author plug]
The O.W.C. Black Book, 2nd Edition
Exclusively on www.lulu.com/owc $19.99
 
A

Alvin Bruney [ASP.NET MVP]

Huh? Our entire telecommunications industry is written in C and C++

Sleight of hand. I worked for a few years in the telecommunications
industry. C and C++ happen to be entrenched there because at the time that
was the dominant languages. As these pieces get re-written, rest-assured
they won't be re-written in these languages because there's nothing to gain
using these technologies in telecommunications. I know, I've been there.

--

Regards,
Alvin Bruney [MVP ASP.NET]

[Shameless Author plug]
The O.W.C. Black Book, 2nd Edition
Exclusively on www.lulu.com/owc $19.99
-------------------------------------------------------


Peter Duniho said:
C++ is a dying language. [...]

Huh? Our entire telecommunications industry is written in C and C++ and
C++ is still the way to go for embedded systems.

I think he meant that "C++ is a dying language" in the same way that
FORTRAN and COBOL are "dying languages". Of course, those languages have
been dying for decades and still are in broad use. So C++ could take a
little while to finally kick the bucket too. :)

As far as embedded systems go, I think you will find that just as C++
superceded assembly and hand-written machine code for embedded systems,
so too is C++ likely to be superceded by some other language. For
example, Java is already in widespread use as a platform language for
mobile phones, and it's not unreasonable to expect that inasmuch as
Windows is the OS for some embedded systems, C# and .NET will wind up
being commonly used in embedded systems as well.

Pete
 
D

Daniel Boulerice

Thanks for the reply. I'll check into it.

Rudy Velthuis said:
No, it isn't. At runtime, it is compiled just-in-time and it runs
natively, it is not interpreted. The CLR is not another program either,
it is the main runtime library that comes with .NET, and also runs
natively. AFAIK, most C++ products also have a runtime library. .NET's
CLR is just more extensive.
--
Rudy Velthuis http://rvelthuis.de

"This book fills a much-needed gap."
-- Moses Hadas (1900-1966) in a review
 
H

Hendrik Schober

Daniel James said:
No, if you really /want/ bad, crashing, code you can write it just as
easily in C++ as in C (it might be a bit harder in C#, but you can
still do it).

I wasn't talking about Macchiavelli.
("C++ tries to guard against Murphy, not Machiavelli.")
[...]
Daniel.

Schobi
 
G

Giovanni Dicanio

Andre Kaufmann said:
RFOG said:
En 21/06/2008 06:39:43, MC <[email protected]>
escribió:
[...]

And actually it is impssible to buid an OS in Java or in a .NET languge.

What about Singularity and Cosmos ?

I think that those are *experimental* stuff, not commercial OSes, available
in shops to buy.

The "real" things (Windows, GNU/Linux, Mac OS X OSes) are written in C
and/or C++.

Giovanni
 
R

Rudy Velthuis

Giovanni said:
Andre Kaufmann said:
RFOG said:
En 21/06/2008 06:39:43, MC
[...]

And actually it is impssible to buid an OS in Java or in a .NET
languge.

What about Singularity and Cosmos ?

I think that those are experimental stuff, not commercial OSes,
available in shops to buy.

But it is possible, and it could well be that it is done, also
commercially, one day.
 
A

Arne Vajhøj

Rudy said:
Giovanni said:
Andre Kaufmann said:
RFOG wrote:
En 21/06/2008 06:39:43, MC
[...]

And actually it is impssible to buid an OS in Java or in a .NET
languge.
What about Singularity and Cosmos ?
I think that those are experimental stuff, not commercial OSes,
available in shops to buy.

But it is possible, and it could well be that it is done, also
commercially, one day.

It could. And I am sure it will.

But new mainstream OS's are rather rare. I think the newest
must be Linux from 1991.

It may take some time before the next one shows up.

Arne
 
A

Arne Vajhøj

Hendrik said:
MC said:
[...]
That is a good point. Object-oriented programming wasn't mature when C++ came into use. There is a lot of bad C++ code in the
world, and C++ makes it easy to write bad code and create programs that crash.

I think C will outlive C++. C is going to continue to be a good language for small routines where performance is paramount. For
such things, I find myself writing "C-barely-plus-plus," which is C with slight use of the C++ extensions. [...]


IMO these to paragraphs contradict each other. C makes it a lot
easier to write bad, crashing code, than C++ does.

Since C++ support practically all of C then ...

Arne
 
A

Arne Vajhøj

Cholo said:
Just some clarification: In C++ you have interfaces (abstract classes) and
delegates (std::tr1::function or boost::function)

C# also has abstract classes and even though abstract classes can
be used instead of interfaces, then interfaces especially when
combined with the only inherit from one class but implement
multiple interfaces rules really guide users towards good
OOP style.

TR1 is fine, but strictly speaking it is not C++ yet (it may
be in 2009 rumors say).

Arne
 

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