So recently, I've been working on my personal project cssgr.id using vanilla JS. The code uses a lot of different objects and arrays and I needed to use Array.reduce() for something.
For some reason, I've never quite understood how this method worked. Something inside my brain didn't quite grasp it, but...with a few (a lot of) console logs I finally got it working how I needed it to and moved on to my next task.
After coming back to the code the next day and reading through what I'd done previously, it just...clicked! I understood how reduce() worked! I finally grasped what it was doing with my data and why it returned the values it did. This is what I'm referring to in the title as the 'oh my god I get it' moment.
I remember having a similar experience when first using GIT and working with branches. I even had it when first learning how to nest rules in SCSS!
I'm really interested to know firstly, if anyone else has experienced these awesome moments during their work, and second, what it was for you that just 'clicked'!
Top comments (29)
Hey Dan,
As a newbie, I had one of these when I first realised that a nested for loop would execute completely every time the outer loop ran once! I literally stood bolt upright in front of my computer and the relief was incredible lol
Sweeeeet Relieeffff. Nice. 👍🏻
I remember the exact moment I understood recursion. I was sitting on this bench, and trying to wrap my head around this function:
I really had to struggle with the idea that the function added up the whole list without there being any variable that actually held that number.
At some point, my brain pictured a red carpet unrolling infinitely into space, and the light went on. The idea locked into place and I totally understood. I loved that class. (C211) It was a summer session, so it was warm days in flip-flops practicing my tuba, and evenings hanging out in the CS dept computer lab with the other students. Good memories.
I think the toughest thing for someone who doesn't know it coming to this code is translating things from "car" and "ls" and "cdr" and so on. In fact, "define", "sum" and "if" are the only words here that are obvious to a newcomer.
Awesome piece of code to bring one back down to Earth. A-ha moment killer. 😉
I was a music student at the time, so programming was completely new and amazing to me.
I just had this moment on Monday. I finally made an app that interacts with OAuth 2 and didn't use a library! I'd read all the wiki articles and seen the diagrams but for some reason it wasn't clicking. OAuth seemed so unnecessarily complicated and then I finally made something with it and it worked! I literally screamed out loud in excitement lol!
For reversing a string i used reduce method🤗
Nice!
Absolutely relatable! I struggled to understand loops and cursors in SQL, and eventually someone on Stack Overflow wrote one in a way I could kind of understand. But after using them for ages and knowing that they work, I realised "Oh my god, I actually know how this works now!".
One involved classes. I was just learning .NET and I was reading nothing but examples of classes as cars, with properties for headlights, methods for starting the engine, etc. I could understand the code but had no idea how it related to anything real I might write. So I asked a manager, and she introduced me to an experienced dev who printed out (this was early 20th century) examples of real production classes. It clicked, and was the first step on a long road.
The other was when someone showed me dependency injection using .NET. They didn't explain it. They just told me to follow the pattern of an existing WCF service to create a new one. So I did it first and understood it later. Then he explained to me what it was doing. When I saw how that changed the way to write a class, it was like flipping a light switch. I never wrote unit tests because my code was untestable, but it showed me how to write code that I could unit test.
That second one was after I had stagnated for a few years. It changed everything for me because it led to learning more principles which led to more and more. It was a catalyst.
That's great! It's funny, I remember understanding how basic HTML worked many many years ago when a university lecturer printed it out for me too. You can't be some old fashioned paper sometimes.
Great Question Dan!
My "aha" moment came the first time i read someone else's code and actually understood it! I had cloned someone's repository because they did something cool and i wanted to create another version of it. I spent h o u r s just trying to grasp the flow, and then suddenly it just fell into place! I felt so awesome!!
PHP developer here. Mine has to do with the first time I understood the concept of an API. When I started out the sound of API always sent some chills down my spine!
Eventually I decided I needed to understand it. Google to the rescue..... After a lot of reading here and there I eventually got it.
I tried the Github API and oh what a joy it was to see the JSON data returned on my browser screen.
I was like oh I get it now!!!!
I still have these moments every now and then. My first was with MVC and MVVM. (When I did some android dev many years ago) The whole concept was just too confusing for me, but one day some lightbulb just switched on and suddenly I understood the concept without any issue!
My general amazement of programming started back in '94 when I first used QBASIC. Amazing how we can use plain english and magic happens inside a little metal box!
A relatively recent one for me would be Erik Meijer talking about monads as just another way to do function composition. A whole world of imagined complexity fell away and I saw a beautiful simple thing for what it is.
infoq.com/interviews/meijer-monads