frontpage.
newsnewestaskshowjobs

Made with ♥ by @iamnishanth

Open Source @Github

fp.

Determinate Nix 3.14.0: introducing a new command for visualizing Nix builds

https://determinate.systems/blog/changelog-determinate-nix-3140/
1•biggestlou•1m ago•0 comments

Bitchat Secure Worldwide Messenger

https://bitchat.free/
1•Fake4d•1m ago•0 comments

Ask HN: Should we start switching payment providers dynamically

1•marchypolite•1m ago•0 comments

Show HN: An Automated Document Gap Analysis Tool Using AI

https://riftur.com/
1•sophia-martinez•2m ago•0 comments

US Fed will start buying Treasury bills to manage market liquidity

https://www.reuters.com/business/finance/fed-says-will-start-reserve-management-treasury-bill-buy...
2•nimbius•4m ago•0 comments

Show HN: Alter – Switch Git username and email and credential in one line

https://github.com/AmaseCocoa/alter
1•amase•5m ago•0 comments

Ask HN: What're the most annoying repo setup stories you have?

1•kamesstory•5m ago•0 comments

Show HN: WhatsApp Backup Reader – Browse exports offline, data stays local

https://rodrigogs.github.io/whats-reader/
1•rodrigogs•6m ago•0 comments

Qobuz: 100M tracks in the best sound quality available for streaming

https://www.qobuz.com/us-en/discover
1•doener•6m ago•0 comments

Show HN: RepoSquirrel – Identify Code Ownership and Subsystem Contributors

https://github.com/reposquirrel/reposquirrel
1•reposquirrel•8m ago•0 comments

Half of people arrested in London may have undiagnosed ADHD, study finds

https://www.cam.ac.uk/research/news/half-of-people-arrested-in-london-may-have-undiagnosed-adhd-s...
2•gnabgib•11m ago•0 comments

YouTube CEO says more AI moderation is coming despite creator backlash

https://www.dexerto.com/youtube/youtube-ceo-says-more-ai-moderation-is-coming-despite-creator-bac...
3•not4uffin•11m ago•1 comments

After Microsoft's $17.5B commitment, Amazon announces a $35B investment by 2030

https://timesofindia.indiatimes.com/business/india-business/amazon-doubles-down-on-india-announce...
2•whoknowsidont•11m ago•1 comments

India proposes charging OpenAI, Google for AI training; lobbying group protests

https://techcrunch.com/2025/12/09/india-proposes-charging-openai-google-for-training-ai-on-copyri...
1•ilamont•12m ago•0 comments

EPA website removes fossil fuels as cause of global warming

https://www.euronews.com/green/2025/12/10/we-look-ridiculous-us-government-website-removes-fossil...
3•OutOfHere•14m ago•2 comments

Ode to My Office Lethargy

http://andersource.dev/2025/02/02/ode-to-my-office-lethargy.html
1•andersource•16m ago•0 comments

Solving Boggle (2021)

https://benknoble.github.io/scribblings/2021-10-27-boggle/2021-10-27-boggle.html
1•bariumbitmap•17m ago•0 comments

Code agents does not handles Jupyter well, so I build a special AI agent for it

https://www.youtube.com/watch?v=DNDVSAUAMsc
2•loa_observer•19m ago•0 comments

PowerWash Simulator

https://store.steampowered.com/app/1290000/PowerWash_Simulator/
1•doener•20m ago•0 comments

US seizes oil tanker off coast of Venezuela

https://www.usatoday.com/story/news/politics/2025/12/10/us-venezuela-oil-tanker/87704943007/
7•geox•21m ago•0 comments

macOS Music Players

https://andreyor.st/posts/2025-12-10-macos-music-players/
2•ibobev•22m ago•2 comments

Show HN: Clearquran.ai – Multi-agent LLMs translate the Quran

https://clearquran.ai
2•talal-itani•23m ago•1 comments

Reproductive risk of Neonicotinoids: A review of male rodent studies

https://www.sciencedirect.com/science/article/pii/S0013935125021553?via%3Dihub
2•PaulHoule•24m ago•0 comments

Lithium-ion battery pack prices fall to $108/kWh

https://www.ess-news.com/2025/12/09/bnef-lithium-ion-battery-pack-prices-fall-to-108-kwh-stationa...
4•toomuchtodo•26m ago•2 comments

51% attack simulator for PoW blockchain

https://fifty-one-attack.fmiras.com
1•fmiras•26m ago•0 comments

The Bubble Is Labor

https://danielmiessler.com/blog/the-real-bubble-is-human-labor
2•janpio•31m ago•2 comments

Parkinson's Might Be in the Water

https://www.wired.com/story/scientists-thought-parkinsons-was-in-our-genes-it-might-be-in-the-water/
7•wjb3•32m ago•0 comments

Renormalization: Gemini AI helped me see sense and beauty in two turbulent years

https://renormalize.substack.com/p/on-renormalization
1•getnormality•32m ago•0 comments

Show HN: A non-encrypted password manager

https://www.bloodless.ai/
1•shayarma•40m ago•1 comments

AI-Generated Misstatement Risk:A Framework for Enterprise Organisations

https://zenodo.org/records/17885472
1•businessmate•40m ago•1 comments
Open in hackernews

Understanding Java's Asynchronous Journey

https://amritpandey.io/understanding-javas-asynchronous-journey/
17•hardasspunk•7mo ago

Comments

Neywiny•7mo 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•7mo 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•7mo 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•7mo 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•7mo 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•7mo 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•7mo 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();
wpollock•7mo 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.

AtlasBarfed•7mo 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•7mo 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";
  }