473,799 Members | 2,837 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
25 2096
On 1 Aug, 14:58, "Larry Smith" <no_spam@_nospa m.comwrote:
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)
Well, I don't want to keep this thread alive longer than necessary, in
fact I've booked the abattoir and there will be a remembrance service
shortly.

My experience differs from yours. C++ developers I've worked with have
generally worked server side or in quant type positions. I've only
worked with one team who actively developed GUI's in C++ and it was a
nightmare. Partly down to the technology, mainly down to their severe
incompetence. Server side code was always about speed and looked
pretty much like C in wolves' clothing. OO was a smiley denoting their
blank eyed expressions rather than our anything oriented around
objects.

On the VB side, I've worked with developers working mainly on GUI's,
but also server side code and also similar quant type stuff.

On the GUI side the amount of knowledge you need to be a good GUI
developer in VB, to bypass the bottlenecks and restrictions VB imposed
required a significant understanding of what Windows was doing. I also
wasted lots of time interviewing alleged "programmer s" with a VB
background who had actually just figured out that you could make
buttons... So in a way you're right, there's a high noise to sound
ratio with VB programmers, but that's no reason to dismiss them.

Both groups, and I make them distinct groups purely for this
discussion, had strong and weak members. I'm talking only about those
I've worked with/employed here, not the noise.

If I wanted a GUI developer or ASP developer to work in C# I would not
immediately look for C++ on their CV. I'd be after GUI oriented or web
based experience respectively. If I wanted a server guy I'd be looking
for that sort of related experience. In both cases I'd be open to
anyone who appeared to demonstrate skill and an ability to learn
regardless of their background, but also an understanding of the
technology they'll be using. So C# developers will need to show they
understand C# and the "modernity" that comes with it.

Then there's the question of business knowledge, related skills (SQL
as an example). That's just two for the trifecta.

I do understand where you're coming from, but spotting wheat in the
chaff is not directly related to previous language experience unless
you can almost directly map it to your current new world requirements
and don't need to engage your potential employee outside of that box.


Aug 1 '07 #11
Jon Skeet [C# MVP] wrote:
raylopez99 <ra********@yah oo.comwrote:
>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.
I think that is true.

And COBOL and PL/I programmers are typical more senior than C++
programmers.

It is not particular surprising that the average age/experience
of developers in a new language are lower than for an older
language.

Arne
Aug 2 '07 #12
Larry Smith wrote:
>>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).
There are some merit to that argument.

But it does not really have any consequence. There are a limited
number of skilled people. It is obvious better to have 10 good C#
programmers than 1 good C++ programmer.
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.
It is not obvious to me that users of Win32 API should get a better
understanding of OS's than users of .NET framework.

Arne
Aug 2 '07 #13
>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.

It is not obvious to me that users of Win32 API should get a better
understanding of OS's than users of .NET framework.
The WinAPI is the raw interface to the OS. Those who work with it directly
on a regular basis (normally C/C++ programmers) are working closer to the OS
than most other programmers (assembly developers not included). Ergo they
develop a much better understanding of the OS and how it works. If this
isn't obvious then you haven't spent any time with it.
Aug 2 '07 #14
"Larry Smith" <no_spam@_nospa m.comwrote in message
news:%2******** ********@TK2MSF TNGP05.phx.gbl. ..
Absolutely not. A VB programmer's exposure to the WinAPI is almost
non-existent.
That is an incredibly ignorant statement, typical of most C developer's
understanding of VB. Usage of APIs is *huge* in VB, it has to be because VB
is so limited on it's own. To say it is non-existant is simply comical.
Although I do agree that generally C developers are on average stronger,
this is just an average and there are many VB developers who are very strong
developers.

Michael
Aug 6 '07 #15
"Larry Smith" <no_spam@_nospa m.comwrote in message
news:e%******** ********@TK2MSF TNGP03.phx.gbl. ..
The WinAPI is the raw interface to the OS. Those who work with it directly
on a regular basis (normally C/C++ programmers) are working closer to the
OS than most other programmers (assembly developers not included). Ergo
they develop a much better understanding of the OS and how it works. If
this isn't obvious then you haven't spent any time with it.
A good example of this is developers who do not dispose of Pens or Brushes.
Anyone who has worked with the API knows this is critical.

Michael
Aug 6 '07 #16
Larry Smith wrote:
>>2) For obvious reasons, C++ programmers will normally have much better
OS/WinAPI experience than other programmers. Their mechanical
understandi ng 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.
It is not obvious to me that users of Win32 API should get a better
understandin g of OS's than users of .NET framework.

The WinAPI is the raw interface to the OS. Those who work with it directly
on a regular basis (normally C/C++ programmers) are working closer to the OS
than most other programmers (assembly developers not included). Ergo they
develop a much better understanding of the OS and how it works. If this
isn't obvious then you haven't spent any time with it.
No. Win32 is *not* the raw interface to NT/2000/XP/2003/Vista.

It is a library provided by MS on multiple operating
systems (95/98/ME and NT/2000/XP/2003/Vista).

It is procedural not object oriented and therefore more low level
than .NET Framework.

But low level does not make it the raw interface to the operating
system.

Arne

Aug 6 '07 #17
tOn Aug 1, 8:02 am, Peter Bromberg [C# MVP]
<pbromb...@yaho o.yohohhoandabo ttleofrum.comwr ote:
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

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.
You have a problem with trolling? I find trolls usually ask the best
questions myself. After all, if you know everything, there's no need
for a usenet group.

I thought this thread was interesting myself, and beats the usual post
of just solving some individual's particular bug of the moment. But
if you disagree feel free to killfile me or otherwise ignore.

BTW sorry for using some wrong terminology in the OP (meant multiple
inherietance from multiple classes, not multiple interfaces, which are
supported by C#).

RL
Aug 6 '07 #18
On Aug 5, 5:35 pm, Arne Vajhøj <a...@vajhoej.d kwrote:
No. Win32 is *not* the raw interface to NT/2000/XP/2003/Vista.

It is a library provided by MS on multiple operating
systems (95/98/ME and NT/2000/XP/2003/Vista).

It is procedural not object oriented and therefore more low level
than .NET Framework.

But low level does not make it the raw interface to the operating
system.

Thanks I didn't know that. I'm tempted to ask what exactly is the raw
interface and how you would access it, but I have a suspicion it's
something like assembly language programming, and I would not be
surprised if MSFT has not made this interface publically available
(being paranoid about people understanding the innards of WIndows).

RL
Aug 6 '07 #19
No. Win32 is *not* the raw interface to NT/2000/XP/2003/Vista.

The precise architecture of Windows is a very deep subject. For all intents
and purposes however, the WinAPI is the de facto core set of APIs for
controllling the OS. It's not just another ordinary library as you would
have yourself believe. Things are somewhat different if you require true
low-level access to the OS but this applies almost exclusively to the world
of device drivers. For the vast majority of the world's development
community however, the WinAPI is what you deal with either directly (mostly
by C/C++ programmers) or indirectly via higher-level languages or interfaces
(which includes both VB and C#). Note that this does not mean that these or
other languages can't access the WinAPI at a lower-level with or without
restrictions (depending on the language), but they don't normally (usually)
do so directly. C/C++ programmers do. They regularly access the WinAPI via
the raw set of interfaces it provides unlike all other high-level languages.
Their understanding of the OS's behaviour and subtle nuances will therefore
be superior most of the time. If you honestly think that a C# or VB
programmer really understand the WinAPI at the same level as a comparable
(experienced) C/C++ programmer, I can easily think of many programming
exercises that would quickly prove otherwise.
Aug 6 '07 #20

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
19180
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
4281
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
3302
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
9687
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
9541
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
10251
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10225
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
10027
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
5463
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
4139
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
2
3759
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2938
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.