473,786 Members | 2,607 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

What I don't like about C# so far, compared to C++ (managed or otherwise)

First in an occasional series.

I'm somewhat experienced in C++, and am using .NET Visual Studio 2005
as the IDE. I'm learning C#.

What I don't like about C#, compared to C++ (all flavors):

1/ no pointers or tracking pointers or handles--this is absurd. I
realise references are by and large like tracking pointers effectively
(does anybody know of any differences--other than pointer arithmetic,
which you cannot do anymore in managed C++ anyway, I don't see any big
differences so far), but why not leave pointers in? When porting code
it's a pain to have to convert to references.

2/ no read-only "const" modifier for objects; just for data members
(public const int wheel = 4 // is OK in C#). See below*** How to you
avoid accidentally changing an object passed to a function--unless
you're very careful with your coding?

3/ static classes not supported. A minor gripe but still

4/ Sparse to non-existant library. For example, no linked list (you
have to roll your own). I was pleasantly surprised that a dynamically
sized array exists in C#--whoo hoo!--progress.

5/ Iterrators are kind of primitive ("for each * in"); though today I
learned IEnumerable is supported in C#--more progress.

6/ No copy constructor, though with managed C++ that's pretty much
gone away.

7/ stupid "in-line" class definitions. Ridiculous. .h and .cpp files
work fine and are logical--why get rid of them?

8/ C# programmers seem more junior than C++ programmers (not that I'm
a code guru, but that seems to be true).

9/ stuff like ADO.NET only supported on C#.

10/ multiple class inheritances and interfaces not supported. Not
that I really am a big fan of multiple inherietance or interfaces
anyway, since I usually nest classes or use composite classes unless I
cannot avoid using inheritance, like with dynamic runtime binding of
objects, so it's a minor gripe for me, but others I'm sure are
bothered by it.

I'll think of more later. It seems C# is like Java or J++ but with
"smart pointers" (garbage collection).

RL

*** 2/ no "const" modifier for objects; just for data members (public
const int wheel = 4).

http://www.msnewsgroups.net/group/mi...opic29393.aspx

Hyun-jik Bae
Is there any way to prohibit writing values to an object A retrieved
from
another object B if B gives A for read only purpose?

For example,

public class B
{
public int xx;
}

public class A
{
public B aa=new B();
public B a
{
get
{
return aa;
}
}
}

class Program
{
static void Main(string[] args)
{
A q = new A();
int w=q.a.xx;
q.a.xx = 3; // STATEMENT X
}
}

where I want STATEMENT X be prohibited.

Please reply. Thanks in advance.
Hyun-jik Bae

11 Sep 2006 6:40 PMJon Skeet [C# MVP]
Hyun-jik Bae <im***********@ paran.comwrote:
Is there any way to prohibit writing values to an object A retrieved from
another object B if B gives A for read only purpose?

Unfortunately not. (I disagree with Nick on this front - I think
there
are plenty of times when it would be useful to return something in a
read-only way.)

C++ has the idea of "const-correctness" and it's been put forward
many
times both for .NET and Java. The main difficulties as I understand
them are:

1) Making the syntax simple but expressive. For instance, if I return
an array of Foo, you might want to declare that the receiver can't
change the contents of the array, or can't change the Foo instances
referred to by the array, or both. We've seen how generics can make
for
some pretty long type declarations - const correctness would do the
same kind of thing.

2) Unless it's supported by the standard libraries, it's not nearly
as
much use - and making the standard libraries const-correct in
retrospect would quite possibly break a lot of things.

Now admittedly, your example code isn't ideal: B.xx would usually be
exposed as a property instead of a public field, and the property
could
be read-only, but I assume in real life other uses of B would need it
to be writable.

Jul 31 '07 #1
25 2093
raylopez99 wrote:
First in an occasional series.
And the last, I hope. IMHO, that sort of rant has no place here,
especially given the subjective nature of many of your complaints. It's
just trolling.
Jul 31 '07 #2
Ray,

You really should have a look at Intel assembler, that goes much more in
your direction than C#, you can do with that everything you cannot do with
C++.

Cor

"raylopez99 " <ra********@yah oo.comschreef in bericht
news:11******** **************@ 22g2000hsm.goog legroups.com...
First in an occasional series.

I'm somewhat experienced in C++, and am using .NET Visual Studio 2005
as the IDE. I'm learning C#.

What I don't like about C#, compared to C++ (all flavors):

1/ no pointers or tracking pointers or handles--this is absurd. I
realise references are by and large like tracking pointers effectively
(does anybody know of any differences--other than pointer arithmetic,
which you cannot do anymore in managed C++ anyway, I don't see any big
differences so far), but why not leave pointers in? When porting code
it's a pain to have to convert to references.

2/ no read-only "const" modifier for objects; just for data members
(public const int wheel = 4 // is OK in C#). See below*** How to you
avoid accidentally changing an object passed to a function--unless
you're very careful with your coding?

3/ static classes not supported. A minor gripe but still

4/ Sparse to non-existant library. For example, no linked list (you
have to roll your own). I was pleasantly surprised that a dynamically
sized array exists in C#--whoo hoo!--progress.

5/ Iterrators are kind of primitive ("for each * in"); though today I
learned IEnumerable is supported in C#--more progress.

6/ No copy constructor, though with managed C++ that's pretty much
gone away.

7/ stupid "in-line" class definitions. Ridiculous. .h and .cpp files
work fine and are logical--why get rid of them?

8/ C# programmers seem more junior than C++ programmers (not that I'm
a code guru, but that seems to be true).

9/ stuff like ADO.NET only supported on C#.

10/ multiple class inheritances and interfaces not supported. Not
that I really am a big fan of multiple inherietance or interfaces
anyway, since I usually nest classes or use composite classes unless I
cannot avoid using inheritance, like with dynamic runtime binding of
objects, so it's a minor gripe for me, but others I'm sure are
bothered by it.

I'll think of more later. It seems C# is like Java or J++ but with
"smart pointers" (garbage collection).

RL

*** 2/ no "const" modifier for objects; just for data members (public
const int wheel = 4).

http://www.msnewsgroups.net/group/mi...opic29393.aspx

Hyun-jik Bae
Is there any way to prohibit writing values to an object A retrieved
from
another object B if B gives A for read only purpose?

For example,

public class B
{
public int xx;
}

public class A
{
public B aa=new B();
public B a
{
get
{
return aa;
}
}
}

class Program
{
static void Main(string[] args)
{
A q = new A();
int w=q.a.xx;
q.a.xx = 3; // STATEMENT X
}
}

where I want STATEMENT X be prohibited.

Please reply. Thanks in advance.
Hyun-jik Bae

11 Sep 2006 6:40 PMJon Skeet [C# MVP]
Hyun-jik Bae <im***********@ paran.comwrote:
>Is there any way to prohibit writing values to an object A retrieved from
another object B if B gives A for read only purpose?


Unfortunately not. (I disagree with Nick on this front - I think
there
are plenty of times when it would be useful to return something in a
read-only way.)

C++ has the idea of "const-correctness" and it's been put forward
many
times both for .NET and Java. The main difficulties as I understand
them are:

1) Making the syntax simple but expressive. For instance, if I return
an array of Foo, you might want to declare that the receiver can't
change the contents of the array, or can't change the Foo instances
referred to by the array, or both. We've seen how generics can make
for
some pretty long type declarations - const correctness would do the
same kind of thing.

2) Unless it's supported by the standard libraries, it's not nearly
as
much use - and making the standard libraries const-correct in
retrospect would quite possibly break a lot of things.

Now admittedly, your example code isn't ideal: B.xx would usually be
exposed as a property instead of a public field, and the property
could
be read-only, but I assume in real life other uses of B would need it
to be writable.
Jul 31 '07 #3
>8/ C# programmers seem more junior than C++ programmers (not that I'm
>a code guru, but that seems to be true).

Not my experience, and also not really a statement about the language.
That is true IMO (with no slight intended against C#) but it follows
naturally for two reasons:

1) C++ is a much more demanding language (read harder to learn and easier to
screw things up). It therefore forces programmers to think about what
they're doing more so than in C#. This will generally create programmers
whose heads are better wrapped around programming issues than those who work
in simpler languages. Unfortunately, the majority of C++ programmers are
marginal at best (a euphemism for other adjectives).

2) For obvious reasons, C++ programmers will normally have much better
OS/WinAPI experience than other programmers. Their mechanical understanding
of the OS gives them a huge edge over other programmers. In this area, a
grizzled C# programmer will simply not be in the same league as his C++
counterpart. Even on a supposedly neutral platform like .NET, the reality is
that you can and often do make better decisions based on sound knowledge of
the OS and WinAPI.
Aug 1 '07 #4
On Aug 1, 6:36 am, raylopez99 <raylope...@yah oo.comwrote:
First in an occasional series.

I'm somewhat experienced in C++, and am using .NET Visual Studio 2005
as the IDE. I'm learning C#.

What I don't like about C#, compared to C++ (all flavors):

1/ no pointers or tracking pointers or handles--this is absurd. I
realise references are by and large like tracking pointers effectively
(does anybody know of any differences--other than pointer arithmetic,
which you cannot do anymore in managed C++ anyway, I don't see any big
differences so far), but why not leave pointers in? When porting code
it's a pain to have to convert to references.

2/ no read-only "const" modifier for objects; just for data members
(public const int wheel = 4 // is OK in C#). See below*** How to you
avoid accidentally changing an object passed to a function--unless
you're very careful with your coding?

3/ static classes not supported. A minor gripe but still

4/ Sparse to non-existant library. For example, no linked list (you
have to roll your own). I was pleasantly surprised that a dynamically
sized array exists in C#--whoo hoo!--progress.

5/ Iterrators are kind of primitive ("for each * in"); though today I
learned IEnumerable is supported in C#--more progress.

6/ No copy constructor, though with managed C++ that's pretty much
gone away.

7/ stupid "in-line" class definitions. Ridiculous. .h and .cpp files
work fine and are logical--why get rid of them?

8/ C# programmers seem more junior than C++ programmers (not that I'm
a code guru, but that seems to be true).

9/ stuff like ADO.NET only supported on C#.

10/ multiple class inheritances and interfaces not supported. Not
that I really am a big fan of multiple inherietance or interfaces
anyway, since I usually nest classes or use composite classes unless I
cannot avoid using inheritance, like with dynamic runtime binding of
objects, so it's a minor gripe for me, but others I'm sure are
bothered by it.

I'll think of more later. It seems C# is like Java or J++ but with
"smart pointers" (garbage collection).

RL

*** 2/ no "const" modifier for objects; just for data members (public
const int wheel = 4).

http://www.msnewsgroups.net/group/mi...et.languages.c...

Hyun-jik Bae

Is there any way to prohibit writing values to an object A retrieved
from
another object B if B gives A for read only purpose?

For example,

public class B
{
public int xx;
}

public class A
{
public B aa=new B();
public B a
{
get
{
return aa;
}
}
}

class Program
{
static void Main(string[] args)
{
A q = new A();
int w=q.a.xx;
q.a.xx = 3; // STATEMENT X
}
}

where I want STATEMENT X be prohibited.

Please reply. Thanks in advance.
Hyun-jik Bae

11 Sep 2006 6:40 PMJon Skeet [C# MVP]

Hyun-jik Bae <imays_NOSP...@ paran.comwrote:
Is there any way to prohibit writing values to an object A retrieved from
another object B if B gives A for read only purpose?

Unfortunately not. (I disagree with Nick on this front - I think
there
are plenty of times when it would be useful to return something in a
read-only way.)

C++ has the idea of "const-correctness" and it's been put forward
many
times both for .NET and Java. The main difficulties as I understand
them are:

1) Making the syntax simple but expressive. For instance, if I return
an array of Foo, you might want to declare that the receiver can't
change the contents of the array, or can't change the Foo instances
referred to by the array, or both. We've seen how generics can make
for
some pretty long type declarations - const correctness would do the
same kind of thing.

2) Unless it's supported by the standard libraries, it's not nearly
as
much use - and making the standard libraries const-correct in
retrospect would quite possibly break a lot of things.

Now admittedly, your example code isn't ideal: B.xx would usually be
exposed as a property instead of a public field, and the property
could
be read-only, but I assume in real life other uses of B would need it
to be writable.
I think you'd better learn more about C# before you make some
conclusions about the language

Aug 1 '07 #5
Larry,
>
2) For obvious reasons, C++ programmers will normally have much better
OS/WinAPI experience than other programmers. Their mechanical
understanding of the OS gives them a huge edge over other programmers. In
this area, a grizzled C# programmer will simply not be in the same league
as his C++ counterpart. Even on a supposedly neutral platform like .NET,
the reality is that you can and often do make better decisions based on
sound knowledge of the OS and WinAPI.
In my idea is one of the reasons for Net to get rid of all those demanding
current Dos API's.

To say it simple, they are wrapped now in Net classes, which makes it
possible to do more than only the conversation with the API.

Cor

Aug 1 '07 #6
>2) For obvious reasons, C++ programmers will normally have much better
>OS/WinAPI experience than other programmers. Their mechanical
understandin g of the OS gives them a huge edge over other programmers. In
this area, a grizzled C# programmer will simply not be in the same league
as his C++ counterpart. Even on a supposedly neutral platform like .NET,
the reality is that you can and often do make better decisions based on
sound knowledge of the OS and WinAPI.

In my idea is one of the reasons for Net to get rid of all those demanding
current Dos API's.

To say it simple, they are wrapped now in Net classes, which makes it
possible to do more than only the conversation with the API.
I agree in theory but .NET isn't a replacement for the WinAPI. It's really
just a large class library wrapping much of the underlying OS functionality.
The transition to .NET is therefore much easier if you already have solid
WinAPI experience. A simple example: If you work with forms and threads then
it's very helpful if you already understand Windows message loops (and have
done raw WinAPI threading using functions like PostMessage()") . Your
conceptual understanding of functions like "Control.Invoke ()" will therefore
be much better than someone who doesn't have any WinAPI experience at all.
Aug 1 '07 #7
On 1 Aug, 12:36, "Larry Smith" <no_spam@_nospa m.comwrote:
2) For obvious reasons, C++ programmers will normally have much better
OS/WinAPI experience than other programmers. Their mechanical
understanding of the OS gives them a huge edge over other programmers. In
this area, a grizzled C# programmer will simply not be in the same league
as his C++ counterpart. Even on a supposedly neutral platform like .NET,
the reality is that you can and often do make better decisions based on
sound knowledge of the OS and WinAPI.
In my idea is one of the reasons for Net to get rid of all those demanding
current Dos API's.
To say it simple, they are wrapped now in Net classes, which makes it
possible to do more than only the conversation with the API.

I agree in theory but .NET isn't a replacement for the WinAPI. It's really
just a large class library wrapping much of the underlying OS functionality.
The transition to .NET is therefore much easier if you already have solid
WinAPI experience. A simple example: If you work with forms and threads then
it's very helpful if you already understand Windows message loops (and have
done raw WinAPI threading using functions like PostMessage()") . Your
conceptual understanding of functions like "Control.Invoke ()" will therefore
be much better than someone who doesn't have any WinAPI experience at all.
I think it's interesting that you think that. I don't strictly
disagree, and with the amount of P/invoke questions in this forum
alone this is probably a valid point. But given the points the OP
tried to make at the beginning I think we can see other areas that
mean a C++ programmer is not necessarily going to make a totally clean
transition. "Where are my pointers!!! Waaa!!!" being an example of a
fundamental conflict in mind sets.

I could make the point that a good VB6 developer will already be
pointer free, will be quite comfortable with p/invoke as he's probably
been doing it since day 2, well the VB style Declare Function
equivilent and would be more open to differences and learning because
the two languages are so different.

Ultimately, as long as the developer is capable I don't care what
their background is.

Aug 1 '07 #8
I think it's interesting that you think that. I don't strictly
disagree, and with the amount of P/invoke questions in this forum
alone this is probably a valid point. But given the points the OP
tried to make at the beginning I think we can see other areas that
mean a C++ programmer is not necessarily going to make a totally clean
transition. "Where are my pointers!!! Waaa!!!" being an example of a
fundamental conflict in mind sets.
Seasoned C++ professionals won't cry over the lack of pointers. They might
(rightfully) point out weaknesses such as a lack of "const"
references/functions, no covariant return types (though MSFT has hinted it
might remedy this), etc., but a real professional will try to put his biases
aside. There are certainly things that C++ could learn from C# as well IMO.
Nevertheless, C++ programmers will move to C# much easier than anyone else.
This is based on my own experience and those of many others I've talked to.
It just makes sense given that C# is already syntactically very close to C++
(obviously its progenitor). Combine that with the (vastly) superior
knowledge of Windows itself and C++ programmers have a significant advantage
over all other programmers.
I could make the point that a good VB6 developer will already be
pointer free, will be quite comfortable with p/invoke as he's probably
been doing it since day 2,
Absolutely not. A VB programmer's exposure to the WinAPI is almost
non-existent. The WinAPI is in C itself so C/C++ programmers are in the best
position to deal with P/Invoke issues.
Ultimately, as long as the developer is capable I don't care what
their background is.
While many C++ programmers are arrogant about the skills of VB developers
(frequently malicious in fact), it is generally true that VB programmers are
weaker than C++ programmers (in my long experience). While you and others
might disagree with this, IMO you'll improve your odds of finding a more
skilled and talented programmer in the C++ pool (certainly much more
knowledgeable about Windows itself)
Aug 1 '07 #9
Agreed. Raised the signal to noise ratio, didn't contribute miuch content
other than more "me me".
--
Recursion: see Recursion
site: http://www.eggheadcafe.com
unBlog: http://petesbloggerama.blogspot.com
bogMetaFinder: http://www.blogmetafinder.com

"Peter Duniho" wrote:
raylopez99 wrote:
First in an occasional series.

And the last, I hope. IMHO, that sort of rant has no place here,
especially given the subjective nature of many of your complaints. It's
just trolling.
Aug 1 '07 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
1521
by: Jerry | last post by:
Hi people: I'm experiencing the following problem and don't know what it is about. Any help greatly appreciated: My script retrieves the data from a remote file using the file() function. However, when I run the script it returns the following error (or warning): "Warning: file("http://........") - Message too long in
220
19164
by: Brandon J. Van Every | last post by:
What's better about Ruby than Python? I'm sure there's something. What is it? This is not a troll. I'm language shopping and I want people's answers. I don't know beans about Ruby or have any preconceived ideas about it. I have noticed, however, that every programmer I talk to who's aware of Python is also talking about Ruby. So it seems that Ruby has the potential to compete with and displace Python. I'm curious on what basis it...
9
2517
by: ForHimself Every Man | last post by:
What's better about Rattlesnakes than Python. I'm sure there's something. What is it? This is not a troll. I'm a snake shooping and I want people's answers. I don't know beans about Rattlesnakes or have an preconceived ideas about them. I noticed, however, that everyone I talk to who are aware of Pythons are also afraid of Rattlesnakes. So it seems that Rattlesnakes have the potential to compete with and displace Pythons. I'm...
17
764
by: Sarah Tanembaum | last post by:
Beside its an opensource and supported by community, what's the fundamental differences between PostgreSQL and those high-price commercial database (and some are bloated such as Oracle) from software giant such as Microsoft SQL Server, Oracle, and Sybase? Is PostgreSQL reliable enough to be used for high-end commercial application? Thanks
9
1595
by: Martin | last post by:
Due to the the large numbers of MS trained programmers unemployed we are looking at using MS Development environments. VB programmers are currently 10 a penny. However I find C a bit more logical as I come from a Clipper background. Current;y .NET seems to be the latest fashion, so what is it about and should we use it please?
19
4278
by: gsteff | last post by:
I'm a computer science student, and have recently been trying to convince the professor who teaches the programming language design course to consider mentioning scripting languages in the future. Along those lines, I've been trying to think of features of Python, and scripting languages in general, that can't be found in older languages, and have been having a surprising amount of trouble. Dynamic typing can be found in Smalltalk, the...
3
3301
by: DaTurk | last post by:
Hi, I'm implementing the Idisposable pattern and am wondering what the difference it between managed, and unmanaged resources? http://msdn2.microsoft.com/en-us/library/fs2xkftw.aspx in the code snippet where it's overloading the Dispose method it disposes of managed and unmanaged resources if disposing == true, and only unmanaged resources if disposing is false. I'm not sure I completely understand. Thank you in advance.
0
1649
by: danbst | last post by:
There are script languages compiled at runtime. So, we can download interpreter and code-file to run the program. Everybody knows it. here is my idea. I create redistributable package (for *nix and win platforms) with compilers/interpreters of Python language, including for example, QT, TCL and other crossplatform libraries. then I create .exe file to access this interpreter in win platform, bin-file to access interpreter in *nix platform,...
0
9647
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9496
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10363
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
10110
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8989
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6745
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5534
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4066
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2894
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.