Live data from Hacker News

Ask HN: Concepts that clicked only years after you first encountered them?

news.ycombinator.com

91–100 of 946 posts

Re: Ask HN: Concepts that clicked only years after you first encountered them?

#92

Earlier quoted context omitted.

> dependency injection The term is unfamiliar to me -- is it related to "fault injection"?

Going to steal a description I wrote for a blogpost several years ago, when I had recently understood DI for the first time so it was very fresh in my mind: https://hasura.io/blog/build-fullstack-apps-nestjs-hasura-gr... Dependency Injection solves the problem of when you want to create something, but THAT something also needs OTHER somethings, and so on. In this example, think about a car. A car might have many sepa…

The first example is also dependency injection. The rest of what you described is why a dependency injection framework often becomes useful in a system with a large dependency tree.

The alternative to dependency injection is for functions to instantiate dependencies internally rather than having them be passed in from the calling context.

Re: Ask HN: Concepts that clicked only years after you first encountered them?

#93
post #90

One of the big aha moments which clicked for me only fairly recently was staring at some physics equations my own internalized realization that light doesn't experience time and then I had to tell everyone haha - but that one eureka moment unlocked a whole lot of understanding and certainly a lot more questions. This of course was after all the schooling and physics where it somehow sailed over my head the whole time…

I'm not sure how this works out in media which slow down light

https://en.wikipedia.org/wiki/Cherenkov_radiation

There, e.g. gravitational waves will be at c (in a vacuum), but wouldn't photons experience time there?

Edit: I suppose the photons are still actually moving at c

Re: Ask HN: Concepts that clicked only years after you first encountered them?

#94
post #69

Socialism When I got out of my middle class bubble, made friends with people working multiple jobs and struggling to make ends meet, and experienced a period of financial instability; I began to realize that something wasn't working in our current system. Then I started struggling with burnout and other issues and found that corporations were happy to just replace me. I also found that management wanted programmers t…

Observing the debate in the US from the outside, I believe the term "socialism" has to die. It's carrying so much baggage it's a major reasons the US cannot have a sensible debate over what alternatives there are to full-blown free-market capitalism. While also somewhat contested in Germany, and not free of (some) valid criticism, I would advocate to try and use the term "Social market economy" [1]. [1] https://en.wi…

> full-blown free-market capitalism

Well, full-blown free-market capitalism would be one alternative to the current US system, albeit probably not the best.

Re: Ask HN: Concepts that clicked only years after you first encountered them?

#95

Earlier quoted context omitted.

Seven years into my career I'm increasingly convinced that the emperor has no clothes with respect to unit tests that are just transcripts of the code under test with "mock.EXPECT()" prepended to everything - 95% by volume of the unit test code I've ever read, written, or maintained.

Yep, I think mocks are mostly a smell. The "functional core" of a module should be entirely or almost entirely unit testable with (possibly fake) dependencies passed in. The glue code ("imperative shell") should be tested at a higher level - "integration" or "end to end" or whatever you want to call it - which looks at the externally observable effects of running the code (database changes or API responses or whateve…

[deleted]

Re: Ask HN: Concepts that clicked only years after you first encountered them?

#96

Earlier quoted context omitted.

Another solution is to eliminate classes and only use structs or similar plain objects. Makes mocking and testing functions much easier. At this point I see no reason for OOP whatsoever and consider it a big mistake.

Getting rid of data abstraction and encapsulation is throwing the baby with the bath water. The abstract concept of OOP (messages between complex objects, as defined by Alan Kay) is an attempt at mimicking biological systems. Most modern languages implement data abstraction, but call it OOP, where they encapsulate some functionality with the data it operates on. Really helped with varying data formats in the AirForce…

I believe that combining state and functionality - the root of OOP - is a mistake. Tons of programming patterns and concepts exist to solve this fundamental mistake. When you stop using classes all of your code becomes so much cleaner, easier to reason about, test, debug, and so on. You can never create only pure functions in the real world but you get closer to this ideal.

I stand by my statement that OOP is totally unnecessary.

Re: Ask HN: Concepts that clicked only years after you first encountered them?

#97

Earlier quoted context omitted.

Seven years into my career I'm increasingly convinced that the emperor has no clothes with respect to unit tests that are just transcripts of the code under test with "mock.EXPECT()" prepended to everything - 95% by volume of the unit test code I've ever read, written, or maintained.

Yep, I think mocks are mostly a smell. The "functional core" of a module should be entirely or almost entirely unit testable with (possibly fake) dependencies passed in. The glue code ("imperative shell") should be tested at a higher level - "integration" or "end to end" or whatever you want to call it - which looks at the externally observable effects of running the code (database changes or API responses or whateve…

This is the way, but it’s tough to sell “we’re not going to unit test this part” in a professional setting where there are incentives to look more responsible than thou, directors are looking at unit test coverage reports, etc.

Re: Ask HN: Concepts that clicked only years after you first encountered them?

#98

Earlier quoted context omitted.

Another solution is to eliminate classes and only use structs or similar plain objects. Makes mocking and testing functions much easier. At this point I see no reason for OOP whatsoever and consider it a big mistake.

This seems totally orthogonal to me. Using a totally non-OOP functional style, you can either instantiate state within a function or pass it in from the calling context, which is the same trade-off that dependency injection targets.

If you work on a legacy code base with tens of many millions of lines of code, the non-OOP will be a better code base. My opinion.

Re: Ask HN: Concepts that clicked only years after you first encountered them?

#99
I have one example and an anti-example. Both are related to algorithms and computer science.

A) Packing a binary tree into an array. Anyone that has attended an algorithms course has likely created a binary tree with nodes, leaf nodes, left and right child etc. Seen the pine-tree like sketch with a larger example where each node except the leaf nodes have a left and right child. So how do you pack this tree into an array and traverse it efficiently?

Well you turn it 90 degrees side-ways, slightly shift all nodes on the same level so that none align and put them into an array by going from leftmost to rightmost. (or other way depending on if you shifted 90 degrees or -90 degrees). Congrats, you've packed nodes into an array. How do you traverse it? Our root node is at index 1 and if you packed the array correctly then `idx = (idx * 2) + 1` will move down one side and `idx = (idx * 2) + 0` moves down the other. I don't have a good visual explanation of this but you can think of the integer/index as a bit-sequence describing when in the tree a left vs. right path was taken (with the exception of the root node).

B) Anti-example: Ford Fulkerson algorithm for finding shortest paths between all nodes in a graph. The algorithm is basically just three for-loops stacked on top of each other, but I still can't grasp why it works. Something with dynamic programming and incrementally building on prior established intermediate paths. The algorithm is truly the product of a beautiful mind.

Re: Ask HN: Concepts that clicked only years after you first encountered them?

#100
post #87

Earlier quoted context omitted.

The big take-away is that explicit study of grammar rules, and even vocabulary to some extent, is kind of a waste of time. They encode information in a format and region of the brain that generally isn't accessible to the areas that are used in fluent communication. The way our brains have evolved to build up a functional language model is by observing lots and lots (and lots) of examples of the language being used f…

Given you eureka moment, besides what you didn't do (as you outlined), what did you do to increase your second language real world examples with feedback? Did you try immersion?

"Immersion" is a tricky word that I don't feel comfortable using without qualification.

What I like to do is spend at least an hour a day reading, listening to podcasts and audiobooks, or watching videos. A good day for me is a day when 100% of my media consumption for entertainment purposes is happening in my target language.

And that really is it.

I don't really bother soliciting explicit feedback. I suspect that it's potentially harmful because it can trigger the affective monitor. I've also encountered some SLA researchers saying the research indicates that it's not actually helpful. I'm becoming increasingly enamored of Bill VanPatten's conceit that, in a language learning context, there's no such thing as errors, there are only differences between the learner's interlanguage and their target language. Which is something that should be embraced as a natural and essential part of the process rather than a problem that needs explicit correction.

So what I do instead is just pay attention to whether successful communication has happened. When getting input, that means I'm focused on whether I understood the content or not. I want it to be a little bit difficult, enough so that I'm not getting bored, but not so difficult that I feel I'm really straining to comprehend. (There's nothing scientific to that, it's just personal taste.) When I'm having a conversation with somebody, I'm just interested in whether or not I am having a successful interaction. In a sense, what I'm trying to do is set up a feedback loop that optimizes for pure enjoyment, which, for me, seems to be a very good proxy for learning effectiveness.

To that end, I don't really intend to shit on Duolingo and practice exercises and whatnot. A lot of people enjoy those approaches to language learning, and the single most important thing is that you enjoy what you're doing.

Post reply on HN