Live data from Hacker News

Java is still worth learning

empatheticdeveloper.wordpress.com

31–40 of 82 posts

Re: Java is still worth learning

#31
JVM is probably the most impactful piece of software ever written.

our world literally runs on the JVM.

however - the "Java" ecosystem used to suffer from architecture astronauts & complexity merchants. Certain things like Quarkus & SpringBoot have helped reduce that.

if you keep Java simple, don't ingest too much OOP Kool-aid. You can literally make anything that will work today, 10 years from now, 20 years from now. that's reliability you won't get from Python, Ruby & Javascript.

Remember the JVM offers alternatives - Clojure, Kotlin. with a Kotlin a nice compromise.

Re: Java is still worth learning

#33

I’ve been working as a backend developer for close to six years now, but reading this brought me right back to college. Like many others, I started with C. It taught me the basics - memory, pointers, writing data structures from scratch - but most of the time it felt like I was just trying not to break things. Solving problems became more about handling the language than understanding the logic. Then I came across Ja…

I had same experience with c#

You focus on algorithms and solving problems instead of fighting with language, building systems, linker errors, solved problems being annoying, etc

In general the joke is real:

How much c# is faster than cpp?

By a few months at least

Re: Java is still worth learning

#34

Earlier quoted context omitted.

I think you might need to look into java (or better kotlin) then. Is gradle not a package manager on top of a build system, just like npm? Is a fatjar/shadowjar not a "single binary"?

> Is a fatjar/shadowjar not a "single binary"? No, it isn't. `go build` is a single binary.

You can compile java aot into binary executable native to your platform. There's many options to do it.

You can do it with a fatjar so that all the dependencies are there. You have all the dependencies clearly stated and versioned (and they are referenced globally - so you don't need to remember where you downloaded that one library from or how to compile that weird dll).

Of course if you actually care about being able to run the code in 20 years - you're far better off leaving it as a fatjar instead of making it an executable.

I have java programs that I made 20 years ago when I was at university that still run on my modern linux machine.

I also wrote C++ programs back then and none of the executables work out of the box (even building one of them is a struggle because half the libraries I used were abandoned - RIP libparagui, some you can't even download from the internet anymore, and most that you can download - don't have versions working with the most recent libc).

That despite the fact I tried to make a static executable for linux when I compiled it back then. I just failed.

I spent a week like 10 years ago trying to make my master's thesis program run again. I basically had to port it to a different graphic library because of dependency hell.

Re: Java is still worth learning

#35
As a senior Java developper, I would say the most important things you will learn from Java (beyond types) are:

stream on collections (the local functional implementation of map/reduce/…),

interfaces everywhere,

and more importantly safe function extraction by your favorite IDE.

Let me elaborate the last one: you write an horribly long spaghetti code (because you are a junior, or you are in a hurry). That’s ok because the “Extract method” instant feature of your IDE will help you safely extract each piece of code AFTERWARDS into its own small function (that can be tested in isolation, where local variables stays internal to the function, where the interface contract in term of input/output/sideEffect is clear, where the function naming is meaningful).

The IDE can even tell you that this code you are extracting as a function appears at several other locations that should also be replaced with a call to that new function.

I don’t know if Typescript support in IDEs reaches the same level of simplicity/safety in term of function extraction.

But that feature is absolutely critical to go from spaghetti code to clean modular code, when you are a junior/work with juniors.

Re: Java is still worth learning

#36

I don't know. I started my career as a Java dev, but what made me grow as a software developer was learning Scala. I learned a lot about functional programming, algebraic data types, effects, and so on. I'd say Java is a great production language, mostly because it's so simple that I don't need to "learn" it (when you know better than using madness like `==` or Serializable).

I get the point you're trying to make, but there's something ironic about touting a language as "simple" immediately followed by mentioning that using the basic equality operator that's used by pretty much every other mainstream language is "madness". I know every language has warts, but that one is pretty egregious both in terms of how quickly people would run into it for the first time and how easily it could have been avoided (e.g. by using something else for the less commonly needed equality operator, like how Python uses `is`). Having things that look correct and compile fine but then fall for reasons that you have to explicitly learn isn't really "simple".

Re: Java is still worth learning

#37
post #29

I’ve been working as a backend developer for close to six years now, but reading this brought me right back to college. Like many others, I started with C. It taught me the basics - memory, pointers, writing data structures from scratch - but most of the time it felt like I was just trying not to break things. Solving problems became more about handling the language than understanding the logic. Then I came across Ja…

Funny I had the exact opposite reaction to Java when I needed to use it in college. So many abstractions, forced design patterns and boilerplate. Absolute soul sucking joyless development.

may be it was the way you were taught java.

It had abstractions but you were never forced to use them. Ditto with design patterns - you could use them, but none were forced, unless you _had_ to use a framework (like spring), but that's a choice! May be it wasn't your choice, but it was a choice someone made.

If you used java like you used C, java is much easier and less mentally demanding, and therefore less prone to mistakes.

Re: Java is still worth learning

#38

I’ve been working as a backend developer for close to six years now, but reading this brought me right back to college. Like many others, I started with C. It taught me the basics - memory, pointers, writing data structures from scratch - but most of the time it felt like I was just trying not to break things. Solving problems became more about handling the language than understanding the logic. Then I came across Ja…

> Solving problems became more about handling the language than understanding the logic.

I've worked with Java for 25 years and have a love/hate relationship.

Java garbage collection is both great, and terrible. Sometimes objects are instantiated in a method, and should be marked for GC when you leave the method but aren't. There isn't logic or reason, and it trips up juniors hard and reworking "new" features like streams into basic for loops fixes it, even though there isn't any really good reason why.

When it works first time you never even need to think about it, and its awesome. When it doesn't, there is no escape hatch to fix it. Its probably for the best, I would probably prefer someone switched a stream to a loop to fix a GC bug than to keep the stream and add additional code for flagging objects.

Re: Java is still worth learning

#39

If Java can be compiled into a single binary and have a package manager then I would learn it. I really want to like Java, or JVM-based languages specifically, but its extremely annoying and complicated to figure out how and why thing works.

Java can be compiled into a single binary. You can use for instance Graal VM for that: https://www.graalvm.org/latest/reference-manual/native-image... Java has Maven and Gradle that serve as package managers. I'd say they are not any more complex than npm, except if you need complexity to do something very specific.

> except if you need complexity to do something very specific.

and i do argue that maven has the complexity correctly silo'ed - you need to write a maven plugin to do anything complex and custom, and fit that plugin into the maven ecosystem/api/framework (however deep you need to go).

As opposed to the 'normal' Makefile style build, where you add instructions and scripts (which i think both Ant and gradle inherited the idea from, and thus neither really makes for better builds imho).

Re: Java is still worth learning

#40
post #29

I’ve been working as a backend developer for close to six years now, but reading this brought me right back to college. Like many others, I started with C. It taught me the basics - memory, pointers, writing data structures from scratch - but most of the time it felt like I was just trying not to break things. Solving problems became more about handling the language than understanding the logic. Then I came across Ja…

Funny I had the exact opposite reaction to Java when I needed to use it in college. So many abstractions, forced design patterns and boilerplate. Absolute soul sucking joyless development.

Abstract objects are optional. I haven't seen a codebase that really uses them (outside of going into the Spring Framework)

Design patterns are optional, but are applicable across languages. Their purpose is to communicate effectively.

Post reply on HN