1. 운영체제에 독립적이다.
기존의 언어는 한 운영체제에 맞게 개발된 프로그램을 다른 종류의 운영체제에 적용하기 위해서 많은 노력을 기울였지만, Java에서는 더 이상 그런 노력을 하지 않아도 된다. 이것은 일종의 에뮬레이터인 자바 가상 머신(JVM)을 통해서 가능한 것인데, 자바 응용프로그램은 운영체제나 하드웨어가 아닌 JVM하고만 통신하고 JVM이 자바 응용프로그램으로부터 전달받은 명령을 해당 운영체제가 이해할 수 있도록 변환하여 전달한다. 자바로 작성된 프로그램은 운영체제에 독립적이지만 JVM은 운영체제에 종속적이어서 썬에서는 여러 운영체제에 설치할 수 있는 서로 다른 버전의 JVM을 제공하고 있다. 그래서 자바로 작성된 프로그램은 운영체제와 하드웨어에 관계없이 실행 가능하며 이것을 'Write Once, Run Anywhere' 이라고 표현하기도 한다.
2. 객체지향언어이다.
자바는 객체지향 프로그래밍언어 중의 하나로 객체지향개념의 특징인 상속, 캡슐화, 다형성이 잘 적용된 순수한 객체지향언어라는 평가를 받고 있다.
3. 자동 메모리 관리(Garbage Collection)
자바로 작성된 프로그램이 실행되면, 가비지 컬렉터(garbage collector)가 자동적으로 메모리를 관리해주기 때문에 프로그래머는 메모리를 따로 관리하지 않아도 된다. 가비지 컬렉터가 없다면 프로그래머가 사용하지 않는 메모리를 체크하고 반환하는 일을 수동적으로 처리해야 할 것이다.
4. 네트워크와 분산처리를 지원한다.
풍부하고 다양한 네트워크 프로그래밍 라이브러리(Java API)를 통해 비교적 짧은 시간에 네트워크 관련 프로그램을 쉽게 개발할 수 있도록 지원한다.
5. 멀티쓰레드를 지원한다.
일반적으로 멀티쓰레드의 지원은 사용되는 운영체제에 따라 구현방법도 상이하며, 처리 방식도 다르다. 그러나 자바에서 개발되는 멀티쓰레드 프로그램은 시스템과 관계없이 구현가능하며, 관련된 라이브러리(Java API)가 제공되므로 구현이 쉽다.
그리고 여러 쓰레드에 대한 스케줄링(scheduling)을 자바 인터프리터가 담당하게 된다.
6. 동적 로딩(Dynamic Loading)을 지원한다.
자바는 동적 로딩을 지원하기 때문에 실행 시에 모든 클래스가 로딩되지 않고 필요한 시점에 클래스를 로딩하여 사용할 수 있다는 장점이 있다. 그 외에도 일부 클래스가 변경되어도 전체 애플리케이션을 다시 컴파일하지 않아도 되며, 애플리케이션의 반경사항이 발생해도 비교적 적은 작업만으로도 처리할 수 있는 유연한 애플리케이션을 작성할 수 있다.
+) 자바의 단점으로는 속도문제가 가장 대표적인 것인데 바이트코드를 하드웨어의 기계어로 바로 변환해주는 JIT 컴파일러와 Hotspot과 같은 신기술의 도입으로 JVM의 기능이 향상됨으로써 속도문제가 상당히 개선되었다.
출처 : Java의 정석 1편, 저자 남궁성
'Java' 카테고리의 다른 글
좋은 객체 지향 설계의 5가지 원칙(SOLID) (0) | 2023.02.15 |
---|---|
static 살짝 알아보기 (2) | 2023.02.04 |
리플렉션 : 스프링의 DI 동작 (0) | 2022.09.29 |
abstract class (0) | 2022.07.15 |
JVM (0) | 2022.07.02 |