frontpage.
newsnewestaskshowjobs

Open Source @Github

fp.

Association of sedentary behaviors w cortical, subcortical &white matter volumes

https://alz-journals.onlinelibrary.wiley.com/doi/10.1002/alz.71582
1•bookofjoe•3m ago•0 comments

Where B2B Buyers Ask on Reddit: 30 Days of Scan Data

https://cuescout.com/blog/where-b2b-buyers-actually-ask-on-reddit
1•tgdaimov•3m ago•0 comments

The asymmetry problem: AI safeguards are mainly annoying to the good guys

https://cephalosec.com/blog/the-asymmetry-problem-ai-safeguards-are-mostly-hindering-the-good-guys/
1•Versipelle•3m ago•0 comments

We're Squandering LEDs' Potential to Save Our Night Skies

https://spectrum.ieee.org/led-light-pollution
1•defrost•4m ago•0 comments

Landmark Science Report Confirms Big Oil's Fingerprints on Extreme Weather

https://www.commondreams.org/newswire/landmark-science-report-confirms-big-oils-fingerprints-on-e...
1•robtherobber•5m ago•0 comments

Codex is wearing out our devices

https://old.reddit.com/r/codex/comments/1v0m3lt/codex_is_wearing_out_our_devices/
1•spenvo•6m ago•2 comments

Grading Is Easy, Feedback Is Hard: Evaluating LLMs for OOP Assessment [pdf]

https://github.com/elipcs/grading-is-easy-feedback-is-hard/blob/main/docs/Grading_Is_Easy_Feedbac...
1•lucis•8m ago•0 comments

Memory Safety's Hardest Problem

https://matklad.github.io/2026/07/20/memory-safety-hardest-problem.html
1•surprisetalk•9m ago•0 comments

Show HN: Give your AI agent a personality (and a voice) without external APIs

https://fellowgeek.github.io/mcp-speak/
1•pcbmaker20•10m ago•0 comments

AgentBaiting: Fake AI Skills and MCP Servers Delivered Malware

https://www.island.io/blog/agentbaiting-how-800-fake-ai-skills-and-mcp-servers-delivered-malware
1•deronEx•10m ago•0 comments

Anduril reveals Thunder, a 'loyal wingman' drone for helicopters

https://breakingdefense.com/2026/07/anduril-reveals-thunder-a-loyal-wingman-drone-for-helicopters/
1•atlasunshrugged•10m ago•0 comments

The Most Counterintuitive Way to Build a Brain [video]

https://www.youtube.com/watch?v=cDxtFtoQVNc
1•surprisetalk•10m ago•0 comments

Chinese AI model Kimi K3 halts new signups amid skyrocketing demand

https://www.euronews.com/next/2026/07/20/chinese-ai-model-kimi-k3-halts-new-signups-amid-skyrocke...
2•teleforce•10m ago•0 comments

NYC Roam: 3D world with real transit and building data

https://www.nycroam.com/
2•heresalexandria•12m ago•1 comments

MIT researcher proposes a way to detect nuclear weapons in space

https://news.mit.edu/2026/mit-researcher-proposes-way-to-detect-nuclear-weapons-in-space-0708
2•JeanKage•12m ago•1 comments

Yunnan's mineral wealth and border corridors could solve China's Malacca dilemma

https://www.scmp.com/news/china/military/article/3361079/how-yunnans-mineral-wealth-and-border-co...
1•teleforce•13m ago•0 comments

Soofi – Sovereign Open Source Foundation Models

https://www.soofi.info/
2•Fake4d•19m ago•0 comments

Datasette-plot – Datasette Plugin for building data visualizations

https://www.datasette.cloud/blog/2023/datasette-plot/
2•ankitg12•19m ago•0 comments

How Would For-Hire Autonomous Vehicles Impact NYC?

https://www.openplans.org/how-for-hire-autonomous-vehicles-impact-nyc
1•geox•21m ago•0 comments

The Return (2024 Film)

https://en.wikipedia.org/wiki/The_Return_(2024_film)
1•BiraIgnacio•21m ago•1 comments

The Reverse Information Paradox (Satya Nadella)

https://snscratchpad.com/posts/reverse-information-paradox/
1•adletbalzhanov•22m ago•0 comments

CRA Compliance Kit – EU Cyber Resilience Act in One Pip Install

https://starcaller.uk/cra-compliance/
1•sparka•22m ago•0 comments

Hugging Face Data Breach

https://techcrunch.com/2026/07/20/hugging-face-confirms-breach-affected-internal-datasets-and-cre...
3•dotmanish•23m ago•0 comments

Stop Using OpenCode

https://wren.wtf/shower-thoughts/stop-using-opencode/
2•alekq•25m ago•0 comments

AgentAbstain: Do LLM Agents Know When Not to Act?

https://arxiv.org/abs/2607.10059
2•embedding-shape•26m ago•0 comments

AGI Singer: Take the Next Exit

https://medium.com/@miho999lv/agi-singer-take-the-next-exit-21355823c289
2•miho999lv•28m ago•0 comments

E-scooters set to be banned for under-18s

https://www.rte.ie/news/ireland/2026/0720/1584131-escooters-ireland-meeting/
2•austinallegro•28m ago•1 comments

ESP32 Server: Distributing HTTP/2 Streams over TLS

https://c410-f3r.github.io/thoughts/esp32-server-distributing-http2-streams-over-tls/
1•CaioFer•29m ago•0 comments

How the Apple Watch water lock feature works

https://www.engadget.com/2213629/how-apple-watch-water-lock-feature-works/
1•bookofjoe•30m ago•0 comments

The Tablet the Doctor Ordered

https://cuencahighlife.com/the-tablet-the-doctor-ordered/
1•dxs•30m ago•0 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.