I had this talk with a friend a while back and now i remmember that he said that C# is like a newer version of C++, but i think thats not correct, since C, C++, C# is kinda all oriented in this or that, what do you guys think of it?
thines01 401 Postaholic Team Colleague Featured Poster
All languages serve a particular purpose (or were created to solve a particular problem).
C# is no exception.
If I'm coding only on a Windows platform, it is my language of choice.
I know it can also run under Unix/Linux under Mono, but I have not tried that.
I spent most of my career coding in C++ and have switched to C# as my primary language.
The syntax is familiar and it has one significant advantage (in my opinion) -- LINQ.
Some other languages have an internal query-type construct, but I have not run across anything that is as easy to use as the LINQ that is bundled with C#.
So, to answer your question. C# is a hybrid language that is like a mixture of C++, Java, Ruby and some other things.
mike_2000_17 2,669 21st Century Viking Team Colleague Featured Poster
"C# is like a newer version of C++" -- Microsoft's Ministry of Public Enlightenment and Propaganda
Here goes another rant:
C#, like most other programming language that came after C/C++, has a syntax that is largely based on or similar to C/C++. This is purely to ease the adoption of the language, in the same way as all cars have a steering wheel and pedals, but that doesn't mean that Toyotas are the newer versions of Fords. There is only one language that is truly the "newer version" of C++, and that is, the newer version of C++! I.e., the new language standard called C++11.
Personally, I don't even consider C++/CLI to be a newer version of C++.
Even Microsoft is beginning to realize that all the efforts that they have been deploying in the last several years to try to squash C++ (and other languages) in favor of their own proprietary languages that depend on their own proprietary platforms (.NET or Silverlight) which effectively depend on their own proprietary operating systems is just another painfully obvious attempt at "vendor lock-in" that programmers just aren't buying anymore (but sadly, some companies and academic institutions will chow down any pablum that Microsoft serve them, and they especially target the third world).
C# is as similar to C++ as Java is. In fact, most of the time, from a perspective of describing the design principles of programming languages, you almost always end up putting C# and Java in the same category all the time because they are almost identical except for trivial syntactic differences and better "generics" in C#. Both Java and C# are basically reduced-functionality languages over C++ that make for a safer and more cushioned environment in which to develop applications (and these are their sale-points), but the main intent of these languages is pretty clear: to force consumers to adopt the runtime environment that they require to run, and to use features that are attractive to novice programmers in order to create the supply of applications that create the demand for their product. You can't blaim Oracle or MS for trying, but the promises that they tout to programmers are starting to look more empty as time goes on.
The point is this, C was a simple procedural language that was widely adopted. Then, C++ took C and added two hugely important features: classes and templates. This made C++ a multi-paradigm programming language that seeminglessly mixes functional, object-oriented, generic, and meta- programming paradigms natively, while allowing for just about any other programming paradigm with ease. C#/Java came along with the idea of having a managed environment (runtime environment or virtual machine) so that the programmer can be protected from himself and deal with an abstract system (which are very good ideas in general), but to do that, they had to sacrifice value-semantics in favor of reference-semantics which leads to non-deterministic execution (and a host of other quirks), and then they had to exclude meta-programming and generic programming as infeasible for a JIT-compiled environment in favor of a "pure" object-oriented programming language. C#/Java proponents typically try to diminish C++ by saying that it is just C with some object-oriented features (that aren't "pure"), while their language (C#/Java) is truly and purely object-oriented, but as generic programming and template meta-programming techniques have started to occupy a more predominant role in C++, when C#/Java proponents still come up with that argument they are generally met with ridicule and ill-conceived laughter (well, I'm exagerating a bit here!). But that is still the main talking-point in the propaganda / self-deception / confirmation-bias world of C#/Java, and your friend is just another example of it. The idea is simple: if C# is just the new version of C++, then why on earth would you use C++?
Until a language comes along with a drasticly new set of features that would really take programming to a new plane, like the move from C to C++ did, there is no language that can be called a "newer version" of C++, at least, not to the same tune as C++ is often described as a superset of C or newer version of C (although strictly speaking, neither are true). The marketing campaigns don't change the fact that there is no such fundamental improvement from C++ to C#/Java, and arguably there are too many drawbacks to even consider C#/Java as better (this is arguable and depends largely on the context of applications).
nuclear -9 Junior Poster in Training
I enjoyed the read and i can see what you mean, also i agree with thines01 that ""
all languages serve a particular purpose (or were created to solve a particular problem)
and i think that theres a lot to discuss about this, anyhow, thanks for interesting posts.
Edited by nuclear
stereomatching 17 Posting Whiz in Training
I don't know C# very well, but I know C, C++(primary language) and using java to develop some
app on android(even I don't like the philosophy of java, everything should be object?pointer is
too dangerous so we should not use it?you don't have to care about memory and so on).Before
I learn C++ and java, I always though they are almost equal to each other, C++ is just a "better c",
java is a safer and better C++.
The syntax of these languages are very similar to each other, but we can't simply say
"java is a next c++".If you have times, you will discover that these language are design
by different philosophy.
and arguably there are too many drawbacks to even consider C#/Java as better
After I study java, I find out that the abstaction mechanisms provided by java are not really
"much more powerful" than C++ as those companies propagate.An example is, java don't support generic programming as C++ do(no kidding, I don't think it is same as the generic of C++).
But the standard libs of java are very big, much more bigger than the libs of C++11, you don't
need to find libs A or libs B when you are using java like C++, maybe the biggest weakness
of C++ is the skinny standard libs.
This made C++ a multi-paradigm programming language that seeminglessly mixes functional, object-oriented, generic, and meta- programming paradigms natively
I like generic programming and the thing meta-programming could do, but I don't think that meat-programming
stlye of C++ would make most of the programmers feel "natively" at the first glance, we have to pay
a lot of time to adopt this powerful feature, just like a brand new language in C++.
Edited by stereomatching
Tumlee 42 Junior Poster in Training
Java has the advantage that is has a virtual machine that runs under many Operating Systems. Like so, you can expect many things to work on as well on under OSx as you are under Linux and Windows (more or less). I don't really understand the point of C# though. I actually found it extremely annoying to use a program that was written in C#, as I had to do a lengthy install of some ".NET architecture" or whatever which doesn't even seem as self-contained as Java's JRE.
Every operating system I have ever come in contact with (except for DOS) has had enough memory protection to shut your program down if you try to write to memory that doesn't belong to your program, so it's not like you could end up writing a program that accidentally trashes your entire computer. There's nothing truly "dangerous" about pointers anymore (unless you consider your program terminating to be dangerous).
thines01 401 Postaholic Team Colleague Featured Poster
@Tumlee: the CLR has not been around as long as the JVM. ...and by the time it has, the game will change again (anyway).
I remember having to install the JVM back when it was "new" and slow and buggy and difficult to deal with -- most of which has changed now.
I have noticed that most die-hard Java programmers are NOT writing on Windows anyway -- and that most programmers are not trying to write cross-platform code at the OS or VM level anyway (since the web became prominent).
What about Scala? No one seems to be mentioning THAT.
Wasn't that supposed to be the new-shiny-thing on the JVM?
mike_2000_17 2,669 21st Century Viking Team Colleague Featured Poster
Every operating system I have ever come in contact with (except for DOS) has had enough memory protection to shut your program down if you try to write to memory that doesn't belong to your program, so it's not like you could end up writing a program that accidentally trashes your entire computer.
Managed-memory environments like JVM and .NET were never meant to protect the computer from being screwed up by careless programmers. Of course, do all the crazy stuff you like with pointers, and the worse that will happen is that your own program will crash. When you consider a virtual machine (and garbage collector) from a point of view of managing allocation / deallocation of memory and protecting against wrongful read / write operations (out-of-bounds, and such), the whole idea is to protect the programmers from themselves, nothing more, it has never been about protecting the OS or the user's computer, or the other programs. That would be like saying that the cushions on a wall are there to protect the walls from the mental patient, of course not, the cushions prevent the mental patient from cracking his own skull, the walls will survive. The JVM or .NET work in a similar fashion, they don't protect the OS or the computer, they form a cushion layer so that the programs running inside them can't hurt themselves too much. This is not a bad idea at all, but it can cost a lot in terms of performance, load on the system (and harddrive), and pain to the user (having the install .NET for example).
Java has the advantage that is has a virtual machine that runs under many Operating Systems.
Adopting a good API standard does just as well for cross-platformness. Writing apps for POSIX makes them compatible, without modification, for just about every modern OS today, except for Windows, because they use their own standard (Win32). If Windows was POSIX-based from the start, the computer world would look very different today. If the main advantage of the JVM is that it abstracts the underlying system, then it's really an overkilled design.
and that most programmers are not trying to write cross-platform code at the OS or VM level anyway (since the web became prominent).
Don't be so narrow-minded. There are plenty of application domains in which web-based applications play very little to no part at all, and where OS-level cross-platform code (like cross-platform C/C++ libraries) play a major role.
I like generic programming and the thing meta-programming could do, but I don't think that meat-programming
stlye of C++ would make most of the programmers feel "natively" at the first glance, we have to pay
a lot of time to adopt this powerful feature, just like a brand new language in C++.
You're right. Template meta-programming isn't a very native-looking way of programming in C++, it looks more like hacking the compiler into doing things it wasn't designed for. And originally, TMP was discovered that way, by making hacks after hacks to realize that TMP was actually a complete programming language in its own right. But I think that with the additional features of the new standard, there is motion in the direction of making TMP a more "native" paradigm in C++. Nonetheless, TMP is still native in C++, even though the syntax can be cumbersome and ugly.
But the standard libs of java are very big, much more bigger than the libs of C++11, you don't
need to find libs A or libs B when you are using java like C++, maybe the biggest weakness
of C++ is the skinny standard libs.
The difference in size of the libraries is mostly a decision based on the target audience. Of course, C++ could have a very large standard library just like Java, or even a bigger one. Java is targetted for novice programmers, hobby programmers, people in academia, and some commercial app developers, but mostly the target audience demands a language with lots of off-the-shelf features and libraries that are at arm's length, and they have very little platform restrictions to deal with. In the world of C++, there is a vast amount of production code, some running on legacy platforms, some running on very restricted platforms, some running on high-performance demands, etc. etc., many of these people are not interested in a large monolithic standard library that provides everything and everything else. They want a solid standard library that is not too large, not too heavy, and that provides basic access to most systems plus solutions to some important, general-purpose and recurring programming problems (e.g. STL algorithms). And as one of the fundamental system programming languages (in what language do you think the CLR, JVM, Python libraries and all that is programmed in?), and you can't ask platform makers (OS or hardware) for too much in terms of library support (if you create a new OS or embedded architecture, it's fairly easy to implement the C standard library for it, or even the C++ standard library, but if you had to provide one of the magnitude of that of Java (not to mention its VM), it would be really hard). In some sense, this has shaped the software ecosystem of C++ into a much more modular environment (in the Unix style of a system being composed of many little parts that serve many different purposes). So, it's true that when you adopt C++ you don't get a lot of library features out-of-the-box, but is that really a disadvantage of C++, or is it one of its advantages? There are many perspectives to consider, it's not as simple as it looks at first, it's not just a matter of "the more the merrier" when it comes to standard library feature-sets.
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.