CIS 068 JAVA vs. C++ Main Differences CIS 068.

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.
Road Map Introduction to object oriented programming. Classes
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++
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 and C++, The Difference An introduction Unit - 00.
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.
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.
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.
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.
Computer Programming 2 Why do we study Java….. Java is Simple It has none of the following: operator overloading, header files, pre- processor, pointer.
Introduction to Java COM379 (Part-Time) University of Sunderland Harry R Erwin, PhD.
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.
Object-Oriented Programming Chapter Chapter
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.
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.
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.
Java and C# - Some Commonalities Compile into machine-independent, language- independent code which runs in a managed execution environment Garbage Collection.
 It is a pure oops language and a high level language.  It was developed at sun microsystems by James Gosling.
Fundamental of Java Programming (630002) Unit – 1 Introduction to Java.
Eighth Lecture Exception Handling in Java
Object Oriented Programming in
1. Introduction To JAVA.
Data Types In Text: Chapter 6.
JAVA MULTIPLE CHOICE QUESTION.
BRIEF Overview ON THE MAJOR Similarities & Differences
Chapter 1. Understanding Java
Abstract Data Types and Encapsulation Concepts
Java Programming Language
Review: Two Programming Paradigms
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.
11.1 The Concept of Abstraction
Classes & Objects.
CNIT 133 Interactive Web Pags – JavaScript and AJAX
Introduction Enosis Learning.
Advanced Programming Behnam Hatami Fall 2017.
Introduction Enosis Learning.
Lecture 9 Concepts of Programming Languages
Abstract Data Types and Encapsulation Concepts
Java Programming Language
Conditional Statements
The Building Blocks Classes: Java class library, over 1,800 classes:
Dr. Bhargavi Dept of CS CHRIST
BRIEF Overview ON THE MAJOR Similarities & Differences
Classes and Objects.
Classes, Constructors, etc., in C++
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.
(Computer fundamental Lab)
Java Programming Language
Submitted By : Veenu Saini Lecturer (IT)
SPL – PS2 C++ Memory Handling.
11.1 The Concept of Abstraction
Lecture 9 Concepts of Programming Languages
Chapter 11 Abstraction - The concept of abstraction is fundamental in
Introduction to C CS 3410.
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++ http://java.sun.com 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 ! CIS 068