Java Flashcards
Java Platform (3 elements) aka Java Development Kit (JDK)
- Programming language
- Java runtime environment (where the code is executed)
- Standard library (can be used in applications)
Standard library
Java Standard Edition (SE) APIs
Runtime environment
Java Virtual Machine (JVM) converts source code into the bytecode into the actual hardware.
Java’s principles
- Portability (should be running on any platform) (WORA - write once run anywhere)
- Readability
- Backward Compatibility (newer versions of Java must be compatible with the previous ones, so an old feature cannot be simply removed in the new release, it will only be removed after some releases, maybe even never)
Advantages
- Widely used, large community
- Many libraries
- No need to manage memory, it’s done automatically (no need to free data)
Disadvantages
- Bad in times of real-times systems (traffic, self-driving)
- Native code is nearly impossible to view / edit
Java vs C#
Differences:
- C# is faster in terms of new features
- .NET is only recently made cross-platform
- C# is dominated by Microsoft (not as rich platform)
Java vs C/C++
- Java is inspired by C
- C++ is also object-oriented like Java
Differences:
- C and C++ are unmanaged languages (you have to manage memory)
- More language features in C / C++
- C and C++ compile into the native machine code directly
Java vs Python
- Both high-level
- Both managed
Differences:
- Python is interpreted language (there is no compilation step, so a lot of time is dedicated to the runtime part to run the code immediately line by line)
- In Python you don’t specify types (it’s NOT statically typed)
- In Python they don’t care much about compatibility like Java
- Python is good for small applications where performance is not a big issue
Java vs JavaScript
NodeJS took JavaScript from Web
Differences:
- No compilation step (interpreted language)
- Not statically typed
- Single-threaded (using all the cores in PC is problematic)
Desktop applications (using Java)
Desktop Java
Using GUI toolkit (AWT - Abstract Windowing Toolkit)
Swing (Pure Java GUI) –> allows you to choose how your layout will be, regardless of your platform
Java FX also exists where you can do drag and drop, supports 3D graphics…
Enterprise Java (Java EE –> Jakarta EE)
When you are in the enterprise, you need to select/create libraries to match your business applications.
Enterprise Java offers APIs for common enterprise application tasks, Java updates them.
Java in the Cloud
Uses Microframeworks such as Spring Boot.
Android and Java
- Primary development language for Android applications
- But you must use Java 7 or 8 only
- Javabytecode isn’t run on phones, DEX is run instead (Dalvik Executable Format) so Dalvik VM exists –> has to be quicker to preserve phone battery)
- But Java on Android looks different to Java for coding
Libraries
Utility Libraries
1. Spring Framework (dependency injection)
2. Google Guava (helps with IO libraries)
3. Apache Commons (Collections, CSV, IO)
4. Apache Log4J (Structured application logging)
Distributed Systems Libraries
1. Netty
2. Akka
3. RxJava
4. Apache Camel
Data-access Libraries
1. Java Database Connectivity (JDBC) (MySQL, Postgres, Oracle, H2)
Java-based Data Processing Libraries
1. Apache Hadoop (written in Java application) - it’s a distributed system for processing Big Data implemented in Java (good for batch processing)
2. Apache Spark (newer and good for streaming data)
3. DL4J - Deep Learning for Java (for NNs)
4. Datastores: Cassandra (written in Java to deal with databases), Neo4J, ElasticSearch, Hadoop Distributed File System (HDFS)