Microsoft C# a replacement for old C++ language

M

Mathias Gaunard

DragonSt0rm said:
It is also the C++ paradigm when due to some other restriction you have to
allocate on heal instead of the stack.

Consider for example an embedded (or old DOS) system with a small stacksize,
where you have to allocate a RGBA image of 500x300 pixels. You can't do
that on stack. The "invention" of smartpointers (like auto_ptr) was fueled
exactly because of the fact that this paradigm was widely used.

Yes, strangely enough for Mathias, the new/delete operators preceded the
auto_ptr in the C++ (not C) language history :)

How are smart pointers related to what you're saying?

What you need here is an Image type, which indeed does dynamic
allocation. It is way closer to a container. (and the easiest
implementation is to directly use a std::vector as a member, which
replaces advantageously any usage of new[]).

Smart pointers where invented because of the polymorphism problem,
mainly, and eventually to move around non-copyable types too. That's
totally unrelated.

Anyway, what I was saying is that all resources must always be freed in
destructors. That is RAII, and you should follow it ; it is the main C++
idiom.
If for some obscure reason you don't want to follow it (which is your
right, and is actually safe to do if you're only playing around things
with nothrow guarantee) then don't mark it as a standard idiom or good
practice.

The fact that is modern days, it is thought at the same moment, it is a
mater of evolution of language and of the teaching methods. But it wasn't
always that way. Borland 1.0 didn't knew about templates at all.

Borland 1.0 didn't know about C++. It didn't even follow the ARM.
C++ was defined in 1998 and includes templates.

So, from the historical perspective I was talking about (when Java was
designed) what I presented there IT WAS the standard C++ paradigm.

That's just a C paradigm where you replaced malloc with new.
Just like old C++ was just C with classes.

Java tried to eliminate the "delete problem" by introducting the GC, yet
this generated a whole set of issues related to nonmemory resource
allocation/disposal.

GC isn't just about the "delete problem" as you call it.
Maybe you should consider learning about GC and what its applications
are before trying to criticize it.
 
T

terminator

Howard said:
Yep, I agree that's the "preferred" method in C++, but the statement that
new/delete is a C paradigm is what I was arguing against. It's not even
available in C, so it can't be a C paradigm.

-Howard

this concept exists in C via malloc/free but the C++ terminology is
new/delete with the ability to initialise via ctor.
 
?

=?ISO-8859-15?Q?Juli=E1n?= Albo

Mathias said:
Borland 1.0 didn't know about C++. It didn't even follow the ARM.
C++ was defined in 1998 and includes templates.

The first Borland C compilers were called "Turbo C". If I remember well, the
only products called "Borland Csomething" were "Borland C++", years after
Turbo C 1.0, and after some packages called Turbo C++. Later they sell both
packages called "Turbo C++", and "Borland C++", differing in the number and
variety of tools included in each.
 
D

Diego Martins

Master said:
I heard from a friend that C++ is mainly being replaced as language of
choice for most C++ programmers around the world. I guess this makes
sence as it means that when learning you dont have to **** around
sencelessly with low level garbage like pointers. I was going to learn
C++ but if times are changing I think I will just learn C#, it seems
more modern. I also thought about Java but its WAY too slow. I think
it should be easy to learn as I have heaps of experience making complex
programs using all versions of Visual Basic.

Any comparisons out there?

Thanks
The Grand Master

What the hell is a "Master Programmer" with "heaps of experience making
complex programs in Visual Basic" ?

Just trolling too :)
 
H

Howard

Feel free to write bad, exception unsafe and leaky code.
That's not my problem.

What makes you think I write bad, leaky code? If you're saying that all
code using new and delete is bad and leaky, then you're simply incorrect.
Granted, exception safety is more difficult to ensure with raw pointers, but
not impossible. A competent programmer should be able to use new and delete
correctly. Only an incompetent programmer writes bad, leaky code
(regardless of whether or not raw pointers are used).

-Howard
 
N

Noah Roberts

Howard said:
What makes you think I write bad, leaky code? If you're saying that all
code using new and delete is bad and leaky, then you're simply incorrect.
Granted, exception safety is more difficult to ensure with raw pointers, but
not impossible.

Depends on the guarantee required. There may very well be cases when
using raw pointers makes the strong guarantee unfeasable or impossible
to provide. It can also be pretty difficult to provide even the basic
guarantee when using raw pointers. This is what RAII has been invented
to answer. More often than not people that use raw pointers aren't
even aware of the miriad of possible leaks in their code.
 
H

Howard

Noah Roberts said:
Depends on the guarantee required. There may very well be cases when
using raw pointers makes the strong guarantee unfeasable or impossible
to provide. It can also be pretty difficult to provide even the basic
guarantee when using raw pointers. This is what RAII has been invented
to answer. More often than not people that use raw pointers aren't
even aware of the miriad of possible leaks in their code.

No argument from me. I agree 100% that RAII is the preferred way to go. I
just take exception (excuse the pun) with the opinion that it's "wrong" to
use pointers, or that because there are pointers in my code I must be
writing bad, leaky code.

-Howard
 
Z

Zara

I heard from a friend that C++ is mainly being replaced as language of
choice for most C++ programmers around the world. I guess this makes
sence as it means that when learning you dont have to **** around
sencelessly with low level garbage like pointers. I was going to learn
C++ but if times are changing I think I will just learn C#, it seems
more modern. I also thought about Java but its WAY too slow. I think
it should be easy to learn as I have heaps of experience making complex
programs using all versions of Visual Basic.

Any comparisons out there?

Thanks
The Grand Master


This ng needs a troll from time to time. So peaceful, so long. Now a
troll apperas, and everyone runs to answer. Where is the old "Don't
feed the trolls " warning?

Zara
 
E

Earl Purple

Zara said:
This ng needs a troll from time to time. So peaceful, so long. Now a
troll apperas, and everyone runs to answer. Where is the old "Don't
feed the trolls " warning?

Zara

lol! (that you yourself added to this topic)
 

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

Similar Threads


Members online

Forum statistics

Threads
473,754
Messages
2,569,521
Members
44,995
Latest member
PinupduzSap

Latest Threads

Top