Search code examples
javascriptrubylanguage-design

languages that always had triple equals


What popular programming languages were intentionally designed from the beginning to have both === and == (and require the programmer to figure out which one to use).
Javascript, PHP, ruby (and probably others) have a triple equals operator today. But, it is not clear if this was a deliberate design decision, or happened only by accident (perhaps because the language started with double equals, but at some point it was discovered that double equals wasn't quite doing what people wanted it to do).
Specifically in javascript, does anyone remember if it had the triple equals when it first came out?


Solution

  • Since my memory isn't very reliable, I can't say that I remember either or, but since ECMA has kindly kept all revisions of the ECMA-262 specification, it's possible to defer from reading them when the "The Strict Equals Operator" was introduced into the language.

    I can't find any mention of it in neither ECMA-262 1st Edition, nor ECMA-262 2nd Edition, but in ECMA-262 3rd Edition we find mention of it in chapter 11.9.4 (page 56). The natural conclusion to draw from this is thus: No, JavaScript did not have === when it first came out.

    Since the other languages you mention aren't (as far as I know) ratified in any standardisation body, I guess it's harder to find old revisions of the language's specification, if there is any such thing as a specification for the language at all.

    It's important to note, however, that the meaning of === in Ruby can be widely different than in JavaScript or PHP (where it is fairly similar). In Ruby, it's usually used for "subsumption", i.e. to check whether something exists within something else (a set, for instance), while in the two other langauges, it's used for strict equality checking, which means no type conversion is performed on either side of the operator before applying it.