---
title: Lecture 1. Introduction
weight: 5
---

# Why do we choose Java?

According to **TIOBE Programming Community Index** Java is one of the most demanded languages in the programming field.

![TIOBE Programming Community Index](assets/tiobe.png)
*Img. 1 - TIOBE Programming Community Index*

Also, Java has a lot of advantages for beginners such as:

* It's fairly easy
* It has a broad spectre of usage
    * Server
    * Desktop
    * Mobile devices
    * Smart-cards

# What does Java consist of?

Java consists of multiple main components. The first one being the **Java compiler**. The process of converting *human-readable* text to *machine code* is called **compilation**.

![Compilation Process Simplified](assets/compilation-process-simplified.svg) 
*Img.2 - Simplified Compilation Process*

The behaviour of the Java compiler is described by the [Java Language Specification](https://docs.oracle.com/javase/specs/) or JLS.

Let's talk about compilers a little bit. For example if we will take *C++*. If we take C++ compiler for *x86-64* platform and *Windows* operating system, and launch the compiler on source code it will turn it directly into assembly code.

![C++ code compilation under x86-64](assets/cpp-x86-64-compilation.svg) 
*Img. X -- C++ code compilation process under x86-64 architecture.*

But what if I want to run my program on *Linux* instead of Windows. I will need to take a different compiler under different operating system and recompile my code using a new compiler. It's not very convenient. 

Java tries to protect us from that. By converting the *Java source code* into *Java byte code*. And then the *byte code* will be ran on the *Java virtual machine* which will run our program on the native processor.

![Java code compilation](assets/java-code-compilation.svg) 
*Img. X -- Java code compilation*

This approach allows to change only **JVM** according to our platform (*x86_64, ARM, ...*) and operating system (*Windows, MacOS, GNU-Linux, ...*) while *byte code* stays the same. We can only write our code once, than compile it and run under everywhere. 

As the motto says:

> Write once -- ~debug~ run everywhere.

 The third component of Java is the standart library which is included in the JVM. 

There are multiple redactions of Java-platforms:

* Standart edition
  - *For regular aplications*
* Enterprise edition
  - *For server aplications*
* Micro-edition
  - *For mobile aplications*
  - *Isn't in use nowadays 🪦*
* Java Card
  - *Sim- and smart-cards*

There also were multiple versions of Java throughout its history.


- JDK 1.0 (Jan 1996)
- J2SE 1.2 (Dec 1998)
  * *Collections Framework*
- J2SE 5.0 (Sep 2004)
  * *Generics*
- Java SE 8 (Mar 2014)
  * *Streams and Lambdas*
- Java SE 9 (Sep 2017)
  * *Modules*
- Java SE 10 (Mar 2018)
  * `var`
- Java 11 (Sep 2018)
  * `jshell`
- Java 17 [LTS-old] (Sep 2021)
  * *Previous stable version*
  * *Many little changes*
- Java 21 [LTS] (Sep 2023)
  * *Current stable version*
- Java 25 (Sep 2025)
  * *Next version*

Java comes in two parts: **JDK - Java Development Kit** and **JVM - Java Virtual Machine**.

There is also a **JRE - Java Runtime Environment**. For example if we want to run our code somewhere on the server we don't need to compile it there because we have our byte code and we just need JRE to run it.


