Live data from Hacker News

Java Is Underhyped

jackson.sh

661–670 of 808 posts

Re: Java Is Underhyped

#661
post #228

Earlier quoted context omitted.

Yes, they are: @FunctionalInterface public interface ThrowingConsumer { void accept(T value) throws E; } public static void forEach(Collection elements, ThrowingConsumer consumer) throws E { for (T element : elements) { consumer.accept(element); } } There is a significant shortcoming, which is that you can't catch exceptions using the type parameter - this does not compile: public static Optional forEach(Collection e…

Yeah, that sort of works, though I’m not sure a function that throws two distinct exception could be compatible with a generic method that takes functions throwing three distinct exceptions (that may sound crazy but some java.security crypto stuff does it).

You can bind unused parameters to RuntimeException! I'm not telling you you should enjoy doing this, mind, just that it's possible.

Re: Java Is Underhyped

#662

For my use cases, Java has all the wrong compromises: - not high level enough to compete with Python/Ruby/JS/PHP, etc - not low level enough to compete with Rust/D/Nim/Zig - not specialized enough to compete with Erlang/R/Go/Julia - not opinionated enough to compete with Lisp/Haskell So why use Java ? It's good, it's fast, it's productive, it's well supported, battle tested and documented for decades with a huge pool…

I agree mostly. Some good use cases for Java: - cryptography: It has a wide range support of symmetric/asymmetric algorithms from legacy to modern ones. - XML and SOAP with Web Service Security in particular. - Modeling large business concepts because of static typing, Objects inheritance and polymorphism, no memory management while still being performant. I would not use Python for that but other languages can compe…

Python and Ruby both would fit the bill perfectly for all those use cases for me.

The cryptography module in Python is awesome. lxml and sud deals with XML and Soap in a blink.

Modeling large business concept is a joy with dataclasses, and the language will never be the perf bottleneck.

Now I understand that if you are experienced with Java, it would solve all those problems perfectly.

But again, I would not, personally, gain anything by using it for this.

Re: Java Is Underhyped

#663
post #351

Earlier quoted context omitted.

It's not a matter of better. The original comment is all about what compromises work for me, and why I don't have a use case for Java. You are trying to move the debate toward the quality of java, which is was never my point.

Not at all, I though your point was how Rust and Go are a much better option. > If I do, I won't go Java, I will choose something that is built for performance. Python is good enough for 99% of my performances need. The last 1%, jumping to java is not a big difference, I'll use rust or go. So given that, I am curious where are those GUI alternatives with the required perfomance in Go and Rust.

So you are in the very niche use case where:

- you need a GUI

- you need perf beyond what Python is capable and you identified it clearly in advance

- you can't use numpy / multiprocessing / cython, pypy or they won't give you the perf you need

- you can't find a main hotpath you can optimize with a 5 lines c or rust extension and write 99.99% of your app in python. Or you don't want to bother.

If you ever find yourself in this very use case, then yes, use Java.

But I never found myself in this very precise use case.

Re: Java Is Underhyped

#664
post #594

Earlier quoted context omitted.

I guess given the recent court ruling we should see if Google sticks with Kotlin as a hedge, sticks with Kotlin because the community has embraced it, or pulls away from Kotlin as a no longer needed source of extra work.

It's Google. They'll probably come up with a completely new programming language which they'll force on the community in some ham fisted way, then suddenly drop it in a few years when they can't figure out a way to massively monetize it.

I thought that was Dart. Which is honestly a shame because it’s a genuinely great language. But it does very much fit the bill otherwise

Re: Java Is Underhyped

#665

Earlier quoted context omitted.

Java is orders of magnitude faster than Python for code that doesn't spend all of its time waiting for IO. Java perf and Go perf are about the same.

Even IO heavy code, it is much easier to write multithreaded async code for the jvm than it is for python

If it's just about I/O, then no, threads in Python are super easy:

    import random
    import time
    from concurrent.futures import ThreadPoolExecutor, as_completed


    def hello(seconds):
        print(f"Starting hello in {seconds}s")
        time.sleep(seconds)
        print(f"End of hello in {seconds}s")
        return seconds


    # At the end of this blocks, it automatically join() and clean
    with ThreadPoolExecutor(max_workers=2) as executor: # 2 tasks in parallel max

        # this send jobs to threads via safe queues
        a = executor.submit(hello, random.randint(0, 5))
        b = executor.submit(hello, random.randint(0, 5))

        # this collect results from queues in order of completion
        # sync is automatic
        for future in as_completed((a, b)):  
            print(future.result())
And if about network I/O only, you can get even more perfs using asyncio.

Threads in Python are only inferior to Java threads when it's about using several CPU.

Re: Java Is Underhyped

#666

Earlier quoted context omitted.

Could you clarify the point on Android and copyright issues? At least at the time in 2017 when Google blessed Kotlin as an officially supported language, it seemed like the reasoning was Kotlin was far more ergonomic than Java. How does copyright come into this?

Oracle suited Google for copying the APIs (not the implementation) of the Java standard APIs. It all started in 2010 [0] Kotlin was Google's backup if the suit went Oracle's way. [0] https://en.wikipedia.org/wiki/Google_LLC_v._Oracle_America,_... .

I'm no expert in the Android ecosystem, but I think it was primarily a good choice for giving devs features they wanted to have while the underlying runtime and standard library got stuck at Java 6. The reason why they are still on Java 6 might have to do with the law suit, though.

Re: Java Is Underhyped

#667

For my use cases, Java has all the wrong compromises: - not high level enough to compete with Python/Ruby/JS/PHP, etc - not low level enough to compete with Rust/D/Nim/Zig - not specialized enough to compete with Erlang/R/Go/Julia - not opinionated enough to compete with Lisp/Haskell So why use Java ? It's good, it's fast, it's productive, it's well supported, battle tested and documented for decades with a huge pool…

> Python is older than Java, well supported WELL SUPPORTED???? Have you ever coded a real thing in python? I'm getting "Warning, no longer supported" console messages in all my basic well established tools and libraries written in python because a guy that lives in a world of academics and theory and not in a world of business and delivery dates decided that python3 was not going to have backwards compatibility with…

Dropbox, Instagram, Google, Youtube, reddit and Nasa all have been heavily Python powered for a decade.

I myself have coded a streaming platform getting half a million user every day in Python. Baring the CDN to store the content, it runs on 2 servers, one for the DB.

So real things get done in Python pretty well.

Re: Java Is Underhyped

#668
post #491

Earlier quoted context omitted.

I've interacted to a ton of Java projects. And with a ton of various other commercial and Open Source projects. In my experience (sample size of hundreds of projects), Maven projects are >, on average, easier to build and manage than most other languages. The repo structure is standardized, the build cycle is standardized, the built packages are always in the same place, etc. The Java installation is a 1-time think.…

Well Java is arguably one of the most IDE-reliant mainstream languages. It's completely unusable and unergonomic without the myriad of constant code generation and fixing as you write. Treating the IDE like a separate problem is not realistic with java. With e.g. Rust, I can use vim, vscode, whatever floats your boat. > no idea why you'd have to configure "getting the actual logs"? Some genius java logging library, I…

100% lombok can only be developed on eclipse. They have an open issue to make it compile on intellij...

Re: Java Is Underhyped

#669
post #336

For my use cases, Java has all the wrong compromises: - not high level enough to compete with Python/Ruby/JS/PHP, etc - not low level enough to compete with Rust/D/Nim/Zig - not specialized enough to compete with Erlang/R/Go/Julia - not opinionated enough to compete with Lisp/Haskell So why use Java ? It's good, it's fast, it's productive, it's well supported, battle tested and documented for decades with a huge pool…

My main issue is that people writing Java (or for the JVM) because of their backgrounds (app-level code printers) almost completely disregard how that code works on the JVM, at scale, in a highly responsive and/or high throughput service. You can't just use a big, "safe bet" framework like spring, which taints EVERYTHING in that project, write a simple REST API and then do heavy work "in the background" without side…

> "Every Java project is also __severely__ underdocumented. That's because even if you write documentation for YOUR code, the framework has books of documentation on ITS specifics, and includes high-level libraries which THEMSELVES have heaps of specific documentation. Climbing the tree until one arrives at actual standard library calls is like climbing into clouds and hoping to see the sun some day."

This weaknes stems from Java being OO. On larger projects you start to have abstractions which tend to be insucfficiently documented or the documentation not being updated with changes. Throw in some helper classes here and there, from a certain point of complexity of the project from an outside perspective the whole thing looks like being obfuscated.

Re: Java Is Underhyped

#670
post #488

Earlier quoted context omitted.

I think Kotlin is pretty much what a modernized Java should be. Between it and Clojure I don't spend very much time with Java anymore.

Kotlin could he better, but doesn't go all the way. Without HKTs and implicit injection, Java is going to eat its lunch. Java already has records, type inference, parametric null safety with Optional, Loom provides coroutines, vavr and streaming apis have given us theabilitytodo FP... what's left as a unique feature? Kotlin will survive because it was picked for Android to avoid copyright issues. But the difference b…

Dream on. Java, even including upcoming features, has nowhere near what's included in Kotlin out of the box. Nullability? Extension methods? First class functions? I could go on. Kotlin is much more than a better Java.
Post reply on HN