What is Java Programming: The History and ImpactJava is a general-purpose programming language that follows the object-oriented programming paradigm and the Write Once Run Anywhere approach. Java is used for desktop, web, mobile, and enterprise applications. You can out find more about it here:
- Java downloads
- Java documentation
- Oracle Java community
- JavaWorld - popular portal for all things Java
- JavaRanch - forums for Java developers
Java Development Kit (JDK) - with that and a standard Notebook app you can write and run/compile Java code
Java Runtime Environment (JRE) - software distribution tool containing a stand-alone Java Virtual Machine, the Java standard library (Java Class Library), and a configuration tool
Integrated Development Environment (IDE) - tools that help you run, edit, and compile your code. IntelliJ IDEA, Eclipse, and NetBeans are the most popular ones
Java can be found anywhere you look. It’s a primary language for Android development. You will find it in web applications, governmental websites, and big data technologies such as Hadoop and Apache Storm. And it’s also a classic choice for scientific projects, especially natural language processing. Java was dominating mobile even in pre-smartphone days - first mobile games in the early 2000s were mostly made in Java. So, it’s fair to say that Java, thanks to its long history, has earned its place in the Programming Hall of Fame. TIOBE index, one of the most reputable programming rankings in the world, uses search engine results for calculation. Despite the growing popularity of Go and Python, Java has remained at the top of the list for more than a decade.
TIOBE Index data as of August, 2018It all started in early 1990s, when the Sun Microsystems team began developing a better version of C++ - easily portable, novice-friendly, and enabled with automated memory management. The research resulted in the creation of an altogether new language, and the name was picked from dozens of others yelled out in the meeting room. Today, the logo of a steaming coffee cup is the silent, universally recognizable symbol of programming. And it’s no longer clear what came first - the programmers’ obsession with caffeine or associations with java, synonymous with coffee.
Evolution of Java logosThese are just some of the changes Java introduced to the programming world:
Flexibility. Java proved that C’s procedural, manually-allocated, and platform-dependent code wasn’t the be-all and end-all. Thanks to Java, more people started adopting object-oriented programming, a commonly-accepted practice today.
Test-driven development. With Java, TDD was no longer an experimental practice, but the standard way to develop software. The introduction of JUnit in 2000 is considered one of Java's biggest contributions.
Let's dive in and discuss Java pros and cons in more detail.
Benefits of programming in JavaThough no longer the only officially supported language for Android development and, of course, far from the only choice for web programming, Java keeps pace with the alternatives. And since that's not only thanks to its respectable age, let’s explore what advantages Java has to offer.
⊕ Object-oriented programmingJava embraces object-oriented programming (OOP) - a coding concept in which you not only define the type of data and its structure, but also the set of functions applied to it. This way, your data structure becomes an object that can now be manipulated to create relationships between different objects.
In contrast to another approach - procedural programming - where you have to follow a sequence of instructions using variables and functions, OOP allows you to group these variables and functions by context thus labeling them and referring to functions in the context of each specific object.
Comparing procedural programming and object-oriented programmingWhy is OOP an advantage?
- You can easily reuse objects in other programs
- It prevents errors by having objects hide some information that shouldn’t be easily accessed
- It makes programs more organized and pre-planned, even the bigger ones
- It offers simple maintenance and legacy code modernization
⊕ High-level language with simple syntax and a mild learning curveJava is a high-level language, meaning that it closely resembles human language. In contrast to low-level languages that resemble machine code, high-level languages have to be converted using compilers or interpreters. This simplifies development, making a language easier to write, read, and maintain.
Writing Hello World in Java Source: Java Programming CheatsheetJava derived its syntax (set of rules and structure used by programmers) from C++, which is why you will notice that it closely resembles the C code. However, it’s much simpler, allowing beginners to learn the technology faster and code more effectively to achieve specific results.
Java may not be as beginner-friendly as Python, but any developer with a basic understanding of frameworks, packages, classes, and objects can grasp it pretty soon. It’s straightforward, strongly-typed, and has very strict expectations that soon help guide your thinking in the right direction. Besides, tons of free online tutorials and courses, won’t keep a novice helpless.
⊕ Standard for enterprise computingEnterprise applications are Java’s greatest asset. It started back in the 90s when organizations began looking for robust programming tools that weren’t C. Java supports a plethora of libraries - building blocks of any enterprise system - that help developers create any function a company may need. The vast talent pool also helps - Java is the language used for introduction to computer programming in most schools and universities. Besides, its integration capabilities are impressive as most of the hosting providers support Java. Last but not least, Java is comparatively cheap to maintain since you don’t have to depend on a specific hardware infrastructure and can run your servers on any type of machine you may have.
⊕ Shortage of security risksYou may encounter the notion that Java is a secure language but that's not entirely true. The language itself doesn’t protect you from vulnerabilities, but some of its features can save you from common security flaws. First, compared to C, Java doesn’t have pointers. A pointer is an object that stores the memory address of another value that can cause unauthorized access to memory. Second, it has a Security Manager, a security policy created for each application where you can specify access rules. This allows you to run Java applications in a “sandbox,” eliminating risks of harm.
⊕ Platform-independency (Write Once Run Anywhere)Write Once Run Anywhere (WORA) is a popular programming catchphrase introduced by Sun Microsystems to describe Java's cross-platform capabilities. It meant you could create a Java program on, let’s say, Windows, compile it to bytecode, and run the application on any other platform that supports a Java Virtual Machine (JVM). In this case, a JVM serves as an abstraction level between the code and the hardware.
How WORA approach works in JavaAll major operating systems including Windows, Mac OS, and Linux support JVM. And unless you’re writing a program that relies mostly on platform-specific features and UI, you can share - maybe not all - but a big chunk of bytecode.
⊕ Distributed language for easy remote collaborationJava was designed as a distributed language meaning that it has an integrated mechanism for sharing data and programs among multiple computers for improved performance and efficiency.
Distributed computing vs parallel computingUnlike other languages, where you have to use external APIs for distribution, Java offers this technology at its core. Java-specific methodology for distributed computing is called Remote Method Invocation (RMI). Using RMI allows you to bring all Java benefits, such as security, platform-independency and object-oriented programming, to distributed computing. Apart from that, it also supports Socket Programming and the distribution methodology of CORBA for sharing objects between programs written in different languages.
⊕ Automatic memory managementJava developers don’t have to worry about manually writing code for memory management tasks thanks to automatic memory management (AMM), also used in the Swift programming language, and garbage collection, an application that automatically handles allocation and deallocation of memory. What exactly does it mean?
A program’s effectiveness is directly linked to memory - and memory is limited. By using languages with manual management, developers risk forgetting to allocate memory resulting in increased memory footprint and lagging. A garbage collector can locate objects that are no longer referenced by your program and remove them. Despite the fact that it affects your program’s CPU, you can reduce or prevent it with smart optimization and tuning.
⊕ MultithreadingIn programming, a thread is the smallest unit of processing. To maximize utilization of CPU time, Java allows you to run these threads simultaneously - in a process called multithreading.
Threads share the same memory area so switching between them takes little time. They are also independent, so if one thread faces exception, it doesn’t affect other threads. This is especially useful for gaming and animation-heavy programs.
⊕ Stability and massive communityJava has survived to a respectable age thanks to the community, Oracle’s support, and the cornucopia of applications and languages that keep running on JVM. Besides, new versions of Java are regularly released with fresh, interesting features.
Java’s developer community is also unmatched. About 45 percent of StackOverflow 2018 survey respondents use Java. It has an extremely large ecosystem of well-tested libraries and frameworks for any use case. Java is most likely to be one of the first languages beginning developers encounter in their studies as there are 1000+ Java-related courses on Udemy and 300+ on Coursera.
Drawbacks of programming in JavaHere are the cons you want to know before writing your next project in Java.
Θ Paid the commercial licenseOracle recently announced that they will start charging Java Standard Edition 8 for “business, commercial, or production” use starting in 2019. To get all new updates and bug fixes, you’ll need to pay by the number of users or per processor.
Today, the current version of Java is free and available for redistribution for general purpose computing. To prepare for the change, each company has to evaluate how much of Java they use and seek an alternative technology if the price upgrade promises to be too painful.
Θ Poor performanceAny high-level language has to deal with poor performance due to the compilation and abstraction level of a virtual machine. However, it’s not the only reason for Java’s often criticized speed. Take garbage collector, a useful feature that unfortunately can lead to significant performance problems if it takes more than 20 percent of CPU time. Bad caching configuration can also cause excessive memory and garbage collection usage. There are also thread deadlocks that happen when several threads are trying to access the same resource, and - every Java developer’s nightmare - Out-of-Memory errors. Although each of these problems can be prevented with skillful planning, they do add up and can cause different volumes of damage.
Θ Far from a native look and feel on the desktopTo create a program's graphical user interface (GUI), developers use different language-specific tools. Thus, for Android apps, there’s Android Studio that helps create apps that look and feel native. However, when it comes to desktop UI, Java noticeably lacks.
There are a few GUI builders Java programmers can choose from: Swing, SWT, JavaFX, JSF being the most popular. Swing is old but reliable, cross-platform, and already integrated in various Java IDEs including Eclipse and NetBeans. But unless you’re using templates, you’ll notice interface inconsistencies. SWT uses native components but it’s not suitable for complicated UI. JavaFX is clean and modern-looking, but it’s not very mature. Overall, choosing a good fit for your GUI building on Java requires additional research.
Θ Verbose and complex codeWhen the code is verbose, it means it uses too many words. While it may seem an advantage when you’re trying to understand the language, long, over-complicated sentences make code less readable and scannable. By trying to emulate English, many high-level languages tend to make too much noise. Java, created to tone down the unapproachable C++, forces programmers to type exactly what they mean which makes the language more transparent to non-experts but unfortunately - less compact.
If we compare Java to its rival Python, we can see how clear Python code appears: It doesn’t require semicolons; uses “and,” “or,” and “not” as operators instead of Java’s “&&,” “||,” and “!”; and generally has fewer bells and whistles such as parentheses or curly braces.
Java vs Python code Source: reddit.com/r/ProgrammerHumor
In conclusion: Where is Java used?Most organizations use Java in one way or another. A wide range of use cases makes these applications almost invisible, which is why the question “where to use Java” is often raised. To finish our overview, let’s see which domains can be covered by Java:
Android apps. Despite Kotlin’s invasive growth, Java is still the de facto language for Android apps, which automatically turns a big pool of Java developers into Android programmers. While Android uses Android SDK instead of JDK, the code is still written in Java.
Software products. Apart from already-mentioned Hadoop and Apache Storm, Java was used to create Eclipse, OpenOffice, Gmail, Atlassian, and more.
Finance programs. Being one of the most demanded language skills in the financial industry, Java is used both on server- and client side to build reliable, fast, and simple websites. It’s also a preferred language for data simulations and modeling.
Point of sale systems. Many businesses use Java to create PoS systems as they usually require platform-independency and a vast talent pool.
Trading applications. Murex, a popular bank management program for front and back connectivity is written in Java.
Big data programs. Hadoop is written in Java. Scala, Kafka, and Spark use JVM. Also, Java gives you access to tons of tried-and-tested libraries, debuggers, and monitoring tools.
This post is a part of our “The Good and the Bad” series. For more information about the pros and cons of the most popular technologies, see the other articles from the series:
The Good and The Bad of Xamarin Mobile Development
The Good and the Bad of Node.js Web App Development
The Good and the Bad of ReactJS and React Native
The Good and the Bad of Swift Programming Language
The Good and the Bad of .NET Framework Programming
The Good and the Bad of Angular Development
The Good and the Bad of Selenium Test Automation Tool
The Good and the Bad of Android App Development