Live data from Hacker News

Don’t call it a comeback: Java is still champ

github.com

501–510 of 557 posts

Re: Don’t call it a comeback: Java is still champ

#501
post #373

Earlier quoted context omitted.

FizzBuzz Enterprise Edition [1] is an oldie but a goodie worth a re-mention. 1. https://github.com/EnterpriseQualityCoding/FizzBuzzEnterpris...

The Issues in that repo are hilarious

>package com.seriouscompany.business.java.fizzbuzz.packagenamingpackage

>Issue #597 : It's written in java but doesn't support my blu-ray player

Re: Don’t call it a comeback: Java is still champ

#502

Earlier quoted context omitted.

Yes, thank you. Spring Boot is annotation hell. Annotations are the worst part of Java—it’s what happens when a language can’t support a true DSL. Just as ridiculous is the HttpSecurity method chaining “DSL”.

Java annotations can support compile time validation (e.g. see micronaut or checker framework). DSLs don't.

> DSLs don't.

DSL is a general name to any embedded language inside a host language. C++'s templates can be used to write DSLs, they are compile-time checked. Kotlin's lambda syntax can also create very convincing DSLs[1] to describe hierarchical structures\processes, and they are fully typed, compile-time checked constructs.

There are far more to DSLs than hacky strings (regex) or chaining method calls at runtime (fluent APIs). It's a very general pattern.

[1] Example from https://kotlinlang.org/docs/type-safe-builders.html

html {

        head {

            title {+"XML encoding with Kotlin"}

        }

        body {

            h1 {+"XML encoding with Kotlin"}

            p  {+"this format can be used as an alternative markup to XML"}

        }

}

Re: Don’t call it a comeback: Java is still champ

#503
post #423

Earlier quoted context omitted.

> If it does that optimally ah, the "sufficiently smart compiler" argument. There is no such compiler, FYI, and there may not ever be. Not for every situation that developers are creating in Java today. it's a matter of hitting your CPU cache as often as possible. Neither javac nor the runtime has any freaking clue how to do that, but you, as a developer, do. When you write Java, you can't do a lot to control how tha…

There is an interesting presentation titled death of optimizing compilers, where it is claimed that programs increasingly are either in their hot path where performance is absolutely crucial and not even C/C++ is sufficiently low-level (you can achieve 2-3 orders of magnitude faster code by hand-optimized assembly), or on cold paths where even Bash would suffice. Nonetheless, I found that it is easy to find these hot…

I would love to see a video game implemented in Bash with the hottest spots implemented in Assembly, just to see how poorly that would perform.

I work for a company that has AWS Lambdas which are invoked 10s of trillions of times per year, with about 45% of that happening in a single month, and another 45% happening 6 months later, also within a single month.

I cannot imagine what our AWS bill would be like if those lambdas ran Bash. 100x larger? At least.

Performance matters. It's not obvious how much it matters until you look, but it matters. There are zero users who will complain that an application makes them wait less than it did previously. There are zero managers who will complain that their AWS bill gets lower because code takes less time to run and uses less RAM.

I have no idea why anyone would even begin to argue the opposite.

Re: Don’t call it a comeback: Java is still champ

#504

Earlier quoted context omitted.

> records/pure immutable data classes Example? As far as I know, Java has final, which means that particular reference can't be re-assigned, but the object referred to remains mutable. You have to resort to e.g. having separate immutable and mutable interfaces or whatever to restrict a someone from mutating your object. If you want an immutable data class more than one level deep, I don't know if there's a convenient…

JDK 17 record classes: record User(String name, Integer age, Boolean isActive) {} https://docs.oracle.com/en/java/javase/18/language/records.h...

If you have mutable members you can still absolutely do myRecord.member().methodThatMutates().

The only way to stop this is to remove the mutable methods from the interface entirely, which is what I'm complaining about.

Re: Don’t call it a comeback: Java is still champ

#505
post #423

Earlier quoted context omitted.

There is an interesting presentation titled death of optimizing compilers, where it is claimed that programs increasingly are either in their hot path where performance is absolutely crucial and not even C/C++ is sufficiently low-level (you can achieve 2-3 orders of magnitude faster code by hand-optimized assembly), or on cold paths where even Bash would suffice. Nonetheless, I found that it is easy to find these hot…

I would love to see a video game implemented in Bash with the hottest spots implemented in Assembly, just to see how poorly that would perform. I work for a company that has AWS Lambdas which are invoked 10s of trillions of times per year, with about 45% of that happening in a single month, and another 45% happening 6 months later, also within a single month. I cannot imagine what our AWS bill would be like if those…

I didn’t write that I agreed with said presentation, but it was interesting, and a good take away is that if you have such a scorching hot loop that iterates over megabytes of data, a compiler may not be sufficient even in low-level languages. (Think of video codecs). And the other side, routine optimizations done on cold paths may not be as worthy (the bash line was me exaggerating the effect - but just think of any Python deployment, they are basically that, slow code calling into optimized libs in C and Fortran)

Re: Don’t call it a comeback: Java is still champ

#506
post #411

Earlier quoted context omitted.

> records/pure immutable data classes Example? As far as I know, Java has final, which means that particular reference can't be re-assigned, but the object referred to remains mutable. You have to resort to e.g. having separate immutable and mutable interfaces or whatever to restrict a someone from mutating your object. If you want an immutable data class more than one level deep, I don't know if there's a convenient…

You are right, though I seldom find it a problem in practice. Also, OOP sort of makes immutability hard to define (e.g. is a getter with an internal counter of accesses immutable? In a way, it is. Also, Rust’s internal mutability pattern is similar). Nonetheless, recently more and more standard classes are made deliberately immutable, and there was a proposal for frozen arrays as well (not sure on their status).

> You are right, though I seldom find it a problem in practice.

Although it's easy to to tell people that mutation is confusing and to avoid it, enforcing that is much easier if the compiler is on your side and will prevent mutation with const.

I've encountered unnecessary mutation (introducing implicit assumptions on the order of calls, and making things more confusing) constantly in both Java and C++, but enforcing const in C++ cuts down on that. Or at least, it forces a const_cast which I won't approve without a really good reason.

You're right about Rust of course, internal mutability is possible and maybe even common with RefCell, but culturally it seems like that's avoided. On the other hand, mutability is extremely common in Java.

Maybe I'm just traumatized from some of the horrific code heavily using mutation I've seen over the years.

Re: Don’t call it a comeback: Java is still champ

#507

Earlier quoted context omitted.

Old school xml based Spring is horrible and if that was your only exposure, I understand your aversion. But spring-boot has an almost zen like quality once you get that it favor convention over configuration. When I was a Java developer, I'd usually use spring-boot with the following dependencies to make the experience better: - lombok: to generate the boilerplate: constructors, getters, setters, equals, hashcode...…

Sorry, but the popularity of tools which generate boilerplate for you is, in my opinion, one of the biggest indictments of the whole ecosystem.

I've used Lombok, and I wouldn't describe it as "generating boilerplate," and yes, I see that GP used those words first.

Instead, Lombok allows me to mark fields with an annotation and then use getters and setters that never actually exist in my code. In practice, it's just adding an annotation in places to control functionality, which is not what I usually think of when I read "generate boilerplate."

Re: Don’t call it a comeback: Java is still champ

#508

Earlier quoted context omitted.

Why write many lines of validation when one line can suffice? @Entity class User { @NotBlank String username; } // Use site public User addUser(@Valid User user) { ... } as opposed to class User { String username; public void validate() throws ValidationException { if (username.isBlank()) throw new ValidationException("username is empty"); } } // Use site public User addUser(User user) { user.validate(); // ... }

Code like this is expected in Spring https://hastebin.com/jevibugiqu.less . Literally all the classes I see are filled with annotations. Can we even write code in pure java without a single annotation ? Theres a lot of magic going on with annotation. It works great while it is running. God forbid there is some issue and we have to figure it out where all the magic is happening.

It was the @Query annotation which finally killed Spring for me. So I have to stuff all my SQL into an annotation now if I want raw JDBC? Madness. **ck that.

Re: Don’t call it a comeback: Java is still champ

#509
post #421

Earlier quoted context omitted.

I agree with most of your points, but also really dislike Visual Studio. Rider has very good compatibility (unless you care about the constant hangs and crashes and buggy, nonsensically laid out eye sore UI and dumb defaults and ...) and VSCode (the one with all the proprietary Microsoft stuff) is quite usable. What kind of blew me away was finding out that they support Jupyter notebooks now. The Visual Studio team s…

Microsoft's multi-platform play is only skin-deep. Witness the lag in features for Visual Studio for Mac which will not be getting .Net MAUI compatibility until a long time after the Windows version.

Visual Studio for Mac is yet another branding fail. It's just Xamarin/Mono Studio and has very little to do with the VS code base.

Re: Don’t call it a comeback: Java is still champ

#510

Java was actually not bad for me in class when learning software design and data structures, but soul-crushing to work with in the real world. Mindless, unnecessary use of getters/setters, interfaces, and AbstractFactoryImpls. Hiding almost every piece of functionality behind 10+ layers of indirection. Dependency Injection with Spring. They all make it feel like Java draws folks who actually __enjoy__ writing bloated…

I don't think this is an issue with Java, it's an issue with Spring. I'm baffled by the popularity of Spring.

I have worked with Spring and Spring Boot extensively, and I also don't understand why people like it. It is convenient when it works, but otherwise it's a hindrance. It adds a significant layer of complexity to understanding how an application works, and to debugging.
Post reply on HN