4 ms·
There’s a secret competition between C++ and JavaScript to come up with more variants of nothing.
by pavlov 2y ago
There’s a secret competition between C++ and JavaScript to come up with more variants of nothing.
- shadowgovt 2y agoIf you like that, you'll love how many ways you can test for equality in LISP.
- MathMonkeyMan 2y agoThat always chafed me about Scheme. I see the utility of `eq?` and `eqv?`, but I'd prefer that there were only `equal?` and functions were defined to get an object's "id" or "numeric equivalency class," or whatever, instead of having different flavors of data structures that differ only for certain values.
- tuveson 2y agoDon’t forget good ole `=` for comparing numbers.
- koito17 2y agoEach equality function, at least in Common Lisp, has a distinct goal. Numbers use = if you don't care about type. For instance, the real number 0 and the complex number 0 + 0i would be treated equal by this function. Do you care about strict pointer equality? eq. Do you want to distinguish 0 and 0d0? eql. Do you care about isomorphism? equal. The only weird function to me would be equalp, given that it performs case-insensitive comparison of characters etc. Overall, I find complaints about the equality predicates to be based on a misunderstanding of the definition of "equality". Clojure goes the opposite direction and has a single = function that performs all sorts of reflection and deep comparisons; it's convenient in practice, but it's also easy to burn CPU cycles if you are e.g. comparing large collections and only care about pointer equality.
- DonHopkins 2y agoProof that Brendan Eich never really cared about equality. https://www.reddit.com/r/ProgrammerHumor/comments/225i15/proof_that_brendan_eich_never_really_cared_about/ https://www.reddit.com/r/ProgrammerHumor/comments/225i15/pro... (To contextualize and clarify: It's a classic old JavaScript joke about how Brendan Eich hates gay people getting married so much that he donated money to a political campaign against marriage equality, even though he enjoys the human right of marriage himself. Some bigots think they are more equal than others.)
- otabdeveloper4 2y agoMarriage isn't a human right. Just ask any "men's rights" activist.
- DonHopkins 2y agoWho cares what they think?
- shadowgovt 2y ago> Overall, I find complaints about the equality predicates to be based on a misunderstanding of the definition of "equality". It's more that LISP is the only language I know that exposes how complex the concept of equality actually is. All the other ones I use more-or-less make an implicit assumption that equality means one of the things that LISP offers but if you want the other definitions of equality you either have to build support for them by hand or call out to a library function that's going to use (static or dynamic) reflection to reduce the problem to the one kind of equality the language implements. (Apart from that, the only other complaint is that LISP being as old as it is, the default names for those equalities are too terse to self-describe. You just have to memorize which one is 'eq' and which one is 'eql', there's no way to guess looking at the names themselves).
- kazinator 2y agoCommon Lisp doesn't do a very good job, unfortunately. [1]> (equal '(1 2 3) '(1 2 3)) T [2]> (equal "abc" "abc") T [3]> (equal #(1 2 3) #(1 2 3)) NIL [4]> (subtypep 'string 'vector) T ; T So a string is formally a kind of vector according to t he type system itself, but vectors don't use equal comparison whereas strings do. We can reach for equalp: [1]> (equalp #(1 2 3) #(1 2 3)) T But then we have to accept, something we might not necessarily want: [2]> (equalp #(1 2 3) #(1 2 3.0)) T which will not be true under the equal function that we really wanted to Just Work for simple vectors: [3]> (equal '(1 2 3) '(1 2 3.0)) NIL eql being the default equality function throughout the library is also suboptimal. The specification allows (eq 1 1) to be false, which caters to unrealistically poor implementations such as ones that heap-allocate all integers. This, in spite of the fact that fixnum is required to be at least 16 bits wide: most-positive-fixnum must be at least 32767, and the fixnum type must be a supertype of (signed-byte 16). What this means is that if Common Lisp were fit into a 16 bit machine (good luck with that at all), it would have to provide 16 bit fixnums (easily doable, but not unboxed ones) which defeats the fixnum concept of fixnums being the unboxed range of integers, beyond which we have boxed bignums.
- DonHopkins 2y agohttps://news.ycombinator.com/item?id=40192911 https://news.ycombinator.com/item?id=40192911 DonHopkins 85 days ago | parent | context | favorite | on: What if null was an Object in Java? Why stop at null, when you can have both null and undefined? Throw in unknown, and you've got a hat trick, a holy trinity of nothingness! Of course the Rumsfeld Matrix further breaks down the three different types of unknowns. https://en.wikipedia.org/wiki/There_are_unknown_unknowns https://en.wikipedia.org/wiki/There_are_unknown_unknowns >"Reports that say that something hasn't happened are always interesting to me, because as we know, there are known knowns; there are things we know we know. We also know there are known unknowns; that is to say we know there are some things we do not know. But there are also unknown unknowns—the ones we don't know we don't know. And if one looks throughout the history of our country and other free countries, it is the latter category that tends to be the difficult ones." -Donald Rumsfeld 1) Known knowns: These are the things we know that we know. They represent the clear, confirmed knowledge that can be easily communicated and utilized in decision-making. 2) Known unknowns: These are the things we know we do not know. This category acknowledges the presence of uncertainties or gaps in our knowledge that are recognized and can be specifically identified. 3) Unknown unknowns: These are the things we do not know we do not know. This category represents unforeseen challenges and surprises, indicating a deeper level of ignorance where we are unaware of our lack of knowledge. And Microsoft COM hinges on the IUnknown interface. https://en.wikipedia.org/wiki/Tony_Hoare#Research_and_career https://en.wikipedia.org/wiki/Tony_Hoare#Research_and_career >Speaking at a software conference in 2009, Tony Hoare apologized for inventing the null reference: >"I call it my billion-dollar mistake. It was the invention of the null reference in 1965. At that time, I was designing the first comprehensive type system for references in an object oriented language (ALGOL W). My goal was to ensure that all use of references should be absolutely safe, with checking performed automatically by the compiler. But I couldn't resist the temptation to put in a null reference, simply because it was so easy to implement. This has led to innumerable errors, vulnerabilities, and system crashes, which have probably caused a billion dollars of pain and damage in the last forty years." -Tony Hoare https://news.ycombinator.com/item?id=19568378 https://news.ycombinator.com/item?id=19568378 >"My favorite is always the Billion-Dollar Mistake of having null in the language. And since JavaScript has both null and undefined, it's the Two-Billion-Dollar Mistake." -Anders Hejlsberg >"It is by far the most problematic part of language design. And it's a single value that -- ha ha ha ha -- that if only that wasn't there, imagine all the problems we wouldn't have, right? If type systems were designed that way. And some type systems are, and some type systems are getting there, but boy, trying to retrofit that on top of a type system that has null in the first place is quite an undertaking." -Anders Hejlsberg
- ThrowawayTestr 2y agoMathematicians got nothing on lazy programmers
- immibis 2y agoVBA has 4 kinds. Null, Nothing, Missing, and Empty.