Better HN
topnewbestaskshowjobs
Log inSign up

voidnullnil

-9 karma · joined Jul 3, 2021 (5y ago) · 68 submissions

Submissions

comment 5y ago · link · parent

> To solve that problem, the practitioner only needs to know that "mutex.lock()"

This is true, but they do not know that. If you do not give some kind of substantiation, they will shrug it off and go back to "nah this thing doesn't need a mutex", like with a polling variable (contrived example).

comment 5y ago · link · parent

How many programmers do you know put locks around polling varibles for seemingly no reason (as they are not cognizant of the memory model)?

comment 5y ago · link · parent

> This "Memory Model" discussion is only for people who want to build faster systems: for people searching for a "better spinlock", or for writing lock-free algorithms / lock-free data structures.

Actually, most practitioner code has bugs from their implicit assumptions that shared variable writes are visible or ordered the way they think they are.

comment 5y ago · link · parent

These "memory models" are too complex for languages intended for dilettante developers. It was a disaster in Java/C#. Not even more than a handful of programmers in existence know in depth how it works, as in, can they understand any given trivial program in their language. At best they only know some vague stuff like that locking prevents any non visibility issues. It goes far deeper than that though (which is also the fault of complex language designs like Java and C#).

The common programmer does not understand that you've just transformed their program - for which they were taught merely that multiple threads needs synchronization - into a new game, which has an entire separate specification, where every shared variable obeys a set of abstruse rules revolving around the happens-before relationship. Locks, mutexes, atomic variables are all one thing. Fences are a completely different thing. At least in the way most people intuit programs to work.

Go tries to appeal to programmers as consumers (that is, when given a choice between cleaner design and pleasing the user who just wants to "get stuff done", they choose the latter), but yet also adds in traditional complexities like this. Yes, there is performance trade off to having shared memory behave intuitively, but that's much better than bugs that 99% of your CHOSEN userbase do not know how to avoid. Also remember Go has lots of weird edge cases, like sharing a slice across threads can lead to memory corruption (in the C / assembly sense, not merely within that array) despite the rest of the language being memory-safe. Multiply that by the "memory model".

Edit: forgot spaces between paragraphs.

comment 5y ago · link · parent

Coming up with this "return $this" pattern to emulate a composition operator seems like a very AI thing to do.

comment 5y ago · link · parent

Blogs about "return" inside "finally" in Java and the likes were common in the 2000s. The fact that languages have so many simple things like this that surprise people indicates that there is a problem somewhere. I'm sure some of the older school languages (like VB maybe) had some insane semantics like an interrupted return will return null, I can't remember them in that much detail.
123