Hacker News new | ask | show | jobs
by carlmcqueen 1675 days ago
When I worked for a major financial institution in a data science / analytic group there were a lot of very, very smart math types who couldn't code. They'd ask how I'd gotten my code working and I'd never lie, that many parts of it I'd fixed using SO. This was 2012-2015 when a lot of the machine learning wasn't in helpful R packages or python libraries pre-written.

Many would ask to see the page I'd read and I'd show them and they would ask how I got my code working from an example that had nothing to do with what our task was.

I think there is a lot of value to looking at a SO answer, generalizing it and making it work in your code and doing it quickly. Knowing which SO articles are junk and which ones are gems is something many take for granted but is actually something close to having the right 'gut' feeling.

6 comments

Absolutely true. A lot of people think "cut-n-paste" is how people get code written, but the truth is you almost never find a snippet that is exactly what you want. It might be trivial like changing the name of the variable, or it might be some very small piece of a snippet you need, but the superpower isn't being to search for things, it's making sense of them and being able to reason about how to adapt it for your own case.
I find SO gets contrasted with RTFM(read the manual) frequently, But i dont know which manual to read untill ive seen some SO answers
The difference in effort in inventing a solution vs verifying a solution is correct. Most of the stuff on stack overflow or the suggestions from copilot are wrong, but its the fact that you can usually read and know if it is correct and then you have been saved the time which would be starting from scratch.
SO is a great place for finding that one little code snippet that plugs a hole in your understanding of a problem. Many times you're 3 layers deep in a dependency chain of problems solved, and the question addresses some totally unrelated problem, but the question's answer uses that special argument to the framework's / language's library function in just the right way where it unlocks your understanding and lets you continue on your merry way.
This is particularly true when you're thinking "is this use of X a horrible hack or a performant best practice?". Someone laying out and linking to the guarantees on offer by X in a completely unrelated use case will clarify everything.
I agree, I have worked places where there was no internet access and it was a major slow down. Also, every time I find the answer I was looking for, it is closed as not an appropriate question, but not until after someone gave it the answer I needed.
Not only do you need to find the snippet which is hard enough as it is, but you also need to understand the snippet and often take out a line or two from a 20 line snippet which do what you need.
If I ever have to solve something especially weird and use a stackoverflow result, I leave a comment above the weird code linking directly to the stackoverflow answer. And usually some extra context if the stackoverflow question isn't a perfect replica of our situation.
I do this too, just so I can refer back to it when I inevitably forget what exactly I did.
A highlight of my development career thus far is when I was able to fix a build that happened to be broken on a colleague's machine, which had stumped three other developers for multiple hours spread across a week.

I don't remember the line of reasoning or detailed investigation that led to the solution, but I found something in a build configuration file that looked suspicious enough to warrant a search for an exact phrase in the code. It turned up a StackOverflow answer, where three lines had been cut and pasted into the build file.

There was some specific change in a library or binary upgrade that had broken the thing that this particular change was meant to fix, and the problem was solved by removing the lines in question.

The commit comment for these three lines was "merge hmmmm", which was also the only local documentation I found that I could have used to cross-reference with anything else.

This is very similar to academics and published papers. Most other labs aren't really working on things that similar to another lab, and so techniques have to be modified and not just directly lifted.

Some point to that as an aspect of the replication crisis, but it's really just the nature of identifying and abstracting common elements out of specific goals.

> I think there is a lot of value to looking at a SO answer, generalizing it and making it work in your code and doing it quickly.

This will probably get downvoted but I disagree with this.

IMO you should never be "generalizing" random pieces of code. What you should rather look for is help in augmenting your own logical reasoning process: e.g., I want to transform X to Y with BigO of Z complexity, how do I do that? Look for stuff that helps you understand how to do this. Once you do, you shouldn't need to generalize other people's code.

I don't mean to say that you should reinvent the wheel. Rather, you should understand that you need a wheel to solve your problem - where you get the wheel from isn't really that relevant (except for copyright, licenses etc but that's a separate topic).

The internet is a reference (at best).

Legal textbooks are the best example of a reference I've seen: the index is grouped by legal concepts and terminology, and is impenetrable to non-lawyers.

Like jargon, it gatekeeps; but that's not its only purpose.