blog

Home / DeveloperSection / Blogs / What is Java and why is it needed

What is Java and why is it needed

What is Java and why is it needed

John Grehhem921 28-Oct-2020

Java programmers are appreciated, they do complex projects, they are especially loved in the Android development environment and in various corporate fields. Here's what this language is and why it's worth learning.

The main thing is briefly:

Multiplatform. Works on a huge number of operating systems and hardware.

OOP. For those who like clear structures and data delimitation.

Large community and a lot of already written code. No problems with work and with ready-made solutions.

Cons - also brief:

Not enough speed. Sometimes this is critical.

Verbose code. Where C ++ uses one command, Java requires five.

Virtual machine

Let's say we have some Java code. It doesn't matter what the syntax is, how the classes are arranged, etc. Just the code. How do you do it?

If it were a language like C ++, we would need to compile it for the required hardware or operating system. Compile - that is, transform the code that we understand into instructions that the processor understands. Since there are many processors, you will need to compile in different ways. Plus, in different operating systems, components, buttons, networking, etc. are arranged differently. Before compilation, the program will need to be finished for these features.

The power of Java is in the JVM (Java Virtual Machine) . It is a program that translates human-readable Java code into processor-understandable code. To make the code universal, the developers made virtual machines for each operating system and processor. These machines take into account all the peculiarities of the architecture of their platform and know how to process any Java command. This means that the same Java code can be run on a phone, on a computer, and anywhere else.

Especially for programmers: we deliberately simplified the principles of the JRE and JVM and are not talking about bytecode, compilation, etc. Instead, we've focused on principles that help you understand the very essence of how Java works. If it seems to you that due to simplicity, we have not described something important - tell us about it in the comments.

Where can you run Java code

Therefore, you can run Java code anywhere, for which the JVM has already been developed, that is, the Java virtual machine. For instance:

ultra-powerful servers,

computers,

smartphones,

push-button telephones,

robots and microcontrollers such as Arduino, Raspberry Pi and many others,

fitness bracelets,

GPS trackers,

smart watch,

smart TVs, refrigerators, microwaves, kettles and other home gadgets,

smart cards for access to premises.

Imagine this situation: you wrote a Java program that monitors the free space on the disk, and as soon as it becomes less than 20%, it displays a message, saying, delete unnecessary files. Now you can run this program wherever JVM is. She herself will figure out the code, understand for which processor she is doing this, and run your program. As a result, the same code will keep track of the free space on a computer, push-button phone, smartphone, tablet, smart microwave or home alarm.

Benefits of Java programming

Architecture and platform independence. You write code without thinking about the specifics of the operating system or processor. All this is taken over by the virtual machine, and you just write the logic of the work.

Object-oriented programming.

OOP

is the modern programming standard for commercial and industrial systems. In the case of Java, this will happen by itself: the fact is that, like 

Ruby

, Java is a pure OOP language. In it, even functions have turned into methods and can only exist inside a class.

Working with memory. The programmer does not need to keep track of how much memory his program is consuming and how to free it when a variable is no longer needed. To do this, Java has built-in automatic memory management: Java does not allow memory leaks and growth, and after the program finishes it releases all resources.

Safety. The virtual machine itself makes sure that the program does not get access to what goes beyond its authority. For example, a Java program will not be able to read the contents of the rest of the RAM or communicate with another computer if it is not provided with the original access rights.

Great community and support. Java is the third most popular programming language in the world. There are thousands of sites on the web that talk about this language, help you understand the code, or contain ready-made solutions.

The standard in corporate programming. Large companies in programs need reliability, stability of work and the ability to maintain them for a long time. The combination of OOP, memory management, and architecture independence makes Java ideal for this.

Java disadvantages

All of this sounds good, but Java also has significant drawbacks.

Not the best performance. C and C ++ only have a compiler that translates a program into machine code. Java doesn't have that, and everything is done by a virtual machine. It turns out that in order to execute Java code, you have to do double work: the processor starts the JVM, and the JVM executes the code itself. Because of this approach, Java programs are one and a half to two times slower than the same code written in C ++.

Paid license. Since 2019, the company Oracle, which owns the Java license, has divided it into two parts: paid and free. If you need long-term support of the development environment and stable operation of programs, take a paid license, sometimes stability is more important. If you don't need support and you can install each new free build yourself, you don't need to give money.

Bulky code. The Java developers aimed to make C ++ programming easier, and they succeeded. The price to pay for this is the large and long constructs in the language, which often get in the way of understanding the essence of what is happening. Compare the code that draws the pyramid of asterisks in Java and Python:

public class JavaPyramid {

  public static void main(String[] args) {

    for (int i=1; i = 5; i++){

      for (int j=0; j i; j++){

        System.out.print("*");

      }

      System.out.println(" ");

    }

  }

}

Java

def create_pyramid (rows):

  for i in range (rows):

    print('*'*(i+1))

Python

Who uses Java and what for

First, a list of companies and technologies that use Java as their primary programming language:

Amazon,

LinkedIn,

eBay,

Yahoo!

OpenOffice,

IBM, Intel и Oracle.

Development for Android. Java is still the primary mobile development language for this operating system, despite the growing popularity of Kotlin. Android Studio is an official Java development environment recognized by Google.

Terminals and payment systems. Thanks to the virtual machine, Java code can run on equipment that is installed in payment terminals and ATMs.

Working with finances. If you need a simple and reliable site for processing payments or transferring money - use Java. Built-in security systems will help to avoid unauthorized program actions.


Art director. My name is Mike and im living in the Finland. So, I love to play tennis and basketball. At the weekends, me and my wife making party at the our house. So we are offer to our friends join!

Leave Comment

Comments

Liked By