Better HN
topnewbestaskshowjobs
Log inSign up

haglin

114 karma · joined Sep 6, 2017 (9y ago) · 66 submissions

Submissions

comment 1w ago · link · parent

The benefit is that they will fall down in 5-10 years.

That's an automatic off switch.

comment 1mo ago · link · parent

> 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.

comment 1mo ago · link · parent

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.

comment 4mo ago · link · parent

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.

comment 1y ago · link · parent

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.

comment 1y ago · link · parent

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.

comment 1y ago · link · parent

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.

comment 1y ago · link · parent

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

comment 1y ago · link · parent

Since JDK 11 (released in 2018).

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

comment 2y ago · link · parent

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.

comment 2y ago · link · parent

"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"

comment 3y ago · link · parent

> 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

comment 3y ago · link · parent

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.

comment 3y ago · link · parent

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();
    ...

comment 4y ago · link · parent

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.

comment 5y ago · link · parent

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

comment 5y ago · link · parent

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

comment 6y ago · link · parent

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.

comment 7y ago · link · parent

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());
     });
   }

20.

JEP 349: JFR Event Streaming Targeted (Java)(openjdk.java.net ↗)

2 points · by haglin · 7y ago · 1 comment

comment 7y ago · link · parent

New IO.

comment 7y ago · link · parent

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.

comment 7y ago · link · parent

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++.

comment 7y ago · link · parent

If you want to sell software or services to the government you need to be 508 compliant

https://www.section508.gov/sell

comment 7y ago · link · parent

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....

comment 7y ago · link · parent

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/

comment 7y ago · link · parent

Data Classes for Java https://cr.openjdk.java.net/~briangoetz/amber/datum.html

comment 7y ago · link · parent

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));

}

comment 7y ago · link · parent

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.

comment 8y ago · link · parent

I agree that the Android APIs are not good.

Have you looked at JDK itself?

123