What properties make an operator universal
1.3 Properties of Java
Java is an object-oriented programming language that is characterized by a number of central properties. These make them universally applicable and interesting for industry as a robust programming language. Since Java enables object-oriented programming, developers can program modern and reusable software components.
1.3.1 Bytecode and the virtual machine
First of all, Java is a programming language like any other. However, in contrast to conventional translators of a programming language, who usually generate machine code for a special platform (e.g. Linux or Windows) and a specific processor (e.g. for x86 microprocessors or processors of the ARM architecture), the Java compiler generates program code , the so-called bytecode, for a virtual machine. Bytecode is comparable to microprocessor code for an imaginary processor that knows instructions such as arithmetic operations, jumps and more. The Java compiler from Oracle and the Java compiler of the Eclipse development environment are implemented in Java themselves and generate this bytecode (there are also Java compilers in C ++, such as the Jikes compiler [http://tutego.de/go/ jikes]).
So that the program code of the virtual processor can be executed, the runtime environment (also called runtime interpreter), i.e. the Java Virtual Machine (JVM), executes the bytecode after the compilation phase. [The idea of the bytecode (the typesetting program FrameMaker suggests “God's messenger” here as a correction) is already old. The company Datapoint created the programming language PL / B around 1970, which maps programs on bytecode. The original implementation of UCSD-Pascal, which was created around the beginning of 1980, also uses an intermediate code - p-code for short. ] So Java is a compiled, but also interpreted programming language - apart from the hardware method. The virtual machine itself is programmed in C ++, as are some libraries. All of this is quite extensive and includes around 900,000 lines of C ++ code. [http://llvm.org/devmtg/2009-10/Cifuentes_ParfaitBugChecker.pdf]
Optimization and just-in-time compilation
The pure interpretation naturally causes speed problems, since recognizing, decoding and executing the commands takes time. Java programs of the first hour were significantly slower than compiled C (++) programs. The technology of just-in-time (JIT) compilers [This idea is also old: around 1970 HP had JIT compilers for BASIC machines. ] solved the problem. A JIT compiler accelerates the execution of the programs by translating the program instructions of the virtual machine into machine code for the respective platform at runtime. A program adapted to the architecture is then stored in the memory, which the physical processor executes quickly without interpretation. With this technique, the speed is the same as that of other translated languages.
Java on a chip
In addition to a runtime environment that interprets the Java bytecode and translates it into the machine code of a host system, a processor was also designed that executes bytecode in the hardware. At that time, the development came from Sun, and one of the first processors was PicoJava. When developing the processor, the focus was not on maximum speed, but rather on the cost per chip in order to be able to install it in every household appliance. The interest in Java on a chip is now picking up again after a lull, because many mobile devices want to be supplied with fast execution units.
The ARM technology of the company ARM Limited allows a very fast execution of Java bytecode through Jazelle DBX. With the processor S5L8900, Samsung has cast the ARM technology ARM1176JZ (F) -S together with memory interfaces and parts for connectivity, peripherals and multimedia options in silicon, and as a 667 MHz processor it is now in Apple's iPhone. The irony of fate is that Apple has not yet provided Java support in the iPhone.
The aJ-100 from aJile Systems Inc. is another processor. And if we can believe the press releases from Azul Systems [http://www.azulsystems.com/], there will soon be a 64-bit processor with 48 cores that executes Java and .NET bytecode. A double heart is also good for Java.
1.3.2 Object orientation in Java
The Java language is not object-oriented to the last detail, as Smalltalk demonstrates in an exemplary manner. Primitive data types such as integers or floating point numbers are not managed as objects. The reason for this design was probably that the compiler and the runtime environment were better able to optimize the programs with the separation. However, the Microsoft virtual machine for the .NET platform clearly shows that good performance is possible even without the separation.
Java was designed as a language that should make it easy to write bug-free software. From a statistical point of view, an error awaits us in C programs every 55 program lines. Even in large software packages (from one million lines of code), regardless of the underlying programming language, an error occurs on average every 200 program lines. It goes without saying that these errors must be corrected, although a comprehensive strategy for large-scale software development has not yet been found. Much of the work in computer science deals with the question of how thousands of programmers can work together over decades and design software. This problem is not easy to solve and was hotly debated in the wake of the software crisis in the 1960s.
1.3.3 The Java security model
The Java security model ensures that the program runs securely on various levels. The verifier reads code and checks the structural correctness and type safety. If the bytecode already has errors, the program code will not even be executed. The check is important because a class loader can load class files from anywhere. While the bytecode from the local drive may be trusted, this may not apply to code transmitted over an unsecured network where a third party suddenly inserts malicious code in the middle. If the bytecode is correctly registered in the virtual machine, further checks follow. For example, read / write access to private variables is not possible (with the appropriate adaptation). If security problems occur, these are reported by exceptions at runtime - for example, there are no buffer overflows. At the program level, a security manager monitors access to the file system, network ports, external processes and other system resources. The security model can be expanded by the programmer and can be easily configured using configuration files.
1.3.4 Pointers and References
In Java there are no pointers as they are known and feared from other programming languages. Since an object-oriented programming language does not work without references, references are introduced. A reference represents an object, and a variable stores that reference. The reference is of a type that cannot change. A car remains a car and cannot be addressed as a lamination system. A reference under Java is not to be understood as a pointer to memory areas.
Example The following program shows that messing around in C ++ is easy and we can get access to private elements using pointer arithmetic. For us Java programmers, this is a daunting example.
This example demonstrates how problematic the use of pointers can be. The pointer badguy, initially intended as a reference to the VeryUnsafe class, mutates into a char pointer pass due to the explicit type conversion. The characters can easily be read out of the memory byte by byte via this. This also allows indirect access to private data.
In Java it is not possible to access any part of the memory. Private variables are also safe for the time being. [That is not entirely true, however. With Reflection, something can be done if the security settings don't prevent it. ] The compiler aborts with an error message - or the runtime system throws an exception - if the program tries to access a private variable.
1.3.5 Take out the garbage, garbage collector!
In programming languages such as C ++, around half of the errors can be traced back to incorrect memory allocation. Working with objects inevitably means creating and deleting them. However, the Java runtime environment takes care of the management of these objects independently - the consequence: They do not have to be released, a garbage collector (GC for short) removes them. The GC is part of the Java runtime system. Generating an object in a block followed by an operation causes the GC to clean up. After leaving the effective area, the system recognizes the no longer referenced object. Another advantage of the GC: When subroutines are used, objects are often returned, and in conventional programming languages the discussion then begins again as to which part of the program must now delete the object or whether it is just a reference. In Java this does not matter, even if an object is only the return value of a method (anonymous object).
The GC is a concurrent thread in the background that marks unreferenced objects and removes them from time to time. The garbage collector thus makes the functions free () from C or delete () from C ++ superfluous. We can be happy about this technique because many problems have disappeared with it. Unreleased memory areas exist in every major program, and wrong destructors are often responsible for this. At this point it should not be overlooked that there are also similar techniques for C (++). [A well-known garbage collector comes from Hans-J. Boehm, Alan J. Demers, and Mark Weiser. It can be found at http://tutego.de/go/boehmgc. However, the algorithm works conservatively, which means that it is not guaranteed to find all unreachable memory areas, but only some. The Boehm-Demers-Weiser-GC is used in the X11 library, among other things. There the malloc () and free () functions have simply been replaced by new methods. ]
1.3.6 Exception Handling
Java supports a modern system for dealing with runtime errors. Exceptions were introduced in the programming language: Objects that are generated at runtime and display an error. These problem areas can be encapsulated by program constructs. In many cases, the solution is cleaner than the one with return values and illegible expressions in the program flow. In C ++ there are also exceptions, but they are not used as intensively as in Java.
For speed reasons, C (++) checks [In C ++ a variant could be solved with an overloaded operator. ] by default, the array limits (range checking) are not, which is a cause of many security problems. Incorrect access to element n + 1 of a field of size n can cause two things: an access error occurs or, much worse, other data is overwritten during write access and the error can no longer be traced.
The Java runtime system automatically checks the boundaries of an array. This monitoring cannot be switched off, as compilers of other programming languages sometimes allow. A clever runtime environment finds out whether it cannot be exceeded and then optimizes this query away; Field reviews are therefore no longer costly and do not automatically result in poorer performance.
1.3.7 No preprocessor for text replacement
Many C (++) programs contain preprocessor directives such as #define, #include or #if for integrating prototype definitions or for conditional compilation. There is no such preprocessor in Java for various reasons:
- Header files are not necessary in Java because the compiler reads the required information such as method signatures directly from the class files.
- Since the data types in Java have a fixed, always the same length, there is no need to define different lengths depending on the platform.
- Pragma controls are unnecessary in the program code, since the virtual machine optimizes the program without external control.
Without the preprocessor, dirty tricks like #define private public or macros that generate errors through double evaluation are excluded from the start. The private / public hack can also be found in the source code of StarOffice. The definition above replaces every occurrence of private with public - with the consequence that the access protection is bypassed.
Conditional compilation with #ifdef is no longer possible without a preprocessor. In Java, within statement blocks, we can make do with formulating conditions of the type if (true) or if (false); Variables can be introduced using the -D switch on the command line, which can then be checked by an if statement using System.getProperty () at runtime. [But since preprocessor instructions for different devices are particularly useful for mobile devices, there are manufacturer extensions such as those from NetBeans (http://tutego.de/go/nbpreprocessor). ]
1.3.8 No user-defined overloaded operators
When we use an operator like the plus sign and add expressions with it, we usually do this with well-known arithmetic variables such as floating point numbers or integers. Since the same operator character is valid for different data types, such an operator is called "overloaded". Operators such as +, -, *, / are overloaded for integers and floating point numbers, as are the operators or, and or Xor for integers and Boolean values. The comparison operator == or! = Is also overloaded, because it can be used for all numbers, but also for truth values or object references. A conspicuous overloaded operator is the plus sign in character strings. Strings can easily be put together with it. Computer scientists like to use the word concatenation in this context (rarely catenation). With the strings "Hello" + "" + "du da", "hello you da" is the concatenation of the character strings.
Some programming languages allow the existing operators to be given new meanings. This is not possible in Java. Operator overloading is allowed in C ++, so that the plus sign can be used to add geometric point objects, split fractions or write a line to a file. If the objects represent mathematical constructs, it is very practical if operations are named using short operator characters and not using longer methods - a matrix1.add (matrix2) is more bulky than a matrix1 + matrix2. Although user-overloaded operators can be useful at times, the option is often misleading. Therefore it is not yet possible to overload the operators in Java, but some alternative languages on the JVM allow this, because it is a language restriction and not a restriction of the virtual machine.
1.3.9 Java as language, runtime environment and standard library
Java is not only a programming language, but also a runtime system, which Oracle wants to clarify with the term »Java Platform«. In addition to the Java programming language, there are other languages that run a Java runtime environment, such as various scripting languages such as Groovy (http://groovy.codehaus.org/), JRuby (http://jruby.org/), Jython ( http://www.jython.org/) or Scala (http://www.scala-lang.org/). Scripting languages on the Java platform are becoming increasingly popular; they establish a different syntax but use the JVM and the libraries.
In addition to the programming language and JVM, there is a set of standard libraries for graphic interfaces, input / output and network operations. This forms the basis for higher-quality services such as database connections or web services. Threads are still an integral part of the standard library since Java 1.0. They are easy-to-generate threads that can work independently of one another. All popular operating systems now support these "lightweight processes" out of the box, so that the JVM does not have to reproduce these parallel program parts, but can refer to the operating system. With the new multi-core processors, the operating system ensures optimal utilization of the computing power, since threads can really work concurrently.
Commercial or open source libraries are then added to the standard libraries. No matter whether it is a question of writing PDF documents, reading Excel documents, transferring data to SAP or controlling the ejection of money at a Wincor ATM, there are Java libraries for all of this.
1.3.10 Java is open source
The source code of the standard libraries has been around since Java 1.0 (if it was installed with the JDK, it is in the root directory under the name src.zip), and anyone interested could take a look at the implementation. Sun disclosed the implementations at the time, but neither the runtime environment, nor the compiler, or the libraries were under an accepted open source license. Ten years since the first release of Java, there have been demands on Sun to place the entire Java platform under a more well-known form of license such as the GNU General Public License (GPL) or the BSD license. Jonathan Schwartz already hinted at the 2006 JavaOne conference in San Francisco: "It's not a question of whether we'll open source Java, now the question is how." , Rich Green announced the final release of Java as OpenJDK [http://openjdk.java.net/] under the open source license GPL 2 at the opening speech of the JavaOne conference in May 2007. This was preceded by the release of the compiler and the virtual machine at the end of 2006.
The story is a little more complicated than that, however. Although OpenJDK was now under the GPL, it still contained parts such as the font renderer, sound support, color management, and SNMP code, which were included as binary packages because, for example, the rights to publish were missing. Sun calls these parts, which make up about 4% of JDK 6, "encumbered code" [http://www.sun.com/software/opensource/java/faq.jsp#h]. This prevented puristic Linux distributors from delivering OpenJDK. RedHat then published the IcedTea project in June 2007 to replace these binary parts with GPL software based on the OpenJDK. For example, the font renderer is based on FreeType [http://www.freetype.org/] and the color management on little CMS [http://www.littlecms.com/]. With these replacements, the OpenJDK with IcedTea fulfilled the Technology Compatibility Kit (TCK) in June 2008. Thereupon the OpenJDK 6 plus the replacements flowed under the GPLv2 in Linux distributions like Fedora and Debian.
The OpenJDK forms the basis of Java 7, and every developer can put together their own Java and publish any extensions. This means that Java can also find space on Linux distributions that Java previously did not want to integrate for licensing reasons.
1.3.11 What is Java less suitable for
Java was designed as a programming language for general problems and covers large areas of application (general-purpose language). However, this also means that there are significantly better programming languages for a sufficient number of applications, for example in the area of scripting, where the property that every Java program requires at least one class and method is rather annoying, or in the area of automated word processing, where other programming languages can work more elegantly with regular expressions.
Even when there are extremely machine and platform-dependent requirements, it becomes cumbersome in Java. Java was designed to be platform-independent so that all methods should be able to run on all systems. Properties that are very close to the system, such as the clock frequency, are not visible, and manipulations that pose security problems such as access to certain memory cells (the PEEK and POKE) are also prohibited. Here is a far incomplete list of things that Java cannot do by default:
- Clear screen on the text console, position cursor and set colors
- access low-level network protocols such as ICMP
- Control Microsoft Office remotely
- Access to USB [Actually there should be support for the Universal Serial Bus, but here - as unfortunately also elsewhere - Sun has not pursued the JSR-80: Java USB API project any further. ] or Firewire
From the disadvantages mentioned, that Java cannot access the hardware, it follows that the language cannot easily be used for system programming. Driver software that addresses graphics, sound or network cards can only be implemented in Java indirectly. Exactly the same applies to access to the general functions of the operating system provided by Windows, Linux or another system. Typical system programming languages are C (++) or Objective-C.
As a result of these limitations, Java cannot replace a low-level language such as C (++). But the language doesn't have to either! Each language has its preferred terrain, and Java is a general application programming language; C (++) can still be used for hardware drivers and Java virtual machines.
If a Java program is still to use system-related properties - and it can do this with the corresponding libraries without problems - a native call to a system function is an option. Native methods are subroutines that are not implemented in Java, but in another programming language, often C (++). In some cases, an external program can also be called up and, for example, manipulated the Windows registry or set file permissions. But it always boils down to the fact that the solution has to be implemented anew for each platform.
1.3.12 Java compared to other languages
If developers are concerned with the design of programming languages, existing language properties are often checked for their suitability and then incorporated into the concept. Java is also an evolving language that shares features of other languages.
Java and C (++)
The syntax of Java is heavily based on C (++), for example in terms of data types, operators and brackets, but has not adopted all properties. In the historical chain, Java is often seen as the successor to C ++ (and as the predecessor of C #), but the programming language deliberately avoids problematic constructs such as pointers.
The class concept - and thus the object-oriented approach - was not insignificantly inspired by SIMULA and Smalltalk. The interfaces, which offer an elegant way of class organization, are based on Objective-C - there they are called Protocols. While Smalltalk manages all objects dynamically and in C ++ the compiler statically combines classes into one program, Java mixes dynamic and static binding in a very elegant way. The JVM loads all classes - optionally also from another computer via the network - at runtime. Even method calls are possible over the network. [This option is known as RMI (Remote Method Invocation). Certain objects can communicate with one another over the network. ] All in all, it can be said that Java adopts well-known and proven concepts and the language certainly does not represent a revolution; modern script languages are more advanced and also adopt concepts from functional programming languages.
Java and C # /. NET
Since C # appeared shortly after Java and after a dispute between Microsoft and Sun and the languages were syntactically very similar at the beginning, it could easily be assumed that Java is the godfather of the C # programming language They only ever talk about the fact that C # had other languages such as C ++, VB and Delphi as models. ] was standing. But that is a long time ago. In the meantime, C # has developed such a strong momentum that Microsoft's programming language is much more innovative than Java. C # has become complex over the years, and Microsoft integrates elements into the programming language without a major coordination process, where in the Java world a huge number of people first discuss and vote. At times it gives the impression that Java can finally do what C # offers. Seen in this way, Java today benefits from the experience of the C # world.
While Oracle divides Java into Java SE for the "general" programs and Java EE as an extension for the "large" enterprise systems, everything at Microsoft flows into one framework. The .NET framework is of course larger than the Java framework, since everything that Windows has to offer can be programmed with .NET. This property is particularly noticeable in the GUI area, and the platform-independent Java is less useful. If it weren't for platform independence, it wouldn't really matter which programming language large systems were developed in. Mono is an interesting alternative to the Microsoft .NET development and runtime environment, but patent uncertainty discourages many companies from large-scale use of Mono. It can be said somewhat cynically that Java may only be alive because Microsoft wants to make Windows attractive, but does not want to strengthen other platforms by placing C # and the .NET Framework under an open source license and the runtime environment on different ones Platforms. Cheers to industrial policy! With Silverlight, however, Microsoft has released a kind of slimmed-down .NET on different systems, and it is exciting to see what implications this will have for the development of client applications.
1.3.13 Java and the Web, applets instead of apples
Although applets are perfectly normal Java programs, there are understandably some limitations. Unless they are signed, applets are not allowed to access the file system and delete any files, which Java applications can do without any problems.
Netscape was one of the first companies to integrate a Java interpreter into their web browser. Today every browser offers Java support, often also through Oracle's help, which integrates the latest Java versions into the browser with the Java plug-in. Without the Java plug-in, the support would look different. Internet Explorer (IE) from Microsoft, for example, accepts applets, but with MS's own JVM it does not go beyond version 1.1.4. Oracle patches diligently here in order to always be able to offer the most current and secure Java versions on all popular browsers.
Java on the server side instead of the client side and in the browser
Although Java has become known through the web and there are many areas of application there, it is not limited to this medium. Many companies discover their affection for this language and can no longer break away from it - IBM among them. It has been shown that the motto "write once, run anywhere" (WORA) largely applies on the server side. Java is now probably the most important language for the design of Internet applications on the server. It supports structured and object-oriented programming and is ideal for larger projects in which the uncertainties of C ++ should be avoided.
After the initial hype, it is now paradoxically often said that Java is too slow for client applications. The virtual machines have become much faster in recent years due to the development of JIT compilers and hotspot technology. The speed of the processors has also continued to grow. Applications such as development environments written in Java show that programs can also run at a reasonable speed on the client side - assuming a correspondingly large amount of RAM. Java is at least as demanding as new, colorful operating systems from MS.
RIA with JavaFX
1.3.14 Features, Enhancements and a JSR
Java is growing from version to version, so there are regular major increases in the libraries as well as well-proportioned changes to the language and minimal changes to the JVM. Changes to the Java SE platform are categorized into features and enhancements. An enhancement is a small change that is not worth mentioning - for example, a small function such as isEmpty () is added to the String class. These extensions do not require much coordination and planning and are simply integrated by Oracle employees.
Features, on the other hand, are a bit bigger in terms of implementation effort. Or the community urgently expects this functionality - it makes this clear by placing a feature request on Oracle's website and many votes for this feature. Another specialty is how many of these features are planned. Often a JSR (Java Specification Request) arises, which prescribes a certain sequence during planning. Most of the changes to the libraries are described in a JSR, and there are now hundreds of JSRs.
1.3.15 Development of Java and future prospects
In general, a book about Java should have a positive mood and shouldn't scare readers off with apocalyptic scenarios. But there are some indications that Java as a programming language will not develop much and will rather go into a "maintenance mode". Part of the success of the language is that it was much easier to learn than its predecessor, C ++, and that it avoided "dangerous" syntactic constructs (although there were still a few points left). One of the language fathers, James Gosling - who left the company after Sun was taken over by Oracle - wrote as early as 1997:
»Java is a working language. It is not the product of a doctoral thesis, but a language for a job. Java feels very familiar to many programmers, because I tend to have a strong tendency towards things that have already been used a lot compared to things that sounded more like a good idea. "[Originally:" Java is a blue collar language. It's not PhD thesis material but a language for a job. Java feels very familiar to many different programmers because I had a very strong tendency to prefer things that had been used a lot over things that just sounded like a good idea. «(Http://www.computer.org/portal/web/ csdl / doi / 10.1109 / 2.587548)]
This attitude has remained to this day. Java should just stay simple, even if the other programming languages around Java have syntactic features that make every compiler builder sweat. There were only significant language changes in Java 5 (about ten years after its introduction), and for Java 7 the language changes had to remain small. Therefore there are no big hits in Java 7, but features that would provoke a shrug in other languages. As an example, it should be mentioned that underscores are allowed in numbers, which increase readability. Instead of 123456 it can then be called 12_34_56.
With the trinity of the Java platform - Java as the programming language, the standard libraries and the JVM as the runtime environment - it can be seen that there is great movement in the different programming languages on the Java runtime environment. It is becoming apparent that Java developers will continue to develop in Java, but will also use a second programming language on the JVM. This can be Groovy, Scala, Jython, JRuby, or any other JVM language. Because the alternative programming languages are based on the JVM, they can use all Java libraries and therefore replace Java as the programming language in some areas. The fact that the alternative languages use the usual standard libraries works smoothly, but the opposite way, that for example Scala libraries from Jython, is not (yet) standardized. This works better with the .NET platform, and here it really doesn't matter whether C # or VB.NET classes are declared or used.
When the acquisition of Sun was near, Oracle was very committed to Sun technologies. After the takeover, the picture has changed a bit, and Oracle made more negative headlines, for example when it stopped supporting OpenSolaris. In terms of information policy and support for user groups, Oracle behaves very differently from Sun. For a long time there were no reliable statements about Java 7, and Oracle made no friends with the lawsuit against Google over Android.
your commentHow did you like the
- How does burning coal generate electricity?
- Where can I buy paws in America
- Word means compound boundaries
- Why does mouth breathing cause dental problems
- Why did Ronaldinho withdraw from football?
- Can life and relationships really be defined
- How do you run a business plan?
- What happened to replaceable batteries in smartphones
- What causes black corners in an image
- Can chess help you train the brain
- What are the best security apps for smartphones
- Are LiteSpeed servers really faster than Apache
- Why did Ashwatthama try to kill Parikshit
- What's a great way to share recipes
- There is a test question to answer
- What's your wow moment in PUBGM
- Why do people go to singers concerts
- What DJ software does Avicii
- Where can I learn printf
- What does this emoji U0001f60b
- Singing helps against throat cancer
- Are Belgians and the Quebecois are French
- What are examples of environmental influences
- What is the electroweak vacuum