










































































Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
Community
Ask the community for help and clear up your study doubts
Discover the best universities in your country according to Docsity users
Free resources
Download our free guides on studying techniques, anxiety management strategies, and thesis advice from Docsity tutors
In this thesis, the research in programming language was conducted. Four of the most popular programming languages C, C++, C# and Java are chosen to be the ...
Typology: Study notes
1 / 82
This page cannot be seen from the preview
Don't miss anything!
ABSTRACT
Author Hao Chen Title Comparative Study of C, C++, C# and Java Programming Languages Year 2010 Language English Pages 78 + 4 Appendices Name of Supervisor Dr. Ghodrat Moghadampour With the rapid development of software industry, more and more people want to learn programming languages. But nowadays there are more than 200 programming languages available, only a few of them can be applied comparatively widely.
In this thesis, the research in programming language was conducted. Four of the most popular programming languages C, C++, C# and Java are chosen to be the objects to study. The technical features of these four programming languages were summarized and compared with each other. To know the actual performance of these four chosen programming languages, an experiment was carried out by implementing the benchmark for each programming language. The result from the experiment was recorded and analyzed.
The research concluded the most suitable application fields for these four of the most popular programming languages according to the technical features and the result from the experiment. C is suitable for systems-programming applications, hardware related applications, embedded device, chip designing, and industrial automation products. C++ is appropriate for the software development such as application software, device drivers and high-performance server. C# is proper for application development and the development of web application. Java has three different forms, Java2 Standard Edition (J2SE), Java2 Micro Edition (J2ME), and Java2 Enterprise Edition (J2EE). J2SE is suitable for the desktop applications. J2ME is proper for embedded systems development for mobile phones, wireless application and PDA programming. Finally, J2EE is appropriate for the development of server programming.
Key word: Programming language, C, C++, C#, Java
1. Introduction
Software has extended many areas of modern life. People might use the software to write the article in the office, communicate with each other and play games on the computer or on the phone to relax. In recently years, the applications of software have dominated in many fields of our life. First, there is office software such as Microsoft Office and Open Office which brought us a huge improvement in the efficiency of study and work related to the text editor. Secondly, with the wide application of communication software such as Skype, MSN, Yahoo Message, the communication between people become more and more convenient. Furthermore, it is also became cheaper and cheaper for people to contact with each other. For example, by using one software call “Fring”, people can make free mobile call through the wireless network. Last but not at least, more and more vivid and attractive games are available for the game machines such as “play-station 3” and “WII”. By playing the games, people can not only relax but also do exercise.
Clearly the public has experienced the power of the software. And all the software is written by the programming languages. The development in the technology of programming languages is also rapid. Since the first generation of programming languages emerges in early 1950, programming languages have five generations. The latest generation of programming languages is aimed to “make the computer solve a given problem without the programmers.” [1] However, according to the TIOBE Programming Community index that “gives an indication of the popularity of programming languages” [2], third generation of programming language is still be widely used. The table 1 shows the TIOBE Programming Community index for May
The number of the programming languages is thousand from general purpose programming languages to special purpose programming languages that are used in one application. People always have difficulties about which programming language should be learn and use to develop certain software.
The main problem of this thesis: Among the four of the most popular programming languages C, C++, C# and Java, which programming language should be adopted when starting to build a new software system to meet the general requirements of this new software system such as stable performances with fast speed and the limited time for developing?
This thesis is aimed to solve the problem above by the theoretical analysis and the practical experiment.
By the introduction of programming languages and the deep analysis of four chosen programming languages C, C++, C# and Java from theatrical aspect to practical aspect, this thesis expresses the general idea about the whole programming languages, the deep insight in technical features and actual performance of these four chosen programming languages. The main purpose of this thesis is to guide people to make a strategic decision to use the most suitable programming language to develop the new software system.
The importance of this study is significant.
A software system built with wrong programming language can lead to some big
problems. The time spent on the development of the new software system can be very long. The maintenance of the new software system can be very difficult. Even worse thing can happen. Because of the poor performance of the new software system, it has to be rebuilt with a new programming language. This is really a big waste of time, money and human resource.
This thesis can help people avoid these problems mentioned above. With a correct programming language, the time spent on developing a new software system can be reduced significantly and the performance of the new software system can be improved obviously.
In this thesis, only four of the most programming languages C, C++, C# and Java are chosen to be the subjects to introduce and compared with each other from theoretical aspect, such as language grammars and technical features to the practical aspect- running benchmark of these four chosen programming languages to know the actual performance of these four chosen programming languages.
The other programming languages were not discussed and compare in this thesis.
The outline of the study follows a structural pattern with five chapters after this, concerning: Chapter II – Brief history of programming languages, C, C++, C#, and Java Chapter III- Comparison of C, C++, C#, and Java from theoretical aspects, including summarizing the technical features of these four chosen programming languages and comparing these features with each other Chapter IV- Experiment on the benchmark of C, C++, C#, and Java, including the
2. Brief history of programming languages, C, C++, C#, and
Java
In this chapter, the definition of programming languages and the brief history of their development were introduced by the time sequence. Then the brief history of four of the most popular general-purposed programming languages C, C++, C# and Java were presented.
“A programming language is an artificial language designed to express computations that can be performed by a machine, particularly a computer.” [3]
Programming languages has developed very rapid since early 1950’s which lead to over hundreds of different programming languages being invented. With the rapid technological development in the hardware with faster processors, more and more powerful programming languages can be used to meet the demands of designing more efficient programs for various applications. In this chapter, five generations of programming languages were briefly described by time sequence.
2.1.1 Machine languages
The first generation of programming languages is machine languages appearing in early 1950’s. It was written in binary, a series of zeros and ones. Binary is difficult to understand for human-being and was very prone to errors. The main problem of machine languages is machine dependency because “Machine languages were created differently for different for each CPU”. [4]
2.1.2 Symbolic assembly languages
The second generation of programming languages is symbolic assembly programming
languages which was “written in a more simplistic form and at a higher level of abstraction machine languages, instead of a series of zeros and ones there were symbols (percent, dollar and portions of a word and number combination used to make commands.” [4] But symbolic assembly programming languages still have the problems of high hardware dependency and lack of portability which means assembly codes could not implemented on the different machines.
2.1.3 Problem-oriented languages
The period from the early 1960's till 1980’s brought us third generation programming languages. Third generation of the programming languages is called problem-oriented languages and is also considered as the high level languages. “Third generation programming languages were converted from English into machine languages; compilers were used to convert these instructions.” C, C++, C and Java are all examples of third generation programming languages. Most of third generations of programming languages have the compilers or the interpreters. The advantage of this is that the programs can run very fast after compiling. The problem of “machine dependency” which was encountered by the first and second generation of programming languages is no longer for the third generation of the programming languages any more. The main problem of third generation programming languages is that different type of processors need different source codes of third generation programming languages and third generation programming languages are quite hard to work out. [4]
2.1.4 Non-procedural languages
Fourth generation programming languages are more focused on problem solving. The main difference between other generation programming languages is that they are more concerned with what is to be done than the actual how. “Features evident in fourth generation languages quite clearly are that it must be user friendly, portable and independent of operating systems, usable by non-programmers, having intelligent
There is something interesting about the name of C. It was named C because its predecessor was called B which was also developed by Ken Thompson of Bell Labs. [6]
“C++ was written by Bjarne Stroustrup at Bell Labs during 1983-1985. C++ is an extension of C. Prior to 1983, Bjarne Stroustrup added features to C and formed what he called ‘C with Classes’. He had combined the Simula's use of classes and object-oriented features with the power and efficiency of C. The term C++ was first used in 1983.” [7]
“C++ was designed for the UNIX system environment, it represents an enhancement of the C programming language and enables programmers to improve the quality of code produced, thus making reusable code easier to write.”[8]
“The primary architects of C# were Peter Golde, Eric Gunnerson, Anders Hejlsberg, Peter Sollichy and Scott Wiltamuth. Of course, the principal designer of the C# language was Anders Hejlsberg, a lead architect at Microsoft.” [9]
C# was designed to be a pure object-oriented programming language. “C# debuted in the year 2000 at the Professional Developers Conference (PDC) where Microsoft founder Bill Gates was the keynote speaker. At the same time, Visual Studio .NET was announced.” [9]
Java started to be developed in 1991 by James Gosling from Sun Microsystems and his team. The original version of Java is designed for programming home appliances.
In 1994, James Gosling started to make a connection between Java and internet. “In 1995, Netscape Incorporated released its latest version of the Netscape browser which was capable of running Java programs.”[10]
The original name of Java is Oak. But it had to change its original name because Oak had been used by another programming language. The new name Java was inspired by a coffee bean.
“While Java is viewed as a programming language to design applications for the Internet, it is in reality a general all-purpose language which can be used independent of the Internet.”[10]
Table 3. The basic data types and qualifiers in C. [34]
The table 4 lists all the reserved keywords in C language. “These keywords cannot be abbreviated, used as variable names, or used as any other type of identifiers.”[36]
Table 4. Reserved keywords in C language. [36]
auto else long switch break enum register typedef case extern return union char float short unsigned const for signed void continue goto sizeof volatile default if static while do int struct _Packed double
In C, every data type such as a character, integer, or floating-point number has a range of values associated with it. The range is decided by the amount of storage that is allocated to store a particular type of data in the memory of the computer. It depends on the computer you’re running. This feature for C language is called “machine-dependent”. For example, an integer might take up 32 bits on your computer, or perhaps it might be stored in 64 bits on another computer. Don’t write any program that assumes the size of the data types in C. [35]
In C++, the basic data type is almost the same as C.
In C++, there is one more type Booleans. A Boolean, bool, can have one of the two values true or false. A Boolean is used to express the results of logical operations.
The table 5 summarizes the basic data types and qualifiers in C++.
Table 5. The basic data types and qualifiers in C++. [37]
There are 32 keywords both in C and C++ as shown in table 6:
The Boolean type in C# has a little difference between that in C++. In C#, the Boolean type can only have two values: true or false. But in C++, the Boolean type can also have 0 as the value which means false and anything else means true. [39]
Integral Types in c# is also different from C and C++. In C and C++, the integral type is only one type. But “in C#, an integral is a category of types. They are whole numbers, either signed or unsigned, and the char type. The char type is a Unicode character, as defined by the Unicode Standard.” Table 8 shows the integral types, their size, and range. [39]
In C#, the long data type is 64 bits, while in C++, it is 32 bits.
Table 8. Integral types, size, and range. [39] Type Size (in bits) Range sbyte 8 -128 to 127 byte 8 0 to 255 short 16 -32768 to 32767 ushort 16 0 to 65535
int 32 -2147483648 to 2147483647 uint 32 0 to 4294967295
long 64
to 9223372036854775807
ulong 64
0 to 18446744073709551615 char 16 0 to 65535
“The floating point type in C# is either a float or double, which the same as that in C
and C++ is. But there is one more data type decimal that should be used when representing financial or money values.” [39] Table 9 shows the floating point and decimal types, their size, precision, and range.
Table 9. Float types and Decimal type. [39]
Type Size (in bits) precision Range
float 32 7 digits
1.5 x 10-45 to 3.4 x 1038
double 64 15-16 digits
5.0 x 10-324 to 1. x 10308
decimal 128
28-29 decimal places
1.0 x 10-28 to 7.9 x 1028
There are much more key words in C# than those in C and C++. There are total 87 reserved words in C#. Table 10 shows all the keywords in C#.
Table 10. C# keywords. [38]
C# keywords / C# reserved words
abstract as base bool
break by 2 byte case
catch char checked class
const continue decimal default
delegate do double descending 2
explicit event extern else
enum false finally fixed
float for foreach from 2
goto group 2 if implicit