frontpage.
newsnewestaskshowjobs

Open Source @Github

fp.

What Should I Build?

1•gooob•1m ago•0 comments

ClawMoat, runtime containment for AI agents after Fable 5

https://clawmoat.com/
1•ildar•2m ago•0 comments

5.3M-year-old deep-sea whale necropolis in the Diamantina Zone

https://www.nature.com/articles/s41586-026-10546-z
3•defrost•4m ago•0 comments

Ask HN: Which cheap Chinese LLM are you using?

1•linzhangrun•5m ago•0 comments

GIER: A Danish computer from 1961 with a role in the modern astronomy

https://arxiv.org/abs/1704.05828
1•andrewstuart•7m ago•0 comments

Lime 2.0 – Zero Human Auth for AI Agents

https://lime.pics
1•MawyxxY•18m ago•1 comments

Brew Browser: A Native macOS GUI for Homebrew

https://github.com/msitarzewski/brew-browser
2•amichail•23m ago•0 comments

Vincent's parents 'never say he's good enough' so he turned to a couple online

https://www.bbc.com/news/articles/cpq3dnr5vlzo
2•breve•26m ago•0 comments

The whirlwind 24 hours that led to export controls on Anthropic

https://www.politico.com/news/2026/06/13/inside-the-whirlwind-24-hours-that-led-the-white-house-t...
4•ls612•28m ago•1 comments

Surface Data vs. Deep Data [video]

https://www.youtube.com/watch?v=vk6lgHjjGp8
1•zetamax•31m ago•0 comments

The Siren Song of Illness

https://www.nybooks.com/articles/2026/06/25/the-siren-song-of-illness-master-of-contradictions-je...
2•t0lo•34m ago•0 comments

The Missing Infrastructure Between AI Agents and the EVM

https://blog.bridgexapi.io/the-missing-infrastructure-between-ai-agents-and-the-evm
1•Bridgexapi•34m ago•0 comments

Fable: Two edges of one opinion, on a model switched off

https://rebraining.org/fable
1•Jakko-KAAMOS•36m ago•0 comments

'Tell Him He's a Piece of Shit': Meta's New AI Unit Is a Total Mess

https://www.wired.com/story/mark-zuckerberg-meta-employee-meeting-interrupt-ai/
15•momentmaker•41m ago•4 comments

Let's Destroy American Science

https://nasawatch.com/policy/lets-destroy-american-science/
7•voxadam•45m ago•1 comments

Russian families use AI to 'resurrect' loved ones killed in Ukraine

https://www.bbc.com/news/articles/cwy24v72n19o
3•breve•46m ago•1 comments

Monero Inflation Checker

https://www.moneroinflation.com/
1•Cider9986•49m ago•0 comments

Switzerland to vote on plan to cap population at 10 million

https://www.bbc.com/news/articles/cx23kz7e76po
2•breve•51m ago•0 comments

4 things to know about the new sunscreen ingredient the FDA approved

https://www.npr.org/2026/06/13/nx-s1-5856385/sunscreen-skin-protection-bemotrizinol
30•mikhael•54m ago•1 comments

The "Best" HN Comments

https://news.ycombinator.com/bestcomments
3•embedding-shape•56m ago•0 comments

There is no such thing as an AI 'artist'

https://www.spiked-online.com/2026/06/07/there-is-no-such-thing-as-an-ai-artist/
4•mikelgan•58m ago•2 comments

The AI supply chain is a software supply chain with new failure modes

https://blog.r-lopes.com/newsletter/2026-06-03
3•dovelome•59m ago•0 comments

Fable 5: They switched off my AI mid-build. The timeline is the story

https://medium.com/@alirezarezvani/fable-5-anthropic-and-us-gorvernment-how-ai-export-controls-ju...
2•jungard•59m ago•0 comments

FDA OKs first new sunscreen ingredient in more than 25 years

https://apnews.com/article/sunscreen-fda-bemotrizinol-ingredient-uva-protection-9b9c7e04b418b3c9c...
15•marc__1•1h ago•2 comments

The Future of Software Engineering Is Here; It's Just Not Evenly Distributed

https://twitter.com/jmugan/status/2065962078322438524
2•jmugan•1h ago•0 comments

Goldman and Morgan Stanley to Pocket $100M Each in SpaceX IPO Fees

https://www.wsj.com/livecoverage/spacex-ipo-stock-market-06-12-2026/card/goldman-and-morgan-stanl...
4•vismit2000•1h ago•0 comments

Color Photos of Stalin-Era Soviet Union Taken by a US Diplomat

https://rarehistoricalphotos.com/stalin-era-soviet-union-pictures-martin-manhoff/
8•Cider9986•1h ago•1 comments

Anthropic's Economic Policy Framework [pdf]

https://www-cdn.anthropic.com/files/4zrzovbb/website/9ea607a5dd67c168093829b701f3a0a6d21156d5.pdf
2•jonbaer•1h ago•0 comments

Policy on the AI Exponential

https://www.anthropic.com/policy-on-the-ai-exponential/epf
2•jonbaer•1h ago•0 comments

10th Gen Honda Civic Updates Are Signed with AOSP Test Keys

https://juniperspring.org/posts/honda-evil-valet/
5•librick•1h ago•1 comments
Open in hackernews

Understanding Java's Asynchronous Journey

https://amritpandey.io/understanding-javas-asynchronous-journey/
17•hardasspunk•1y ago

Comments

Neywiny•1y ago
I don't get it. The first example in JS vs Java looks very similar. Now all those other code blocks, they certainly have more going on but idk how that compares to JS. And to answer the questions:

A completable future is something that in the future may complete. I think that's self explanatory. A promise seems equally vague.

Boilerplate looks the same. JS is just a function, Java they put a class around it. Java requires exception handling which is annoying but having fought errors in async JS, I'll take all I can get.

API is eh. Sure. But that's not even shown in this example so I have no idea.

So JS saves like 3 lines? Is that really so much better?

cogman10•1y ago
> A completable future is something that in the future may complete. I think that's self explanatory.

But not the reason for the name :).

It's called "completable" because these futures have a method on them `future.complete("value")`. Before their introduction, there was a `Future` API that java had.

nogridbag•1y ago
Yeah that first example is rather poor. And it uses the word boilerpate to seemingly refer to the stuff unrelated to the async code (class declaration, exception handling, main method).

I don't use Java async much, but I guess if you have a utility method named "setTimeout" than the example can simply be:

    public CompletableFuture<String> fetchData() {
        return setTimeout(() -> "Data Fetched", 10000);
    }

    public void loadData() {
        fetchData().thenAccept(System.out::println);
    }
Which is simpler or equivalent to the JS example.
stevoski•1y ago
The Java 1 example uses lambdas, which were introduced in Java 8.

It’s probably intentional, because it allows showing the Java 1 Thread approach succinctly.

But as long-term Java person, I find it jarring.

philipwhiuk•1y ago
Java's had `var` since Java 10 but apparently the author deliberately ignored that to make the example as wordy as possible.

It's a little tiring to read a Java example with an entry-point (the public-static-void bit) and then a JavaScript example without one.

If you strip that out the original Java is:

  var future = CompletableFuture.supplyAsync(() -> {
        try {
                Thread.sleep(10000);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
            return "Data Fetched";
        });
  future.thenAccept(result -> System.out.println(result));
  System.out.println("Prints first"); // prints before the async result
which is only obtuse due to checked exceptions.

Arguably it's still a different thing you're doing, because it's not scheduling a task on a pool, it's creating a thread which sleeps for 10 seconds.

elric•1y ago
`var` is very unhelpful in situations where the reader might not be entirely familiar with the context, especially when using factory methods.

I don't think the author was trying to make the example "wordy" so much as "clear".

cogman10•1y ago
Also, arguably, the wrong way to do something like this.

The author uses `setTimeout` for javascript. The equivalent for Java is either the `Timer` class or a `ScheduledExecutorService`. Doing a `Thread.sleep` simply isn't how you should approach this.

With that in mind, if you want to use both these things and keep the completable future interface you'd have to do soemthing like this.

    ScheduledExecutorService scheduler = Executors.newScheduledThreadPool(1);
    var future = new CompletableFuture<String>();
    scheduler.schedule(()->future.complete("Data Fetched"), 10, TimeUnit.SECONDS);
    future.thenAccept(result -> System.out.println(result));
    System.out.println("Prints first"); // prints before the async result
    scheduler.shutdown();
AtlasBarfed•1y ago
Does no.js still limit you to a single core/CPU use?

Or as a node successfully been able to start utilizing more cores underneath its JavaScript single thread model. It presents the programmer?

I just remember early node.js from like 15 years ago and the single background task limitation of JavaScript running in a web page.

Cuz you got async code is nice, but what you really wanted to be able to harness in modern CPUs is multi-core

That said, I've been looking for an article like this for a while, although I think there are other associated libraries that also had steps in here. I do think the jvm adopted a lot of those, but I'm not sure if they actually are better than the original extension libraries.

msgilligan•1y ago
I simplified the first example to:

  void main() {
      CompletableFuture<String> future = CompletableFuture.supplyAsync(this::asyncMethod);
      future.thenAccept(result -> IO.println(result));
      IO.println("Prints first");             // prints before the async result
      future.join();                          // Wait for future to complete
  }

  String asyncMethod() {
      try {
          Thread.sleep(10000);
      } catch (InterruptedException e) {
          return "Interrupted";
      }
      return "Data Fetched";
  }
I made the following changes:

1. Move the asynchronous function called in the CompletableFuture to its own method

2. Use Java 25 "instance main method" (see JEP 25: https://openjdk.org/jeps/512)

3. Use Java 25 IO.println() to simplify console output

4. Instead of throwing a fatal exception on interruption, return "Interrupted" immediately.

5. Use future.join() so the main method waits for the future to complete and the "Data fetched" output is printed.

This program can be run directly from source with `java Example.java`. (If you're using Java 24 or a version of Java 25 prior to EA 22, you need to use `java --enable-preview Example.java`)

Here is a modified version of the example that interrupts the thread:

  void main() {
      ExecutorService executor = Executors.newSingleThreadExecutor();
      CompletableFuture<String> future = CompletableFuture.supplyAsync(this::asyncMethod, executor);
      future.thenAccept(result -> IO.println(result));
      IO.println("Prints first");             // prints before the async result
      executor.shutdownNow();
      future.join();                          // Wait for future to complete
  }

  String asyncMethod() {
      try {
          Thread.sleep(10000);
      } catch (InterruptedException e) {
          return "Interrrupted";
      }
      return "Data Fetched";
  }
wpollock•1y ago
In Java 24, new features support educational and demonstration use. You don't need a class to wrap your main method, which also has a simpler signature. To compare JavaScript with Java examples, one should make use of these features.

While the examples may need some work, I enjoyed this post, it nicely shows the evolution of Java concurrency.