frontpage.
newsnewestaskshowjobs

Made with ♥ by @iamnishanth

Open Source @Github

fp.

How can AI ID a cat?

https://www.quantamagazine.org/how-can-ai-id-a-cat-an-illustrated-guide-20250430/
37•sonabinu•3d ago•6 comments

Line scan camera image processing for train photography

https://daniel.lawrence.lu/blog/y2025m09d21/
102•dllu•5h ago•18 comments

A 2k-year-old sun hat worn by a Roman soldier in Egypt

https://www.smithsonianmag.com/smart-news/a-2000-year-old-sun-hat-worn-by-a-roman-soldier-in-egyp...
30•sensiquest•2h ago•5 comments

Static sites with Python, uv, Caddy, and Docker

https://nkantar.com/blog/2025/08/static-python-uv-caddy-docker/
50•indigodaddy•1d ago•31 comments

Manim: Animation engine for explanatory math videos

https://github.com/3b1b/manim
350•pykello•14h ago•61 comments

Acronis True Image costs performance when not used

https://randomascii.wordpress.com/2025/05/26/acronis-true-image-costs-performance-when-not-used/
43•juanviera23•3d ago•8 comments

Librebox: An open source, Roblox-compatible game engine

https://github.com/librebox-devs/librebox-demo
200•libreboxdevs•10h ago•56 comments

Motion (YC W20) Is Hiring Senior Software Engineers

https://jobs.ashbyhq.com/motion/7355e80d-dab2-4ba1-89cc-a0197e08a83c?utm_source=hn
1•ethanyu94•1h ago

RFC 9839 and Bad Unicode

https://www.tbray.org/ongoing/When/202x/2025/08/14/RFC9839
198•Bogdanp•9h ago•95 comments

Children of the Geissler Tube

https://www.hopefulmons.com/p/children-of-the-geissler-tube
25•paulkrush•3d ago•2 comments

Optimizing FizzBuzz in Rust

https://github.com/nrposner/fizzcrate
15•Bogdanp•2h ago•4 comments

Writing Speed-of-Light Flash Attention for 5090 in CUDA C++

https://gau-nernst.github.io/fa-5090/
118•dsr12•9h ago•17 comments

Texas Instruments' $60B U.S. project, the next iPhone chips fabric

https://www.cnbc.com/2025/08/22/apple-will-make-chips-at-texas-instruments-60-billion-us-project....
78•giuliomagnifico•1d ago•53 comments

Optimizing our way through Metroid

https://antithesis.com/blog/2025/metroid/
87•eatonphil•1d ago•8 comments

A simple way to generate random points on a sphere

https://www.johndcook.com/blog/2025/05/06/random-points-on-a-sphere/
48•piinbinary•4d ago•35 comments

Exploring EXIF (2023)

https://hturan.com/writing/exploring-exif
24•jxmorris12•2d ago•3 comments

Practical approach for streaming UI from LLMs

https://www.timetler.com/2025/08/19/unlocking-rich-ui-components-in-ai/
38•scranglis•4d ago•2 comments

I made a floppy disk from scratch

https://kottke.org/25/08/i-made-a-floppy-disk-from-scratch
167•bookofjoe•11h ago•67 comments

The Amiga games and demo scene collection

https://amiga.vision/
7•doener•1h ago•0 comments

450× Faster Joins with Index Condition Pushdown

https://readyset.io/blog/optimizing-straddled-joins-in-readyset-from-hash-joins-to-index-conditio...
86•marceloaltmann•4d ago•28 comments

Recreationally overengineering my location history

https://overengineer.dev/blog/2025/08/19/overengineering-location-history/
15•kickofline•3d ago•2 comments

Romhack.ing's Internet Archive Mirror No Longer Available

https://romhack.ing/database/news/entry/DW8BKnRHSEqaGDwXTiKjMw
5•pharrington•1h ago•0 comments

Rethinking the Linux cloud stack for confidential VMs

https://lwn.net/Articles/1030818/
102•Bogdanp•10h ago•41 comments

Reproducing prospect theory with 'differentiable decision theories'

https://www.science.org/doi/full/10.1126/science.abe2629
15•timshell•2d ago•4 comments

Ergonomic errors in Rust: write fast, debug with ease, handle precisely

https://gmcgoldr.github.io/2025/08/21/stackerror.html
3•garrinm•1d ago•2 comments

Stepanov's biggest blunder? The curious case of adjacent difference

https://mmapped.blog/posts/43-stepanovs-biggest-blunder
17•signa11•2d ago•1 comments

Lightning declines over shipping lanes following regulation of sulfur emissions

https://theconversation.com/the-world-regulated-sulfur-in-ship-fuels-and-the-lightning-stopped-24...
204•lentoutcry•4d ago•52 comments

Developer's block

https://underlap.org/developers-block/
166•todsacerdoti•12h ago•89 comments

Determinants and causal effects of admission to selective private colleges [pdf] (2023)

https://www.nber.org/system/files/working_papers/w31492/w31492.pdf
21•EvgeniyZh•11h ago•22 comments

WebR – R in the Browser

https://docs.r-wasm.org/webr/latest/
128•sieste•4d ago•27 comments
Open in hackernews

Waitgroups: What they are, how to use them and what changed with Go 1.25

https://mfbmina.dev/en/posts/waitgroups/
56•mfbmina•6h ago

Comments

nikolayasdf123•6h ago
> wg := sync.WaitGroup{}

just `var wg sync.WaitGroup`, it is cleaner this way

mr90210•5h ago
Oh you are one of those. The nit picker. This is not at a PR review mate.
nikolayasdf123•5h ago
"one of those", name calling, telling me what to say,

cool it down a little. touch some grass. and hopefully you will see beauty in Go zero-values :P

dwb•5h ago
Why?
nikolayasdf123•5h ago
zero value. container-agnostic initialization. say your type is not struct anymore, you would not have to change the way you intialize it. what you care here is zero value, and let the type figure out that it is zero and use methods appropriately. and it is just more clean this way

here is google guideline: https://google.github.io/styleguide/go/best-practices#declar...

dwb•5h ago
That is a much better argument than saying it is "more clean", which doesn't mean anything. I don't necessarily agree, because I don't think zero values are a good feature of the language, and even if they were this is a completely trivial case. But at least I don't have to work out what "cleanliness" is.
fozdenn•5h ago
doesn't this point to a bigger problem that there are two ways of doing the same thing?
nikolayasdf123•5h ago
no. it is different thing. container-agnostic zero value vs struct init.
unsnap_biceps•3h ago
multiple ways of doing something isn't inherently bad.

For example, if you want to set a variable to the number of seconds in seven hours, you could just set the variable to 25200, or you could set it to 60 * 60 * 7. The expanded version might be clearer in the code context, but in the end they do exactly the same thing.

pests•2h ago
Your math equation turned the asterisks into italics.
unsnap_biceps•2h ago
Whoops, fixed. Thanks for the note
stefanos82•6h ago
Personally I wished they had it backported to previous versions too, because it's rather convenient!

What is quite sad is that we cannot add it ourselves as it's so simple of what they have done:

    func (wg *WaitGroup) Go(f func()) {
        wg.Add(1)
        go func() {
            defer wg.Done()
           f()
        }()
    }
cedws•6h ago
You can wrap WaitGroup if you really want to.
stefanos82•6h ago
Can you provide an example please?
listeria•6h ago
something like this would do it:

  package main
  
  import (
    "sync"
    "time"
  )
  
  type WaitGroup struct {
    sync.WaitGroup
  }
  
  func (wg *WaitGroup) Go(fn func()) {
    wg.Add(1)
    go func() {
      defer wg.Done()
      fn()
    }()
  }
  
  func main() {
    var wg WaitGroup
    wg.Go(func() { time.Sleep(1 * time.Second) })
    wg.Wait()
  }
stefanos82•5h ago
This is really amazing, thank you so much!
listeria•5h ago
It's called struct embedding, there an article about it in Go by Example if you're interested: https://gobyexample.com/struct-embedding
stefanos82•5h ago
Thank you @listeria, today I learned about struct embedding lol!
genghisjahn•3h ago
I rediscover this about once a year and am always so happy when I do.
evanelias•6h ago
You can just use golang.org/x/sync/errgroup instead, which has always provided this style of use.

errgroup also has other niceties like error propagation, context cancellation, and concurrency limiting.

porridgeraisin•5h ago
errgroup cancels the whole task if even one subtask fails however. That is not desirable always.
Groxx•4h ago
It does not, which is easy to verify from the source. Every func passed in is always run (with the exception of TryGo which is explicitly "maybe").

At best, using the optional, higher-effort errgroup.WithContext will cancel the context but still run all of your funcs. If you don't want that for one of the funcs, or some component of them, just don't use the context.

evanelias•3h ago
If the context cancellation is undesirable, you just choose not to use WithContext, as the sibling comment mentions.

You could also just make your subtask function return nil always, if you just want to get the automatic bookkeeping call pattern (like WaitGroup.Go from Golang 1.25), plus optional concurrency limiting.

Also note, even if a subtask function returns an error, the errgroup Wait blocking semantics are identical to those of a WaitGroup. Wait will return the first error when it returns, but it doesn't unblock early on first error.

Cyph0n•4h ago
Context cancellation is not always desirable. I personally have been bitten multiple times by the default behavior of errgroup.
CamouflagedKiwi•3h ago
You have to explicitly propagate the group's context if you want it to cancel. You can just not do that if you don't want - there certainly are cases for that.
CamouflagedKiwi•3h ago
They basically don't backport anything for Go, but the quid pro quo for that is that the backwards compatibility is pretty strong so upgrades should be safe. I have seen one serious issue from it, but still it's the language I'm the most confident to do an upgrade and expect things to Just Work afterwards.
porridgeraisin•5h ago
Love this. Majority of concurrency in a usual web service is implemented using waitgroups IME (see below) This will greatly simplify it.

  var wg sync.WaitGroup
  wg.Add(1)
  go func(){
    callService1(inputs, outParameter)
    wg.Done()
  }
  // Repeat for services 2 through N
  wg.Wait()
  // Combine all outputs

BTW, this can already be done with a wrapper type

  type WaitGroup struct { sync.WaitGroup }

  func (wg *WaitGroup) Go(fn func()) {
    wg.Add(1)
    go func() {
      fn()
      wg.Done()
    }()
  }
Since you're doing struct embedding you can call methods of sync.WaitGroup on the new WaitGroup type as well.
a-poor•5h ago
This means you can't pass variables in as function arguments. Even the example in the official go docs doesn't handle the scope correctly:

  func main() {
   var wg sync.WaitGroup
   var urls = []string{
    "http://www.golang.org/",
    "http://www.google.com/",
    "http://www.example.com/",
   }
   for _, url := range urls {
    // Launch a goroutine to fetch the URL.
    wg.Go(func() {
     // Fetch the URL.
     http.Get(url)
    })
   }
   // Wait for all HTTP fetches to complete.
   wg.Wait()
  }
https://pkg.go.dev/sync#example-WaitGroup

You need to use this pattern instead:

   for _, url := range urls {
    url := url
    // ...
jeremyloy_wt•5h ago
This isn’t necessary anymore as of Go 1.22

https://go.dev/blog/loopvar-preview

9rx•4h ago
> This means you can't pass variables in as function arguments.

Well, you could...

    for _, url := range urls {
        wg.Go(func(u string) func() {
            return func() {
                http.Get(u)
            }
        }(url))
    }
> You need to use this pattern instead

Why? Seems rather redundant. It is not like WaitGroup.Go exists in earlier versions.

danenania•4h ago
I like WaitGroup as a concept, but I often end up using a channel instead for clearer error handling. Something like:

  errCh := make(chan error)
  for _, url := range urls {
    go func(url string){
      errCh <- http.Get(url)
    }(url)
  }

  for range urls {
    err := <-errCh
    if err != nil {
      // handle error
    }
  }
Should I be using WaitGroup instead? If I do, don't I still need an error channel anyway—in which case it feels redundant? Or am I thinking about this wrong? I rarely encounter concurrency situations that the above pattern doesn't seem sufficient for.
javier2•4h ago
How you handle err here? If you return, the go routines will leak
danenania•3h ago
Ah, good point—should be using a buffered channel to avoid that:

  errCh := make(chan error, len(urls))
unsnap_biceps•3h ago
buffered channels won't help here. That's just how many results can be buffered before the remaining results can be added to the channel. It doesn't wait until all of them are done before returning a result to the consumer.
danenania•2h ago
> It doesn't wait until all of them are done before returning a result to the consumer.

Right, but it prevents goroutine leaks. In these situations I'm usually fine with bailing on the first error, but I grant that's not always desirable. If it's not, I would collect and join errors and return those along with partial results (if those are useful).

c0balt•3h ago
You would probably benefit from errgroup, https://pkg.go.dev/golang.org/x/sync/errgroup

But channels already do the waiting part for you.

danenania•3h ago
Thanks! looking into errgroup
tombert•3h ago
Forgive a bit of ignorance, it's been a bit since I've touched Go, but this looks awfully similar to a Java CountdownLatch [1]. Is this just a glorified Go port of that or am I missing something vital here?

[1] https://docs.oracle.com/javase/8/docs/api/java/util/concurre...

xh-dude•3h ago
Pretty much. It’s a counting semaphore underneath.
arccy•2h ago
CountDownLatch looks like it can only count down? the go one you can add/remove at will
layer8•2h ago
Phaser [0] would be the more flexible equivalent in Java.

[0] https://docs.oracle.com/javase/7/docs/api/java/util/concurre...

tombert•2h ago
You are right; it looks like a Phaser is a bit more analogous: https://docs.oracle.com/javase/8/docs/api/java/util/concurre...