Live data from Hacker News

Ask HN: What is a modern Java environment?

news.ycombinator.com

131–140 of 153 posts

Re: Ask HN: What is a modern Java environment?

#131
post #119

Earlier quoted context omitted.

Containerization is great. It allows you to write all the infrastructure for you Java app as code and then just simply type 'docker-compose up' to get it running (or whatever your orchestrator). This makes it super portable. Just something to think about. I personally think the win's from Containerization are greater than the challenges.

You don't necessarily need containers for that though?

The alternative would be hosted functions, like lambda, which is just running in someone else's containers.

Re: Ask HN: What is a modern Java environment?

#132
post #129

Earlier quoted context omitted.

> We avoid the fanfare of Docker, as really it's not needed for Java apps; they're somewhat self-contained anyway and it created more problems than it solved. What does this mean?

Because the code runs in a VM already, they are not concerned about isolating further. For example, if you're writing code in C++ targeting Linux, using Docker helps with reproducible builds and deploying on any hardware. But if you have a VM, there are less advantages. There still are some, of course, with orchestration etc if you want it.

I guess I was implying that I don't view the benefits between the prior and the later as an onto mapping.

Re: Ask HN: What is a modern Java environment?

#133
post #78
post #33

Earlier quoted context omitted.

Netbeans was really great, maybe still is, but the noise jetbrains made with the astroturfing advertizing has jetbrains dominating everything. IMHO Netbeans was ahead of idea in many ways. But since they didn't buy commenteers to hype their product it's pretty much nowhere, at least I don't know anyone who uses it.

I'm someone who has regularly recommends Jetbrains software (including IntelliJ and Resharper) to others in comments, and now I'm wondering if they forgot to send me my check.

I too lack a check.

Re: Ask HN: What is a modern Java environment?

#134
post #120

Personally, after the log4j fiasco, I wouldn't touch Java. The standard ecosystem setup is to use all the major 3p libraries for all your functionality (Jaxrs, swagger, log4j, jersey, e.t.c) While this generally works, the ecosystem is full of holes (like log4j), and crappy behavior. You get things like "javax.ws.rs.ProcessingException: Already connected", exceptions which mask underlying issues like not being able t…

> Network latencies dominate the processing speed these days I want to see data on this. It gets repeated over and over but this doesn't match my experience at all. Am I crazy?

It takes me about 250ms to load hackernews as seen on the browser debug network tab. The total compute for that request is minimal. Speeding this up may reduce total infrastructure costs, where if everything is kept static you will see benefits long term, but in terms of reducing total latency, it will be next to irrelevant.

Re: Ask HN: What is a modern Java environment?

#135

I'll chime in my opinion: Java is getting something right that I don't see much elsewhere: Dependency Injection. Combine this with a mocking framework and you can write _actual_ isolated unit tests for every single part of your stack. We're fans of CDI, it's a more polished Spring framework without the legacy weight. We're developing in Quarkus, MicroProfile, and bigger monoliths in Apache TomEE. We use ActiveMQ exte…

I've been a developer over a decade, never touched the JVM because I always figured it was bloated Enterprise garbage. I did a project using GraalVM's polyglot abilities and needed an API. Tried Spring, Micronaut, Helidon, Ktor and Quarkus. Quarkus is the best web framework I've ever used, in any language. Can't go back now. It's so well-architected that I was able to contribute an extension for Scala 3 support withi…

Just had a look at your scala 3 extension, it's really nice. Does it support hot code reload like you would get in quarkus dev mode with java?

Re: Ask HN: What is a modern Java environment?

#136

Earlier quoted context omitted.

I'd suggest using koin instead of Dagger. Dagger is alright but mainly popular in the Android world where Koin is the main alternative. However, Koin is native to Kotlin and a kotlin multiplatform project. So you can use it on Android, server development, IOS native, kotlin-js, etc.

Nice, I haven't seen this one. We've been using Dagger to get people off of runtime DI for migrating to serverless, but I'll take a look. I assume it's compile-time DI?

Koin is a kotlin DSL. So no annotations, reflection, or compiler magic are needed. Basically it just instantiates things for you on demand and uses normal kotlin features like lambda functions, receiver objects, and property delegation.

You can inject a property by defining it as a koin injected property:

  class SomeClass {
    val foo by koinContext.inject()
  }
And this is how you could create your koin context:

  class Bar()
  class Foo(bar: Bar)

  val myModule = module { 
    single { Bar() } 
    // get() knows the type from the argument position at compile time
    // and it looks the object from the context by type
    single { Foo(get()) }
  }

  // trigger this in your main or at application startup
  startKoin {
    modules(myModule)
  }

  // if you want to use inject, you can use a global variable for getting at the context
  val koinContext by lazy { GlobalContext.get() }
Modules can be tied to life cycles on Android and there are a few more features like being clever about co-routine scopes. But there's not a lot more to it in terms to using it. Very simple code to write. Low overhead. It's all just function calls.

Spring has a similar kotlin bean dsl that was added a while ago that you can use as an alternative to annotation processing (which is much slower).

Re: Ask HN: What is a modern Java environment?

#137
post #91

Earlier quoted context omitted.

Yes. Perhaps to add to this, use a modern asynchronous IO framework. If you use Spring Boot, ignore some of the legacy stuff that still comes with it and make sure you use webflux with Kotlin co-routines. Also use Asynchronous IO for talking to your database, queues, etc. Kotlin makes all of this easy. Hibernate is something I tend to avoid for various reasons but apparently recent versions of that now also support a…

I really wouldn’t go the async way unless it was deemed absolutely necessary for maximal performance — it makes reasoning/debugging much harder with often not much gain. Also, if one can just wait a few years, loom will make many part of it obsolete - when blocking code will magically get non-blocking while it retains the readibility.

I've had very few issues with that. Mostly the async code looks almost identical to the synchronous variant with Kotlin. There's a bit of a learning curve and it helps if you understand parallel and asynchronous programming a little. There is no magic with blocking vs. non blocking. Your IDE will tell you if you are doing it wrong. The fix is usually to have a co-routine context backed by a thread pool and schedule co-routines that block there.

Loom won't make any of this obsolete. If anything, co-routines will probably be the most user friendly API to use Loom when it comes available. Loom is a pretty low level API and you probably should not use it directly and instead use something that uses that. Like Kotlin co-routines, which is designed as a high level API that can be backed by all sorts of asynchronous and parallel computing implementations/

Extension functions exist for webflux, rx-java, vert.x, thread pools and much more. Basically, it sits on top of these things. It also works on kotlin native, kotlin-js (in a browser and node-js) and in the JVM where the underlying platform of course provides very different implementations. For the end user, it works pretty much in the same way across these platforms.

Loom will just be another low level backend for the co-routine API. It will likely give you some performance benefits if it's available and that's about it. Update the co-routine library, maybe fiddle a bit with your co-routine scope's and you'll be using Loom. I'd expect very little code changes would be needed when the time comes. Perhaps none at all actually (aside from bumping a version number).

Re: Ask HN: What is a modern Java environment?

#138
post #120

Earlier quoted context omitted.

> Network latencies dominate the processing speed these days I want to see data on this. It gets repeated over and over but this doesn't match my experience at all. Am I crazy?

It takes me about 250ms to load hackernews as seen on the browser debug network tab. The total compute for that request is minimal. Speeding this up may reduce total infrastructure costs, where if everything is kept static you will see benefits long term, but in terms of reducing total latency, it will be next to irrelevant.

I can list a ton of tools I use daily that are incredibly slow, but don't even need the network most of the time.

By "incredibly slow" I mean comparing what it does versus how fast it could be on an average machine.

Network and other I/O latency is often used as an excuse and sweeping generalization. It's never that easy. You need to actually look at a running process and gather data about it before you can make claims about what the bottlenecks are. Also even if there are constant factors that you cannot optimize it doesn't absolve a program from being slow in every other aspect, secondly there are techniques to mitigate and isolate latency bottlenecks.

Re: Ask HN: What is a modern Java environment?

#139
post #135

Earlier quoted context omitted.

I've been a developer over a decade, never touched the JVM because I always figured it was bloated Enterprise garbage. I did a project using GraalVM's polyglot abilities and needed an API. Tried Spring, Micronaut, Helidon, Ktor and Quarkus. Quarkus is the best web framework I've ever used, in any language. Can't go back now. It's so well-architected that I was able to contribute an extension for Scala 3 support withi…

Just had a look at your scala 3 extension, it's really nice. Does it support hot code reload like you would get in quarkus dev mode with java?

Yes, that's correct =)

Admittedly the install instructions for Gradle are a bit dated. Gradle 7.4 shipped with Scala 3 support.

Re: Ask HN: What is a modern Java environment?

#140
post #109

Earlier quoted context omitted.

Unfortunately not. Records are not compatible with JPA, so classic beans with getters and setters would still be a choice for many people. Record-friendly ORMs do not exist yet (I’m currently working on one).

Could you please share your ORM? I would really like to use java with much less reflection.

Feel free to star this repo and comment: https://github.com/ivan-gammel/orm16
Post reply on HN