Java attracts on a few years of programming expertise with different languages in its alternative of features it has. it’s worth taking time to compare Java at a high level with another programming languages, each for the advantage of those of you with different programming expertise and for the newcomers. We do not expect you to have a knowledge of any particular programming language in this book and when we refer to other languages by way of comparison, we hope that the comments are self-explanatory.
At least three (3) pillars area unit necessary to support a universal programming language today: portability, speed, and security.
You may have detected that Java could be a ton like C or C++, however that’s extremely not true except at a superficial level. after you first investigate and loon Java code, you will find that the essential syntax are like C or C++. however that’s wherever the similarities finish. Java is by no means that an immediate descendant of C or a next-generation C++. If you compare language options, you’ll see that Java really has additional in common with extremely dynamic languages like Smalltalk and Lisp. In fact, Java’s implementation is regarding as off from native C as you’ll be able to imagine.
If you’re accustomed/familier to the current language landscape, you’ll notice that C#, a popular language, is missing from this comparison. C# is basically Microsoft’s answer to Java, true with variety of niceties stratified on prime. Given their common style goals and approach (e.g., use of a virtual machine, bytecode, sandbox, etc.), the platforms don’t dissent well in terms of their speed or security characteristics. C# is in theory as transportable as Java, however so much|thus far|up to now|to this point} it’s supported on far fewer platforms. Like Java, C# borrows heavily from C syntax however is actually a more in-depth relative of the dynamic languages. Most Java developers realize it comparatively simple to select up C# and contrariwise. the bulk of your time spent moving from one to the opposite is learning the quality library.
The surface-level similarities to those languages area unit price noting, however. Java borrows heavily from C and C++ syntax, thus you’ll see laconic language constructs, as well as associate degree abundance of crisp braces and semicolons. Java subscribes to the C philosophy that an honest language ought to be compact; in different words, it ought to be sufficiently tiny and regular thus a software engineer will hold all the language’s capabilities in his or her head right away. even as C is protrusible with libraries, packages of Java categories will be additional to the core language elements to increase its vocabulary.
C has been winning as a result of it provides a fairly feature-packed programming atmosphere, with high performance and an appropriate degree of movability. Java additionally tries to balance practicality, speed, and movability, however it will thus in an exceedingly} very totally different means. C trades practicality for movability; Java ab initio listed speed for portability. Java additionally addresses security problems that C doesn’t (although in fashionable systems several of these issues area unit currently self-addressed within the OS and hardware).
In the period before JIT and adaptational compilation, Java was slower than statically compiled languages and there was a continuing refrain from detractors that it might ne’er catch up. however as we tend to delineated within the previous section, Java’s performance is currently admire C or C++ for equivalent tasks and people criticisms have usually fallen quiet. ID Software’s open supply Quake2 computer game engine has been ported to Java. If Java is quick enough for first-person combat video games, it’s definitely quick enough for business applications.
Scripting languages like Perl, Python, and Ruby area unit very fashionable. There’s no reason a scripting language can’t be appropriate for safe, networked applications. however most scripting languages aren’t compatible for serious, large-scale programming. The attraction to scripting languages is that they’re dynamic; they’re powerful tools for fast development. Some scripting languages like Perl additionally offer powerful tools for text-processing tasks that additional all-purpose languages realize unwieldy. Scripting languages are extremely transportable, albeit at the ASCII text file level.
The problem with scripting languages is that they’re rather casual regarding program structure and knowledge writing. Most scripting languages (with a hesitant exception for Python and later versions of Perl) aren’t object-oriented. They even have simplified kind systems and usually don’t offer for classy scoping of variables and functions. These characteristics build them less appropriate for building giant, standard applications. Speed is another drawback with scripting languages; the high-level, typically source-interpreted nature of those languages typically makes them quite slow.
Java offers a number of the essential blessings of a scripting language: it’s extremely dynamic, along side the additional advantages of a lower-level language. Java includes a powerful Regular Expression API that competes with Perl for operating with text and language options that contour secret writing with collections, variable argument lists, static imports of strategies, and different syntactical sugar that build it additional crisp.
Incremental development with object-oriented elements, combined with Java’s simplicity, build it doable to develop applications apace and alter them simply. Studies have found that development in Java is quicker than in C or C++, strictly supported language options. Java additionally comes with an outsized base of ordinary core categories for common tasks like building GUIs and handling network communications. however along side these options, Java has the measurability and software-engineering blessings of additional static languages. It provides a secure structure on that to create higher-level frameworks (and even different languages).
As we’ve already aforementioned, Java is comparable in style to languages like Smalltalk and Lisp. However, these languages were used principally as analysis vehicles instead of for development of large-scale systems. One reason is that these languages ne’er developed a typical transportable binding to OS services, like the C customary library or the Java core categories. Smalltalk is compiled to associate degree taken bytecode format, and it will be dynamically compiled to native code on the fly, a bit like Java. however Java improves on the look by employing a bytecode protagonist to confirm the correctness of compiled Java code. This protagonist provides Java a performance advantage over Smalltalk as a result of Java code needs fewer runtime checks. Java’s bytecode protagonist additionally helps with security problems, one thing that Smalltalk doesn’t address.
Throughout the remainder of this chapter, we’ll gift a bird’s-eye read of the Java language. We’ll make a case for what’s new and what’s not-so-new regarding Java and why.