this post was submitted on 02 Oct 2023
124 points (100.0% liked)

Programmer Humor

19154 readers
2012 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
 
top 44 comments
sorted by: hot top controversial new old
[–] [email protected] 18 points 11 months ago* (last edited 11 months ago) (4 children)

There are really few problems that are “impossible.” That is, if you count those customers/managers are interested in. All the rest is just “I’ll need 10 years, 230 million Dollars and a research team”

XKCD 1425 by Randall Munroe. License: CC BY-NC 2.5

[–] [email protected] 12 points 11 months ago (4 children)

“The other programmers keep accidentally writing code that ends up in an infinite loop. I'd like you to make a program that can reliably detect that.”

[–] [email protected] 5 points 11 months ago (2 children)

You may joke, but if I had a penny for every time someone asked me to solve a problem, that basically boils down to the halting problem, I'd be rich.

[–] [email protected] 6 points 11 months ago (1 children)

Yeah, accidentally running into the halting problem is common in automatic code analysis.

[–] [email protected] 8 points 11 months ago

It'd be nice if we wrote something to detect it running into the halting problem.

[–] [email protected] 3 points 11 months ago

I was recently tasked with the traveling salesman problem on a project. My first pass was quick but produced sloppy inefficient results. Well boss didn't like it so he had me go back at it again so it would be far more accurate. Well now it slogs through figuring out an optimal solution of several thousand points.

[–] [email protected] 3 points 11 months ago* (last edited 11 months ago)

Just because it's not possible on a Turing Machine doesn't mean it's impossible on a PC with finite memory. You just have to track all the memory that is available to the algorithm and once you detect a state you've seen already, you know it's not halting ever. The detection algorithm will need an insane amount of memory though.

Edit: think about the amount of memory that would need. It's crazy but theoretically possible. In real world use cases only if the algorithm you're watching has access to a tiny amount of memory.

[–] [email protected] 0 points 11 months ago (1 children)

Easy.

If( loop == inf) {

End;

}

Pay check please?

[–] [email protected] 4 points 11 months ago (1 children)
[–] [email protected] 3 points 11 months ago

Woah! This is worthless!

[–] [email protected] 0 points 11 months ago (2 children)

A full solution to the halting problem can't exist. But you can definitely write a program that will "reliably" detect them to a certain percentage.

And many applications do exactly that. Firefox asked me today if I wanted to stop a tab because it was processing for too long.

[–] [email protected] 4 points 11 months ago (2 children)

That’s not even close to solving the halting problem. FF doesn’t check if the program has been in its current state before. It literally just checks if 10 seconds have passed without JS emptying its event loop.

[–] [email protected] 3 points 11 months ago

My loop isn’t infinite, just longer than the heat death of the universe.

[–] [email protected] 0 points 11 months ago (1 children)

Right. There is no solution to the halting problem, that's been proven. But you just showed you can very easily create a way of practically solving it. Just waiting for 10 seconds does it. That will catch every infinite loop while also having some false positives. And that will be fine in most applications.

My point is that even if a solution to the halting problem is impossible, there is often a very possible solution that will get you close enough for a real world scenario. And there are definitely more sophisticated methods of catching non-halting programs with fewer false positives.

[–] [email protected] 0 points 11 months ago (1 children)

And that will be fine in most applications.

Have you never written a useful program that took more than 10 seconds to complete?

[–] [email protected] 2 points 11 months ago (1 children)

I fully agree with your sentiment. But just in case: If you’re blocking the main thread of a browser for seconds at a time, you should look into that.

[–] [email protected] -1 points 11 months ago

I'm not talking about web applications.

[–] [email protected] 3 points 11 months ago

For JavaScript apps, stopping them when they consume too much resources is definitely a good idea. But if you work on some project where it's common to run computionally intensive tasks, it can be harder to detect non-halting.

[–] [email protected] 10 points 11 months ago

respect for uploading the image, linking the page, and crediting the author :)

[–] [email protected] 7 points 11 months ago

This. Very few problems are truly impossible to solve, they arem in fact, just wildly impractical to solve. So don't try to tell the PM/client/coworker-with-a-'brilliant'-idea it can't be done, tell them what it'll take to work out what it'll take to do it. Either they go away, or you end up in charge of a project with an astronomical budget and no clearly defined deliverables.

[–] [email protected] 1 points 11 months ago (1 children)
[–] [email protected] 2 points 11 months ago (1 children)

a miserable little pile of secrets

[–] [email protected] 3 points 11 months ago* (last edited 11 months ago)

Diogenes bursts into Dracula's throne room while holding a chicken.

[–] [email protected] 17 points 11 months ago (4 children)

Customer: Why is there so much latency over my tunnel from us-east to us-west?

Me: checks latency seems pretty normal, what's the issue?

Customer: The latency is too much. Why is it not as fast as us-east-1 to us-east-2?

Me: They are near each other. Us-West is across the entire United States

Customer: Make faster

Me: This is the speed of light. And over copper it's about 2/3 that

Customer: hmm are you sure that's as fast as it can go?

Me: Well, unless we change the laws of physics your not going to get any better latency

[–] [email protected] 11 points 11 months ago (1 children)

For the low price of billions and a decade of work they could build out hollow core fiber coast to coast to get the last 1/3 c.

[–] [email protected] 0 points 11 months ago (1 children)
[–] [email protected] 4 points 11 months ago (2 children)

Its a type of fiber optic cable where the center of the cable is literally hollow. Normal fiber uses a glass core. Light passing through glass also travels about 2/3 the speed of the light since the speed of light is only constant in an empty vacuum. With hollow core, light is no longer passing through glass so its speed is much closer to the actual speed of light.

[–] [email protected] 2 points 11 months ago

How do you get internal reflectance with a hollow core?

[–] [email protected] 1 points 11 months ago (2 children)

... wait, how does that work? Total internal reflection happens at the boundary to a lower index of refraction.

[–] [email protected] 2 points 11 months ago (1 children)

My dumb person guess is that it needs to be in a perfectly straight line.

There's probably more to it.

[–] [email protected] 2 points 11 months ago

Looks like it comes in spools.

https://www.ixblue.com/store/ixf-hcf-10-100-950/

I don't know the physics of it. I posted some info for the parent you responded to. My understanding is the applied physics is different from traditional fiber.

The main physical principle behind propagation of light in conventional optical fibers is total internal reflection (TIR). However, engineering of optical materials with features on the scale of the wavelength of light offers many new possibilities for manipulating light. In particular, some microstructured fibres make it possible to guide light by a mechanism different from total internal reflection. In these fibres, light is trapped in the core by an out-of-plane band-gap, which appears over a range of axial wavevectors and prevents propagation of light in the microstructured cladding [Cregan (1999)], allowing guided modes to form in the central hollow core.

https://mpl.mpg.de/research-at-mpl/russell-emeritus-group/research/about-pcf/hollow-core-pcf

[–] [email protected] 1 points 11 months ago

I don't know the physics well enough, but here is some general information.

https://en.m.wikipedia.org/wiki/Photonic-crystal_fiber

https://www.rp-photonics.com/hollow_core_fibers.html

High Group Velocity, Low Latency Signal Transmission

The group velocity of guided light is usually close to the vacuum velocity of light. This implies substantially lower latency for signal transmission through hollow-core fibers.

[–] [email protected] 8 points 11 months ago

So can you give me an estimate for when you can solve that?

[–] [email protected] 7 points 11 months ago

Then you find out the real reason they need faster latency is because they're pinging the server for new data every 1ms

[–] [email protected] 6 points 11 months ago

Anytime I run into that question I tell them if I could manage FTL comms I wouldn't be working here.

[–] [email protected] 4 points 11 months ago (3 children)

Unionize, people. It's terrifying how few IT workers are unionized.

[–] [email protected] 2 points 11 months ago

While I completely agree, the meme would not really be different with a unionised workplace

[–] [email protected] 2 points 11 months ago (1 children)

It’s because we can just leave for better positions.

[–] [email protected] 1 points 11 months ago

okay, do that then and stop complaining i guess?

[–] [email protected] -1 points 11 months ago

Unions only make sense when you are easily replaceable as a worker so you don't have any barganing power on your own. As an individual IT worker you can usually tell your boss to fuck off if things get bad and just look for a new better job...

[–] [email protected] 4 points 11 months ago

Corp IT when the team gets ready for production

[–] [email protected] 2 points 11 months ago

You forgot sales

[–] [email protected] 2 points 11 months ago

Hah, yes, I was a few times between these two sides. My role was to understand both and doing something you could call "translating."

[–] [email protected] 1 points 11 months ago

this is where the art of bullshit ..... managing expectations, comes in handy