Programming language
Java
Java is a statically typed, class-based language compiled to bytecode for execution by a Java Virtual Machine.
What is Java and what does it do?
Java is a general-purpose, statically typed language whose source is normally compiled into class files containing bytecode. A Java Virtual Machine loads and executes those classes on a host platform. The language emphasizes explicit types, classes, interfaces, packages, automatic memory management, and a large standard library.
Java suits contracts that need to remain readable as a system grows. The useful structure is not the number of classes. It is the clarity of who owns a rule, which dependency is allowed, and what a caller can rely on.
Bytecode separates language from machine
The route from source to execution has distinct responsibilities:
- The Java compiler checks source and produces bytecode.
- Class files carry that bytecode and related metadata.
- The JVM loads, links, verifies, and executes classes.
- Libraries and the host operating system provide external capabilities.
This model distinguishes Java syntax, JVM behavior, and operating-system behavior as related but separate layers.
Small values can own their rules
A record is useful when a value has named components and value-oriented behavior. The example keeps a conversion next to the value it uses.
public class Main {
record Temperature(double celsius) {
double fahrenheit() {
return (celsius * 9 / 5) + 32;
}
}
public static void main(String[] args) {
var value = new Temperature(20);
System.out.println(value.fahrenheit());
}
}
The state and operation remain readable without a setter, inheritance tree, or separate utility class. If construction requires validation, that rule belongs at the value's boundary.
A contract is more than inheritance
A practical Java structure can rely on a few simple tools:
- A package groups a coherent responsibility.
- An interface describes behavior needed by a caller.
- Composition joins collaborators without forcing an identity relationship.
- Generics preserve type information across reusable containers and operations.
- Exceptions represent failures that cannot be returned as ordinary results.
Inheritance is available, but a hierarchy should not exist merely to share a few lines of implementation.
Predictability has a cost
Java's explicit structure, JVM model, libraries, and tooling can make a long-lived system easier to inspect. The same structure can become ceremony in a tiny program. Automatic memory management also removes manual deallocation, not the need to understand allocation, retention, threads, or external resources.
Java fits when its contracts and runtime make change more predictable. For a short script or a native component where those layers add no value, a smaller tool is the clearer fit.