|
Volguus posted:Hahaha. This reminds me of another JSP page that I had the pleasure of seeing a few years back: It was holding the currently logged in users in a static java.util.Hashtable. 2 people could not log in/browse at the exact same time or the application would crash.
|
# ? Jun 8, 2019 11:37 |
|
|
# ? May 17, 2024 15:06 |
|
Soricidus posted:Why did it crash? Hashtable is supposedly thread-safe so it can’t be that. Hashtable is not thread safe. Methods in it are synchronized, that's true, so you can call "put" from 2 different threads and it works fine. But you can't iterate over it while trying to call put, for example. In general, in java, if you need a thread safe map one should use ConcurrentHashMap.
|
# ? Jun 8, 2019 15:23 |
|
Volguus posted:Hahaha. This reminds me of another JSP page that I had the pleasure of seeing a few years back: It was holding the currently logged in users in a static java.util.Hashtable. 2 people could not log in/browse at the exact same time or the application would crash. That was in addition to its many other issues. We had something similarly horrific in our DBManager class through which all db connectivity in the platform flowed. As a manager it was a Singleton, but one of the class level static fields of the thing was WHO IS CONNECTING. Normally this wasn't a problem because we would at least set the thing at the last possible moment before connections opened, until we happened to have two requests come in at the exact same millisecond. Ugh that was a bad night. Thankfully my only involvement in it was in the aftermath because I was one of the few devs who knew how to read packet traces.
|
# ? Jun 9, 2019 00:57 |
|
Volguus posted:Hashtable is not thread safe. Methods in it are synchronized, that's true, so you can call "put" from 2 different threads and it works fine. But you can't iterate over it while trying to call put, for example. In general, in java, if you need a thread safe map one should use ConcurrentHashMap. Hashtable has the worst kind of thread-safety, in that you pay the performance cost of locking but don't actually get any beneficial semantics in exchange.
|
# ? Jun 9, 2019 09:52 |
|
I think you can read and write elements atomically; the problem is that that’s not really an adequate API for a concurrent dictionary. But iterating isn’t a good example of why, both because IIRC you can safely iterate it (by synchronizing on it yourself) and because iteration is not an operation you should generally be using on concurrent data structures.
|
# ? Jun 9, 2019 21:52 |
|
Java code:
|
# ? Jun 10, 2019 17:35 |
|
code:
code:
|
# ? Jun 12, 2019 07:32 |
|
Cuntpunch posted:
|
# ? Jun 12, 2019 18:15 |
|
Just found out that our software provider who have trouble providing fixes for relatively simple bugs, have decided to not use on open source map solution with the new GIS module, but will instead roll out their own implementation. Fun times ahead.
|
# ? Jun 13, 2019 18:28 |
|
Do they have access to ships, cartographers, or constellation-tracking equipment? Or are they gonna drive around in their car taking GPS readings
|
# ? Jun 13, 2019 18:48 |
|
Dumb Lowtax posted:Do they have access to ships, cartographers, or constellation-tracking equipment? Or are they gonna drive around in their car taking GPS readings
|
# ? Jun 13, 2019 19:13 |
|
code:
code:
|
# ? Jun 13, 2019 21:14 |
|
Do they also define IS_THE_SAME because if so I'm behind them.
|
# ? Jun 13, 2019 21:30 |
|
Nolgthorn posted:Do they also define IS_THE_SAME because if so I'm behind them. No, only code:
|
# ? Jun 13, 2019 21:36 |
|
At least it's not:code:
|
# ? Jun 13, 2019 21:44 |
|
Y'all are unnecessarily afraid of some literate programming.
|
# ? Jun 13, 2019 21:45 |
|
I'm being triggered by these worth assignments, who's to say one number is better than another??
|
# ? Jun 13, 2019 21:48 |
|
CPColin posted:At least it's not:
|
# ? Jun 13, 2019 21:49 |
|
Scaramouche posted:I'm being triggered by these worth assignments, who's to say one number is better than another?? You're having a panic attack because of bad code?
|
# ? Jun 13, 2019 22:17 |
|
Doom Mathematic posted:You're having a panic attack because of bad code? More of a Guru Meditation
|
# ? Jun 13, 2019 22:33 |
|
If you did code:
|
# ? Jun 13, 2019 23:43 |
|
Subtly grammatically incorrect literate programming, now there’s a trend I could jump on!
|
# ? Jun 14, 2019 00:00 |
|
|
# ? Jun 14, 2019 00:02 |
|
So I assume there's potential for very slightly negative floats to compare as not less than 0 and they solved this issue in the most ridiculous way possible?
|
# ? Jun 14, 2019 00:21 |
|
I've seen code like that in production, namely the lack of a free alongside stupid things like calling strdup doing one test and abandoning the memory.
|
# ? Jun 14, 2019 00:23 |
|
jit bull transpile posted:So I assume there's potential for very slightly negative floats to compare as not less than 0 and they solved this issue in the most ridiculous way possible? You tell me (yes that's python and not a C-like, sue me)
|
# ? Jun 14, 2019 00:24 |
|
MrMoo posted:I've seen code like that in production, namely the lack of a free alongside stupid things like calling strdup doing one test and abandoning the memory. Could be Java
|
# ? Jun 14, 2019 00:32 |
|
jit bull transpile posted:So I assume there's potential for very slightly negative floats to compare as not less than 0 and they solved this issue in the most ridiculous way possible? I don't think so, but it is different from return (x < 0.0) in exactly one situation -0.0 is a valid floating point value, and -0.0 < 0.0 evaluates to false
|
# ? Jun 14, 2019 00:36 |
|
Jeb Bush 2012 posted:I don't think so, but it is different from return (x < 0.0) in exactly one situation -0 is still 0. So therefore, it's false because it's less than, not less than or equal to
|
# ? Jun 14, 2019 00:46 |
|
iospace posted:-0 is still 0. So therefore, it's false because it's less than, not less than or equal to oh sure, I'm not saying it's the wrong answer (and if the output of your code depends on whether -0.0 < 0.0, something has almost certainly gone very wrong), just that it's the only situation I can think of where the weird stringcasting code would give a different answer from returning x < 0.0
|
# ? Jun 14, 2019 00:55 |
|
jit bull transpile posted:So I assume there's potential for very slightly negative floats to compare as not less than 0 and they solved this issue in the most ridiculous way possible? Floating point does a lot with the space it has. The biggest trick is a hidden '1', every binary floating point number would look like 1.010101 x 210101, so the leading "1." is dropped. To represent those very small numbers the exponent of '0' indicates that there's no leading "1.". I thought it might have something to do with not caring if the input was a 32bit float or 64bit? A 20-character string is properly sized for a 64bit float, which can expand to 17 significant decimal digits plus 3 for the the sign, decimal point, and terminating \0. But I think it's just a waste of 8 bytes, per call. The most obvious optimization is using 'snprintf' with the size set to 1 to (hopefully) bail once the stringifier has sussed out that sign bit.
|
# ? Jun 14, 2019 01:05 |
|
Kuule hain nussivan posted:Just found out that our software provider who have trouble providing fixes for relatively simple bugs, have decided to not use on open source map solution with the new GIS module, but will instead roll out their own implementation. Fun times ahead. Ahaha. AHAHAHAHA. AHAHAHAHAHAHAHAHAHA Sure. Yes. Professional software outfits at the very least use established open-source libraries like GDAL if they're cheap, but sure, I bet this one podunk outfit is going to outdo all of them.
|
# ? Jun 14, 2019 02:11 |
|
JawnV6 posted:No. There's a sign bit. That doesn't change for the subnormal numbers, they just needed to check it. Cool. I know just enough about float to understand precision issues but wasn't sure if that extended to comparisons between zero and a really small negative number.
|
# ? Jun 14, 2019 03:35 |
|
no you don't. nobody does. (For real though, to actually understand precision issues, you have to be domain expert in floating point computation and in whatever you computation is doing, because all of exact comparison, absolute margin comparison, relative margin comparison, ULP comparison, can be the right or wrong choice, dependent on what you are actually doing)
|
# ? Jun 14, 2019 09:02 |
|
Volguus posted:
How else are you going to make the code work both for basketball and golf?
|
# ? Jun 14, 2019 13:52 |
|
And how else am I going to make absolutely sure the compiler will inline it?
|
# ? Jun 14, 2019 15:01 |
MononcQc posted:How else are you going to make the code work both for basketball and golf? Easy. code:
Now the code correctly shows that BASKETBALL BETTER_THAN GOLF.
|
|
# ? Jun 14, 2019 16:07 |
|
VikingofRock posted:Easy. You can just go ahead and #define GOLF LONG_MIN
|
# ? Jun 14, 2019 19:03 |
|
Jeb Bush 2012 posted:I don't think so, but it is different from return (x < 0.0) in exactly one situation Your standard library may write a NaN value with its sign bit set as "-nan", but since it's a NaN that comparison is still false. So the function differs from a plain compare in at least two situations
|
# ? Jun 14, 2019 19:52 |
|
|
# ? May 17, 2024 15:06 |
|
Bonfire Lit posted:Your standard library may write a NaN value with its sign bit set as "-nan", but since it's a NaN that comparison is still false. So the function differs from a plain compare in at least two situations maybe. python prints NaN with a set sign bit as just "nan", but I haven't tried writing it in C (and it could be implementation-dependent anyway I guess)
|
# ? Jun 14, 2019 20:06 |