Hacker News new | past | comments | ask | show | jobs | submit login

Is there a good guide to learning modern Java? At my workplace, we’re thinking about using it for a few things from Python. I’m not looking for a “Java for Python developers” but more like “Java for people who already know about the basic structures of programming languages”. I would love to hear about variable instantiating and for loops as little as possible to grok the Java model of programming, then drive right into the meaty bits of how Java programmers think today. I did Java 20 years ago in college.



I recommend The Core Java pair of books by Cay Horstmann, supplemented by Effective Java by Bloch. Those are probably the two most authoritative sources on Java out there, and both highly readable.

I heard not so good things about Herb Schildt's book.


I second this recommendation! I read Horstmann's books recently and they were excellent. He really puts things in context – any time I was thinking "WTF? Why would they do things this way?" he had an explanation coming up (or in some cases an acknowledgment that it is indeed a WTF).


Horstmann was one of my favorite teachers at San Jose State. He's a really sharp guy, and very enthusiastic teacher. I had him for a programming languages class and we dove into the various implementations of closures that were to be added to Java. We compared these to Scala and some other languages. Really fun diving in with his explanations along the way.


Effective Java by Joshua Bloch is fantastic for covering up to Java 9. There have been incremental updates since then but this book will get you 95% of the way, and it is very well written.


not really good for learning Java though, more for intermediate Java programmers. A much better book for someone learning the language is Core Java by Horstmann, which starts from the beginning and goes into depth.



this looks awesome, thank you!


Other have great recommendations. Two of mine:

1. The Java Programming Language book:

The K&R of Java

https://www.amazon.com/Java-Programming-Language-4th/dp/0321...

2. Zantorc's videos: https://www.youtube.com/@Zantorc/

He really gets into the nitty gritty. You can listen to this while commuting, etc; Just finish 1 video per 3 days, say. It adds up quickly.


#1 is really out of date though; looks like published in 2005. I recommend Horstmann's Core Java, which covers up to Java 17.


Have you ever heard of the book Core Java for the Impatient?


"Java for Developers Pocket Primer" is a new book that ramps you up fast (~200 pages) assuming you are already a developer familiar with programming.


In 2023 don't write java but kotlin code.


Kotlin has no community process and is the work of single company. The dev experience is mostly bound to IntelliJ. Java is picking up the slack every release and actually innovates over Kotlin in new features.


Only when targeting Android.

When is JetBrains coming out with KVM?


What do you mean with KVM? A Kotlin-specific VM? I don't see the need for that as Kotlin the language is rapidly evolving into a higher level language that runs on top of JVM, Android, web and native platforms (iOS, MacOS, windows, Linux)


Thus it isn't a Java replacement to start with, a minimum common standard library, without having a platform to call its own.

Guest language everywhere besides Android.


Now in 2023 I'd strongly think twice before investing heavily in Java. For the vast majority of use cases where Java is utilized Go ends up being a better choice w/ cleaner codebases, static binaries (none of this JDK/JRE deployment mess), and phenomenal performance. Not to mention proper interop with native (C/C++) code without JNI funny business.


I work at Microsoft and I'd use Java (not even C# and yes at work) a hundred times before I'd consider using Go again. Go dependency management is a bit better these days, but the build system is an absolute mess, logging is dreadful, and IDE support seems pretty primitive. Also, Exceptions are vastly superior for most services compared to returning an error outside of a few edge cases since most of the time I have no idea how to handle errors at the callsite and really just need to handle any errors at a high level (like reverting the transaction and returning an HTTP error code).


I love how these people think I have a choice in languages to use, or that I haven’t tried several others as well and honestly don’t mind the idea of Java. My company wants to make money don’t cutting edge algorithms, not test out Google’s language du jour.


> I love how these people think I have a choice in languages to use

Probably because you wrote, "At my workplace, we’re thinking about using it" and not "my workplace is demanding we use it"

> or that I haven’t tried several others

(I'm not the person who replied and suggested Go, but your comment does make it sound like you are in the language-evaluation phase, not the "we're fully committed to Java after reviewing multiple options" phase)


My friend, I specifically asked for good Java resources, but did not ask for other opinions. Those who suggested other languages were just cutting in to the conversation. I don’t care about their reasoning, I just wanted to learn Java.


Then you should have ended the comment at the question mark:

"Is there a good guide to learning modern Java?"

The end. YOU obfuscated your own comment with everything after it.


I love how these people think I have a choice in languages to use, or that I haven’t tried several others as well and honestly don’t mind the idea of Java. My company wants to make money don’t cutting edge algorithms, not test out Google’s language du an.


The choice is to switch job.


I have used both Go and Java extensively. I prefer Go. However, I have to admit that checked exceptions is the best thing about Java compared to Go.


Why do Go still insists no exceptions?


Go has exceptions, with the usual stack unwinding. The standard library does not use them (for the most part, panics are sometimes used to simplify error handling code, see encoding/gob). It's like Perl and Rust in this regard. Undocumented exceptions/panics are often considered security vulnerabilities by the Go team.

The argument against exceptions is that non-local control flow can introduce obscure bugs, like forgetting to clean up resources on the (invisible) exceptional execution path. On the other hand, without exceptions, it's possible to end up with no error handling at all by accident, and that too is not visible in the source code (but linters can help, of course).

Many languages which are anti-exception as a matter of principle still use them to report out-of-memory conditions, out-of-bounds array indices, integer division by zero, or attempts to access absent optional values. Not doing this results in code that is simply too verbose.


> like forgetting to clean up resources on the (invisible) exceptional execution path

Except this is still possible on the non-exceptional execution path. You simply just need to forget the defer call. The only thing that solves this is RAII and destructors.


You explained Go but why not C#?


No more JRE deployment mess (https://openjdk.org/jeps/282) -- in fact the JRE no longer exists; no more need for JNI (https://openjdk.org/jeps/442).

Java in 2023 is not what you may remember.


You talking about JDK/JRE deployment mess means you haven't looked at java for 5+ years, as that's no longer an issue. Hence it's hard to trust your advice when you're so off.

And no, the vast majority of use cases for java isn't distributing binaries or interoping with JNI.


Having done in-depth work both with JNI and with cgo, I don't agree that Go is without "funny business". Indeed, cgo leaves a lot to be desired IMO, especially if you with to distribute a library for other projects to consume. The interplay between native and managed code is also fairly tricky.


Simple binaries, terrible abstractions.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: