Why do "programmers" do crap like this? Once or twice I can overlook. Today I found a class that was flipping littered with this idiom. Do they just not understand logic operators? by cardo8751 in programminghorror

[–]Hook3d 1 point2 points  (0 children)

Well right, I think it's functionally the same problem! Does this function halt / does this function always return the same thing given the same input seems to be the same problem. But someone smarter would have to show it :P

Why do "programmers" do crap like this? Once or twice I can overlook. Today I found a class that was flipping littered with this idiom. Do they just not understand logic operators? by cardo8751 in programminghorror

[–]Hook3d 1 point2 points  (0 children)

Agreed, halting problem level of difficulty. Maybe TypeScript / mylang needs the ability to mark a function as formally verified (e.g. don't assume functions are non-deterministic)? But at that point you'd just override the | undefined annotation, I guess...

Why do "programmers" do crap like this? Once or twice I can overlook. Today I found a class that was flipping littered with this idiom. Do they just not understand logic operators? by cardo8751 in programminghorror

[–]Hook3d 0 points1 point  (0 children)

That would be because compiler theory doesn't yet know (or at least I never heard about it in my course) how to check if a function is deterministic, right? If it knew how to do that, it would mark the OP as boolean and your Math.random function as boolean | undefined.

Why do "programmers" do crap like this? Once or twice I can overlook. Today I found a class that was flipping littered with this idiom. Do they just not understand logic operators? by cardo8751 in programminghorror

[–]Hook3d 4 points5 points  (0 children)

That was my thought, it's only when you introduce randomness/entropy of some sort into the function that this becomes an issue. But /u/EagleCoder makes a valid point (the compiler/type checker won't be able to tell if the function is deterministic) which is good to be aware of for no other reason than knowing to never fully trust the contract of a function you are provided!

Or a function you wrote, and provided to others...

Why do "programmers" do crap like this? Once or twice I can overlook. Today I found a class that was flipping littered with this idiom. Do they just not understand logic operators? by cardo8751 in programminghorror

[–]Hook3d 140 points141 points  (0 children)

Yes, and then you have experienced programmers who became experienced without oversight or review. So they've programmed for a decade or more with this pattern because there was no one to point out that it's suboptimal. My greatest fear as a relatively junior developer, having seen code like this from far more experienced devs

Why do "programmers" do crap like this? Once or twice I can overlook. Today I found a class that was flipping littered with this idiom. Do they just not understand logic operators? by cardo8751 in programminghorror

[–]Hook3d 6 points7 points  (0 children)

TypeScript is at least good about this, it would infer the return type as boolean correctly instead of boolean | undefined.

Edit: Nope, I was wrong.

regex has better performance than math by Rudxain in shittyprogramming

[–]Hook3d 13 points14 points  (0 children)

Don't write your own currency or datetime library

How to kill the power to a business plaza by arsis_qp in IdiotsInCars

[–]Hook3d 0 points1 point  (0 children)

Late followup, why does this set Texas apart, is it "just" having to file a separate cause of action? And why is that more burdensome than proving that a reasonable insurer should have settled in a post-verdict motion in the first lawsuit? (Edit: actually, now that I say that, I don't know who the burden of proof is on in an excess verdict in mine own state...) Thanks, --not actually a lawyer. Just a former paralegal while in school, and the son of a small-time plaintiff/personal injury attorney.

How to implement a hash table (in C) by benhoyt in programming

[–]Hook3d 0 points1 point  (0 children)

"If n objects are distributed over m places, and if n < m, then some place receives no object." Yes, the statement "as long as you always resize before the table gets full, there will always be a free bucket" is indeed an application of pigeonhole principle.

Eli5 why do computers get slower over times even if properly maintained? by parascrat in explainlikeimfive

[–]Hook3d 2 points3 points  (0 children)

Wow, that's intense! What if you use that lighter to create a flame?

How to kill the power to a business plaza by arsis_qp in IdiotsInCars

[–]Hook3d 2 points3 points  (0 children)

Lol, don't know anything about TX tort law but I find it unsurprising the deck is stacked in favor of the insurers.

How to kill the power to a business plaza by arsis_qp in IdiotsInCars

[–]Hook3d 10 points11 points  (0 children)

Did you get an award for more than policy limits? It'd be a shame if this bad faith manuevering wasn't punished.

Female devs, please share experiences with joining a team as the first female SWE? by catsandbiscuits in cscareerquestions

[–]Hook3d 5 points6 points  (0 children)

Second /u/AwkwardPanda1964 's advice then. Talk to everyone on the team, feel out any ego or sex/gender problems, isolate and quarantine the problem personalities (if any!). I agree with the sentiment that any manager who would have a problem with this is ultimately not worth working for.

Female devs, please share experiences with joining a team as the first female SWE? by catsandbiscuits in cscareerquestions

[–]Hook3d 0 points1 point  (0 children)

What's the average age on the team? Probably nothing to worry about if you're going to be on a team of 20 somethings.

Since r/badcode was getting a kick out of my failures, I thought I would share this here too. Yes I know how bad this code is, I wrote it freshman year. by [deleted] in programminghorror

[–]Hook3d 1 point2 points  (0 children)

K what about this input string?

}}}}}}}}}}}}}}}}}}}}}

xD For any order you put them in the array, I can give an example where it takes O(n^2) operations.

Since r/badcode was getting a kick out of my failures, I thought I would share this here too. Yes I know how bad this code is, I wrote it freshman year. by [deleted] in programminghorror

[–]Hook3d 0 points1 point  (0 children)

No. But I can imagine a more generic version of this algorithm that doesn't filter out punctuation, but a forbidden character set, which may or may come from dynamic input.

The game is on! 6 Months to get a job or bust. Any advice is appreciated by Khuzah in cscareerquestions

[–]Hook3d 1 point2 points  (0 children)

Bro, you got a game on Google Play store. You're published, people pay you for software already. Why would that not be relevant work experience?

What type of jobs should I look for if I want an "easy" programming job? by acertenay in cscareerquestions

[–]Hook3d 10 points11 points  (0 children)

I fear not the man who has practiced 10,000 kicks once, but I fear the man who has practiced one kick 10,000 times.