Skip to content

Did you know MyCIIS is transitioning to CIIS Connect SharePoint?

Transition Timeline:

  • August 15th - MyCIIS will become read-only
  • September 15th - MyCIIS to CIIS Connect SharePoint content migration deadline
  • October 15th - MyCIIS will be taken offline

Visit CIIS Connect SharePoint - https://ciisedu.sharepoint.com/sites/CIIS (requires university single sign-on)

Questions? Please contact Office of the Dean of Information Technology at dot@ciis.edu

Help

What is Java and why do we need it?

What is Java and why do we need it?

Is it like JavaScript? No!

 

What is Java and why you need it

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

The main points are brief:

 

  • Multi-platform. Works on a huge number of operating systems and hardware.

  • OOP. For those who like clear structures and data separation.

  • A large community and a lot of code already written. No problems with working and ready-made solutions.

Cons - also briefly:

 

  • Lack of speed. Sometimes this is critical.

  • Lots of verbose code. Where C++ uses one command, Java requires five.

Virtual Machine

Suppose we have some code in Java. So far, it doesn't matter what the syntax is, how classes are arranged, etc. It's just code. How to execute it?

 

If it were a language like C++, we would have to compile it for the desired hardware or operating system. To compile, that is to convert the code we understand into instructions understandable to a processor. Since there are many processors, we would have to compile in different ways. There are many processors, and different operating systems have different components, buttons, networking, and so on. Before compiling, you have to modify the program to suit these features.

 

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

 

Especially for programmers: we've intentionally simplified the principles of JRE and JVM and don't talk about bytecode, compilation, and so on. Instead, we've focused on principles that help you understand the very essence of how Java works. If you think there's something important we haven't covered because of simplicity, tell us about it in the comments. 

Where you can run Java code

So you can run Java code everywhere for which a JVM, i.e. a Java Virtual Machine, has already been developed. For example:

 

  • Ultra-powerful servers,

  • computers,

  • smart phones,

  • push-button phones,

  • robots and microcontrollers like Arduino, Raspberry Pi and many others,

  • fitness bracelets,

  • GPS trackers,

  • smart watches,

  • smart TVs, refrigerators, microwave ovens, kettles and other home gadgets,

  • smart cards for indoor access.

Imagine the following 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 everywhere you have a JVM. It will sort out the code itself, see what processor it is doing it for, and run your program. As a result, the same code will keep track of available space on your computer, push-button phone, smartphone, tablet, smart microwave, or home alarm system.

 

Advantages of Java programming

Independence of architecture and platform. You write code without thinking about the peculiarities of the operating system or processor. All this is taken care of by a virtual machine, and you only write the logic of the work.

Object-oriented programming.

OOP

- is the modern standard of programming in commercial and industrial systems. In the case of Java, it will work itself out: the fact is that, like 

Ruby

Java is a pure OOP language. Even functions have become methods and can only exist inside a class.

 

Working with memory. The programmer does not need to worry about how much memory his program uses and how to free it when a variable is no longer needed. For this purpose automatic memory management is implemented in Java: Java does not allow its leaks and growth of size, and after program's termination frees all resources.

 

Security. The virtual machine itself makes sure that the program doesn't get access to anything that goes beyond its authority. For example, a Java program can't read the contents of the rest of the RAM, or contact another computer, unless the original access rights provided for it.

 

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

 

The standard in corporate programming. Large companies want programs to be reliable, stable, and maintainable for a long time. The combination of OOP, memory management, and architecture independence makes Java the perfect solution for this.

Disadvantages of Java

This all sounds good, but Java has disadvantages that are quite significant.

 

Not the highest performance. C and C++ only have a compiler that translates the program into machine code. Java does not have such a compiler, and everything is done by a virtual machine. This means that to execute Java code you have to do double work: the processor runs 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. As of 2019, 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 the paid license, sometimes stability is more important. If you do not need support, and you can install each new free build yourself - no need to give money.

 

Bulky code. The developers of Java aimed to simplify C++ programming, and they succeeded. The price they had to pay for this was large and long constructs in the language, which often interfere with understanding the essence of what's going on. Compare the code that draws a pyramid of stars 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 for what

First we have a list of companies and technologies which use Java as their primary programming language:

 

  • Amazon,

  • LinkedIn,

  • eBay,

  • Yahoo!

  • OpenOffice,

  • IBM, Intel, and Oracle.

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

 

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

 

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