CIS 068 JAVA vs. C++ Main Differences. CIS 068 JAVA vs C++ Java is (an interpreted) write once, run anywhere language. –The biggest potential stumbling.

Slides:



Advertisements
Similar presentations
Portability and Safety Mahdi Milani Fard Dec, 2006 Java.
Advertisements

Lab Information Security Using Java (Review) Lab#0 Omaima Al-Matrafi.
Lab#1 (14/3/1431h) Introduction To java programming cs425
George Blank University Lecturer. CS 602 Java and the Web Object Oriented Software Development Using Java Chapter 4.
ISBN Chapter 11 Abstract Data Types and Encapsulation Concepts.
C#.NET C# language. C# A modern, general-purpose object-oriented language Part of the.NET family of languages ECMA standard Based on C and C++
U NIVERSITY OF M ASSACHUSETTS A MHERST Department of Computer Science Computer Systems Principles C/C++ Emery Berger and Mark Corner University of Massachusetts.
Guide To UNIX Using Linux Third Edition
Java Data Types  Everything is an Object  Except Primitive Data Types  For efficiency  Platform independent  Portable  “slow”  Objects are often.
Abstract Data Types and Encapsulation Concepts
Session-02. Objective In this session you will learn : What is Class Loader ? What is Byte Code Verifier? JIT & JAVA API Features of Java Java Environment.
Review of C++ Programming Part II Sheng-Fang Huang.
JAVA v.s. C++ Programming Language Comparison By LI LU SAMMY CHU By LI LU SAMMY CHU.
OOP Languages: Java vs C++
Java. Why Java? It’s the current “hot” language It’s almost entirely object-oriented It has a vast library of predefined objects It’s platform independent.
Java and C++, The Difference An introduction Unit - 00.
Overview of Previous Lesson(s) Over View  OOP  A class is a data type that you define to suit customized application requirements.  A class can be.
 Java Programming Environment  Creating Simple Java Application  Lexical Issues  Java Class Library.
Names Variables Type Checking Strong Typing Type Compatibility 1.
Introduction to Java CSIS 3701: Advanced Object Oriented Programming.
Comparing C++ and Java. As a C++ programmer, you already have the basic idea of object-oriented programming, and the syntax of Java no doubt looks familiar.
1 Module Objective & Outline Module Objective: After completing this Module, you will be able to, appreciate java as a programming language, write java.
Algorithm Programming Bar-Ilan University תשס"ח by Moshe Fresko.
Introduction to Java University of Sunderland CSE301 Harry R. Erwin, PhD.
University of Houston-Clear Lake Proprietary© 1997 Evolution of Programming Languages Basic cycle of improvement –Experience software difficulties –Theory.
CS212: Object Oriented Analysis and Design Lecture 6: Friends, Constructor and destructors.
CNIT 133 Interactive Web Pags – JavaScript and AJAX Advanced topic - variable.
Lecture :2 1.  DEFENTION : Java is a programming language expressly designed for use in the distributed environment of the Internet. It was designed.
Netprog: Java Intro1 Crash Course in Java. Netprog: Java Intro2 Why Java? Network Programming in Java is very different than in C/C++ –much more language.
Programming for Beginners Martin Nelson Elizabeth FitzGerald Lecture 15: More-Advanced Concepts.
Everything Is an Object Manipulate objects with references The identifier you manipulate is actually a “reference” to an object. Like a television.
Computer Programming 2 Why do we study Java….. Java is Simple It has none of the following: operator overloading, header files, pre- processor, pointer.
We will talking about story of JAVA language. By Kristsada Songpartom.
Programming in Java CSCI-2220 Object Oriented Programming.
Introduction to Java COM379 (Part-Time) University of Sunderland Harry R Erwin, PhD.
Chapter 6 Introduction to Defining Classes. Objectives: Design and implement a simple class from user requirements. Organize a program in terms of a view.
Copyright Curt Hill Variables What are they? Why do we need them?
Everything is an object (CH-2) Manipulating Objects with References. Manipulating Objects with References. String s; String s = “IS2550” String s = new.
Java Basics Opening Discussion zWhat did we talk about last class? zWhat are the basic constructs in the programming languages you are familiar.
CS-1030 Dr. Mark L. Hornick 1 Basic C++ State the difference between a function/class declaration and a function/class definition. Explain the purpose.
 In the java programming language, a keyword is one of 50 reserved words which have a predefined meaning in the language; because of this,
C++ 程序语言设计 Chapter 12: Dynamic Object Creation. Outline  Object creation process  Overloading new & delete.
PHP vs. Python. Similarities are interpreted, high level languages with dynamic typing are Open Source are supported by large developer communities are.
Object Oriented Software Development 4. C# data types, objects and references.
JAVA INTRODUCTION. What is Java? 1. Java is a Pure Object – Oriented language 2. Java is developing by existing languages like C and C++. How Java Differs.
Programming Fundamentals. Topics to be covered Today Recursion Inline Functions Scope and Storage Class A simple class Constructor Destructor.
Duke CPS From C++ to Java l Java history: Oak, toaster-ovens, internet language, panacea l What it is ä O-O language, not a hybrid (cf. C++)
© 2006 Pearson Addison-Wesley. All rights reserved 1-1 Chapter 1 Review of Java Fundamentals.
Recap Introduction to Inheritance Inheritance in C++ IS-A Relationship Polymorphism in Inheritance Classes in Inheritance Visibility Rules Constructor.
Reference Types CSE301 University of Sunderland Harry R Erwin, PhD.
C# Fundamentals An Introduction. Before we begin How to get started writing C# – Quick tour of the dev. Environment – The current C# version is 5.0 –
UMass Lowell Computer Science Java and Distributed Computing Prof. Karen Daniels Fall, 2000 Lecture 10 Java Fundamentals Objects/ClassesMethods.
Java and C# - Some Commonalities Compile into machine-independent, language- independent code which runs in a managed execution environment Garbage Collection.
Java Programming Language Lecture27- An Introduction.
 It is a pure oops language and a high level language.  It was developed at sun microsystems by James Gosling.
CIS 068 JAVA vs. C++ Main Differences CIS 068.
Object Oriented Programming in
JAVA MULTIPLE CHOICE QUESTION.
BRIEF Overview ON THE MAJOR Similarities & Differences
Java Programming Language
Java Review Hello..This ppt is to give you an introduction about java and why it is soo special The segments all discussed here are the crucial parts of.
Introduction Enosis Learning.
Introduction Enosis Learning.
Java Programming Language
Conditional Statements
The Building Blocks Classes: Java class library, over 1,800 classes:
BRIEF Overview ON THE MAJOR Similarities & Differences
From C++ to Java Java history: Oak, toaster-ovens, internet language, panacea What it is O-O language, not a hybrid (cf. C++) compiled to byte-code, executed.
SPL – PS2 C++ Memory Handling.
Presentation transcript:

CIS 068 JAVA vs. C++ Main Differences

CIS 068 JAVA vs C++ Java is (an interpreted) write once, run anywhere language. –The biggest potential stumbling block is speed: interpreted Java runs in the range of 20 times slower than C. But: nothing prevents the Java language from being compiled and there are just-in-time (JIT) compilers that offer significant speed-ups. – Write once, run everywhere does (nearly) NEVER work with C++, but does (nearly) ALWAYS work with JAVA.

CIS 068 JAVA vs C++ You don't have separated HEADER-files defining class-properties –You can define elements only within a class. –All method definitions are also defined in the body of the class. Thus, in C++ it would look like all the functions are inlined (but they’re not). –File- and classname must be identical in JAVA –Instead of C++ “#include“ you use the “import keyword“. For example: import java.awt.*;. #include does not directly map to import, but it has a similar feel to it

CIS 068 JAVA vs C++ Instead of controlling blocks of declarations like C++ does, the access specifiers (public, private, and protected) are placed on each definition for each member of a class –Without an explicit access specifier, an element defaults to "friendly," which means that it is accessible to other elements in the same package (which is a collection of classes being ‘friends‘) –The class, and each method within the class, has an access specifier to determine whether it’s visible outside the file.

CIS 068 JAVA vs C++ Everything must be in a class. –There are no global functions or global data. If you want the equivalent of globals, make static methods and static data within a class. –There are no structs or enumerations or unions, only classes. –Class definitions are roughly the same form in Java as in C++, but there’s no closing semicolon.

CIS 068 JAVA vs C++ Java has no preprocessor. –If you want to use classes in another library, you say import and the name of the library. –There are no preprocessor-like macros. –There is no conditional compiling (#ifdef)

CIS 068 JAVA vs C++ All the primitive types in Java have specified sizes that are machine independent for portability. –On some systems this leads to non-optimized performance –The char type uses the international 16-bit Unicode character set, so it can automatically represent most national characters. Type-checking and type requirements are much tighter in Java. –For example: 1. Conditional expressions can be only boolean, not integral. 2. The result of an expression like X + Y must be used; you can’t just say "X + Y" for the side effect.

CIS 068 JAVA vs C++ There are Strings in JAVA –Strings are represented by the String-class, they aren‘t only some renamed pointers –Static quoted strings are automatically converted into String objects. –There is no independent static character array string like there is in C and C++.

CIS 068 JAVA vs C++ There are no Java pointers in the sense of C and C++ –There‘s nothing more to say, except that it is a bit confusing, that a pointerless language like JAVA has a ‘null-pointer‘ error- message...

CIS 068 JAVA vs C++ Although they look similar, arrays have a very different structure and behavior in Java than they do in C++. – There’s a read-only length member that tells you how big the array is, and run-time checking throws an exception if you go out of bounds. –All arrays are created on the heap, and you can assign one array to another (the array handle is simply copied).

CIS 068 JAVA vs C++ There is a garbage collection in JAVA –Garbage collection means memory leaks are much harder to cause in Java, but not impossible. (If you make native method calls that allocate storage, these are typically not tracked by the garbage collector.) –The garbage collector is a huge improvement over C++, and makes a lot of programming problems simply vanish. It might make Java unsuitable for solving a small subset of problems that cannot tolerate a garbage collector, but the advantage of a garbage collector seems to greatly outweigh this potential drawback.

CIS 068 JAVA vs C++ There are no destructors in Java. –There's no need because of garbage collection.

CIS 068 JAVA vs C++ Java uses a singly-rooted hierarchy, so all objects are ultimately inherited from the root class Object. –The inheritance of properties of different classes is handled by interfaces. –Java provides the interface keyword, which creates the equivalent of an abstract base class filled with abstract methods and with no data members. This makes a clear distinction between something designed to be just an interface and an extension of existing functionality via the extends keyword. –It’s worth noting that the abstract keyword produces a similar effect in that you can’t create an object of that class.

CIS 068 JAVA vs C++ Java has method overloading, but no operator overloading. –someone missing it ?

CIS 068 JAVA vs C++ Java has both kinds of comments like C++ does. There’s no goto in Java. –The one unconditional jump mechanism is the break label or continue label, which is used to jump out of the middle of multiply- nested loops. Java has built-in support for comment documentation –so the source code file can also contain its own documentation, which is stripped out and reformatted into HTML via a separate program. This is a boon for documentation maintenance and use.

CIS 068 JAVA vs C++ Java contains standard libraries for GUIs –Simple, robust and effective way of creating user-interfaces –Graphical output as part of the language

CIS 068 JAVA vs C++ Java contains standard libraries for solving specific tasks. C++ relies on non-standard third-party libraries. –These tasks include: Networking, Database Connection (via JDBC) Distributed Objects (via RMI and CORBA) Compression, Commerce Whatever you want: VoIP, Video-Telephony, MIDI, Games,... The availability and standard nature of these libraries allow for more rapid application development.

CIS 068 JAVA vs C++ Generally, Java is more robust, via: –Object handles initialized to null (a keyword).Handles are always checked and exceptions are thrown for failures –All array accesses are checked for bounds violations –Automatic garbage collection prevents memory leaks –Clean, relatively fool-proof exception handling –Simple language support for multithreading –Bytecode verification of network applets –Standard GUI

CIS 068 JAVA vs C++ Have a look at Providing: Jdk (Java Development Kit) Tutorials Documentation Examples APIs (Application Programming Interfaces)...

CIS 068 JAVA vs C++...and it‘s FREE !