DUE IN THREE HOURS - parapharsing - 20% allowed for copy and paste no more that- one page needed

Comparing and Contrasting C & C++ Languages

DUE IN THREE HOURS - parapharsing - 20% allowed for copy and paste no more that- one page needed 1

Abstract 1

Introduction 2

A brief History of C 4

A brief History of C++ 5

Features of C++ 6

Features of C 8

8

Differences between C and C++ 9

C Compiler Theory 10

C++ Compiler Theory 11

Conclusion 13

References 14



Abstract

C is a powerful programming language. It is fast, manageable and available in all platforms, and C++ is an excellent programming language with modern features that can be used in various kind of outputs. In this research paper I intend to explain the history of C& C++. Secondly, I will discuss the differences between the C++ & C language. I intend to list out the features of both languages. Lastly, I intend to explain the compiler theory for both C and C++ languages.






Introduction

Naturally, Human brains are able to develop a highly complex linguistic system. The brain has the ability to learn and understand many languages. Natural languages such as Arabic, English and French are used for communication between people and have grown naturally in humans through use, share of feeling, share of thoughts and desires; languages are the foundation of civilization, and science.

On the other hand, programming languages (machine languages) are just for machines. They are intended to communicate instructions and commands which inform the machine to do “something”. These commands are called C++ source code, or just source code. Moreover, there are many different programming languages, such as C, C++, Java, Python and many others. “In 1957, the first major programming language appeared in the form of FORTRAN which stands for FORmula TRANslating system. The language was designed at IBM for scientific computing. The components were very simple, and provided the programmer with low-level access to the computer's innards.”(Ferguson, Andrew) 1

The purpose of this paper is to compare and contrast the C and C++ programming languages. Both languages have interesting history background and the significant features.

A brief History of C

Throughout the 1960s, and into the early 1970s, numerous programs have been written in assembler language. Originally, the C programming language was developed as a language to replace assembler in systems programming. It was very successful, making system code portable and human-readable.

C started to grow in popularity not just for systems programming, but as a general purpose programming language. Today, C is one of the most used programming languages even though it’s an old programming language, but it’s still very strong. The C programmer must understand that C was designed to replace an assembler language and that in several important ways; it retains a very low level view of the machine.

The C programming language was developed at Bell Labs during the early 1970's. Quite suddenly it derived from a computer language named B and from an earlier language BCPL. Originally it was designed as a system programming language under UNIX. It expanded to have wide usage on many different systems. The previous versions of C were known as K&R C after the authors of an earlier book, "The C Programming Language" by Kernighan and Ritchie. As the language further developed and standardized, a version known as ANSI (American National Standards Institute) C became dominant. As you study this language expect to see references to both K&R and ANSI C. Although it is no longer the language of choice for most new development, it still is used for some system and network programming as well as for embedded systems. More importantly, there is a tremendous amount of codes written in the C language and many people are familiar with it and still actively maintained.

A brief History of C++

“C++ was developed by Bjarne Stroustrup starting in 1979 at Bell Labs in Murray Hill, New Jersey, as an enhancement to the C language and originally named C with Classes but later it was renamed C++ in 1983. Stroustrup had been hacking away at his replacement for the C programming language at AT&T Bell labs since 1979, where he and his colleagues in the research department were given free reign to experiment with new ways of building software.” (Calore, Michael).

C++ is one of the most popular modern programming languages ever created. It was designed to be a “general use” language: It can be run on just about any platform, and it shows up almost everywhere, especially in videogames and embedded systems. C++ is known as the middle level programming language. Also, known as C++ is a superset of C and it can run on variety of platforms, such as Windows, Mac OS, and the various version of UNIX.

“If I had thought of it and had some marketing sense,” Stroustrup says, “every computer and just about any gadget would have had a little ‘C++ Inside’ sticker on it.” After publishing The C++ Programming Language, Stroustrup continued to stay active in the C++ community, working on the language’s design, writing compilers and helping to make the language an ISO standard in 1998. (Calore, Michael) 2

Features of C++

The C++ is object oriented programming language and it is a very simple and easy language, this language has following features:

The C++ is an object-oriented program, it was created to writing program for different purposes and it fully supports the four pillars of object-oriented development: Encapsulation, data hiding, inheritance and polymorphism. Also, every C++ program is writing in Basic English language so that it is very easy to understand and developed by programmer.

Moreover, C++ is a very powerful programming language, it have a wide variety of data types, functions, control statements, decision making statements, etc. Also, C++ is a case sensitive programming language. In C++ programming the lower case letter it's treated separately and the upper case letter separately too. For example, 'break and BREAK' both are different.

C++ is a compiler based programming language that means without compilation no C++ program can be executed. First we need compiler to compile our program and then execute.

Furthermore, C++ is a strongly tight syntax based programming language. If any language follow rules and regulation very strictly known as strongly tight syntax based language. Example C, C++, Java, .net etc.

Also, In C++ language pointer concept is available. It is the concept of carrying the instruction from one system to another system. In C++ Language .cpp file contain source code, we can edit also this code. .exe file contain application, only we can execute this file. When we write and compile any C++ program on window operating system that program easily run on other window based system.

Features of C DUE IN THREE HOURS - parapharsing - 20% allowed for copy and paste no more that- one page needed 3

This diagram demonstrates most of the important features of the C language. First of all, the C language is known as a robust language because of its rich set of built-in functions and operators that can be used to write any type complex program. Second of all, Programs written in C are efficient and fast because of the variety of data type and powerful operators. Third of all, C is highly portable this means that programs once written can be run on another machines with little or no modification. Another important feature of C program is its ability to extend itself. Last but not least, A C program is basically a collection of functions that are supported by C library. We can also create our own function and add it to C library. Lastly, the C language is the most widely used language in operating systems and embedded system development today.3

Differences between C and C++

Both languages share some common syntax; however they are very different in nature. The C is language is a procedural language which means it's a programming language that specifies a series of well-structured steps and procedures within its programming context to compose a program. It also does not support classes and objects. On the other hand, C++ is a combination of both procedural and object oriented programming language; therefore C++ can be called a hybrid language.

There are many differences between both languages. First of all, Comparing C to C++, C is a subset of C++. C++ can run most of C code while C cannot run C++ code. Secondly, C supports procedural programming paradigm for code development. On the other hand, C++ supports both procedural and object oriented programming paradigms; therefore C++ is also called a hybrid language. Also, the C language does not support function and operator overloading. However, C++ supports both function and operator overloading. Last but not least, the C language does not support reference variables and it also has no support for virtual and friend functions. On the other hand, C++ supports reference variables and also supports virtual and friend functions.

C Compiler Theory

The first C with Classes compiler was called Cfront, which was derived from a C compiler called CPre. It was a program designed to translate C with Classes code to ordinary C. Also, it's interesting that Cfront was written mostly in C with Classes, making it a self-hosting compiler. Cfront would later be abandoned in 1993 after it became difficult to integrate new features into it, namely C++ exceptions. Nonetheless, Cfront made a huge impact on the implementations of future compilers and on the UNIX operating system.

Furthermore, there are three things that are necessary for creating C programs: a text editor, a compiler and a C standard library. A text editor is all that is needed to create the source code for a program in C or in any other language. Source code is the version of software as it is originally written by a human in plain text. A text editor is a program for writing and editing plain text. It differs from a word processor in that it does not manage document formatting or other features commonly used in desktop publishing. C programs can be written using any of the many text editors that are available for Linux, such as vi, gedit, kedit or emacs. For example:

  • To run or start a file use type the following command before the filename and press ENTER:

Vi myfilename

  • To compile the program type the following command and press the ENTER key:

gcc myfilename.c

  • To execute the program type the following command and press the ENTER key:

./a.out

C++ Compiler Theory

The Cfront was the original compiler for C++. However, nowadays there many other compilers for C++.The two most widely used compilers are probably MSVC) Microsoft Visual C++ compiler and its offered by Microsoft for windows platforms, and GNU Compiler Collection GCC / G++ which contains high quality C and C++ compilers. It should be already installed on most UNIXs, and on windows it is available in MinGW.

The process for compiling a C++ program is similar to the C program, but uses the command g++ instead of gcc. Both languages compilers are part of the GNU Compiler Collection.

➢ In order to demonstrate the use of g++, here is a version of the Hello World program written in C++:

DUE IN THREE HOURS - parapharsing - 20% allowed for copy and paste no more that- one page needed 4

➢ In order to compile the program type the following command and press the ENTER key:

$ g++ -Wall hello.cc -o hello

➢ the resulting executable can be run in exactly same way as the C version, simply by typing its filename:

$ ./hello Hello, world!




Conclusion

Programmers are usually seeking languages that have significant features and high quality compilers. Therefore, both C and C++ languages have significant features that can be considered to be either a weakness or strength, depending on the programmer’s perspective. The main difference between the two languages is the static nature of C++ versus the dynamic nature of Objective C. For the C programmer new to OO programming, the choice is primarily between the feature-rich and complex C++, with its wide industry acceptance, or the easier-to-learn, more flexible, but less widely used, Objective C.


References
  • "Homepage - Max Planck Society." Startseite - Max-Planck-Gesellschaft. N.p., n.d. Web. 02 Aug. 2017.

  • Ferguson, Andrew. A History of Computer Programming Languages. N.p., n.d. Web. 02 Aug. 2017.

  • "C vs C - Which Programming language is better?" Technotification. N.p., 07 June 2017. Web. 02 Aug. 2017.

  • Features of C Language | C Language Tutorial | Studytonight. N.p., n.d. Web. 02 Aug. 2017.

  • Point, Tutorials. "C Overview." Www.tutorialspoint.com. Tutorials Point, 23 July 2017. Web. 29 July 2017.

  • Calore, Michael. "Inventor of C reflects on 25 years of the programming language." WIRED UK. WIRED UK, 22 May 2016. Web. 01 Aug. 2017.

  • Sitesbay.com. "Sitesbay - Easy to Learn." Features of C - Sitesbay. N.p., n.d. Web. 02 Aug. 2017.

  • An Introduction to GCC - Compiling a simple C program. N.p., n.d. Web. 02 Aug. 2017.

  • Kumar, Krishan. "Difference Between C and C With Example. C vs C." Cs-fundamentals.com. Cs-fundamentals.com, n.d. Web. 02 Aug. 2017.

1 Ferguson, Andrew. A History of Computer Programming Languages. N.p., n.d. Web. 02 Aug. 2017.

2Calore, Michael. "Inventor of C reflects on 25 years of the programming language."

3 Features of C Language | C Language Tutorial | Studytonight. N.p., n.d. Web. 02 Aug. 2017.

4 Kumar, Krishan. "Difference Between C and C With Example. C vs C." Cs-fundamentals.com. Cs-fundamentals.com, n.d. Web. 02 Aug. 2017.