News for hackers. Stuff that matters.

haglin

Re:Getting Banned from r/java on Tuesday October 20, 2026 @03:13PM (#50171254)
> AI rarely seems to write better code than humans.

That's my experience as well.

AI does a decent job of reviewing and finding bugs, but it has no concept of what makes code good or bad - too much state, convoluted logic, no invariants, unnecessary methods, poorly defined abstractions, not relying on fail-fast etc.

It's similar to work from a junior developer with little experience maintaining code over a longer period of time.

Re:Artificial Insanity on Sunday October 11, 2026 @06:14PM (#50048450)
If you want to describe the limitations of today’s LLMs, "frozen brains" might be a better metaphor than "stochastic parrots". They can’t learn continuously as we do, which makes it hard for them to invent entirely new concepts - like calculus.
Re:Why low-latency Java still requires discipline? on Monday July 06, 2026 @11:18AM (#48805881)
I work on OpenJDK, so I may be biased, but I’ve also found that JFR works really well with LLMs.

  $ java -XX:StartFlightRecording:maxsize=10M,filename=dump.jfr -jar app.jar

  $ jfr view all-views dump.jfr > report.txt

  $ jfr print dump.jfr > all.txt
Then ask Codex, or whatever AI tool you use, to analyze report.txt for issues and use all.txt to dig deeper, if needed.
Re:Minecraft removing obfuscation in Java Edition on Thursday October 30, 2025 @12:17AM (#45756392)
I find inheritance works best when you model things that don't exist in reality, but only as software concepts, for example, an AbstractList, Buffer or GUI component.
Re:The Theatre of Pull Requests and Code Review on Thursday September 25, 2025 @07:39PM (#45380740)
It would be in the "Files changed" section on GitHub, not in the git history. If you don't want to see the context, you can turn it off.
Re:The Theatre of Pull Requests and Code Review on Thursday September 25, 2025 @07:17PM (#45380540)
Splitting up a PR is a lot of work, especially if you want each commit to compile, but it would be great if you could categorize changes using 5–10 colors and then have checkboxes that you can toggle to hide code corresponding to a color.

What each color means would depend on the PR, but, for instance, yellow = refactoring, brown = test code, blue = drive-by fix, orange = more efficient data structure etc.

The colors and their meanings could be set by either the author or the reviewers. It would be similar to the file checkboxes that exist today, but in this case, it would be per concept, not per file.

Re:MinC Is Not Cygwin on Wednesday April 23, 2025 @10:28AM (#43772642)
Yeah, Windows 2000 was probably the best operating system Microsoft ever produced. It had no crashes, a snappy/intuitive/sleek user interface, and DirectX support for games. I am currently running Mac OS X because I never liked Windows XP/Vista/10/11.

In hindsight, the progress Microsoft made in the ten years between Windows 3.0 (1990) and Windows 2000 seems incredible. They transitioned from a 16-bit shell running on top of DOS to a fully-fledged operating system with a hardware abstraction layer, preemptive multitasking, permissions, a registry, proper device drivers etc.

Twenty-five years later, there has been basically no progress.

At a minimum, I would have expected something like the Knowledge Navigator

https://www.youtube.com/watch?v=umJsITGzXd0

Re:Java is dying and it paid off my mortgage on Friday April 11, 2025 @04:03AM (#43651478)
Since JDK 11 (released in 2018).

"Launch Single-File Source-Code Programs" https://openjdk.org/jeps/330

Re:The sorry state of Java deserialization on Sunday September 22, 2024 @05:46PM (#41620360)
JFR only samples running Java methods.

I would guess at least some of the bottlenecks are in hardware, the operating system or in native code (including the JVM) in this case.

Re:Bending pause times to your will with Generational ZGC on Wednesday March 06, 2024 @06:41PM (#39623261)
"Left unquestioned, assumptions and expectations could have caused us to miss one of the most impactful changes we’ve made to our operational defaults in a decade"
Re:Should I Rust or should I Go on Friday September 15, 2023 @09:51PM (#37531230)
> the only knock you can put on Java for reliability is null-safety

FWIW, nullity control has been added to the Valhalla project, so it might be fixed going forward.

https://youtu.be/Ma0NtbG0mHY?feature=shared&t=1076

Re:Inactive Google Account Policy on Friday August 11, 2023 @10:31PM (#37096408)
Two years it too short.

The reason I now use gmail and not hotmail is because Microsoft did a similar thing 20 years ago. When I lost my hotmail account, I thought I might as well use gmail from now on. Reason I didn't log into my hotmail account was because I used the mail address I got from the university.

Re:Writing a Profiler in 240 lines of pure Java on Wednesday March 29, 2023 @09:38AM (#35357108)
An alternative to avoid safepoints (only samples executing threads)

    var r = new RecordingStream();
    r.enable("jdk.ExecutionSample").withStackTrace().withPeriod(Duration.ofMillis(1));
    r.onEvent("jdk.ExecutionSample", e -> {
        store.addSample(e.getStackTrace().getFrames());
    });   
    r.startAsync();
    ...
Re:Retrofitting null-safety onto Java at Meta on Wednesday November 23, 2022 @02:12PM (#33723338)
There are multiple ways to represent an optional value, for example:

1) an empty list/array 2) throw an exception if the return value is missing. 3) -1

Optional can be used as a better alternative in all these cases. It's not just null.

Hotspot has sub-millisecond GC pause times.

"But as long as your system isn’t heavily over-provisioned, you can expect to see average GC pause times of around 0.05ms (50µs) and max pause times of around 0.5ms (500µs)." https://malloc.se/blog/zgc-jdk16

Re:Java 16 on Wednesday March 17, 2021 @02:46PM (#26495265)
And in JDK 16, ZGC has concurrent thread-stack processing, which typically reduces GC pauses below 1 ms

https://openjdk.java.net/jeps/376

https://youtu.be/88E86quLmQA?t=1525

Re:Java Memory Analyzer on Sunday April 12, 2020 @12:06AM (#22845983)
The JDK comes with a powerful memory leak tool.

$ java -XX:StartFlightRecording:settings=profile MyApp

$ jcmd MyApp JFR.dump paths-to-gc-root=true filename=dump.jfr

$ jfr print --events OldObjectSample --stack-depth 64 dump.jfr

The tool will list objects on the heap, their path to the GC roots and allocation stack trace. That is usually sufficient to solve the memory leak. No need to create a large HPROF file or upload data to a server. Everything can be done in the shell.

https://docs.oracle.com/en/java/javase/13/troubleshoot/troub...

Sensitive information, like credit card numbers, will not even leave the Java heap.

Re:JEP 349: JFR Event Streaming Targeted (Java) on Friday October 18, 2019 @03:54PM (#21294571)
In JDK 14, Flight Recorder events will be available for monitoring.

   try (var rs = new RecordingStream()) {
     rs.onEvent("jdk.GCPhasePause", event -> {
       System.out.println(event.getDuration());
     });
   }
Re:Ask HN: Java NIO stands for non-blocking I/O or New I/O? on Monday September 30, 2019 @02:26PM (#21118244)
New IO.
Re:IT Runs on Java 8 on Saturday May 11, 2019 @04:25PM (#19888190)
I haven't tried serverless, but shouldn't that be Java's cup of tea?

The JVM can load code dynamically and adapt the runtime to the work load. Maybe there is a framework missing, so those that provide serverless starts a new JVM per function call, but they shouldn't really have to do that.

Re:Negotiations Failed: How Oracle Killed Java EE on Tuesday May 07, 2019 @07:21AM (#19848382)
For arbitrage that must happen really fast, FPGAs is the way to go, and for complex code that needs to be rewritten often and quickly, Java is probably a better fit than C++.
If you want to sell software or services to the government you need to be 508 compliant

https://www.section508.gov/sell

Re:Ask HN: CLI – Java or Python or Go? on Friday March 22, 2019 @04:05AM (#19460397)
JDK 11 comes with a new HttpClient. Might be useful and fun to learn.

https://docs.oracle.com/en/java/javase/11/docs/api/java.net....

Re:Koin3D, a Coin3D java port, based on LWJGL on Wednesday March 13, 2019 @07:19PM (#19384971)
With ZGC[1], value types[2] and Panama[3], Java will be great platform for gaming and 3D graphics.

Write once and it will work on Linux, Windows and Mac OS X.

[1] https://openjdk.java.net/projects/zgc/

[2] https://openjdk.java.net/projects/valhalla/

[3] https://openjdk.java.net/projects/panama/

Re:Lombok makes Java cool again on Friday February 01, 2019 @08:55PM (#19060497)
I like to see simplified loops in Java. For example, traverse two collections/arrays of the same size simultaneously.

for (var f : fathers, var m : mothers) {

  families.add(new Family(f, m));

}
Re:JIRA is an antipattern on Sunday December 09, 2018 @03:12PM (#18642986)
It depends on how you use it.

You can create a design ticket where you describe the larger overall picture (city planning) and then as you implement it, add enhancements (neighbourhoods and sewers) as subtasks. If something breaks when you add the enhancement, for example a memory leak when calling method X, you can create a bug ticket that only concerns the micro details.

Re:Why I love Common Lisp and hate Java (2012) on Monday November 05, 2018 @05:02AM (#18381113)
I agree that the Android APIs are not good.

Have you looked at JDK itself?

Re:Why I love Common Lisp and hate Java (2012) on Saturday November 03, 2018 @08:09PM (#18373210)
If you are running JDK 9 or later, you can use jshell:

jshell> "Hello World!"

$1 ==> "Hello World!"

https://openjdk.java.net/jeps/222

Older »