|
Suspicious Dish posted:Paraphrased in JS, the code (in a third-party library) was roughly: Ah, the COBOL programmer's serialiser. Welp, never mind.
|
# ? Oct 31, 2016 21:27 |
|
|
# ? May 14, 2024 18:14 |
|
canis minor posted:SO, please never change I... this... why? Why does that switch work. Does it work? Why does he assign replace to num and return num instead of returning replace? gently caress. I don't even know why I'm reacting to strongly to this.
|
# ? Oct 31, 2016 21:57 |
|
Klades posted:I... this... why? when you say, "does it work?" do you mean can you do that in Javascript and does it do what it looks like it does, or do you mean "does this code do what it purports to do"? to the first one, the answer is "i dunno. probably", to the second one the answer is "no": https://jsfiddle.net/62dpqsqn/ (take a look at 105) (function "out()" is from [url="https://"http://stackoverflow.com/questions/17382200/print-var-in-jsfiddle"]here[/url])
|
# ? Oct 31, 2016 22:27 |
|
As long as we are bitching about JSON: * not supporting nan or inf * making a trailing comma after the last element of a sequence an error
|
# ? Nov 1, 2016 02:32 |
|
(seen on imgur)
|
# ? Nov 1, 2016 02:34 |
|
BigRedDot posted:As long as we are bitching about JSON: It's bad enough JS treats numbers as double precision floating points it is crazy to pass the floating point special values over to real numbers too: -0, (q/s) NaN, +∞ , −∞. I guess you can abuse things using Number.NEGATIVE_INFINITY, Number.NaN, etc, I'm sure more than one library does already. MrMoo fucked around with this message at 02:57 on Nov 1, 2016 |
# ? Nov 1, 2016 02:52 |
|
the real horror is using mongodb
|
# ? Nov 1, 2016 04:17 |
|
Comments not essays.
|
# ? Nov 1, 2016 05:36 |
|
Hammerite posted:when you say, "does it work?" do you mean can you do that in Javascript and does it do what it looks like it does, or do you mean "does this code do what it purports to do"? I've just realised that it also renders 99 as "XCIX", which is longer than the equivalent "IC"
|
# ? Nov 1, 2016 15:17 |
|
code:
foxy boxing babe fucked around with this message at 03:32 on Nov 2, 2016 |
# ? Nov 1, 2016 16:58 |
|
MrMoo posted:It's bad enough JS treats numbers as double precision floating points it is crazy to pass the floating point special values over to real numbers too: -0, (q/s) NaN, +∞ , −∞. Agree to disagree I guess. I work on a cross language data vis platform where people start with data that has NaN's all the time, and JSON's lack of any good (efficient) way to get them from language A to language B is a pain the rear end and a stupid, stupid oversight from where I am sitting.
|
# ? Nov 1, 2016 18:30 |
|
This post was wrong but JavaScript and json still suck.
xtal fucked around with this message at 19:03 on Nov 1, 2016 |
# ? Nov 1, 2016 18:56 |
|
I think you gain on flexibility by punting special values to just a string, i.e. "NaN" rather than forcing extra flags everywhere in the codec. The R language has the wonderful constant NA which is quite useful but does not translate to anything else well. FYI: null is an empty object, NA is a missing object. MrMoo fucked around with this message at 19:04 on Nov 1, 2016 |
# ? Nov 1, 2016 18:57 |
|
xtal posted:What other languages have NaN so I can know not to use them?
|
# ? Nov 1, 2016 19:04 |
|
Bonfire Lit posted:All of the ones that use IEEE754 floats. Which includes basically every single language in wide-spread use. I noticed my misunderstanding after I posted it, I just haven't had to deal with or think about NaN in like 5 years
|
# ? Nov 1, 2016 19:08 |
|
Hammerite posted:I've just realised that it also renders 99 as "XCIX", which is longer than the equivalent "IC" XCIX is correct. In Roman numerals, you're not supposed to subtract a number from a number that's more than 10 times greater. That's why 1999 is MCMXCIX instead of MIM.
|
# ? Nov 1, 2016 20:52 |
|
DaTroof posted:XCIX is correct. In Roman numerals, you're not supposed to subtract a number from a number that's more than 10 times greater. That's why 1999 is MCMXCIX instead of MIM. Oh poo poo. Well before this I had a favourable opinion of roman numerals, and now I think they're some bullshit
|
# ? Nov 1, 2016 20:59 |
|
Hammerite posted:Oh poo poo. Well before this I had a favourable opinion of roman numerals, and now I think they're some bullshit You're not wrong.
|
# ? Nov 1, 2016 21:13 |
|
Today I learned I don't like Roman numerals
|
# ? Nov 1, 2016 21:57 |
|
DaTroof posted:XCIX is correct. In Roman numerals, you're not supposed to subtract a number from a number that's more than 10 times greater. That's why 1999 is MCMXCIX instead of MIM. JFC no wonder they didn't invent algebra - they spent so much time figuring out what numbers looked like they didn't have the mental energy to spare.
|
# ? Nov 1, 2016 22:08 |
Were numerals actually used for anything other than official purposes? Vertical lines on a slab of stone/in the sand/whatever would be preferable to roman numerals for anything approaching arithmetic.
|
|
# ? Nov 1, 2016 22:20 |
|
Joda posted:Were numerals actually used for anything other than official purposes? Vertical lines on a slab of stone/in the sand/whatever would be preferable to roman numerals for anything approaching arithmetic. How do you define "official purposes"? Someone has to keep the accounting books for any non-trivial business, for example. It's not government work but it's definitely important.
|
# ? Nov 1, 2016 22:34 |
TooMuchAbstraction posted:How do you define "official purposes"? Someone has to keep the accounting books for any non-trivial business, for example. It's not government work but it's definitely important. Simply official documents. Like final results of accounting or resource tallies, for instance. I'd imagine doing the arithmetic of adding all those things up would take much more time if you had to accomodate an over-complicated number system as well, but that won't stop you from translating the final result.
|
|
# ? Nov 1, 2016 22:41 |
|
Joda posted:Were numerals actually used for anything other than official purposes? Vertical lines on a slab of stone/in the sand/whatever would be preferable to roman numerals for anything approaching arithmetic. Do you really think etching out 81 vertical lines is less effort than writing LXXXI? The "normal letters are also our numbers" system can be seen in various languages for thousands of years. Even if it was clunky compared to modern place-value numerals, it was still the thing you'd have to use for anything particularly large.
|
# ? Nov 1, 2016 22:42 |
|
I've never looked up what archaeologists have to say about the development of roman numerals, but I always figured it was the formalization of people making tick marks in the dirt while taking inventory of a thing. I figured "IV" standing for four was even some basic arithmetic, like Mr. Bureaucrat has five pairs of shoes marked down then someone comes by and takes a pair and is "all gently caress I just wrote that V and I don't feel like erasing and starting over, so I'll just put a I in front of it to indicate one is missing."
|
# ? Nov 1, 2016 23:00 |
|
As far as I understand it, the Romans didn't use the notation where you subtracted smaller numerals from following larger numerals. The order didn't matter, and you just added it all up. This makes addition trivial, and even subtraction's not too bad - and you can always simplify at the end.
|
# ? Nov 1, 2016 23:04 |
|
This is what the corresponding Greek system looked like: If you're familiar with the alphabet, you'll notice that the first couple numbers are equivalent to saying A=1, B=2 etc. Ancient Hebrew (and modern Hebrew, though like the modern Greeks you'd only use this way to make a statement rather than day to day number writing) worked similar. The Roman system's really a bit more advanced, in that they reduced the number of different letters they'd use to write numbers. Athas posted:As far as I understand it, the Romans didn't use the notation where you subtracted smaller numerals from following larger numerals. The order didn't matter, and you just added it all up. This makes addition trivial, and even subtraction's not too bad - and you can always simplify at the end. That depended on time and usage. You'd be more likely to use the formal system with subtractions if you were writing a final version of something, even if you'd used just the addition system for your first couple drafts. The subtraction system could also be a lot more compact for certain values. Keep in mind that for doing actual calculations, a lot of the time you'd be working with some form of abacus rather than writing all the stuff down too.
|
# ? Nov 1, 2016 23:16 |
|
https://github.com/const-io/max-uint32 somehow this npm package has 9 dependencies and tests
|
# ? Nov 2, 2016 02:34 |
|
It looks like literally all of those dependencies are to test that constant across a range of browsers. Maybe the point of the package is to show the horror that is JS?
|
# ? Nov 2, 2016 02:48 |
|
Suspicious Dish posted:https://github.com/const-io/max-uint32 you forgot to mention the other 50-odd modules that the same author has written to define other numbers i think i'm https://github.com/const-io/cbrt-eps-float64 i'm also disappointed that https://github.com/const-io/zero, https://github.com/const-io/one, etc. do not exist. this cannot be good software engineering practice.
|
# ? Nov 2, 2016 02:54 |
|
code:
quote:Copyright © 2015-2016. The Compute.io Authors.
|
# ? Nov 2, 2016 03:30 |
|
https://github.com/const-io/numeric-constants/blob/master/lib/index.js might be the best one.
|
# ? Nov 2, 2016 04:06 |
Suspicious Dish posted:https://github.com/const-io/max-uint32 I might be reading this wrong, but aren't those all dev dependencies? Still, Jesus Christ.
|
|
# ? Nov 2, 2016 04:33 |
|
necrotic posted:https://github.com/const-io/numeric-constants/blob/master/lib/index.js might be the best one. https://github.com/const-io/pi/blob/master/lib/index.js https://github.com/const-io/pi/blob/master/test/test.js this is the contender for the best imo. they include a bunch of numbers that they can't even use.
|
# ? Nov 2, 2016 06:12 |
|
These illustrate a fascinating interpretation of what it means to "test" software.
|
# ? Nov 2, 2016 06:14 |
|
How the hell would you even test a module that just exports pi?
|
# ? Nov 2, 2016 09:48 |
|
vOv posted:How the hell would you even test a module that just exports pi? Compare it against another module that also exports PI, or do a bunch of calculations with known results with a correct PI and substitute the value of PI from this module in and check that it's got the correct result.
|
# ? Nov 2, 2016 09:55 |
|
The other day at work I found we were using this module to create a new object with only some of the keys of the old object. This module has a total of 40 dependencies spanning 200 files and taking up nearly 1MB on disk - not dev dependencies, just regular dependencies. Figuring out exactly what this code does is a long, very tedious trawl through acres of code which do almost nothing but pull in other microdependencies. All of this person's code is like this. I scrapped it in favour of a four-line loop.
|
# ? Nov 2, 2016 10:09 |
|
vOv posted:How the hell would you even test a module that just exports pi? You stop pretending that all code needs to be tested.
|
# ? Nov 2, 2016 10:38 |
|
|
# ? May 14, 2024 18:14 |
|
qntm posted:The other day at work I found we were using this module to create a new object with only some of the keys of the old object. This module has a total of 40 dependencies spanning 200 files and taking up nearly 1MB on disk - not dev dependencies, just regular dependencies. Figuring out exactly what this code does is a long, very tedious trawl through acres of code which do almost nothing but pull in other microdependencies. All of this person's code is like this. I'm trying to understand why somebody felt the need to put glob matching into a language that supports regex
|
# ? Nov 2, 2016 10:48 |