|
Today I saw something that looked like this:code:
|
# ? Jan 10, 2017 18:47 |
|
|
# ? Jun 5, 2024 17:58 |
|
That's all kinds of special.
|
# ? Jan 10, 2017 18:51 |
|
Mr. Crow posted:HOW DO YOU HAVE A JOB IN IT?
|
# ? Jan 10, 2017 18:57 |
|
SupSuper posted:Oh I know I know! What you actually meant was "please replace the branch with the contents of master" Actually he ended up merging his branch into master, saying he pushed it (he didn't), then asking me to create pull request. From the pull request I was already reviewing. He also kept trying to commit and push updates to his branch directly into master and we went through at least 6 back and forths of "I pushed it, can you see it??" "No, you need to switch to your branch, make the commit there and then push the branch"... "I pushed master can you commit it??" (Literally something he said). And this is why we restrict commits on master to pull requests.
|
# ? Jan 10, 2017 20:00 |
Carbon dioxide posted:Today I saw something that looked like this: I don't know the first thing about netcode, but seems like a fairly reasonable way to test for codes in the 200s?
|
|
# ? Jan 10, 2017 20:07 |
|
That does work but it's in the "I'm so loving clever look how loving smart I am" category. Why not just do a couple greater than/less than comparisons and make the code way more legible? Plus there's the issue where many of the 200 series response codes require special handling if you ever actually get one.
|
# ? Jan 10, 2017 20:15 |
|
Also there's the bit where relying on integer division to behave itself is an easy way to introduce errors later on. It's like not having curly braces for a conditional block -- sure, it works, and it's even defined in the language spec to work the way it does, but you're really better off being more rigorous.
|
# ? Jan 10, 2017 20:20 |
|
xzzy posted:That does work but it's in the "I'm so loving clever look how loving smart I am" category. Why not just do a couple greater than/less than comparisons and make the code way more legible? It's also wrong since 3xx is not an error. Classic mistake. Raising exceptions at all for a successful HTTP response, success code or not, is the real horror.
|
# ? Jan 10, 2017 23:49 |
|
Joda posted:I don't know the first thing about netcode, but seems like a fairly reasonable way to test for codes in the 200s? Cool that redirects throw an exception. edit: ^^^ Or what he said
|
# ? Jan 10, 2017 23:54 |
|
I guess 1xx aren't errors either. Make it >3 problem solved?
|
# ? Jan 10, 2017 23:56 |
|
But wouldn't you want 404 to display "page not found" message, while serving the 404 code as well? Like here https://github.com/ffffffffffffffffffffffffffffffffff for example
|
# ? Jan 10, 2017 23:59 |
|
That was in the context of that snippet and would not fix anything probably. But don't raise exceptions for legit responses of which 4xx and 5xx are. Maybe use a monad or some poo poo but they are not exceptional unlike say a connection failure.
|
# ? Jan 11, 2017 00:04 |
|
Okay, to be completely fair, I found this in code that runs before a bunch of regression tests start. It makes a http connection to the test server's DB to store mock data in case it has been changed since the last run. That way the tests can reproducibly check if the DB query works properly. If it doesn't return a 200 something is wrong with the local DB and you can't run the tests anyway.
|
# ? Jan 11, 2017 00:17 |
|
So it's mongo? I'm not aware of many DBs that have an HTTP protocol
|
# ? Jan 11, 2017 00:20 |
|
necrotic posted:That was in the context of that snippet and would not fix anything probably. But don't raise exceptions for legit responses of which 4xx and 5xx are. Maybe use a monad or some poo poo but they are not exceptional unlike say a connection failure.
|
# ? Jan 11, 2017 00:45 |
|
That is an opinion but it is a wrong one. I prefer to work in a universe where failures are exceptional, thank you.
|
# ? Jan 11, 2017 09:07 |
|
Volte posted:If you are doing an RPC call and it returns a 400 error, an exception makes sense. If you are writing an HTTP request library, then obviously do not raise exceptions on 4xx errors. I smell the start of an exciting new exception derail! Every time it happens we get person after person talking about how, "well exceptions should be like X not like Y and in my favorite language they are like X" and it makes for really tedious discussion because their use is 100% implementation-dependent.
|
# ? Jan 11, 2017 09:12 |
|
ErIog posted:I smell the start of an exciting new exception derail! Every time it happens we get person after person talking about how, "well exceptions should be like X not like Y and in my favorite language they are like X" and it makes for really tedious discussion because their use is 100% implementation-dependent. Only 50 odd pages since the last time! https://forums.somethingawful.com/showthread.php?threadid=2803713&pagenumber=913&perpage=40#post462693270
|
# ? Jan 11, 2017 11:09 |
|
ErIog posted:I smell the start of an exciting new exception derail! Every time it happens we get person after person talking about how, "well exceptions should be like X not like Y and in my favorite language they are like X" and it makes for really tedious discussion because their use is 100% implementation-dependent. also the good old "my english dictionary says exception means X and therefore the programming construct should have behaviour Y", because we definitely slavishly follow standard english definitions for every other bit of computer jargon, that's how jargon works right?
|
# ? Jan 11, 2017 11:27 |
|
Instead of exceptions, computers should just catch fire. There would be far fewer bugs.
|
# ? Jan 11, 2017 15:25 |
|
EssOEss posted:That is an opinion but it is a wrong one. I prefer to work in a universe where failures are exceptional, thank you.
|
# ? Jan 11, 2017 15:35 |
|
EssOEss posted:That is an opinion but it is a wrong one. I prefer to work in a universe where failures are exceptional, thank you. What about the Try pattern? Maybe monads? Error codes?
|
# ? Jan 11, 2017 15:47 |
|
Not code as such, but I have been trying to track down why a program had excessive memory usage. It turns out that the canon SDK function which converts a RAW image in memory to a RGB array spawns ~1100 threads and loads + unloads some of the SDK DLLs repeatedly. WHY!? Ika fucked around with this message at 16:15 on Jan 11, 2017 |
# ? Jan 11, 2017 16:07 |
|
Ika posted:Not code as such, but I have been trying to track down why a program had excessive memory usage. It turns out that the canon SDK function which converts a RAW image in memory to a RGB array spawns ~1100 threads and loads + unloads some of the SDK DLLs repeatedly.
|
# ? Jan 11, 2017 16:53 |
|
It gets better. If I update the SDK, it still uses 1100 threads, but the newer version only opens the image data if I pass a file image reference, and not when passing a memory image reference (which worked before). So I have to dump the data to a temp. file.
|
# ? Jan 11, 2017 18:13 |
|
Found while trying to figure out why one of our queries was taking five minutes to run:code:
|
# ? Jan 12, 2017 00:07 |
|
steckles posted:Found while trying to figure out why one of our queries was taking five minutes to run: Look, you can't trust floats to be precise; everyone knows about rounding errors. That's why we do all our math using strings, it's much safer.
|
# ? Jan 12, 2017 00:25 |
|
Soricidus posted:also the good old "my english dictionary says exception means X and therefore the programming construct should have behaviour Y", because we definitely slavishly follow standard english definitions for every other bit of computer jargon, that's how jargon works right? I don't believe I am the horror here but if I were I doubt I'd know... but that is a line I use when we monitor and alarm on exceptions in production. "Someone trying to cheat at the game is not exceptional, it happens all day every day. Don't throw an exception for it."
|
# ? Jan 12, 2017 00:45 |
|
dougdrums posted:Instead of exceptions, computers should just catch fire. There would be far fewer bugs. if you ain't segfaulting you ain't poo poo
|
# ? Jan 12, 2017 00:57 |
|
Hughlander posted:I don't believe I am the horror here but if I were I doubt I'd know... but that is a line I use when we monitor and alarm on exceptions in production. "Someone trying to cheat at the game is not exceptional, it happens all day every day. Don't throw an exception for it." At some point I saw the aphorism "exceptions should be exceptional," and I've never seen a case that disproved it. Although, that was in a Ruby-focused book, so...
|
# ? Jan 12, 2017 01:15 |
|
Whereas Python will throw an exception just to say that an iterator is out of items to iterate over.
|
# ? Jan 12, 2017 01:21 |
|
Doc Hawkins posted:At some point I saw the aphorism "exceptions should be exceptional," and I've never seen a case that disproved it. Yeah that was the line I was thinking of. Like most such aphorisms it is clever, pithy, memorable, and practically worthless, because it describes someone's theoretical ideal world, not the actual ways exceptions are used by real programmers every day -- almost certainly including the programmers who wrote that standard library that all your scrupulously aphorism-compliant code relies on. Exceptions should be used when they're the right tool for the job. When this is the case depends on factors like the costs involved, the idioms of the language in use, the coding standards being followed, and the maintainability of the resulting code. It rarely depends on someone's interpretation of the word "exceptional" (although the expected frequency of the error case may well be a factor in runtime cost analysis).
|
# ? Jan 12, 2017 01:49 |
|
Doc Hawkins posted:At some point I saw the aphorism "exceptions should be exceptional," and I've never seen a case that disproved it.
|
# ? Jan 12, 2017 02:08 |
|
TooMuchAbstraction posted:Look, you can't trust floats to be precise; everyone knows about rounding errors. That's why we do all our math using strings, it's much safer. To tie it to exception chat, if a negative number is passed the final coercion to double throws an exception that's never checked for anywhere.
|
# ? Jan 12, 2017 02:16 |
|
steckles posted:Strings can have an infinite number of characters therefore strings have infinite precision. Not like those puny doubles with their laughably small number of bits. Kinda makes me want to write a floating-point adder that takes in two strings, for fun. I can't imagine it would be that difficult.
|
# ? Jan 12, 2017 03:04 |
|
Axiem posted:Kinda makes me want to write a floating-point adder that takes in two strings, for fun. I can't imagine it would be that difficult. That's basically a bignum library. Go for it. I'm sure it's good practice.
|
# ? Jan 12, 2017 03:14 |
|
Speaking of exceptions, can someone please tell me what Go is good for? Because I'm not seeing it myself. In particular, there's poo poo like there not being any exceptions, so you do every single function call ascode:
And I'm sure there's even worse horrors, but these are ones that seem to be especially unique to Go. So what does it do well?
|
# ? Jan 12, 2017 03:59 |
|
Axiem posted:Kinda makes me want to write a floating-point adder that takes in two strings, for fun. I can't imagine it would be that difficult. For extra credit, support the combining overline for repeating decimals.
|
# ? Jan 12, 2017 04:05 |
|
Soricidus posted:Yeah that was the line I was thinking of. Like most such aphorisms it is clever, pithy, memorable, and practically worthless, because it describes someone's theoretical ideal world, not the actual ways exceptions are used by real programmers every day -- almost certainly including the programmers who wrote that standard library that all your scrupulously aphorism-compliant code relies on. Actually, of late I've mostly been programming in a language that doesn't have them, and I don't miss them at all. I assume you wouldn't count that as the real world though. "Other people don't do this," by itself, seems like a weak argument against a programming practice. Doc Hawkins fucked around with this message at 04:36 on Jan 12, 2017 |
# ? Jan 12, 2017 04:34 |
|
|
# ? Jun 5, 2024 17:58 |
|
A goto by any other name would be considered as harmful
|
# ? Jan 12, 2017 05:14 |