Why is Java called a safe language

Java programming language

Java is an object-oriented programming language and registered trademark of Sun Microsystems, which was taken over by Oracle at the end of January 2010. The programming language is part of Java technology.

Java programs are translated into bytecode and then run in a special environment called the Java runtime environment or platform. Its most important component is the Java Virtual Machine (Java VM), which executes the programs by interpreting the bytecode and compiling it if necessary (hotspot optimization).

Java programs are platform-independent, which means that they usually run without further adjustments on different computers and operating systems for which a Java VM exists. Sun itself offers Java VMs for the Linux, Solaris and Windows operating systems. Other manufacturers have their Java VM certified for their platform, for example Apple for MacOS X.

In Java, porting is usually used when the source code or bytecode is to be adapted to the status of another Java version. Most of the time, Java programs are only tested or certified for certain Java versions.

Basic concept [edit | Edit source]

The design of the Java programming language essentially aimed at five goals: [4] [5]

  • It should be a simple, object-oriented, distributed and familiar programming language.
  • It should be robust and safe.
  • It should be architecture-neutral and portable.
  • It should be very efficient.
  • It should be interpretable, parallelizable and dynamic.

Simplicity: Compared to other object-oriented programming languages ​​such as C ++ or C #, Java is simple because it has a reduced language scope and does not support, for example, operator overloading, pointers and multiple inheritance.

Object orientation: Java is one of the object-oriented (OO) programming languages.

Distributedity: Java's class library offers a number of simple options for network communication, from TCP / IP protocols to remote method invocation to web services.

Familiarity: Because of the syntactic proximity to C ++, the original similarity of the class library to Smalltalk class libraries and the use of design patterns in the class library, Java does not show any unexpected effects for the experienced programmer / developer.

Robustness: Many of the design decisions when defining Java reduce the likelihood of unwanted system errors: These include strong typing, garbage collection, references instead of pointers, exception handling.

Security: This is represented by concepts such as the code verifier, which ensures that the JVM cannot execute any invalid bytecode, the class loader, which controls the secure supply of class information to the JVM, and security managers, which ensure that only program objects are accessed is allowed for which the corresponding rights are available.

Architecture neutrality: Java was developed in such a way that the same version of a program basically runs on any hardware, regardless of its processor or other hardware components.

Portability: In addition to being architecture neutral, Java is also portable. This means that primitive data types are standardized in their size and internal representation as well as in their arithmetic behavior. For example, a float is always an IEEE 754 float of 32 bits. The same applies to the class library, which, for example, can generate the same GUI (graphical user interface) regardless of the operating system.

Efficiency: Java is one of the most efficient programming languages, especially due to the dynamic optimizations of the virtual machine, and delivers speeds similar to C ++ or C # programs.

Interpretability: Java is an interpretable language. The Java Virtual Machine also interprets Java bytecode before it compiles and optimizes it for performance reasons.

Parallelism: Java supports multithreading, i.e. the parallel running of independent program sections. In addition, the language itself offers the keywords synchronized and volatile - constructs that the "Monitor & Condition Variable Paradigm" by C.A.R. Support Hoare [6]. The class library contains additional support for parallel programming with threads.

Dynamics: Java is structured in such a way that it can be adapted to dynamically changing framework conditions. Since the modules are only linked at runtime, parts of the software (e.g. libraries) can be delivered again, for example, without having to adapt the remaining program parts. Interfaces can be used as the basis for communication between two modules, but the actual implementation can be changed dynamically and, for example, also during runtime.

Features of the language [edit | Edit source]

Object access in Java is implemented using references. For security reasons it is not possible to modify their memory address. So-called pointer arithmetic is excluded with the language. By design, a common type of error that occurs in other programming languages ​​can be excluded from the outset.

Associated classes are combined in packages. These packages make it possible to restrict the visibility of classes, structure larger projects and separate the namespace for different developers. The package names are structured hierarchically and usually begin with the (reverse) Internet domain name of the developer. (Packages that are created by Sun, for example, begin with "com.sun.") Class names only need to be unique within a package. This makes it possible to combine classes from different developers without causing name conflicts. However, the hierarchy of the package names has no semantic meaning. In terms of visibility between the classes of two packages, it does not matter where the packages are in the name hierarchy. Classes are either only visible for classes in their own package or for all packages.

The language also supports threads (concurrently running program parts) and exceptions. Java also includes an automatic garbage collector, which removes objects that are no longer referenced from the memory.

Java makes an explicit distinction between interfaces and classes. A class can implement any number of interfaces, but always has exactly one base class. Java does not support direct inheritance from several classes (so-called "multiple inheritance"), but inheritance across several hierarchy levels (class child inherits from class father, which in turn inherits from class grandfather, etc.). Depending on the visibility (public, protected, default / package-private, private) the class inherits methods and attributes (also called fields) from its class ancestors. All classes are - directly or indirectly - derived from the root class Object.

An extensive class library belongs to Java. The programmer is thus offered a uniform interface (application programming interface, API) that is independent of the underlying operating system.

With Java 1.2, the Java Foundation Classes (JFC) were introduced, which provide Swing, among other things, which is used to generate platform-independent graphical user interfaces (GUI) and is based on AWT.