Remember when you thought you could finish that one-hour coding task in a day? Ah, the naive optimism of a developer before diving into the abyss of endless bug fixes and coffee refills.
Debugging is like being the forensic scientist of your own crime scene. You're the only witness, the prime suspect, and the coffee-addicted investigator who just can't let go.
When you finally manage to solve that bug at 2am, you donโt know whether to sob in relief or lament your choice of career. Just another night in the romantic life of a developer.
You can be the smartest person on your team or the dumbest. Personally Iโve always tried to be the latter
Iโve met many folks who are insecure about their intelligence. Donโt worry! It just means youโre well-surrounded
Mutex is a concept that is often confusing but is actually quite simple to understand. A mutex is a synchronization primitive that helps avoid race conditions.
If let's say you are processing a directory of files and you decided to store the result of each file in a slice. To avoid goroutines racing into which one writes to the slice, we have to synchronize access to the slice.
A Mutex, which stands for mutual exclusion, has two functions - lock and unlock - and a counter.
counter = 0 means it's unlocked
counter = 1 means it's locked
When the first goroutine arrives, it locks access to the slice by increasing the counter to 1. The next goroutine will enter an infinite loop since the counter is one. And only when the first goroutine sets the counter back to zero can the next one proceed with its operation.
Essentially, a Mutex makes sure only one execution path is accessing something at the same time, which is useful like you don't want two goroutines writing to the same index position in a slice.
A semaphore is a mutex with more slots. Mutex is only 1 operator, a semaphore can have any number of slots (sync.WaitGroup in Go uses a semaphore internally).
I have made an example below of a custom implementation of a mutex:
Are you currently hiring for a role that includes using Node.js? Reply with a link to the opening and any relevant context.
If you're not, we'd appreciate a repost for visibility ๐
AI done wrong is making new forms of independent self-replicating intelligent life
AI done right is mecha suits for the human mind
If we do the former without the latter, we risk permanent human disempowerment. If we do the latter, flourishing superinteligent human civilization
Today was one of those days where I spent most of the day feeling like a complete failure trying to figure out a way forward, then the afternoon home stretch had me on some cinematic comeback story where everything just started working.
I really, really, really want this proposal for JS module declarations to be accepted. From a framework perspective, this would unlock so much great stuff.
https://t.co/nAoUyGwZ7O