473,839 Members | 1,542 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

learn C++ or C#

If I haven't made substantial investment in either C++ or C#, which language
would the experts recommend I become well acquainted with?

Daniel
Jul 17 '08
151 4545
Peter Duniho wrote:
On Sun, 20 Jul 2008 16:49:43 -0700, Arne Vajhøj <ar**@vajhoej.d kwrote:
>Jon Skeet [C# MVP] wrote:
>>Java 1.4 and C# 1.0 were very similar, but the languages have
diverged significantly since then. Almost all the new features in C#
2.0 and 3.0 either have no real equivalent in Java (e.g. iterator
blocks, nullable types) or have very significant differences (e.g.
generics).

I don't agree for 2.0.

My list of .NET 2.0 & C# 2.0 new features and their "Java status":

It's not clear to me that your list is a complete enumeration of all
.NET 2.0 and all C# 2.0 features. Heck, you didn't even include
iterator blocks, which was specifically mentioned by Jon.
It is a list I had from another context.
>generics - Java got it in 1.5 (and it is not that different)

I suppose that depends on your definition of "that different".
Personally, I'd say it's _very_ different. Java generics are just a
compile-time wrapper. I understand why they did it that way, but it
significantly limits their utility.
>nullable types - Java has had wrapper objects forever

Not the same at all. Nullable<Tisn't just a "wrapper" for value types
(though I can see why one might view them that way). In particular,
using a wrapper in Java requires boxing the value.

Of course, since in Java you can't define your own non-nullable types,
the need for Nullable<Tin Java is obviously dramatically reduced. But
the wrapper types still aren't the same.
>anonymous methods - Java has anonymous classes

And is missing delegates. Anonymous methods don't really make any sense
without delegates, so sure...maybe you don't see how anonymous methods
aren't the same as anonymous classes. But they aren't.

Now, if you want to argue that C# is missing anonymous classes, I don't
disagree with that. But having anonymous classes doesn't mean that Java
supports the same thing as anonymous methods.
>different accessability get & set - Java getters & setters obviously can

Java doesn't even have properties. The fact that Java's relatively
inferior work-around to lacking properties inherently allows different
accessibility for the getter and setter seems irrelevant to me.
You are missing the point.

The discussion is whether C#'s and Java's ways had split with C# 2.0
features.

The fact that Java does not have Nullable is not an indication of
such a split, because Java does not have any need for Nullable, because
in Java you use the wrapper classes. Different ways of achieving the
same goal.

Same applies to the rest.

These additions to C# made C# more similar to Java not less similar.
>static classes - missing

I don't understand this. Are you saying that C# didn't get to use
"static" when declaring a class until 2.0? That doesn't sound right to
me. I'm also not clear on what you mean by "missing" with respect to
Java, since you can effectively create a static class in Java just as
easily in C#.

I must be misunderstandin g what you mean by "static classes"...plea se
elaborate.
http://www.google.com/search?hl=en&q...=Google+Search
>7 out of 11 seems to be in Java .

I count different: 8 of 11 seem _not_ to be in Java
Only if you count implementation.

But that is not so relevant for the discussion.
Though, since your
list of new features for .NET 2.0 and C# isn't a complete enumeration
anyway, it's not like any count of that particular list is a useful
comparison anyway.
It is a sample of the features.

As all samples it has some uncertainty, but claiming that a sample
is not useful shows a blatant lack of understanding of statistics.

Arne
Jul 21 '08 #71
MC
>>I once met a very senior person in C++ circles (I won't mention his
>>name) and I asked him for his opinion. He suggested that perhaps 5% of
all C++ programmers are competent.

5%? Maybe. It's certainly no more than about 10%.

The percentage doesn't change much for other languages, though, bad
programmers will write bad code in any language.

But in languages like C and C++ they can create bugs that are
both disastrous and very hard to find.
Exactly. And that is what led us to get accustomed to personal computers
crashing, in the 1980s. Ten years earlier, in the mainframe era, with "less
powerful" languages, it was very hard for a program written in a high-level
language to crash the machine. Normally they terminated with recognizable
errors (e.g., divide by zero) or they simply misbehaved (produced the wrong
output). C# thankfully brings us back into that world. Program errors are
program errors, not computer crashes.
Jul 21 '08 #72
Daniel James wrote:
C++ can be used to write software for a huge range of systems -- not
only Windows but also Mac, linux and others (including mini and
mainframe computers, and embedded systems).
True.

But how many real life C++ program will actually run unchanged
(and without a zillion #ifdef's) on all those platforms ?
C++ can be used to write system-level code: operating systems, device
drivers, etc.. Although there are research projects and proof of concept
implementation that use C# for these things, current C# implementations
do not allow C# to be used for this kind of work with mainstream OSes --
you can't write even a Windows device driver in C#. If you want to do
driver work then choose C++ (or even C).
If one is into that type of stuff, then C/C++ is absolutely the rigth
way to go.
A good implementation plan is to write your back-end code -- the
business logic of your application -- in a fast portable language (such
as C++)
But why ? You will be able to write the same business logic cheaper
in Java, C# or Python.

You do not need any of the C/C++ specialties for that.

Arne
Jul 21 '08 #73
On Sun, 20 Jul 2008 18:55:20 -0700, Arne Vajhøj <ar**@vajhoej.d kwrote:
[...]
You are missing the point.
That can only be true if you are as well.
The discussion is whether C#'s and Java's ways had split with C# 2.0
features.

The fact that Java does not have Nullable is not an indication of
such a split, because Java does not have any need for Nullable, because
in Java you use the wrapper classes. Different ways of achieving the
same goal.
So why did you include "nullable types" as an example of the "split" of
"C# and Java's ways"? If anything at all, that's an example of
convergence, not divergence.
Same applies to the rest.
Ditto.
These additions to C# made C# more similar to Java not less similar.
The addition of the Ping class make C# more similar to Java, even though
Java doesn't have that? Likewise all the other things that even you agree
Java doesn't have?

If you're trying to make a point, you're not being very clear about what
point it is you're trying to make. You keep writing things that are
mutually exclusive of each other.
>>static classes - missing
I don't understand this. Are you saying that C# didn't get to use
"static" when declaring a class until 2.0? That doesn't sound right to
me. I'm also not clear on what you mean by "missing" with respect to
Java, since you can effectively create a static class in Java just as
easily in C#.
I must be misunderstandin g what you mean by "static classes"...plea se
elaborate.

http://www.google.com/search?hl=en&q...=Google+Search
Well, that's the definition I use. So that doesn't represent a change in
C# 2.0 at all. In either C# or Java you can write a static class (a class
with no instance members is by definition a static class). Just because
the keyword gained usage as a class declaration modifier in 2.0 doesn't
mean you couldn't static classes in 1.0.

In addition, you are again confused about what you're trying to
demonstrate. If Java's object wrappers for value types is in fact just
"different ways of achieving the same goal", then so too is simply
defining a class without any instance members just a "different way of
achieving the same goal".

Suffice to say, I find your assertions uncompelling.
[...]
> Though, since your
list of new features for .NET 2.0 and C# isn't a complete enumeration
anyway, it's not like any count of that particular list is a useful
comparison anyway.

It is a sample of the features.
Then it's useless with respect to measuring the actual differences between
the languages.
As all samples it has some uncertainty, but claiming that a sample
is not useful shows a blatant lack of understanding of statistics.
Claiming that a sample _is_ useful without showing that it's a
statistically significant (large enough sample size) and statistically
correct (sample collected in a statistically random way) sample shows a
blatant lack of understanding of statistics.

Pete
Jul 21 '08 #74
On Jul 21, 12:49*am, Arne Vajhj <a...@vajhoej.d kwrote:
Java 1.4 and C# 1.0 were very similar, but the languages have diverged
significantly since then. Almost all the new features in C# 2.0 and 3.0
either have no real equivalent in Java (e.g. iterator blocks, nullable
types) or have very significant differences (e.g. generics).

I don't agree for 2.0.

My list of .NET 2.0 & C# 2.0 new features and their "Java status":
I'll restrict it to language features, as that's what I was talking
about.
partial classes - missing
Yup.
generics - Java got it in 1.5 (and it is not that different)
It's *massively* different. Hugely, vastly different. IMO, of course,
but type erasure is fundamental difference IMO.
nullable types - Java has had wrapper objects forever
Not the same thing. While I don't like to micro-optimise too often,
the fact that Nullable<Tis still a value type in C# 2 is a big deal.
Likewise the fact that you can deal with *any* nullable type
generically , instead of having to know the wrapper type in advance.
anonymous methods - Java has anonymous classes
Unwieldy enough to be a real pain, and read-only access to local
variables. As Peter says, the lack of delegates is significant here.
static classes - missing
Yup.
different accessability get & set - Java getters & setters obviously can
Yup.

In addition:
o Iterator blocks
o Other improvements to delegates (irrelevant to Java without
delegates to start with)
7 out of 11 seems to be in Java .
In my count, only "different accessibility for properties" is really
there for Java.

Jon
Jul 21 '08 #75
On Jul 21, 4:28*am, "Peter Duniho" <NpOeStPe...@nn owslpianmk.com>
wrote:
Well, that's the definition I use. *So that doesn't represent a change in *
C# 2.0 at all. *In either C# or Java you can write a static class (a class *
with no instance members is by definition a static class). *Just because *
the keyword gained usage as a class declaration modifier in 2.0 doesn't *
mean you couldn't static classes in 1.0.
No, you couldn't. A static class isn't just "a clas with no instance
members". On the declaration side, when a class is made static the
compiler will *prevent* you from adding instance members. It also
means you don't have any constructors at all, which is impossible in
C# 1 - you get a default constructor if you don't specify any
constructors.

On the calling side, a class declared as static can't accidentally be
used like a "normal" class. You can't declare a variable of that type
(including parameters) or use it as a generic type parameter, for
example.

I'm not claiming these are massive differences, but they're things
which couldn't be achieved in C# 1. They let the compiler help you
find potential problems before they occur - as well as making
intentions clearer to other developers, of course.

Jon
Jul 21 '08 #76
On Sun, 20 Jul 2008 22:45:26 -0700, Jon Skeet [C# MVP] <sk***@pobox.co m>
wrote:
No, you couldn't. A static class isn't just "a clas with no instance
members". On the declaration side, when a class is made static the
compiler will *prevent* you from adding instance members. It also
means you don't have any constructors at all, which is impossible in
C# 1 - you get a default constructor if you don't specify any
constructors. [...]
Yes, I understand that. But by making all the members static, and the
constructor private, without any public member to return an instance of
the class, it's still effectively a static class.

If Arne were willing to accept these kinds of subtle differences as
legitimate differences, I wouldn't push it. But he isn't (see his
comments about nullable types). If he's happy for something to be "the
same" as long as it effectively behaves the same, then there shouldn't in
his view be any difference between these various ways to do a "static
class".

If anything, I'd say you can get a lot closer to a real C# 2.0 "static
class" in Java than you can to a real "nullable type", but Arne says the
former isn't in Java while the latter is. Of course, further complicating
matters is that Arne _also_ says the latter _isn't_. Which is very
confusing. :)

Pete
Jul 21 '08 #77
On Jul 19, 12:40*pm, Pavel Minaev <int...@gmail.c omwrote:
On Jul 19, 4:36*pm, "Giovanni Dicanio" <gdicanio@_NOSP AM_email_DOT_it >
wrote:
The main problem of C++ code is "old style" C++ code, more similar to Cthan
C++.
e.g. when raw pointers like char* are used instead of robust string classes
like std::string/CString, or instead of robust container classes like
std::vector.
Using tools like string classes, container classes and smart pointers makes
C++ code robust and easy to write and manage.

Well, sort of. Until you accidentially invalidate an iterator by
modifying the container - U.B. Or mix signed and unsigned integer
types in an arithmetic expression and get weird results because of the
silent signed->unsigned conversion rule (and it is very easy to do so,
since a lot of standard library functions return unsigned integers -
e.g. size() of any STL container is unsigned). Or forget that
assignment operator and "copy" constructor for auto_ptr are actually
move and not copy. Or put an auto_ptr into a container (and why not,
if it lets you do so without any compaints...). Or try to make sense
of three paragraphs of ISO C++ standard describing overload resolution
for template functions in presence of partial specializations (the one
where synthetic types are involved). The problem is, you have to be a C
++ expert to write good C++ code, and, not any less important, to be
able to understand advanced C++ code written by others that's thrown
at you.

Don't get me wrong, C++ is a great language, and the time I've spent
writing in it was great. But from my experience, I would never let it
anywhere near domain logic except where it is spefically needed, when
I have the choice, because too many times I've witnessed how even
skilled and experienced (5+ years) C++ developers wrote some seemingy
trivial code which then broke things in subtle ways. I once spent 2
whole work days in the debugger trying to find the code that lead to
"Heap corrupted" error which invariably manifested itself under
unclear conditions after the program was used for 2-3 hours. It's not
fun at all. It's also something that's much, much rarer in the
"managed code" land.
Just a definition question. What does "domain logic" mean? Thanks.
Jul 21 '08 #78
On Jul 18, 3:08*pm, "Jon Skeet [C# MVP]" <sk...@pobox.co mwrote:
Indeed, you need the command line option -langversion:lin q but to
quote the documentation:

<quote>
This enables the C# 3.0 support. Only a few features of C# 3.0 have
been implemented in the Mono C# compiler, so not everything is
available.
</quote>
Update to this - I've been chatting with Miguel de Icaza recently
(about something else) and he mentioned that the C# 3.0 support is now
actually completed. I'm not sure how much of it has been released yet,
but when Mono 2.0 comes out it should be fully C# 3.0 compliant.

Jon
Jul 21 '08 #79
On Jul 21, 3:43*pm, jmDesktop <needin4mat...@ gmail.comwrote:
Just a definition question. *What does "domain logic" mean? *Thanks.
Essentially a synonym for "business logic". As usual, see Wikipedia
for details:

http://en.wikipedia.org/wiki/Domain_logic
Jul 21 '08 #80

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

Similar topics

17
3437
by: Rob | last post by:
i know javascript, vbscript, asp css and alot more and im only 14 i was wondering which is easier to learn php or cgi. any help?
42
3733
by: Bicho Verde | last post by:
I have now free time and money to do what I want :-) I have some basic skills in programming (C, Pascal, Macromedia Actionscript) but don't know exactly what to do in the world of programming. And also I don't know exactly why would I learn Python rather than C#, C++ or Perl. Basicaly I don't know where to start, if there is much to do or if it is has it seems and there is software to everything nowadays and so doesn't make sense to spend...
55
46028
by: Elijah | last post by:
I have read many of the topics on learning C++ or Java first. It seems like everyone says something different. I would like to know if I should learn C++ or Java. First a little about myself. I know PHP, BASIC, and of course HTML. I'll be 15 years old in September. I am interested in programming GUI applications. I am also interested in programming games. I know that I should learn C++ to program games, but would learning Java make the...
30
9443
by: Rhino | last post by:
I am giving some thought to applying for some jobs that want people with Java and C++ experience. I have been writing Java for several years and am fluent enough that I don't have to get help with Java very often. I have no real C++ experience and not much C experience for that matter. However, the core Java statements are "borrowed" from C and C++ has often been called "C with classes". It seems to me that it shouldn't take very long to...
8
4053
by: Hermawih | last post by:
Hello , I want your opinion about this . In order to say it clearly , I think I have to describe it in long sentences . I could consider myself as Intermediate/Advance Access Developer ; Intermediate/Advanced Database designer . Because of the requirements , I must create Web Application . Access Pages is not suitable for that so I think about learning VB Net / ASP Net . I am
21
2870
by: TAM | last post by:
Hi, I read that ASP.NET uses VB.NET instead of VBScript. I also read that ASP.NET is a subset of VB.NET. So if I learn VB.NET first then do I have the knowledge for programming ASP.NET applications or do I need to learn both VB.NET and ASP.NET. Thank you. TAM
85
4175
by: abhi | last post by:
hi everybody am new to this group and help me to learn C
31
2640
by: anand devarajan | last post by:
hi friends, im anand im just a beginner in c learning for the past two weeksnow i can write simple prgs can anyone help me to get well known to c lang so that i should able to write even tough prgs in c
34
3168
by: pandit | last post by:
hai all, i want to become a good programmer. one of my friends ( named "arnuld", he posts here infrequently), taught me Lisp. so i am not a programming beginner. i have heard these 2 points. i want to know how : 1. C gives you a strong base of Procedural style of programming which forms the basis of learning other paradigms e.g OOP
65
5314
by: Chris Carlen | last post by:
Hi: From what I've read of OOP, I don't get it. I have also found some articles profoundly critical of OOP. I tend to relate to these articles. However, those articles were no more objective than the descriptions of OOP I've read in making a case. Ie., what objective data/studies/research indicates that a particular problem can be solved more quickly by the programmer, or that the solution is more efficient in execution time/memory...
0
9855
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, well explore What is ONU, What Is Router, ONU & Routers main usage, and What is the difference between ONU and Router. Lets take a closer look ! Part I. Meaning of...
0
9697
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
10906
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...
0
10585
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...
0
10292
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
9426
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 projectplanning, coding, testing, and deploymentwithout 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
5682
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...
0
5866
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
3
3132
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.