Survey
* Your assessment is very important for improving the work of artificial intelligence, which forms the content of this project
* Your assessment is very important for improving the work of artificial intelligence, which forms the content of this project
The differences and similarities of the
two programming languages
A programming language is a
means of communication
between a human being and a
computer.
PROGRAMMING
LANGUAGES
INSTRUCTS
COMPUTERS
PROGRAMS
FRENCH
C++
ITALIAN
JAVA
SPANISH
FORTRAN
LATIN
COBOL
SYNTEX
refers to the ways symbols may be
combined to create well-formed sentences (or programs) in the
language.
SEMANTICS
syntactically valid strings in a language.
reveals the meaning of
Type in the
C++/JAVA
The
C++/JAVA
Source
program
The
C++/JAVA
objects
program
Define the
problem
PROGRAM DEVELOPMENT CYCLE
Design the
problem
Code the
program
Test the
program
Documentation
Eight Symbols
of a Structured Program
/ / this method accepts an integer name ounces
/ / and returns a double name shipping
#include <iostream>
using namespace std;
// this method accepts an integer named ounces
// and returns a double named shipping
public static double getShipping(int ounces)
int main()
{
double basicCharge;
double shipping;
int ounces;
{
double basicCharge;
double shipping;
// set the basic shipping charge to $12.95
basicCharge = 12.95;
// if the ounces are greater than 16 calculate the
// extra charge at 30 cents per extra ounce
if (ounces > 16)
shipping = basicCharge + ((ounces-16) * .3);
else
shipping = basicCharge;
basicCharge = 12.95;
cin >> ounces;
if (ounces > 16)
cout << “shipping =” << basicCharge + ( (ounces – 16) * .3) << endl;
else if (ounces < = 16)
cout << “shipping =” << basicCharge << endl;
cin >> ounces;
return shipping;
}
return 0
}
C++
Java
C++ and Java
The different goals in the development of C++
and Java resulted in different principles and
design trade-offs between the languages.
Some differences are as follows :
Runtime
C++ is compiled directly to machine code which is
then executed directly by the operating system.
Java is compiled to byte-code which the Java virtual
machine (JVM) then interprets at runtime.
Actual Java implementations do Just-in-time
compilation to native machine code, resulting in
comparable execution time to C++.
.
C++
Java
Write once, compile anywhere (WOCA).
Write once, run anywhere / everywhere
(WORA/WORE).
Allows procedural programming, functional
Strongly encourages an object-oriented
programming, object-oriented programming,
programming paradigm.
and template metaprogramming.
Allows direct calls to native system libraries.
Call through the Java Native Interface and
recently Java Native Access
C++
Java
Explicit memory management. Supports
destructors. Third party frameworks exist to
provide better garbage collection.
Automatic garbage collection (can be triggered
manually). Has a finalize() method that works as
a destructor.
Supports classes, structs, and unions, and can
allocate them on heap or stack.
Only supports classes, and allocates them on the
heap.
Source code can be written to be platformindependent (can be compiled for Windows,
BSD, Linux, Mac OS X, Solaris, etc., without
modification) and written to take advantage of
platform-specific features. Typically compiled
into native machine code.
Compiled into byte code for the JVM. Byte code
is dependent on the Java platform, but is
typically independent of operating system
specific features.
The differences between the C++ and Java
programming languages can be traced to their
heritage, as they have different design goals
C++ was designed for systems and applications programming,
Java was created initially as an interpreter for printing
systems but grew to support network computing.
Some applications written in C++ include:
Microsoft, Google, Mozilla, MySQL (including Yahoo, You
Tube, and Wikipedia), a few parts of the Apple OS X, and
a few applications for the ipod.
Some applications written in Java include:
ThinkFree, UltraMixer, Blu-Ray, NASA World Wind,
Skype, Google Maps, Samsung, Blackberry, Nokia, and
Android.
Winner ?…
Both!