473,854 Members | 1,967 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 4555
>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".
Jul 21 '08 #81
>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.
This has absolutely zilch to do with language and everything to do with the
monolithic vs micro-kernel war.
Jul 21 '08 #82
>and IO. C++ is still more unsafe than other languages because it just
>relies on programmers not to do stupid things, but given a modern
combination of compiler/RTL/std lib you get a lot of meaningful run-
time error messages in debug mode while still enjoying full speed in
release mode.

Until we get concepts in C++0x, essentially any C++ program that
heavily uses templates in general, and template metaprogramming in
particular (yes, that includes STL and Boost) is a rather masochistic
exercise when it comes to deciphering compiler error messages.
That's what comments are for. We've had the capability to implement
compile-time asserts for quite some time, and the compile error will bring
you directly to the assert and the associated explanatory comment. Concepts
will be nicer of course, but it's not true to say you can't work with
templates usefully.
Jul 21 '08 #83
Giovanni Dicanio wrote:
[David Wilkinson]
>Fortunately most of my consulting work is cross-platform non-GUI
C++, si I do not need to worry about this. The code is developed in
Visual Studio, but runs as a console application in various
linux/Unix systems, as well as Windows. My client also wraps it in
C++/CLI for Windows GUI with C#, but I am not responsible for that.

Do you know if it is possible to throw native C++ exceptions from the
C++ layer, and directly catch them at the C++/CLI or C# layer?
For synchronous exceptions, no. If the C++ code is compiled with
asynchronous exceptions, then they map onto Win32 structured exceptions,
just like .NET exceptions, and they can be caught by .NET exception handlers
(although they will all appear as a generic 'C++ native exception' with no
more information available).
>
Or must the C++/CLI layer catch all native C++ exceptions (like those
derived from std::exception) and rethrow them in a different form,
derived from managed base exception class System.Exceptio n ?

Thanks,
Giovanni

Jul 21 '08 #84
In article news:<ej******* *******@TK2MSFT NGP05.phx.gbl>, David Wilkinson
wrote:
But even experienced C++ users seem to be embracing C# over C++/CLI.
It's not just the designer tools; some features (such as LINQ) are not
even available in C++/CLI. It's a shame after all the effort that went
into C++/CLI (after the initial MC++ debacle), but there it is.
That comes back to what the blog /does/ say ... MS have apparently decided
(rightly or wrongly) that their customers want to use C# for GUI work, so
they are only providing GUI tools that target C#. That, in turn, gives the
impression that Microsoft want the users to use C# ... it's a vicious
circle.

It's also true that it's much easier to write these automated tools to work
with a simpler language (like C#) than a more complex one (like C++), so MS
make their own job easier by deciding not to support generation of C++
code.

As a programmer and /user/ of these tools, I would much rather that they
did the hard stuff for me automatically and let me do the easy stuff
myself!
What's the solution? I think MS has to fully face up to the fact that
VC++ is for native code, get the IDE back to the level of
usability/responsiveness we had in VC6, and put MFC (and the PSDK)
into VC++ Express. I don't think it is anybody's interest to "entrap"
beginners into C++/CLI.
There are situations that absolutely require code that runs in a sandbox,
for security and/or robustness. In those cases a JVM or CLI language is
essential. For everything else I'd much rather work with native code
generation -- whatever language is being used.

So, yes, I think native code is the way to go for C++ ... and I'd choose
Java rather than C# for the sandboxed environments because it has greater
market penetration. To me, C# is a language that should never have been.
The case for it was only ever a business case (the licensing difficulties
with Sun over Java) not a technical one.

As far as C++/CLI goes: The word coming out of Redmond a couple of years
ago was that Microsoft's own programmers found that programming for the CLI
in C++/CLI (using the internal prototype tools) was more productive than
programming in C#, and that there was some swing back to C++ from C#
internally. I think that happened in Microsoft because Microsoft has some
extremely capable people, and they probably appreciated the power of C++
over C# more than an average programmer would do, and I think that this was
all taking place before some of the more sophisticated C# productivity
tools became available to make life easier for the C# guys.

I think it's tragic that we don't get the same level of tool support for
C++ as for C# -- I know it's harder to do, but I think the rewards are
obvious. C# would not be a serious choice for the professional programmer
if the tool support was as good for C++, and it's sad that C++'s acceptance
is being hampered just because the inferior language has better tools.

Cheers,
Daniel.




Jul 23 '08 #85
JF
C# would not be a serious choice for the professional programmer
if the tool support was as good for C++, and it's sad that C++'s
acceptance
is being hampered just because the inferior language has better tools.
Presumably you've seen what most "C++" programmers pass off for code.
Therefore, while you may in fact be an excellent C++ programmer yourself (a
very rare breed), in reality most companies are bleeding huge $ from the
mess their so-called C++ programmers are producing. The bloodpath for most
other languages is also messy but far less severe. Whether it's
intrinsically superior to C# or not is therefore meaningeless. Outside the
halls of academia, C++ is (usually) a failure because most practitioners
can't handle it as well as a simpler and more forgiving language like C#
(which is hardly a second-rate language in its own right).
Jul 23 '08 #86
On Jul 23, 6:13*pm, Daniel James <wastebas...@no spam.aaisp.orgw rote:
So, yes, I think native code is the way to go for C++ ... and I'd choose
Java rather than C# for the sandboxed environments because it has greater
market penetration. To me, C# is a language that should never have been.
The case for it was only ever a business case (the licensing difficulties
with Sun over Java) not a technical one.
Personally, looking at how slow Java develops, and how much mess they
accumulate due to need to stay backwards, and general resistance to
change (see Java generics for an example), I'm glad that we have C#
for purely technical reasons.
Jul 23 '08 #87
JF wrote:
>C# would not be a serious choice for the professional programmer
if the tool support was as good for C++, and it's sad that C++'s
acceptance
is being hampered just because the inferior language has better
tools.

Presumably you've seen what most "C++" programmers pass off for code.
Therefore, while you may in fact be an excellent C++ programmer
yourself (a very rare breed), in reality most companies are bleeding
huge $ from the mess their so-called C++ programmers are producing.
The bloodpath for most other languages is also messy but far less
severe. Whether it's intrinsically superior to C# or not is therefore
meaningeless. Outside the halls of academia, C++ is (usually) a
failure because most practitioners can't handle it as well as a
simpler and more forgiving language like C# (which is hardly a
second-rate language in its own right).
But most of the C# coders have only a fraction of the skill set (and
understanding of the underlying system) of even the not-so-good C++
developers. So yes, the average mistake made by the C++ dev is more
expensive to fix... but that doesn't mean that the C# coders won't make the
same mistake or that it won't be just as hard to fix when they do (though it
may be "less expensive" in dollars because C# man-hours cost less).
Jul 23 '08 #88
[Daniel James]
So, yes, I think native code is the way to go for C++
Agree.
... and I'd choose
Java rather than C# for the sandboxed environments because it has greater
market penetration. To me, C# is a language that should never have been.
The case for it was only ever a business case (the licensing difficulties
with Sun over Java) not a technical one.
I don't know about C# vs. Java market penetration.
However, I think that C# 3.0 is much better than Java. I'm glad that
Microsoft designed such a language (and framework).

Cheers,
Giovanni

Jul 23 '08 #89
Ben Voigt [C++ MVP] wrote:
JF wrote:
[...]
But most of the C# coders have only a fraction of the skill set (and
understanding of the underlying system) of even the not-so-good C++
The problem is that you don't need the same skill set in C# (or other
languages) to solve a single problem and therefore even an experienced
developer will make less mistakes.

Multi-threading, GUI development is much easier in most of the other
languages compared to the efforts you have to take in C++, because they
support it out of the box. Fortunately C++ has Boost.

I've been a long time a die hard C++ programmer, but after having used
other languages like C#, D, Delphi or extending my C++ applications with
Python, Lua I know ask myself why all the stuff must be that complex in C++.

The only programming paradigm I miss in the other languages is RAII.
That's IMHO still a big plus of C++.
developers. So yes, the average mistake made by the C++ dev is more
expensive to fix... but that doesn't mean that the C# coders won't make the
same mistake or that it won't be just as hard to fix when they do (though it
may be "less expensive" in dollars because C# man-hours cost less).
A simple example:

How do I ensure in C++ that I have successfully overridden a base class
virtual function and that the compiler throws an error if the base class
implementation has changed ?

Andre
Jul 24 '08 #90

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
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
10684
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
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...
0
9517
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
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
5942
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4563
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
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.