HACKER Q&A
📣 SpacePortKnight

Any alternative to Java (OOP) which has the same ecosystem?


I've professionally programmed in Java, Python, Haskell and JavaScript.

Of these, I've found Java to be easiest when dealing with large code bases ( > 100,000 LOC ). It is complied, has a strong type system, very good standard library, good & mature build systems, and excellent tooling with IDEs like IntelliJ.

However, I am not a fan to object oriented programming. I suppose I am looking for a C / Python / Haskell like language with the same ecosystem / popularity as Java.

I tried Go, but it looks like Go is built to programmed on internet connected devices only. With Java, dependencies can even be downloaded and put as Jars.


  👤 OmarAssadi Accepted Answer ✓
Kotlin does both functional and object-oriented programming very well. It also has near-perfect interoperability with Java, so you can reuse your existing libraries without any hassle. And it works well with standard build tools like Gradle.

👤 mindcrash
Scala? With some help from additional libs such as Zio (https://zio.dev/) it allows you to write production quality programs like you would in Haskell on top of the JVM quite quickly...

👤 mdcds
Give Scala a try. It has Java interop and your programs get packaged into jars (by default). I had experience with the same set of languages as you (including Haskell!) when I discovered Scala and it's my favorite language these days. As a bonus, you get to use (if you want) functional effect systems like Cats Effect and ZIO.

👤 guggle
> I tried Go, but it looks like Go is built to programmed on internet connected devices only. With Java, dependencies can even be downloaded and put as Jars.

What's wrong with "go mod vendor" ?

From golangbyexample.com:

"It will create a vendor directory inside your project directory. The vendor directory will have all the direct and indirect dependencies downloaded. You can also check in the vendor directory to your VCS (Version Control System). This becomes useful in the sense that none of the dependency needs to be downloaded at run time as it is already present in the vendor folder checked into VCS."


👤 zaphar
You can vendor your go dependencies the same way as you can java. Go is perfectly happy developing on non internet capable devices. In fact after vendoring the go tool will happily serve all of your documentation via command line or localhost web server so you don't have to go searching the web. It may deserve a closer look from you.

👤 plmpsu
Don't extend classes in Java, only implement interfaces.

You can go so far as to prohibited extending classes using static analysis tooling.


👤 galdosdi
The great thing about the JVM is a lot of languages run on it and you get access to the same ecosystem from any of them. If you like Python, I had a great experience with Jython. It was really easy to interoperate back and forth between Jython and Java. The only major downside is it implements Python2 and is not expected to move forward to Python3.

It's a good choice if you don't expect to pull in modern Python libraries, just do basic scripting and pull in JARs when needed instead.


👤 Tainnor
Kotlin. Its compatibility story with Java is great (although you obviously will lose some benefits such as guaranteed null-safety when interfacing with Java code). It's multi-paradigm and supports FP well, as well as DSLs. You probably can't (or shouldn't) go as crazy with your types as in Haskell or Scala, but you do get more or less concise sum (sealed classes) and product (data classes) types, as well as generics. Plus, if you use IntelliJ, the tooling is great.

👤 procinct
F#? Since it’s still in the .NET ecosystem which is huge, plus it’s functional.

👤 ActorNightly
Python is great because you can make it as OOP as you want, or avoid objects all together.

You can make it strongly typed with type hints and MyPy type checking, or you can avoid it all together.

You can do imperative programming, or functional.

And best part, you can do all of that in one code base depending on what the use case is. And the debugger is great.


👤 karanbhangui
You have tried Scala or Clojure?


👤 chris_armstrong
If you're placing a strong importance on ecosystem, and after something that can be used in a less-OOP / more functional style, it's hard to go past TypeScript (whatever distaste you may have for the dark corners of JavaScript).

A less vibrant ecosystem, but far stronger on the functional and string typing, take a look at OCaml (others have suggested good alternatives like F# or Scala if you want to leverage the existing VM-based ecosystems).


👤 gardenfelder
Few mentions here of Clojure. It's well worth exploring; a strong ecosystem behind it.

👤 didip
Go can be deployed as link-able shared binary if you want.

👤 yulaow
Just curious because I don't understand exactly what you mean, could you go in more details about why you don't like go?

👤 SpacePortKnight
Thank you for the recommendations. I will be sure to check out Scala and go through your suggestions.

👤 PaulHoule
What is your beef with OO?

👤 mapandey
You can try Clojure.

👤 ale_jacques
Kotlin?