frontpage.
newsnewestaskshowjobs

Made with ♥ by @iamnishanth

Open Source @Github

Open in hackernews

How to Think about Parallel Programming: Not! [video] (2021)

https://www.infoq.com/presentations/Thinking-Parallel-Programming/
20•caned•3d ago

Comments

fifilura•6h ago
Disclaimer: at work so I didn't watch the video.

For loops are the "goto":s of the parallel programming era.

Ditch them and the rest can be handled by the programming language abstraction.

Why? Because they 1. Enforce order of execution and 2. Allow breaking computation after a certain number of iterations.

bee_rider•6h ago
I’ve always been surprised that we don’t have a really widely supported construct in programming that is like a for loop, but with no dependency allowed between iterations. It would be convenient for stuff like multi-core parallelism… and also for stuff like out of order execution!

Not sure how “break” would be interpreted in this context. Maybe it should make the program crash, or it could be equivalent to “continue” (in the programming model, all of the iterations would be happening in parallel anyway).

I vaguely feel like “for” would actually have been the best English word for this construct, if we stripped out the existing programming context. I mean, if somebody post gives you instructions like:

For each postcard, sign your name and put it in an envelope

You don’t expect there to be any non-trivial dependencies between iterations, right? Although, we don’t often give each other complex programs in English, so maybe the opportunity for non-trivial dependencies just doesn’t really arise anyway…

In math, usually when you encounter “for,” it is being applied to a whole set of things without any loop dependency implied (for all x in X, x has some property). But maybe that’s just an artifact of there being less of a procedural bias in math…

Weryj•6h ago
Sounds like you're talking about Realtime operating systems. I don't know if there are many/any programming languages that build those operational requirements into the syntax/abstraction.
mannykannot•6h ago
The tricky cases are the very many where there are dependencies between iterations, but not demanding the strict serialization that a simple loop enforces. We have constructs for that, but there's an irreducible complexity to using them correctly.
two_handfuls•5h ago
They're not in the language proper, but "parallel for" is a common construct. I've seen it in C# and Rust, but I'm sure other languages have it too.

It may be a good idea to use a framework with explicitly stateless "tasks" and an orchestrator (parallel, distributed, or both). This is what Spark, Tensorflow, Beam and others do. Those will have a "parallel for" as well, but now in addition to threads you can use remote computers as well with a configuration change.

bee_rider•1h ago
The big C and Fortran compilers have openMP support, which includes parallel for loops. They just feel kind of… bolted on, being a pragma based language extension. And what I really want to express to the thing isn’t “fork here” but “here are some independent operations, tell the optimizing compiler about it,” and then the optimizing compiler can (among other transformations also decide to sprinkle some threads in there)
epgui•5h ago
> we don’t have a really widely supported construct in programming that is like a for loop, but with no dependency allowed between iterations

Uhhh... we don't? It seems to me like we do. This is a solved problem. Depending on what you're trying to do, there's map, reduce, comprehensions, etc.

dkarl•5h ago
And for those who also don't want to be forced to sequence the computations, i.e., wanting to run them concurrently and potentially in parallel, each approach to concurrency supports its own version of this.

For example, choosing Scala on the JVM because that's what I know best, the language provides a rich set of maps, folds, etc., and the major libraries for different approaches to concurrency (futures, actors, effect systems) all provide ways to transform a collection of computations into a collection of concurrent operations.

Curious if the poster who said "we don't have a really widely supported construct" works in a language that lacks a rich concurrency ecosystem or if they want support baked into their language.

epgui•4h ago
That's right-- Personally I like to think in functional programming terms, and with FP concurrency/parallelism is more or less a non-issue.
vlovich123•5h ago
We actually do have the abstractions but the problem is that the vast majority of for loops don’t benefit - you need to have so much work that the overhead of coordinating the threads is sufficient. Additionally, you’ve got all sorts of secondary effects like cache write contention that will fight any win you try to extract out of for loops parallelism. What we’ve been learning for a long time as an industry is that you benefit most from task level parallelism with minimal to no synchronization.
dkarl•4h ago
Granted this probably isn't the parallel application that the other poster was envisioning, but it can be extremely useful when a computation depends on a large number of I/O-bound tasks that may fail, like when you are servicing a request with a high fan-out to other services, and you need to respond in a fixed time with the best information you have.

For example, if you need to respond to a request in 100ms and it depends on 100 service calls, you can make 100 calls with a 80ms timeout; get 90 quick responses, including two transient errors, and immediately retry the errors; get eight more successful responses and two timeouts; and then send the response within the SLA using the 98 responses you received.

mystified5016•2h ago
> like a for loop, but with no dependency allowed between iterations

"Break" is a dependency between iterations, and really only makes sense in a sequential iteration. In a parallel for loop, you can break from the current iteration, but the next is probably already running.

If you want any iteration to be able to cancel all others, they have to be linked somehow. Giving every task a shared cancellation token might be simplest. Or you turn your for loop into a sort of task pool that intelligently herds threads in the background and can consume and relay cancellation requests.

But I agree, we need a new paradigm for parallel programming. For loops just don't cut it, despite being one of the most natrual-feeling programming concepts.

C#'s Parallel.For and ForEach are a step in the right direction, but very unergonomic and unintuitive. I think we could get by with just bolting parallelism onto for loops, but we need a fundamentally parallel concept. I assume it'd look something like cuda programming but I really don't know.

Jtsummers•5h ago
(2011) and was submitted back then: https://news.ycombinator.com/item?id=2105661

Gemini CLI

https://blog.google/technology/developers/introducing-gemini-cli-open-source-ai-agent/
745•sync•7h ago•429 comments

A New Pyramid-Like Shape Always Lands the Same Side Up

https://www.quantamagazine.org/a-new-pyramid-like-shape-always-lands-the-same-side-up-20250625/
24•robinhouston•38m ago•2 comments

A new PNG spec

https://www.programmax.net/articles/png-is-back/
387•bluedel•1d ago•428 comments

What Problems to Solve – By Richard Feynman

http://genius.cat-v.org/richard-feynman/writtings/letters/problems
192•jxmorris12•3h ago•19 comments

Getting ready to issue IP address certificates

https://community.letsencrypt.org/t/getting-ready-to-issue-ip-address-certificates/238777
148•Bogdanp•4h ago•81 comments

Build and Host AI-Powered Apps with Claude – No Deployment Needed

https://www.anthropic.com/news/claude-powered-artifacts
99•davidbarker•3h ago•35 comments

OpenAI Charges by the Minute, So Make the Minutes Shorter

https://george.mand.is/2025/06/openai-charges-by-the-minute-so-make-the-minutes-shorter/
331•georgemandis•7h ago•96 comments

Negative Two-Thousand Lines of Code

https://www.folklore.org/StoryView.py?story=Negative_2000_Lines_Of_Code.txt
16•xeonmc•46m ago•1 comments

LM Studio is now an MCP Host

https://lmstudio.ai/blog/lmstudio-v0.3.17
93•yags•3h ago•33 comments

Writing a basic Linux device driver when you know nothing about Linux drivers

https://crescentro.se/posts/writing-drivers/
56•sbt567•3d ago•3 comments

The Offline Club

https://www.theoffline-club.com
10•esher•56m ago•0 comments

Iroh: A library to establish direct connection between peers

https://github.com/n0-computer/iroh
89•gasull•4h ago•24 comments

FurtherAI (YC W24) Is Hiring for Software and AI Roles

https://www.ycombinator.com/companies/furtherai/jobs
1•sgondala_ycapp•3h ago

Bot or human? Creating an invisible Turing test for the internet

https://research.roundtable.ai/proof-of-human/
72•timshell•5h ago•81 comments

Web Embeddable Common Lisp

https://turtleware.eu/static/paste/wecl-test-gl/main.html
67•todsacerdoti•5h ago•28 comments

A Classical RAM Design That Mimics Quantum Collapse and Entanglement"

https://www.qsymbolic.com
6•networkcrypt•1h ago•0 comments

Reading NFC Passport Chips in Linux

https://shkspr.mobi/blog/2025/06/reading-nfc-passport-chips-in-linux/
246•robin_reala•13h ago•91 comments

DeepSpeech Is Discontinued (2020)

https://github.com/mozilla/DeepSpeech
30•LorenDB•3h ago•15 comments

Do We Need Another Green Revolution?

https://www.newyorker.com/magazine/2025/06/30/do-we-need-another-green-revolution
5•mitchbob•44m ago•1 comments

LLM Hallucinations in Practical Code Generation

https://dl.acm.org/doi/10.1145/3728894
7•appwiz•2d ago•0 comments

Third places and neighborhood entrepreneurship (2024)

https://www.nber.org/papers/w32604
93•WasimBhai•8h ago•128 comments

I built an app to backup Live Photos from iPhone to external hard drives

33•xmasterdev•2d ago•19 comments

Deep Down the Rabbit Hole: Bash, OverlayFS, and a 30-Year-Old Surprise

https://sigma-star.at/blog/2025/06/deep-down-the-rabbit-hole-bash-overlayfs-and-a-30-year-old-surprise/
50•Deeg9rie9usi•6h ago•8 comments

Microsoft Edit

https://github.com/microsoft/edit
450•ethanpil•20h ago•267 comments

California's Corporate Cover-Up Act Is a Privacy Nightmare

https://www.eff.org/deeplinks/2025/06/californias-corporate-cover-act-privacy-nightmare
43•hn_acker•1h ago•7 comments

Thnickels

https://thick-coins.net/?_bhlid=8a5736885893b7837e681aa73f890b9805a4673e
477•jxmorris12•20h ago•101 comments

Show HN: Elelem, a tool-calling CLI for Ollama and DeepSeek in C

https://codeberg.org/politebot/elelem
31•atjamielittle•5h ago•2 comments

Coccinelle for Rust Progress Report

https://www.collabora.com/news-and-blog/blog/2025/06/25/coccinelle-for-rust-progress-report/
6•mfilion•1h ago•0 comments

Games run faster on SteamOS than Windows 11, Ars testing finds

https://arstechnica.com/gaming/2025/06/games-run-faster-on-steamos-than-windows-11-ars-testing-finds/
20•_JamesA_•59m ago•2 comments

Fun with uv and PEP 723

https://www.cottongeeks.com/articles/2025-06-24-fun-with-uv-and-pep-723
591•deepakjois•1d ago•206 comments