473,854 Members | 1,476 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 4557
Ben Voigt [C++ MVP] wrote:
>>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.

Java and C# use the term "static class" in totally different ways. In C#, a
nested class definition provides privileged access to private members of the
parent when properly addressed using a parent reference, and to generic
argument of the parent, but not an instance of the parent. In Java, a
nested class definition creates an "inner class" which is bound to an
instance of the parent, sort of like the closure that C# uses for anonymous
methods. In Java, "static class" is used to create a nested class that
isn't also an "inner class".
I don't think anyone in the discussion was thinking about Java
"static nested class" or "static member class".

They are practically never referenced as just "static class".

Arne
Jul 28 '08 #141
Peter Duniho wrote:
On Sun, 20 Jul 2008 18:55:20 -0700, Arne Vajhøj <ar**@vajhoej.d kwrote:
>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.
I did not. I counted it as an area where it was not a split.
>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?
No. Ping was counted as an area where there was a split.

Are you sure that you read my post before replying ????
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.
No. You seem not to have read what I posted.
>>>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"...pl ease 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.
You can write anything in x86 assembler. That does not make Java and C#
syntax irrelevant.

Adding the static keyword as a class modifier adds the capability to
both enforce only static methods and clearly document the intention.

Two plusses.
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".
There is a difference. It would make just as much sense for Java to
add static class as for C#. It would not make any sense to add nullable
to Java.
>> 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.
????

Samples is used all the time. I don't think they would be if they were
useless.
>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.
It is statistical significant.

And all the readers should have the knowledge to evaluate the validity
of the sample.

So your statement is completely bogus.

Arne
Jul 28 '08 #142
Jon Skeet [C# MVP] wrote:
On Jul 21, 12:49 am, Arne Vajhøj <a...@vajhoej.d kwrote:
>>Java 1.4 and C# 1.0 were very similar, but the languages have diverged
significant ly 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.
It can be very difficult to distinguish between language and library.
>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.
Sure - Java is not exactly like C#, but the Java way is close enough to
the C# way that Java will never implement the C# way in addition to
the Java way.

Well - never say never. I don't think they will.

Arne
Jul 28 '08 #143
Peter Duniho wrote:
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.
That is not good syntax. Syntax should express the purpose of the code.

A private constructor say that this class can only be instantiated
by code inside the class.

A static keyword on the class say that this class only contains
static methods.

The last one is obviously better. So it is not the same.

Whether the change is worth the added complexity or not is
up for debate.

Apparently Hejlsberg said yes and Gosling said no.

That is a true difference in direction.
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.
It would make perfect sense to add static class to Java. They decided
not to do it. That is a divergence.

It would not make any sense to add nullable to Java. The need is not
there because Java has wrapper types. By adding nullable to C# they
solved a problem Java never had. That is certainly not divergence.
Based on functionality I would even call it convergence.
Of course, further
complicating matters is that Arne _also_ says the latter _isn't_. Which
is very confusing. :)
No it is just you that are confused.

Arne
Jul 28 '08 #144
Jon Skeet [C# MVP] wrote:
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.
The language is much easier to implement than the library.

I believe they are still missing a lot of .NET 3.5.

Arne
Jul 28 '08 #145
Peter Duniho wrote:
On Sat, 26 Jul 2008 23:39:58 -0700, Andre Kaufmann
<an************ *********@t-online.dewrote:

[...]
All due respect, C++ (not counting the GC/managed add-ons of C++/CLI)
doesn't even really have the concept of "reachable" . So any claim about
what C++ does _when_ something becomes "unreachabl e" is necessarily
wrong, or at the very least inaccurate.

I haven't assumed that you don't have any clue about C++, if you had the
impression then please apologize - wasn't my intention. I have over 15
years C/C++ experience and we currently seem to have just a different
view point.

But C++ has >IMHO< a concept of reachable objects:

Stack allocated objects
It's quite different to the "reachable" concept of GC objects, but the
compiler has to track, when the object becomes unreachable (due to
normal program flow or exceptions) and therefore must be destroyed.
I think you mean heap allocated objects have no concept of "reachable" -
for this point I agree with you.

[...]
I understand how tempting it is for people to just assume I don't have a
clue about what I'm saying. I also realize that, having only used C++
As I wrote above, wasn't my intention to assume that.
for a decade or so before exploring C#, I may have less C++ experience
I think you have only a different viewpoint.
than others involved in the discussion. But I have found that C# and
its lack of RAII hasn't impeded my usage of C# one iota, not even when
dealing with code that has to interact with the unmanaged, C/C++-centric
paradigms of the Windows API.
Not generally I agree, but I had big trouble to deal with COM objects,
which had been passed with a high frequency to a C# callback.
Finally, just as an aside: I find the "smart pointer" example
particularly weak, as reference counting is itself overused and
Smart pointer haven't necessarily something to do with reference
pointer, although they are quite common.
And I agree - smart pointers can be error prone. But there is IMHO
simply no other chance of freeing resources directly, but using
reference counting >or< preventing sharing of objects.
And with that, I'm done. Thanks for your time and interest.
Then O.k., for me we should just agree to a different viewpoint.

One final word:

C# is a great productive language. I can live without RAII in C#,
although it would be fine to have it.
Regarding C++ I would have to criticize much more than in C#.
I've been a die hard C++ developer, but after having touched several
other languages I have the impression that other languages may be more
productive for general purpose applications as C++.
At least they are evolving faster and allow to use new concepts of
developing.

To sum it up: Simpler is commonly better
Pete
Andre
Jul 28 '08 #146
Peter Duniho wrote:
[...]
Sorry, have a line to add to my previous post.
Thanks for your time and interest.
Thank you too.
Pete
Andre
Jul 28 '08 #147
Peter Duniho wrote:
[...]
Sorry, have a line to add to my previous post.
Thanks for your time and interest.
Thank you too.
Pete
Andre
Jul 28 '08 #148
Arne Vajhøj wrote:
[...]
And it never will.
IMHO it has Dispose, which effectively is the same. But it hasn't a
concept of stack allocated objects, which automatically (would) call
Dispose() / Destructor.
Experience has shown that even though the C++ way of destructors
will work fine with perfect code, then in practice the apps leaks
resources.
I have only one big problem in C#. How do I distinguish if an object
holds resources or not ?

I'm not a C# expert, but the only chance I have to handle this is to
check if the object is derived from IDisposable, automatically or by my
own, looking at the source code.

Automatically is IMHO better, since a used library object may be changed
and hold an resource afterwards I have implemented my code using this
object.

But anyways I have always the feeling to have missed something .e.g.
calling dispose - every time I create a new instance of another object
and holding the pointer in my class.
[...]
Arne
Andre
Jul 28 '08 #149
In article news:<48******* *************** *@news.sunsite. dk>, Arne Vajhøj
wrote:
Ben Voigt [C++ MVP] wrote:
C# is just as capable of hanging, leaking memory, and having
non-deterministic behavior as C++.

I don't believe that.
I don't think Ben means that C# is as prone these sorts of errors as
(badly-written) C++ ... just that C# is not by any means free of them,
and C# programmers need to be aware of the problem areas and capable of
dealing with them.
C# has much less undefined and implementation specific behaviors
than C++.
But it still has some ...
C# has array index checks and no pointers (assuming not using unsafe).
So does C++ if you use checked array classes. C doesn't, but that's not
what we're discussing (or it shouldn't be).
The language is is in general simpler to understand what is going on.
That's true. I don't think the difference it makes in usability is
significant -- especially when weighed against the greater expressiveness
of C++ -- but it does make some.
Those hard to find memory overwrites you can get in C/C++ or mysterious
memory leaks is not possible in C#.
C# has its own problems ... and mysterious memory leaks/overwrites
shouldn't happen in C++ either, as long as you use high-level classes
rather than raw pointers and buffers.

You're really criticizing C here, not C++.

Cheers,
Daniel.
Jul 28 '08 #150

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

Similar topics

17
3439
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
3737
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
46035
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
9444
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
2874
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
4189
by: abhi | last post by:
hi everybody am new to this group and help me to learn C
31
2642
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
3169
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
5319
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
9901
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
9752
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
11031
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
10371
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...
1
7918
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
7082
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
5750
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...
2
4162
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3188
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.