this post was submitted on 24 Jan 2024
1023 points (98.2% liked)

Programmer Humor

19660 readers
784 users here now

Welcome to Programmer Humor!

This is a place where you can post jokes, memes, humor, etc. related to programming!

For sharing awful code theres also Programming Horror.

Rules

founded 1 year ago
MODERATORS
1023
Bug Fixing (programming.dev)
submitted 10 months ago by JPDev to c/programmer_humor
 
you are viewing a single comment's thread
view the rest of the comments
[–] [email protected] 1 points 10 months ago* (last edited 10 months ago)

For your vector issue, I’d go the route of some static examples if possible. Do you have a way to manually work out the answer that your code is trying to achieve?

Not necessarily. In this scenario I'd imagine it's a series of numbers as opposed to something more human-friendly exactly because there's internal complexity that's important but hard to manually survey, let alone generate. If you've worked with GANs at all, maybe it's a point in a latent space.

For side effects, that may indicate what I referred to as tightly coupled code. Could you give an example of what you mean by “side effect”?

I mean it in the standard functional language way, if you're familiar. There's an operation that happens at some step of an algorithm, and it changes a data structure which is referred to or updated at another step. Sometimes you can't really avoid it, because the problem itself has an interconnection like that.

A sorting algorithm example, if that doesn't make this too complicated.

Concurrency it's pretty much guaranteed to do it, so let's say we're trying to implement some sort of bespoke sorting algorithm, where each compare is large and complex enough we have bugs, and which runs in multiple threads.

If threads are interfering with each other in this program, how do you test for that? The whole thing won't give expected results, obviously, but another unsorted array or a failure to terminate doesn't tell you much. Each compare and each swap might look correct at first, and give properly typed results. Let's assume that each thread might traverse to anywhere in the array, so you can't just check when they're overlapping.