1.1 Java as a Programming Platform
- Java is not only a programming language, but also a platform
1.2 The Java "White Paper" Buzzwords
- Simple
- Compared to C++
- Small: 40k for the size of the basic interpreter and class support; 175k for the basic standard libarries and thread support
- Object-Oritented
- Comparable to C++
- The major difference between Java and C++ lies in multiple inheritance, which Java has replaced with a simpler concept of interfaces
- Distributed
- Java has an extensive library of routines for coping with TCP/IP protocols like HTTP and FTP
- Robust
- Java puts a lot of emphasis on early checking for possible problems, later dynamic checking, and eliminating situations that are error-prone
- The single biggest difference between Java and C/C++ is that Java has a pointer model that eliminates the possibility of overwriting memory and corrupting data
- Secure
- Architecture-Neutral
- The complier generates an architecture-neutral object file format. The complied code is executable on many processors, given the presence of the Java runtime system
- Q: What is the role of virtual machine in enabling the Architecture-Neutral feature in Java?
- Portable
- The size of primitive data type in Java is fixed
- Binary data is stored and transmitted in a fixed format, eliminating confusion about byte ordering
- Strings are saved in a standard Unicode format
- Interpreted
- Java interpreter can execute Java vytecodes directly on any machine to which the interpreter has been ported
- Q: What is the role of linking in enabling the Interpreted feature in Java?
- High-performance
- A "just-in-time" compiler have become so good that they are competitive with traiditonal compilers
- Q: What is the difference between "just-in-time" compilers and traditional compilers?
- Multithreaded
- Java is the first mainstream language to support concurrent programming
- Dynamic
- Libraries can freely add new methods and instance variables without any effect on their clients
1.3 Java Applets and the Internet
- Applets: Java programs that work on web pages are called applets; to use an applet, you only need a Java-enabled web brower
1.4 A Short History of Java
- Java was first released in 1996
- Java goes back to 1991, when a group of Sun engineers, led by Patrick Naughton and James Gosling, wanted t odesign a small computer language that could be used for consuer devices like cable TV switchboxes
- The Sun people came from a UNIX background, so they based their language on C++
- The Green Project
1.5 Common Misconceptions about Java
- Java is an extension of HTML -> Java is a programming language; HTML is a way to describe hte structure of a web page
- I use XML, so I don't need Java -> Java is a programming language; XML is a way to describe data. You can process XML data with any programming language, but Java API contains excellent support for XML processing
- Java is proprietary, and should therefore be avoided -> When Java was first created, Sun gave free licenses to distribute and end users
- Java is interpreted, so it is too slow for serious applications -> In the early days of Java, the langauge was interpreted. Nowadays, the Java virtual machine uses a just-in-time compiler.