Optimizing Loops In Go | Prime Reacts
Unlock all features
FREE: Get instant access to 10 AI summaries, chats, or transcripts per day.
Unlock all features
FREE: Get instant access to 10 AI summaries, chats, or transcripts per day.
Unlock all features
FREE: Get instant access to 10 AI summaries, chats, or transcripts per day.
Unlock all features
FREE: Get instant access to 10 AI summaries, chats, or transcripts per day.
Unlock all features
FREE: Get instant access to 10 AI summaries, chats, or transcripts per day.
Related videos
AI Coding Sucks | Prime Reacts
ThePrimeTime
245.8k views
Let's Talk Open Source - Prime Reacts
ThePrimeTime
112.1k views
"Use AI Now!" Prime Reacts
ThePrimeTime
199.1k views
TMUX in 100 seconds | Prime Reacts
ThePrimeTime
322.0k views
Bun vs Go Perf | Prime Reacts
ThePrimeTime
129.4k views
Ascii Elden Ring??? | Prime Reacts
ThePrimeTime
310.0k views
Why I Use C | Prime Reacts
ThePrimeTime
242.9k views
20 Years Of Programming | Prime Reacts
ThePrimeTime
90.1k views
Why CS Is Dead | Prime Reacts
ThePrimeTime
250.8k views
Be Less Precious | Prime Reacts
ThePrimeTime
78.4k views
Top Comments (10)
My guess on why 3 is slower than 2 : index bound checks. Compilers can very often eliminate them when you loop on the actual length of the array, not a pre-cached numerical value.
I ain't gonna lie having an influencer style videos in the coding world just entertainment non educational helps me stay on track when i feel not motivated to study keep it up bro.
The compiler writes better code than you but what if you're writing a compiler? BRAIN MELTING
There’s all sorts of things he could have done here. Changing the order of the loops can give you wild improvements because it can change the proportion of cache hits. Also loop unrolling. Also using arrays in Go (which are a real thing) instead of slices.
Go uses symbol lifetimes to determine whether to allocate on the stack or on the heap. If the object survives after the function returns, it's on the heap. Pretty straightforward.
"The more you write standard code, the more likely you're generally doing well." - ThePrimeagen
Found the channel just few weeks ago. Coming from a background in Webflow, with only a grasp of HTML, CSS, and a bit of JavaScript, I see myself as a puppy. Recently, I've decided to take coding more seriously because it's interesting, and I also have a web app idea that I'm genuinely determined to bring to life. Though 90% of what the man is saying still flies right over my head, I feel like my understanding is expanding. I've never attended school, worked in-house with a team, or studied with guidance. It seems like I found a semblance of a mentor who's bombarding me with jargon I can't possibly comprehend, but ultimately is helping me see throw the fog in a way. Feels like little by little I'm starting to grasp how everything is connected.. weird.
There is a big distinctions between array an slices in go. This video uses slices, which are pointers to arrays. A slatic array will have a compile time length and allows the compiler to do a lot more optimization
The video author should have disassembled the resulting binary to see if he would be able to figure out what the hell is going on.
he could to a follow up by profiling the code to see where CPU and memory are spent, then analyze the assembly output of the code to understand why.
Unlock the Data Inside
Turn Videos into Knowledge
- Get FREE 10/day: transcripts, summaries, chats
- Chat with videos, export text & PDF
- $1 free API credit for RAG, chatbots & research
Free forever plan • All features unlocked
Top Comments (10)
My guess on why 3 is slower than 2 : index bound checks. Compilers can very often eliminate them when you loop on the actual length of the array, not a pre-cached numerical value.
I ain't gonna lie having an influencer style videos in the coding world just entertainment non educational helps me stay on track when i feel not motivated to study keep it up bro.
The compiler writes better code than you but what if you're writing a compiler? BRAIN MELTING
There’s all sorts of things he could have done here. Changing the order of the loops can give you wild improvements because it can change the proportion of cache hits. Also loop unrolling. Also using arrays in Go (which are a real thing) instead of slices.
Go uses symbol lifetimes to determine whether to allocate on the stack or on the heap. If the object survives after the function returns, it's on the heap. Pretty straightforward.
"The more you write standard code, the more likely you're generally doing well." - ThePrimeagen
Found the channel just few weeks ago. Coming from a background in Webflow, with only a grasp of HTML, CSS, and a bit of JavaScript, I see myself as a puppy. Recently, I've decided to take coding more seriously because it's interesting, and I also have a web app idea that I'm genuinely determined to bring to life. Though 90% of what the man is saying still flies right over my head, I feel like my understanding is expanding. I've never attended school, worked in-house with a team, or studied with guidance. It seems like I found a semblance of a mentor who's bombarding me with jargon I can't possibly comprehend, but ultimately is helping me see throw the fog in a way. Feels like little by little I'm starting to grasp how everything is connected.. weird.
There is a big distinctions between array an slices in go. This video uses slices, which are pointers to arrays. A slatic array will have a compile time length and allows the compiler to do a lot more optimization
The video author should have disassembled the resulting binary to see if he would be able to figure out what the hell is going on.
he could to a follow up by profiling the code to see where CPU and memory are spent, then analyze the assembly output of the code to understand why.