this post was submitted on 07 Oct 2025
170 points (91.3% liked)

Programmer Humor

26846 readers
2598 users here now

Welcome to Programmer Humor!

This is a place where you can post jokes, memes, humor, etc. related to programming!

For sharing awful code theres also Programming Horror.

Rules

founded 2 years ago
MODERATORS
 
you are viewing a single comment's thread
view the rest of the comments
[โ€“] Ephera@lemmy.ml 4 points 5 days ago (1 children)

I can figure most of the new style out from context.

  • => is clearly a closure declaration operator, similar to JavaScript.
  • x ??= y is shorthand for "assign y to x if x is not set, and return x" which is kind of nice.

Man, I've successfully stayed away from C# for a few years now, but that's wild to me that the x ??= y operator would be intuitive to you.
This could've easily been two or three operations, without being much more verbose, but actually being somewhat intuitively readable for most devs...

[โ€“] dejected_warp_core@lemmy.world 4 points 5 days ago* (last edited 4 days ago)

Well, I did have the older version on the left as a kind of rosetta stone for this. Plus, this kind of "init and/or return" pattern shows up a bunch of places, so it makes sense someone would want a quick version that's harder to screw up or has fewer side-effects.

I've also spent years investigating better ways to do things through various versions of C++, D, Rust, Go, and TypeScript. After a while, the big-picture patterns start to emerge and you see different camps start to converge on the same kinds of things. Stuff like these weird features start to feel like learning a new slang term for something you've felt, but could never say so succinctly.

In the case of ??= it's a more formalized Python x = x or y or x = x || y in JavaScript. The catch is that not all languages treat assignments like expressions that can be returned, so you get a clunky return as a separate statement; return (x = x or y) doesn't always fly. That friction is all over the place, and it's natural to want a shorthand for this very thing.

Sure enough, after searching a bit, ??= shows up in JS, PHP, and even Ruby has a version.

Edit: more context.