To
understand a language, it helps to know what motivated its development,
its principle concepts (which we call its "programming paradigm"), and
how it relates to other languages. If you have completed CS101:
Introduction to Computer Science I and the first unit of this course,
you should have a strong grasp of Java and C++, their uses, and a basic
understanding of object-oriented programming. In this unit, we will
outline the similarities and differences between these two languages,
noting how each is used in the industry. We will also take an in-depth
look at the basic building blocks of each language in order to draw a
distinction between the two and further acquaint you with both
languages. While there are many syntactual similarities between Java and
C++, they are not necessarily translated one to another easily. As you
study, pay close attention to the distinctions between the two.
Completing this unit should take you approximately 6 hours.
The C programming language is the procedural/modular precursor to C++, which adds object-orientation. Read this history of C to see where the C fits into the 'larger picture' of computing history. The history of C is part of the lore of programming, Unix/Linux, and the Internet, which everyone who studies programming should know.
This article provides an overview of the elements of C++; specifically, the 'C' portion of C++.
Note how section 2.2 describes tokens as the "minimal chunks of a program". The root goal of programming is solving problems using the 'chunks' of a programming language. Of course, the chunks must be appropriate for the type of problems to be solved. Generally, smaller chunks are applicable to many types of tasks, but involve more effort; larger chunks involve less effort, but are designed for more specific tasks.
Solving problems with programs is made easier if we can reuse the same or similar solutions that already exist. We do this using the 'chunks' provided by a language, as described in the previous resources. These sections describe the larger 'chunk' features of C++. Larger 'chunks' consist of programming statements used to write a program and to complete programs or portions of programs that reside in libraries.
The section "Classes and Inheritance" explains and illustrates classes, which enable reuse of large sections of programming code. "Templates" explains and illustrates generic programming using templates. Focus specifically on the Introduction, Function Templates, and Class Templates. It also discusses STL, the standard C++ library. Note that 'list' is a template in C++.
This article provides an overview of the elements of C++; specifically, the 'C' portion of C++.
Note how section 2.2 describes tokens as the "minimal chunks of a program". The root goal of programming is solving problems using the 'chunks' of a programming language. Of course, the chunks must be appropriate for the type of problems to be solved. Generally, smaller chunks are applicable to many types of tasks, but involve more effort; larger chunks involve less effort, but are designed for more specific tasks.
Compatibility of C and C++C gradually evolved into C++, although C is still often used. It is
possible to mix the two in a single program. This article discusses the
compatibility of C and C++. Compatibility of two programming languages
refers to the extent to which a program written in one of the languages
can be used without modification in the other. Compatibility includes
both syntax (grammar) and semantics (the execution of grammatical
statements). C and C++ have a degree of upward-compatibility, but there
are differences since they are distinct languages that have evolved
separately.
Read this page to get the background of the Java programming language. Its history is most interesting.
This page extends on the previous resource to delve deeper into Java itself, relating its use to its history.
While the operation of 'the system' applies to many programming languages, this chapter points out features of Java that improve the operation of the 'system', such as device independence via the Java Virtual Machine, OO, reusable class libraries (for user interfacing, event handling), network support, support for other technologies, and suitability for programming other devices.
Unlike C/C++, Java is purely object-oriented. It is
essential that you grasp the relationship between computer languages and
object-orientation.
In a class hierarchy, a base class is more generic than a class that implements it. In particular, functions or methods of a base class are more generic functions. While generality is desirable, it may be a trade-off with efficiency for certain problems. This section looks at several classes in the class hierarchy for lists and for sets, and the additional features implemented in the subclasses that make them more efficient depending on the problem to be solved.
When comparing two programming languages, consider their underlying concepts (goals, principles, model, paradigm), their syntax (grammar), their semantics (what tasks the language can instruct a computer to do), and what support (resources, libraries, tools, etc.) they provide. These considerations can be broken down into a list of specific features that are used to evaluate and compare the two languages. The table in this article describes the similarities and differences between Java and C++.
This video illustrates the different operational processes (compiling
and linking) used in C++ and Java. Most of the video discusses the
processes for C++, because it is more complicated than that of Java. The
Java processes were described more thoroughly earlier in the course.
Take this assessment to see how well you understood this unit.