Seach in Techno Google

Friday, February 15, 2008

difference between C and C++

1. INTRODUCTION
C proved very useful in running applications coded in assembly language because of its strengths like a simple compiler, lower access levels of memory, lower run time support and an efficient constructing language that was in sync with the hardware instructions. Another of its credits is that it is a highly portable (compatible with a variety of OS & Platforms) with very minimal source code changes required. Thus it has enabled remote operations & independence from the hardware. C is also compliant to a variety of standards, making it work with everything.

C++ is known as a mid-level language. Due to the fact that the C++ comprises of both high-level and low-level language features. Some of the adjectives used to describe C++ are static typed, free-form, multi-paradigm and supporting procedural programming.


2. Characteristics
C

Some of the important characteristics of C are as follows:
  1. Structured programming facilities
  2. Confirming to the ALGOL traditions
  3. Short circuit evaluation – usage of only one operand if the result can be determined with it alone
  4. Static typing system for avoiding unintended operations
  5. Value passed parameters with relevance to pointer value passing
  6. Heterogeneous data combination & manipulation
  7. Reserved keywords and free-format source text
  8. Larger number of compound operators, such as +=, ++
  9. Huge variable hiding capacity, though function definitions being non-nestable
  10. Character – integer usage similar to assembly language
  11. Low-level access to computer memory via machine addresses and typed pointers
  12. Function pointers allow rudimentary forms of closures & polymorphic runtime
  13. Pointer arithmetic defined Array indexing (secondary notion)
  14. Standardized processor for defining macros, including source code files & conditional compilations
  15. Complex Input/Output and mathematical functions with consistent delegation to library routines
  16. Syntax same as “B” (C’s predecessor) but different from ALGOL e.g.: { ... } replaced begin ... end, && and || replaced and & or, which
  17. While B used & and | in both meanings, C made them syntactically distinct from the bit-wise operators
  18. Similarities to Fortran e.g: the equal- sign for assignment (copying) & two consecutive equal-signs to test for equality (compare to EQ) or the equal-sign in BASIC)

Other unofficial features added with time were:

  1. void functions
  2. Functions returning struct or union types instead of pointers
  3. Assignments enabled for struct data types
  4. const qualifier to make an object read-only
  5. Enumerated types
  6. Creationg of tool to avoid the inherent problems of the language

Soon C became powerful enough to have the UNIX Kernel (written in a assembly language) re-written making it one of the first OS Kernels written in a language apart from the assembly languages.

C++

  1. C++ is designed to be a statically typed, general-purpose language that is as efficient and portable as C
  2. C++ is designed to directly and comprehensively support multiple programming styles (procedural programming, data abstraction, object-oriented programming, and generic programming)
  3. C++ is designed to give the programmer choice, even if this makes it possible for the programmer to choose incorrectly
  4. C++ is designed to be as compatible with C as possible, therefore providing a smooth transition from C
  5. C++ avoids features that are platform specific or not general purpose
  6. C++ does not incur overhead for features that are not used
  7. C++ is designed to function without a sophisticated programming environment

Polymorphism, one of the prominent qualities of C++, enablesmany implementations with a single interphase and for objects to act according to circumstances. C++ supports both static (compile-time) and dynamic (run-time) polymorphisms. Compile-time polymorphism does not allow for certain run-time decisions, while run-time polymorphism typically incurs a performance penalty. C++, though considered a superset of C, there exist a few differences causing some valid C codes to be invalid in C++ or to behave differently in C++. Issues like the C++ defining new keywords namely new & class, that are used as identifiers in C. C and C++ codes can be intermixed by declaring any C code that is to be called from/used in C++ with C linkage & by placing it within an extern "C" { /* C code */ } block.

3. Criticisms

Despite its popularity, C has been criticized for having desirable operations being too hard to achieve and undesirable operations being too easy to accidentally invoke thereby involving more programmer skill, experience, effort, and attention to detail than other programming languages for the safe & effective use of the language.

When object-oriented languages became popular, C++ was an extension of C that provided object-oriented capabilities with C++ originally implemented as a preprocessor -- source code was translated into C, and then compiled with a C compiler.

C++ being derived from C, also happens to inherit most of the criticisms leveled against C. But since the language is actually a composition of two different languages, along with the load of huge programs, often end up making the compilation huge and inappropriate in terms of pure size. When this problem is tried to be avoided, by disabling some of the fringe codes, it was again criticized for losing out on several important utilities. The creator of C++ also feels that C++ is justified to be a complex language since the modern day programming requirements have also increased in a huge manner when compared to the yesteryears.


4. Comparison by functions and all
Appeared in:19721985
Designed by:Dennis RitchieBjarne Stroustrup
Developed by:Dennis Ritchie & Bell LabsBjarne Stroustrup
Typing Discipline:Static, WeakStatic, Unsafe, Nominative
Major Implementations:GCC, MSVC, Borland C, Watcom CGNU Compiler Collection, Microsoft Visual C++, Borland C++ Builder
Paradigms:Imperative (procedural) systems implementation languageMulti-paradigm
Influenced by:B (BCPL,CPL), ALGOL 68, AssemblyC, Simula, Ada 83, ALGOL 68, CLU, ML
Influenced:awk, csh, C++, C#, Objective-C, BitC, D, Concurrent C, Java, JavaScript, Limbo, Perl, PHPAda 95, C#, Java, PHP, D, Aikido
OOP(Object Oriented Programming):NoYes-polymorphism and inheritance
Speed:C applications are faster to compile and execute than C++ applicationsC++ applications are generally slower at runtime, and are much slower to compile than C programs
Classes:Uses structures instead, hence more liberty to use internal design elementsUses classes and objects
Programming-include:use #includeuse #include
Programming-String type:Cannot use string type but declare it as an arraCan use string type
Programming-input /output:scanf for input;printf for outputcout<<>>







Take the C-quiz(50 questions)
i made 72% lets see urs.