(no subject)

Date: 2019-05-09 12:10 pm (UTC)
jducoeur: (Default)
From: [personal profile] jducoeur
I mean, it's great that it's not me, but it's not free either, right?

Also absolutely correct.

This shows up best in the Scala world in the form of "lazy val" -- basically, a value that will be computed the first time somebody tries to access it, and is then a constant from then on. Seems easy, right? Folks (including me) litter their code with these things -- it's a core piece of the language.

But in fact, doing this *correctly* -- such that it works in a multi-threaded environment, with confident guarantees that it will only run once, without deadlocks, as efficiently as possible -- is *crazy* difficult, so much so that this language construct has been re-implemented several times over the past fifteen years, and we still don't have it quite right.

If you'd like a sense of just *how* crazy it is, see this proposal to get it entirely right. It's daunting.

Granted, concentrating the bug exposure in the compiler instead of distributing it among all programmers means that when a bug is found it's more likely to get fixed and benefit everyone. I'm not sure I'd want to be on the team that has to make that work, though.

Yep. This is why many of us are deeply grateful to the folks who make the compilers hum along, hiding many of these nasty details under the hood so that we can peacefully get along with our application programming.
(will be screened)
(will be screened if not validated)
If you don't have an account you can create one now.
HTML doesn't work in the subject.
More info about formatting

Profile

jducoeur: (Default)
jducoeur

July 2025

S M T W T F S
  12345
6789101112
13141516171819
20212223242526
27 28293031  

Most Popular Tags

Style Credit

Expand Cut Tags

No cut tags