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:
- Structured programming facilities
- Confirming to the ALGOL traditions
- Short circuit evaluation – usage of only one operand if the result can be determined with it alone
- Static typing system for avoiding unintended operations
- Value passed parameters with relevance to pointer value passing
- Heterogeneous data combination & manipulation
- Reserved keywords and free-format source text
- Larger number of compound operators, such as +=, ++
- Huge variable hiding capacity, though function definitions being non-nestable
- Character – integer usage similar to assembly language
- Low-level access to computer memory via machine addresses and typed pointers
- Function pointers allow rudimentary forms of closures & polymorphic runtime
- Pointer arithmetic defined Array indexing (secondary notion)
- Standardized processor for defining macros, including source code files & conditional compilations
- Complex Input/Output and mathematical functions with consistent delegation to library routines
- Syntax same as “B” (C’s predecessor) but different from ALGOL e.g.: { ... } replaced begin ... end, && and || replaced and & or, which
- While B used & and | in both meanings, C made them syntactically distinct from the bit-wise operators
- 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:
- void functions
- Functions returning struct or union types instead of pointers
- Assignments enabled for struct data types
- const qualifier to make an object read-only
- Enumerated types
- 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++
- C++ is designed to be a statically typed, general-purpose language that is as efficient and portable as C
- C++ is designed to directly and comprehensively support multiple programming styles (procedural programming, data abstraction, object-oriented programming, and generic programming)
- C++ is designed to give the programmer choice, even if this makes it possible for the programmer to choose incorrectly
- C++ is designed to be as compatible with C as possible, therefore providing a smooth transition from C
- C++ avoids features that are platform specific or not general purpose
- C++ does not incur overhead for features that are not used
- 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: | 1972 | 1985 | |||
Designed by: | Dennis Ritchie | Bjarne Stroustrup | |||
Developed by: | Dennis Ritchie & Bell Labs | Bjarne Stroustrup | |||
Typing Discipline: | Static, Weak | Static, Unsafe, Nominative | |||
Major Implementations: | GCC, MSVC, Borland C, Watcom C | GNU Compiler Collection, Microsoft Visual C++, Borland C++ Builder | |||
Paradigms: | Imperative (procedural) systems implementation language | Multi-paradigm | |||
Influenced by: | B (BCPL,CPL), ALGOL 68, Assembly | C, Simula, Ada 83, ALGOL 68, CLU, ML | |||
Influenced: | awk, csh, C++, C#, Objective-C, BitC, D, Concurrent C, Java, JavaScript, Limbo, Perl, PHP | Ada 95, C#, Java, PHP, D, Aikido | |||
OOP(Object Oriented Programming): | No | Yes-polymorphism and inheritance | |||
Speed: | C applications are faster to compile and execute than C++ applications | C++ 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 elements | Uses classes and objects | |||
Programming-include: | use #include | use #include | |||
Programming-String type: | Cannot use string type but declare it as an arra | Can use string type | |||
Programming-input /output: | scanf for input;printf for output | cout<<>> | |||
|
No comments:
Post a Comment