Java Core Technology Volume I - Chapter 1 Overview of Java Programming

1.1 Java Programming Platform

Java was first released in 1996 and aroused great interest. People paying attention to Java are not limited to the computer publishing world, but also mainstream media such as the New York Times, the Washington Post and Business Week. Java is the only programming language to receive a 10-minute presentation on National Public Radio and receive $100,000,000 in venture capital funding.

1.2 Key terms in the Java white paper

1.2.1 Simplicity

​Compared to C++, Java does not have complex syntax such as pointers, structures, unions, operator overloading (a pity), virtual base classes, etc. It is a new language that is independent of but draws on C++.

In addition, one of the goals of Java is to support software development on small machines. Its basic interpreter and class size is only 40KB, and including the basic standard class library and thread support, it only requires 175KB. Such "smallness" also reflects the simplicity of Java.

1.2.2 Object-oriented

Java object-oriented technology is very mature and on par with C++. And there is no multiple inheritance, replaced by the concept of interface.

1.2.3 Distribution

Java has a rich library of routines for handling network protocols (TCP/IP), making handling network objects as portable as accessing local files.

1.2.4 Robustness

The Java compiler is very smart and can detect many problems that may occur at runtime. Also, since there are no pointers, there are no memory issues.

1.2.5 Security

Java was designed from the ground up to be a language that is resistant to a variety of attacks, including:

  • Runtime stack overflow (a common attack method for worms and viruses)
  • Destroy memory outside of own process space
  • Unauthorized reading and writing of files

Although there are still some bugs encountered during development, Java is trustworthy enough today.

1.2.6 Architecture neutrality

Java innovatively uses a virtual machine mechanism. The compiler generates Java code into bytecode (.class file), and the virtual machine is responsible for running the same effect on different platforms.

Although interpreting virtual machine instructions is certainly much slower than running machine instructions at full speed, the Java virtual machine has an option to convert the most frequently executed bytecode sequences into machine code, a process called just-in-time compilation .

1.2.7 Portability

Java clearly specifies the size and operation of basic data types. For example, int is clearly specified as 32 bits. Unlike in C++, the value of int is a range, that is, it may be 16 bits or 32 bits. This approach eliminates a major difficulty in porting C++ code.

1.2.8 Interpretability

The Java interpreter can directly execute Java bytecode on any machine on which the interpreter has been ported.

​ But compared to interpreted languages ​​​​such as Python, it was not until Java 9 that the jshell tool was provided to support fast interactive programming.

1.2.9 High performance

Today's Java just-in-time compilers are comparable to traditional compilers, and in some cases even surpass traditional compilers in performance.

The main reason is that the just-in-time compiler has more code information and can reasonably optimize the code and improve operating efficiency.

1.2.10 Multithreading

​ From the beginning of its design, Java was proactive in supporting concurrent programming.

1.2.11 Dynamics

Java can add code while running the program, and Java libraries can freely add new methods and instance variables without any impact on the client.

1.3 Java applets and the Internet (*)

1.4 A brief history of Java development

In 1991, a team of Sun engineers planned to design a small computer language "Oak" for use in consumer devices such as cable TV converter boxes. The project was named "Green". Since target devices often have limited computing power and memory, the language must be very small and efficient. In addition, since different manufacturers of equipment choose different central processing units (CPUs), the language also needs to be cross-platform. Later, Sun discovered that there was already another computer language named Oak, so it changed its name to Java.

In 1992, Project Green released its first product "*7", which could provide intelligent remote control. But Sun was not interested in the project, so the Green project team bid on a project to design a cable TV box, but unfortunately failed to get the contract.

In 1993, Project Green changed its name to the "First Person" company and sought a buyer for its technology, but was unable to find one and was disbanded in 1994. At that time, the Internet's World Wide Web was growing, and people mainly used Mosaic, a non-commercial Web browser at the University of Illinois Supercomputing Center. Sun used Java to develop a new browser, HotJava, which can execute embedded Java code in web pages to demonstrate the powerful capabilities of the Java language. It was demonstrated at the SunWorld'95 conference in 1995, triggering people's enthusiasm for Java. chase.

In 1996, Sun released the first version of Java, but Java 1.0 was not well used to complete application development. The later Java 1.1 made up for most of the shortcomings of the first version, greatly improved reflection capabilities, and Adds new content to GUI programming, but still has significant limitations.

In 1998, Java 1.2 version was released at the JavaOne conference, which improved the previous toy-like GUI and graphics toolkit. Only 3 days after its release, Sun changed the name of "Java 1.2" to "Java 2 Standard Edition (JAVA SE) Software Development Kit Version 1.2" to attract attention. In addition to the Standard Edition, Sun has also launched two other editions: the "Micro Edition" (Java ME) for embedded devices such as mobile phones and the "Enterprise Edition" (Enterprise Edition, Java ME) for server-side processing. Java EE). Subsequent versions 1.3 and 1.4 made incremental improvements to Java 2, provided an expanding standard class library, improved performance, and fixed some bugs. Java has gradually become the preferred platform for server-side applications.

In 2004, Java version 1.5 was launched, but it was directly changed to Java 5.0 version after the JavaOne conference that year. Java 5.0 added generic types and, inspired by the C# language, added “for each” loops, autoboxing, and annotations.

In 2006, Java 6 (without suffix .0) was released at the end of the year. This version did not modify the language, but improved performance and enhanced the class library.

In 2009, Sun was acquired by Oracle, and Java development stagnated. Until 2011, Java 7 was released, but only some simple improvements were made.

In 2014, Java 8 was released, adding a "functional" programming method that can easily express calculations that can be executed concurrently.

In 2017, Java 9 was released, implementing the "module" system. This "module" system was first proposed in 2008 and took 11 years to implement. This version also provides some new features.

After 2018, Java will release a new version every six months, and every once in a while, a certain version (Java 11, Java 17) will be designated as a long-term support version, and the intermediate version will provide a way to experiment with new features. mechanism.

​ Table 1-1 shows the evolution of the Java language and class libraries.

Table 1-1 Evolution of Java language and class libraries
Version years new language features Number of classes and interfaces
1.0 1996 language itself 211
1.1 1997 inner class 477
1.2 1998 strictfp modifier (currently deprecated) 1524
1.3 2000 none 1840
1.4 2002 affirmation 2723
5.0 2004 Generic classes, "for each" loops, variadic arguments, autoboxing, metadata, enumerations, static imports 3279
6 2006 none 3793
7 2011 String-based Switch statements, diamond operators, binary literals, and exception handling enhancements 4024
8 2014 Lambda expressions, interfaces with default methods, streams, and date/time libraries 4240
9 2017 Modules, additional language and library enhancements 6005
11 2018 Local variable type deduction (var), HTTP client, removal of Java FX, JNLP, Java EE overlay modules and CORBA 4410
17 2021 Switch expression, text block, instanceof pattern matching, record, sealed class 4859

1.5 Common misconceptions about Java

No misunderstanding, thank you!

Supplement 1: Java terminology abbreviations

  • Java SE:Java Standard Edition

    Standard version of the Java platform for desktop environments.

  • Java EE: Java Enterprise Edition

    Enterprise Edition of the Java Platform for Java-based application servers.

  • Java ME:Java Micro Edition

    A miniature version of the Java platform for mobile, wireless, and resource-constrained environments.

  • SDK:Sofare Develop Kit

    Software development kits are used to help developers improve work efficiency. Different types of software development have their own SDKs.

  • JVM:Java Virtual Machine

    A virtual machine that runs Java bytecode. The JVM has specific implementations for different systems (Windows, Linux, macOS) that aim to use the same bytecode and give the same results.

  • JRE:Java Runtime Environment

    The Java runtime environment is the collection of everything needed to run a compiled Java program. It mainly includes Java Virtual Machine (JVM) and Java Basic Class Library (Class Library).

  • JDK:Java Development Kit

    A full-featured Java SDK is provided for developers to create and compile Java programs. It includes JRE, the compiler javac that compiles Java source code, and some other tools, such as javadoc (document comment tool), jdb (debugger), jconsole (visual monitoring tool based on JMX), javap (decompilation tool) etc.

Guess you like

Origin blog.csdn.net/zheliku/article/details/133187729