Live data from Hacker News

BigInt Shipping in Firefox

wingolog.org

101–110 of 172 posts

Re: BigInt Shipping in Firefox

#101
post #75

Earlier quoted context omitted.

Fixed it for you: > I love TCL. > It's my favorite language > to play around in.

Your attempt conflicts with both previous haikus. By their evidence, "TCL" is only two syllables, but you treat it as three. This does make me curious how they're pronouncing TCL in two syllables, though.

TCL is pronounced "tickle." https://en.wikipedia.org/wiki/Tcl

Re: BigInt Shipping in Firefox

#102
post #67

Earlier quoted context omitted.

Because number is practically the same as double, and you can't just go and change double values to integer values. Also, doubles are fast. BigInts are not.

Python has only Number though, and that can get as large as fits in your memory. Not sure why they didn't ship this with decimals and enabled it by default in javascript. I once wrote a replacement for the + operator in javascript because computers can't do proper addition (0.1+0.2!=0.3). It was basically remembering the sign and handling some other notation like 1e100, splitting on the dot, and adding them up the no…

> I once wrote a replacement for the + operator in javascript because computers can't do proper addition (0.1+0.2!=0.3).

...this is a terrible, bad-faith way of making a complaint that isn't even valid. Computers do do proper addition. And they handle the exact example you give perfectly, if that's what you want. JavaScript might have difficulty with that problem, but that's because, unlike the computers it's implemented for, it has no integers.

What do you think "proper addition" would involve if I asked you to tell me 1/7 + 1/3, on paper?

Re: BigInt Shipping in Firefox

#103
post #69

Earlier quoted context omitted.

I think they were making a joke.

Obviously it was some degree of tongue-in-cheek, but I’m not really that amused, to be honest. It needs a leftpad reference or something.

I see I’ve struck a nerve of some kind so I’d just like to clarify that I am not sorry.

Re: BigInt Shipping in Firefox

#104
post #68
post #45

Earlier quoted context omitted.

How about serializing to an array ["bigint", "170141183460469231731687303715884105727"]? It takes more space, but is easy to recognize, and easy to generalize to other types.

Presumably that could be confusing if you ever happen to have an actual array whose first element is the string "bigint".

Nah, you just have to also encode all arrays like

    ["array", [...]]
;-)

Re: BigInt Shipping in Firefox

#105
post #67

Earlier quoted context omitted.

Python has only Number though, and that can get as large as fits in your memory. Not sure why they didn't ship this with decimals and enabled it by default in javascript. I once wrote a replacement for the + operator in javascript because computers can't do proper addition (0.1+0.2!=0.3). It was basically remembering the sign and handling some other notation like 1e100, splitting on the dot, and adding them up the no…

> Python has only Number though, and that can get as large as fits in your memory. This is not true. >>> type(1) >>> type(1.5)

Oh, my bad. I thought those were abstracted away.

Still though, any int can get as large as you like by default, no weird -n suffix (that I never saw in any other language -- just like most of Javascript's other recently added syntax, by the way, it's the new Perl).

I do wonder where I got this notion of Number. Is there some other language that has this?

Re: BigInt Shipping in Firefox

#106

Now let's wait another decade before they add BigDecimal...

I think a friend of mine said he was in a meeting back when Javascript was being standardized. Mike Cowlishaw proposed that Javascript use REXX's Decimal type instead of IEEE 754.

Everyone thought that was a really bad stupid idea.

Re: BigInt Shipping in Firefox

#107
post #67

Earlier quoted context omitted.

Python has only Number though, and that can get as large as fits in your memory. Not sure why they didn't ship this with decimals and enabled it by default in javascript. I once wrote a replacement for the + operator in javascript because computers can't do proper addition (0.1+0.2!=0.3). It was basically remembering the sign and handling some other notation like 1e100, splitting on the dot, and adding them up the no…

> I once wrote a replacement for the + operator in javascript because computers can't do proper addition (0.1+0.2!=0.3). ...this is a terrible, bad-faith way of making a complaint that isn't even valid. Computers do do proper addition. And they handle the exact example you give perfectly, if that's what you want. JavaScript might have difficulty with that problem, but that's because, unlike the computers it's impleme…

The correct answer to someone who insists upon "proper addition" is 10/21 and for it to be annoyingly slow so that they learn to be sure if they really care about "proper addition" or are just being awkward.

If you mean how should the machine do that, it can find the least common multiple of 3 and 7 (which is 21) and then convert both fractions to be in that denominator, then simplify if possible. This is, as I said, annoyingly slow, but if you want "proper" answers that's what you got.

I wouldn't bother because I'm aware that _Almost All Real Numbers are Normal_ and so they're usually completely impossible to express in this fashion anyway and we should stop our foolish pretence that you can add non-integers together and expect to get "correct" answers just because it can be done for some easy cases.

Re: BigInt Shipping in Firefox

#108
post #61

Earlier quoted context omitted.

Python3 mucked with built in types...

I don't think monkey patching is really common in any version of python. I've not seen it done anywhere.

Setuptools monkeypatches distutils. Pip always uses setuptools so pretty much everything installed via Pypi is the fruit of a monkeypatch.

Re: BigInt Shipping in Firefox

#109
post #67

Earlier quoted context omitted.

Because number is practically the same as double, and you can't just go and change double values to integer values. Also, doubles are fast. BigInts are not.

Python has only Number though, and that can get as large as fits in your memory. Not sure why they didn't ship this with decimals and enabled it by default in javascript. I once wrote a replacement for the + operator in javascript because computers can't do proper addition (0.1+0.2!=0.3). It was basically remembering the sign and handling some other notation like 1e100, splitting on the dot, and adding them up the no…

> I once wrote a replacement for the + operator in javascript because computers can't do proper addition (0.1+0.2!=0.3).

That's normal floating point math behaviour and fine in most use cases. You can't fix this for add, sub, mul and div without serious performance implications.

> Would it be that much slower, that it's an awful idea to do by default?

Yes. Easily an order of magnitude slower, perhabs two. The fixed size of uint32, float, double, etc. is an important property that allows computations to be fast. And since the size is fixed, you have to accept trade-offs in how or which numbers can be represented. Also, as someone else already mentioned, you can't even store 1 / 3 as a single numeric value. You'd have to store it as a rational number. Things are going to get super complicated once you combine rational numbers in computations and complex formulas.

I'm doing lot's of number crunching tasks with javascript, with performances of up to almost ~50% of equivalent C++ code. If js would have used a non-natively supported number format by default, it would have been useless for me.

Re: BigInt Shipping in Firefox

#110

Earlier quoted context omitted.

> I once wrote a replacement for the + operator in javascript because computers can't do proper addition (0.1+0.2!=0.3). ...this is a terrible, bad-faith way of making a complaint that isn't even valid. Computers do do proper addition. And they handle the exact example you give perfectly, if that's what you want. JavaScript might have difficulty with that problem, but that's because, unlike the computers it's impleme…

The correct answer to someone who insists upon "proper addition" is 10/21 and for it to be annoyingly slow so that they learn to be sure if they really care about "proper addition" or are just being awkward. If you mean how should the machine do that, it can find the least common multiple of 3 and 7 (which is 21) and then convert both fractions to be in that denominator, then simplify if possible. This is, as I said,…

I'm sorry but where did I insist upon proper addition? I'll annotate the parts of my post that might be mistaken for it:

> a replacement for the + operator in javascript because computers can't do proper addition (0.1+0.2!=0.3).

Just saying they can't do it (I edited this: first I said that JS doesn't do it properly, but I thought that was rather too narrow. I guess 'computers' is too broad again. Pick a name, you know what I mean)

> [an explanation of what worked for me some years ago] Then you have arbitrary size and decimals with perfect addition (no floating point approximations anymore).

Again, just mentioning that this would solve it for addition, not saying this is the perfect way for life, the universe, and everything.

> Would it be that much slower, that it's an awful idea to do by default?

See, I'm not insisting on anything, I'm wondering and asking.

> Python gets away with it,

It doesn't do correct decimal addition either, so I'm not even focusing on resolving floating point inaccuracies, I'm more interested in "if it would be so slow to do arbitrary precision integers---oh and by the way, wouldn't it also solve this addition thing?"

Now, you also didn't exactly say that I was insisting, you said "someone who insists". So maybe this only applies to your parent comment. But every time I bring it up, people stumble over each other to tell me why it is this way. I already know why it is this way. There is a lot other words in the comment that one could reply to, and it's rather frustrating that it's completely overshadowed - every time - by people ignoring everything except those twelve magic characters: 0.1+0.2!=0.3.

Post reply on HN