Can anyone please list me few Advantages of C over C++.
And does anyone know why we use C for designing System application like unix kernels etc... and not C++ even though it is a superset of the lang. and wud provide better functionality.
C over C++?
C is typically considered to be a faster language, for two main reasons:
1. Some of the additions provided in C++ tend to be a little slower than C. Calling virtual functions, for example, requires an extra dereference. construction and destruction of objects can add overhead beyond C structs. These are optional language elements with many, many other advantages, but they can lead to slower code.
2. The C language itself is simpler than C++ and makes it much easier for the compiler to provide optimizations. So in many instances, identical code compiled in C and C++ can have performance differences. The same thing applies to size.
Some of these are as much perception as truth. For example, C++ virtual functions are slower than direct function calls, but they are much faster (typically) than switch statements, which is what they frequently replace. The C compiler can (sometimes) optimize tighter than C++, but using the C++ standard template library almost always leads to better code than building your own linked lists, binary trees, resizable arrays, etc.
Me, I prefer C++.
Reply:Higher-level programming languages like C++ (versus C) are easier to code, debug, and maintain than C. However, they accomplish this at the sacrifice of the language's access to the OS, hardware, and memory that C provides.
C can more easily accomplish certain types of operations—with more degrees of flexibility.
A lot of C++ functionality is wrapped in special packets of code and interfaces; these take additional time and resources to process.
Many people find C to be a much more cryptic programming language. Note that a lot of basic programming concepts and syntax are virtually identical in C and C++.
Reply:To be honest, I like C++ better, simply because I find it easier to find free compilers for it, which is something you should consider. There is also a lot more support for C++, and the community that uses it is growing at a much faster rate than c.
Reply:C has fewer statements. C is a procedural language which makes it simpler to develop software with in certain circumstances. C compilers are relatively simple and mature. C++ does not necessarily provide more functionality. It does have the ability to do OOP(Object Oriented Programming) but because of this and other features becomes more difficult to develop code with. The compilers for C++ have to more complicated and don't produce code that in some instances is not as tight and fast as what a C compiler would produce. There is no one programming language the is the right tool for all problem sets. C is well understood, has decent support across many platforms, can interact "closely" with computer hardware and so on and as such is an excellent candidate for operating systems, virtual machines any problem set where tight efficient code that can interact "closely" with the hardware is needed. C++ is a very good choice to write a GUI or Business Application in but just because it is a superset of C or apparently has more functionality doesn't mean it is the best for everything.
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment