History and Motivation
Once upon a time, in a land far far away… in the early 1990s, a group of Sun Microsystems engineers, led by James Gosling, embarked on a quest to develop a language for interactive television.
They named it Oak, after the tree outside Gosling’s office.
However, Oak was already taken (darn you, trademark laws!), so they settled on Java, inspired by their love for coffee.
Java was designed with the mantra “Write Once, Run Anywhere” (WORA), aiming for platform independence and security.
It quickly gained popularity, especially with the rise of the internet, and became a staple in software development. (en.wikipedia.org)
Personal Memories…
I can attest to the popularity of Java. When it was becoming fashionable in the mid 1990s, I was a C++ nerd.
The Java nerds would wave the Java flag in my face in arrogance..
Oh so many thoguhts I had at the time of what they could do with that flag..
BUTT.. (get it?)… this blog needs to remain kid friendly.. so we move on ..
If you were writing software around this time. Java was “the thing” …
My sister in law (who is not an engineer) , even asked me about it..
It was crazy popular and crazy slow.. but the zealouts didnt care…
Now days Java is all grown up.
I dont hate it anymore. and after working on several larger Java projects I have grown a deeper respect for its consistency, especially in the library design… .
C++ organically grew up.. so things like the design of the libraries can be all over the map and not always consistent..
A nice thing about Java (and one could argue the things that came after ).. is the consistency of patterns and design in the common libraries..
These days I tend to prefer C#, but without Java - we would all still be coding things in DOS Bat files or something…..
Common Operations in Java
Let’s dive into some basic Java operations. Remember, every Java program starts with a main
method. Here’s a simple “Hello, World!” program:
|
|
Want to perform some arithmetic? Java’s got you covered:
|
|
(amazing ! no?)
Advanced Techniques
Feeling adventurous? Let’s explore some advanced Java features.
Generics allow for type-safe data structures:
|
|
Simliar to Templates in C++ and C#.
Lambda Expressions (introduced in Java 8) enable functional programming:
|
|
Web Support
Can you build web services or websites with Java?
YES!
Java offers mature frameworks for web development.
Spring Boot simplifies the creation of stand-alone, production-grade applications:
Heres a dandy little web service:
|
|
More examples on building web services with Java:
Concurrency Support
Java has built-in support for multithreading, allowing you to perform multiple tasks simultaneously (which is like totally multi-threading…).
You can create threads by extending the Thread
class or implementing the Runnable
interface:
|
|
For asynchronous programming, Java provides the CompletableFuture
class:
|
|
More on Java Concurrency:
User Interfaces
Yes, you can create GUIs in Java!
The Swing framework allows for building window-based applications:
|
|
I wrote my first Swing UI around 1993… And it was buggy, and difficult and I hated it..
But after learning WPF \ XAML I have a new appreciation for the declaritive UI pattern.
More on GUIs with Java:
Unit Testing
The meat and potatoes unit testing library is JUnit:
|
|
Unit testing in Java:
Key Ideas
Topic | Description |
---|---|
History | Developed by James Gosling at Sun Microsystems; aimed for platform independence. |
Common Operations | Basic syntax includes classes, methods, and standard operations. |
Advanced Techniques | Features like Generics and Lambda Expressions enhance functionality. |
Web Support | Frameworks like Spring Boot facilitate web service development. |
Concurrency | Built-in support for multithreading and asynchronous programming. |
User Interfaces | Swing framework enables GUI application development. |
Unit Testing | Frameworks like JUnit support effective unit testing. |