8/12/2019 02 - Java vs C++
1/24
CSC 458C++ Programming
Java vs. C++ - What are the similaritiesand differences?
Information from: * C++ for Java Programmers Weiss
* Wikipedia.com
Dr. Paige H. Meeker
Computer Science
Presbyterian College, Clinton, SC
8/12/2019 02 - Java vs C++
2/24
Lecture 2
Brief History of C++
High Level Differences Between
C++ and Java Reasons to use C++
8/12/2019 02 - Java vs C++
3/24
Introduction
Java and C++ look a lot alikesyntactically. Many of the basicconstructs in Java have only minortechnical differences from C++;other Java features (such as OOPsupport for classes) have a similar
look and feel to C++.How did we obtain these languages?
8/12/2019 02 - Java vs C++
4/24
History of Programming Languages
Since we have had computers, wehave needed a means ofcommunicating with them to obtaindesired results. This necessitatessome sort of language that willallow communication between man
and machine.
8/12/2019 02 - Java vs C++
5/24
History of Programming Languages
The first forms of language were actuallyphysical motion languages theprogrammer physically moved gears
and/or wires to convey what they wishedthe computer to do.
Programming was accomplished byrewiring the entire system each time a
new calculation was required.
8/12/2019 02 - Java vs C++
6/24
History of Programming Languages
John von Neumanns ComputingConcepts
Shared-Program Technique
Conditional Control Transfer
8/12/2019 02 - Java vs C++
7/24
History of Programming Languages
1951: First Compiler (GraceHopper)
First High Level Languages: FORTRAN (FORmula TRANslation)
COBOL (COmon Business OrientedLanguage)
LISP (LISt Processing language)
8/12/2019 02 - Java vs C++
8/24
FORTRAN
Computer Science without FORTRANand COBOL is like birthday cakewithout ketchup and mustard.
8/12/2019 02 - Java vs C++
9/24
COBOL
Alternative expansions of theCOBOL acronym have beensuggested:
Compiles Only Because Of Luck
Compiles Only By Odd Luck
Completely Obsolete Business Oriented
Language Completely Obsolete Boring Old
Language
8/12/2019 02 - Java vs C++
10/24
COBOLHello World
IDENTIFICATION DIVISION.Program-Id. Hello-World.
*ENVIRONMENT DIVISION.
*DATA DIVISION.*
PROCEDURE DIVISION.Para1.
DISPLAY "Hello, world.".*
Stop Run.
8/12/2019 02 - Java vs C++
11/24
LISP
Please don't assume Lisp is only useful forAnimation and Graphics, AI, Bioinformatics,B2B and E-Commerce, Data Mining,EDA/Semiconductor applications, Expert
Systems, Finance, Intelligent Agents,Knowledge Management, Mechanical CAD,Modeling and Simulation, Natural Language,Optimization, Research, Risk Analysis,Scheduling, Telecom, and Web Authoring just
because these are the only things theyhappened to list.
Kent Pitman
http://en.wikipedia.org/wiki/Kent_Pitmanhttp://en.wikipedia.org/wiki/Kent_Pitman8/12/2019 02 - Java vs C++
12/24
Algol
Led to:
Pascal
C
C++
Java
First language with a formal
grammar (BNF)
8/12/2019 02 - Java vs C++
13/24
Pascal
Developed out of necessity for agood teaching language
Combined best features of COBOL,FORTRAN, and Algol
Improved pointers, introduced CASEstatements
8/12/2019 02 - Java vs C++
14/24
C
Built to be fast and powerful
Hard to read
Many OS built in C (Unix, Windows,MacOS, and Linux)
8/12/2019 02 - Java vs C++
15/24
C++
C with Classes
Built to maintain speed of C (and
run C programs) and be moreportable
Language of choice in high schoolAP classes
8/12/2019 02 - Java vs C++
16/24
Java
8/12/2019 02 - Java vs C++
17/24
Visual Basic
8/12/2019 02 - Java vs C++
18/24
Perl
Depending on who you ask, Perlstands for:
Practical Extraction and ReportingLanguage
Pathologically Eclectic Rubbish Lister.
8/12/2019 02 - Java vs C++
19/24
Back to C++
C++ should be viewed as a newlanguage, based largely on C. Itincludes modern constructs tosupport OOP and was influenced byseveral design issues.
8/12/2019 02 - Java vs C++
20/24
C++ Design Concerns
Intended to be upward compatible with Cas much as possible (i.e. legal Cprograms should be legal C++ programs)
C++ programs should be as fast as Cprograms if they do the same thing.
No one wants to learn a more complicatedlanguage to produce slower code
This means: no runtime bounds checks, nogarbage collection
8/12/2019 02 - Java vs C++
21/24
C++ Design Concerns
Has continually evolved, firstsupporting classes and inheritance,later adding templates, exceptions,and namespaces
8/12/2019 02 - Java vs C++
22/24
Java Development
Similar to C++ cosmetically, butdesigners had two main goals Allow the programmer to write the same set of
programs that C++ allows, using simplersyntax
Make it harder for incorrect code to run
Requires compiler to detect many sets oferrors when it first compiles the program andrequiring the Virtual Machine to throw an
exceptions when bad things happen atruntime.
This also enhances security against hacking
8/12/2019 02 - Java vs C++
23/24
High Level Differences between C++
and Java
Compiled vs. Interpreted Code
Security and Robustness
Multithreading API
8/12/2019 02 - Java vs C++
24/24
Why learn C++?
C++ is still widely used
Templates
Operator Overloading
STL
Automatic Reclamation of Resources
Conditional Compilation
Distinctions between Accessor and Mutator
Multiple Implementation Inheritance
Space Efficiency Private Inheritance