Advantages of Java

   

Core Java™ 2: Volume I - Fundamentals
By Cay S. Horstmann, Gary Cornell
Table of Contents
Chapter 1.  An Introduction to Java


One obvious advantage is a runtime environment that provides platform independence: you can use the same code on Windows, Solaris, Linux, Macintosh, and so on. This is certainly necessary when programs are downloaded over the Internet to run on a variety of platforms.

Another programming advantage is that Java has a syntax similar to that of C++, making it easy for C and C++ programmers to learn. Then again, Visual Basic programmers will probably find the syntax annoying.

graphics/notes_icon.gif

If you are coming from a language other than C++, some of the terms used in this section will be less familiar just skip those sections. You will be comfortable with all of these terms by the end of Chapter 6.

Java is also fully object oriented even more so than C++. Everything in Java, except for a few basic types like numbers, is an object. (Object-oriented programming has replaced earlier structured techniques because it has many advantages for dealing with sophisticated projects. If you are not familiar with Object-oriented programming, Chapters 3 through 6 provide what you need to know.)

However, having yet another, somewhat improved, dialect of C++ would not be enough. The key point is this: It is far easier to turn out bug-free code using Java than using C++.

Why? The designers of Java thought hard about what makes C++ code so buggy. They added features to Java that eliminate the possibility of creating code with the most common kinds of bugs.

  • The Java designers eliminated manual memory allocation and deallocation.

    Memory in Java is automatically garbage collected. You never have to worry about memory corruption.

  • They introduced true arrays and eliminated pointer arithmetic.

    You never have to worry about overwriting an area of memory because of an off-by-one error when working with a pointer.

  • They eliminated the possibility of confusing an assignment with a test for equality in a conditional statement.

    You cannot even compile if (ntries = 3). . . . (Visual Basic programmers may not see the problem, but, trust us, this is a common source of confusion in C/C++ code.)

  • They eliminated multiple inheritance, replacing it with a new notion of interface that they derived from Objective C.

    Interfaces give you most of what you want from multiple inheritance, without the complexity that comes with managing multiple inheritance hierarchies. (If inheritance is a new concept for you, Chapter 5 will explain it.)

graphics/notes_icon.gif

The Java language specification is public. You can find it on the Web at http://java.sun.com/docs/books/jls/html/index.html.


       
    Top
     



    Core Java 2(c) Volume I - Fundamentals
    Building on Your AIX Investment: Moving Forward with IBM eServer pSeries in an On Demand World (MaxFacts Guidebook series)
    ISBN: 193164408X
    EAN: 2147483647
    Year: 2003
    Pages: 110
    Authors: Jim Hoskins

    flylib.com © 2008-2017.
    If you may any questions please contact us: flylib@qtcs.net