News for hackers. Stuff that matters.
Re:Step Away from Stack Overflow by hooby on Thursday December 23, 2021 @11:10AM (#29663201)
I kinda disagree with the implied notion that there's only these two options mentioned in the article: A) blindly copy paste whatever code shows up on stack overflow without even trying to understand it - or - B) don't ever look up stack overflow at all.

I'll keep doing what I've always done:

Look things up on stack overflow (and other sites), compare different answers and check the discussions as well, figure out WHY people are doing what they do - and then do my own experiments based on that.

For me personally, this leads to faster learning results than experimenting completely on my own, without any guidance.

Re:Step Away from Stack Overflow by lostcolony on Thursday December 23, 2021 @12:01PM (#29663738)
You don't even need to compare answers, per se. I use SO as a way to know what documentation to check. That is, if I want to X, the official documentation is oftentimes extremely difficult to parse through; to do X you have to instantiate a Foo, with an instance of Bar, etc etc etc, and all you have are API level docs. They're usually written the reverse of what I need to solve the problem (given function X -> understand what it does, rather than given what I want to do -> use function X; this gets even worse when you get higher level concepts, where what I want to do -> implies doing 4 different things in this API -> 4 different functions/data types that need to be strung together).

SO and its ilk give me an example that I can start to cross reference with the API level docs, to figure out how to pull it all together, and also where to look to find the "gotchas", tweaks, and options.

Re:Step Away from Stack Overflow by dfinninger on Thursday December 23, 2021 @10:05PM (#29669578)
Definitely. Although one of the reasons I do check other answers is that (at least for Java) the accepted answer is oftentimes Java 8 and then one of the other answers has a Java 11+ version that is half the LoC.
Re:Step Away from Stack Overflow by remram on Thursday December 23, 2021 @01:04PM (#29664518)
I go one further. If I do use a piece of code from Stack overflow (usually a workaround for some API pain point or specific technical gimmick), I linked to the answer from a comment. I then built a tool to notify me if that answer gets new comments or new answers are added. [1] Similar to how I check for new versions of my npm/pip/gem/cargo dependencies, I check for new info on my Stack overflow dependencies.

[1]: https://github.com/remram44/depoverflow

Re:Step Away from Stack Overflow by Larrikin on Thursday December 23, 2021 @07:21PM (#29668285)
I link to SO in a comment if there's some bug I'm working around or similar with an explanation about why a strange code snippet is doing something that looks strange. There is usually a TODO so that the code can be removed when the bug is fixed.
Re:Step Away from Stack Overflow by remram on Thursday December 23, 2021 @07:28PM (#29668336)
That's good too, I just find personally that in larger codebases, those TODOs tend to stay forever.
Re:Step Away from Stack Overflow by georgemcbay on Thursday December 23, 2021 @12:20PM (#29663943)
99% of the value of StackOverflow for me as an older developer is just finding workarounds to bugs in platforms/APIs/tools that people have run into before me.

Example:

Compiler throws error 0x19822943 on what looks like valid code. Googling the error code along with the compiler name almost invariably returns stackoverflow results near the top, so I look at the post(s) with answers and see "Oh yeah this is a known issue, upgrade to version 1.29 and it goes away".

For all the issues I have with the site it is still pretty great for these sorts of problems that should be covered in the support documentation for whatever it is that failed (but often isn't -- or isn't in a way that google is likely to find it easily).

Re:Step Away from Stack Overflow by dfxm12 on Thursday December 23, 2021 @11:47AM (#29663589)
Yeah, this quote:

trying to find some kind of shortcut to just get my code working by copy pasta-ing random bits of spagetti and crossing my fingers. Stop. There’s a better way.

is about as honest as the Juice Loosener pitch from the Simpsons [0]. It's impossible to be able to just copy and paste something you find online and have it work, especially while ignoring all context and learning nothing.

0 - https://www.youtube.com/watch?v=kDiSWKaS3N0

Re:Step Away from Stack Overflow by jonnycomputer on Thursday December 23, 2021 @12:21PM (#29663955)
always read the discussions; and the different answers; and any answers linked to too. and check the date too.
Re:Step Away from Stack Overflow by rbanffy on Thursday December 23, 2021 @01:04PM (#29664515)
> and check the date too.

This, a billion times.

I wonder if there is a way to voluntarily downrank pages in search engines so that answers that are obsolete do not show up first in results.

If I'm having issues with Ubuntu 22.04, the solution to a similar problem in Ubuntu 10.04 is very much likely to be wrong.

Re:Step Away from Stack Overflow by notreallyserio on Thursday December 23, 2021 @02:54PM (#29665777)
I would be happy enough if Stackoverflow put as much emphasis on citing version numbers as it does the less critical x-y problem. At least the former benefits future readers.
Re:Step Away from Stack Overflow by jonnycomputer on Thursday December 23, 2021 @04:57PM (#29666978)
Yeah, version info is more important than date, really.
Re:Step Away from Stack Overflow by johndubchak on Thursday December 23, 2021 @01:15PM (#29664644)
>> I kinda disagree with the implied notion that there's only these two options mentioned in the article

I took that away from the article as well, although I doubt that is the author's original intent.

One thing I like to do, if I have the extra time, is pull out a couple of different algorithm's books (Cormen always being one) and see if I can find a new way of viewing a problem in light of an "algorithmic approach."

Admittedly the research takes time and is always a lot of fun as I explore many other "rabbit holes" but it leads to other insights as well. The thing I will try to do is capture a few bullet points that I may have gleaned during this exercise. The approach is not conducive to goal, or time, sensitive deadlines, however.

Re:Step Away from Stack Overflow by stinos on Thursday December 23, 2021 @12:11PM (#29663846)
This. Even if the solution you come up with in the end is almost literally copied from SO, you'll still have learned something and saw different ways of doing things, which is often more valueable than just writing up a naive but working piec of code. Nothing wrong with that, but especially when still learning a language it's more interesting to figure out the typical way of doing things because you'll come across them again and again. Hence also helps reading other code which uses these constructs. And once you know them they're often faster to write and easier to read/grasp.
Re:Step Away from Stack Overflow by gopher_space on Thursday December 23, 2021 @11:48AM (#29663600)
The article seems geared towards someone working from a book or guide at their leisure. Building things up from first principles is a great way to learn but I personally never have time for the approach on the job.
Re:Step Away from Stack Overflow by DemocracyFTW on Friday December 24, 2021 @02:02AM (#29671097)
I think what the article does get right is a fundamental technique to solve a problem when you're stuck: reduce to the essentials, get your terms / naming things right, write a teeny self-contained thing (I call it 'building a model') to try it out. When the solution is understood and has proven to work, integrate. Especially when you're hard pressed for time, this may prove faster overall than the approach where you fumble with many screws.
Re:Step Away from Stack Overflow by cassandratt on Thursday December 23, 2021 @01:18PM (#29664674)
I have a rule about ZERO copy-pasting from SO or anywhere else on the internet for that matter. If you don't understand the code, when you have all the time in the world to understand it, seek help, test it, and figure it out; you certain won't suddenly understand it better, when it breaks in production. Just because 100 idiots upvoted something, doesn't make it right.

Personally, I avoid SO because I've seen too many wrong answers. I prefer documentation, or blogs explaining approaches. But, it can be a resource, especially to new developers, to help you understand how you need to think and how to approach problems. As a replacement for coding it yourself, it's might be hot garbage, so you should understand it before committing to having produced that code and assign your name to it.

Re:Step Away from Stack Overflow by vanusa on Thursday December 23, 2021 @01:31PM (#29664822)
I prefer documentation,

I do too, in theory. In reality though, 90 percent of the time it's essentially unnavigable / unsearchable / basically intractable to use.

What you want is simply something that tells you "how do I do X" where X is some real-world thing, like strip the end-of-line characters from a file. What you get from "documentation" as such is a huge sprawl of text explaining the guys of 90 different command line options. Good luck digging your way through that.

Imperfect though it is, SO was created to address precisely this huge, gaping disparity between what users want, and what most "documentation" actually delivers. Did I mention it's imperfect? And that you actually have to (shudder) think about the examples given, before randomly cut-and-pasting them into production?

The whole point is though, that it's better than nothing, and frequently is mostly correct (and it's not that hard to tell when the answer is wrong or requires a bit of fine-tuning for your use case). And at the end of the day, still saves me hundreds of hours compared to the nearly useless "documentation" that ships with most running languages and platforms these days.

Re:Step Away from Stack Overflow by cassandratt on Monday December 27, 2021 @05:22PM (#29707532)
I prefer to hire programmers.