Live data from Hacker News

Return True to Win

alf.nu

81–90 of 123 posts

Re: Return True to Win

#81

I already saw this on lobste.rs, but it's still cool. I like ES just fine, but to think we could have had scheme instead. Gee, thanks Netscape: Every time you win, everybody loses.

"it's because of you, motherfucker, that we're not all using lisp" @ 5:00 https://www.youtube.com/watch?v=bzkRVzciAZg

No, that's actually the fault of Netscape.

Anyways, that video is awful and totally wrong. Node code can be clean, threaded code can be ugly. Both can be fast, but the perf characteristics are different (for OS threads, anyways).

Re: Return True to Win

#82
post #21

This table is quite useful to solve some problems: https://dorey.github.io/JavaScript-Equality-Table/

JS gets even weirder when you include all the comparison operators.

https://jsfiddle.net/5Yzs6/17/

Did you know undefined is equal to undefined, but not = undefined?

Or that two instances of the same object/array are not equal (e.g. [-1] != [-1]), but are both = each other?

Or that /.*/ is non-comparable (only != is true) to all numbers, but greater than [-0.5] and "-0.5", and less than [0] and "0"?

Re: Return True to Win

#83
post #21

This table is quite useful to solve some problems: https://dorey.github.io/JavaScript-Equality-Table/

> Moral of the story: Always use 3 equals unless you have a good reason to use 2. NaN === Nan // => false [] === [] // => false {} === {} // => false [1] === [1] // => false [0] === [0] // => false I guess i never see the gains in the triple vs double equal sign wars.

Those non equations are perfectly reasonable.

One array or object does not equal another, different one.

There are definitely gains - I strongly suggest following the 'moral' of the story.

At least the === paradigm is fairly consistent and mostly rational.

Re: Return True to Win

#84

Does anybody really know why JS's type system was designed the way it was? It seems so out of whack with what people want out of a language, dynamically typed or otherwise.

It's because Eich was told to make JS C-like. In C, an empty array, an empty string, 0, false and null are all the same value: a word with all bits 0. So in JS, those are all are falsy and == to each other.

I wish an empty string was not false.

In 'object' terms, an empty string is still a string! It's something.

I guess if you think about it from a memory perspective, it's 'nothing'.

But since JS is not actually like C, I really wish "" were true.

Re: Return True to Win

#87

Earlier quoted context omitted.

Indeed, I refuse to believe there should be a solution to the 'reflexive' task.

That one isn't specific to Javascript, though. If you can find a mainstream language that doesn't have any values that aren't equal to themselves, I'll give you a cookie. (Going from memory of the last time I tried this challenge, since I can't get it to load at the moment.)

The important property of evaluation is determinism defined by the equality of the output. Classically, id(x) != id(x) is logically inconsistent.

Boolean Logic and natural languages are pretty mainstream in my opinion. Do you mean programming languages? If IEEE whatsthenumber is implemented in the FPUs to provide fcmp (Floating-point Compare Instruction), the languages don't have much of a choice.

When there are different types of equality, ie. compare instructions, you have no equality. That's maybe a bit binary. I'm sorry, I thought this was Computer Science.

Re: Return True to Win

#88

Does anybody really know why JS's type system was designed the way it was? It seems so out of whack with what people want out of a language, dynamically typed or otherwise.

It's because Eich was told to make JS C-like. In C, an empty array, an empty string, 0, false and null are all the same value: a word with all bits 0. So in JS, those are all are falsy and == to each other.

In C, empty strings are truthy, being a non-null pointer to a NUL character. Depending on what you mean by "an empty array" that might also be a non-null pointer to a zero-length region of memory, and thus also truthy in C.

Re: Return True to Win

#89
What is with the User/Score/Browser table? I only did like 4 of the tests and that thing popped up. I would finish it but I have some other things to do.
Post reply on HN