Programing Language Equality Test Complexity

By Xah Lee. Date: . Last updated: .

Programing Language Equality Test Complexity

this is the code triangle is bitching about:

const x = null;
const y = 0;

  x == y,
  x > y,
  x == y || x > y,
  x >= y,

basically, his complaint, is that the greater or equal operator x >= y is not the same as x == y || x > y, as is the math definition.

There multiple issues here. First, math n comp lang is totally diff. But this question isn't just about the definition of ≥ in math vs comp lang. It also involves type conversion, and ill shit like null, and, the complexity of defining equality in comp lang.

PowerShell equality wart, not symmetric:

$x = 3,4,5
$y = 3

$x -eq $y
# return 3

$y -eq $x
# return False

WolframLang equality wart:

{} == 2
(* return expression as is *)

(* using Reduce makes it true *)
Reduce[ {} == 2 ] === True

JavaScript equality wart:

console.log([] == "");
console.log("0" == 0);
console.log("" == 0);
console.log(1 == true);

console.log((NaN == NaN) === false);
console.log(([3, 4] == [3, 4]) === false);
console.log(({ "a": 1, "b": 2 } == { "a": 1, "b": 2 }) === false);

// all true

emacs lisp equality wart:

;; wtf string
(eq "e" "e")
;; false

;; wtf symbol
(string-equal "abc" 'abc)
;; true

;; wtf
(equal 3 3.0)
;; false

;; wtf float
(= 3 3.0000000000000001) ; true
(= 3 3.000000000000001)  ; false

;; who invented negative zero?
(eql 0.0 -0.0)
;; false

Is it possible for a programing language to not have shocking warts?

More broadly, cases like this, showcase warts in programing langs. ALL, industrial programing langs have it. Even including WolframLang, as we have discussed here before. That is, given any lang, u could relatively easily, create a construct, very simple that everyone understand, but behavior is totally surprising and hateful.

The interesting task would be, to find a lang, where such do not exist. Now am not sure, if there actually exist a lang, where surprising warts do not exist. I think it might exist... Need to think for few hours to see if it is possible at all. (e.g. Look at the issue of error handing or checking bad input) it might be the case that, if u have a lang that no shocking wart exist, then that lang basically becomes supremely inefficient or impractical.