5 ms·
That's more sensible though. It's just trying to interpret the invention when comparing different types. The fact that == breaks even when the types are the sam
by aflag 4y ago
That's more sensible though. It's just trying to interpret the invention when comparing different types. The fact that == breaks even when the types are the same is much more surprising
- pdpi 4y agoWhen does == break when the types are the same? Can't think of any case.
- matt_kantor 4y agoI'd imagine they are referring to the post we are commenting on (whose context is PHP).
- pdpi 4y agoAh right, forgot the stack overflow post is about PHP.
- deleted 4y ago[deleted]
- jerf 4y agoThis is not a criticism of Javascript; this is history. There has been a lot of work done on Javascript over the decades. But historically, it is a language that was put together in a week in an emergency, last-ditch effort to keep Java from being the language instead. That's literally a week, not a rhetorically-exaggerated week. For a one-week language, it's pretty darned good! But it was still a one-week language. The behavior of the == operator is one of the places where that really shows. I'm sure Brendan Eich would have cleaned that up with more time, but there wasn't any. And the behavior of the == operator is just one of those things that simply can not be fixed for backwards compatibility reasons. That's why an additional one had to be added later that works more sensibly. There's a few other old corners of JS that have survived into the modern era. See also the excitement of hasOwnProperty and all that involves. This was a huge mess for a long time. The work on cleaning it up, against the requirements of backwards compatibility and the uphill battle of having so much of it deployed out in the world, has been exemplary. But there is still some things that just can't have much done about them, == being one of them.
- sitkack 4y agoIf it had been Java, we would have saved billions of dollars, multiple billions of programmer hours. Sounds like a colossal mistake in retrospect.
- jerf 4y agoMight be true in 2023, won't argue either way. In ~1995, it was insane. Java startup costs were dozens of seconds, and that's assuming it didn't have to push anything into swap to do it. The browser needed some sort of language that was always present and didn't have such a staggering footprint, some sort of built-in language that could be parsed and executed without all that. In a perfect world we might have gotten an existing language that fit the bill, but in literally-a-week, it was easier to put something together new inside the browser than to integrate anything into the codebase. The reason for the deadline wasn't that Java was a good idea. You should also bear in mind we're not talking the Java of today, but the Java of not-even-1.0 yet. Java in 1995 wasn't a very good language. Sun was just jamming it everywhere they could, and the browser looked like an appealing target from a marketing point of view. From a technical point of view it was insane. Java grew up, certainly. But it was forced on the world on the back of an enormous marketing budget and a full court press, not the technical merits of Java circa 1995. Many people around here remember the XML push forcing a technology everywhere, even where it doesn't belong, well, the one before that was Java. Completely inorganic.
- sitkack 4y agoEich is a smart man, and already had experience with Scheme at the time. A subset of Java with a fast interpreter would have been much preferable. Lots of great small languages existed. It makes for a great heroic story, but really it should one of a smart person making a hasty design that basically sht on the future. One of the inspirations for Java was the language "Bob" by David Betz https://github.com/dbetz/bob https://github.com/dbetz/bob Even it would have been a win over JS. https://github.com/dbetz/bob https://github.com/dbetz/bob @Article{Betz:1991:YOT, author = "David Betz", title = "Your own tiny object-oriented language", journal = j-DDJ, volume = "16", type = "PL", number = "9", pages = "26, 28, 30, 32--33, 86, 88--89", month = sep, year = "1991", CODEN = "DDJOEB", ISSN = "1044-789X", bibdate = "Tue Sep 10 09:11:02 MDT 1996", bibsource = "http://www.ddj.com/index/author/index.htm; http://www.math.utah.edu/pub/tex/bib/dr-dobbs-1990.bib", note = "Reprinted in \cite{Betz:1994:YOT}.", acknowledgement = ack-nhfb, classification = "C6140D (High level languages); C6150C (Compilers, interpreters and other processors)", keywords = "Bob; C++; C-like syntax; Class system; Interpreter; Lisp; Tiny object-oriented language", thesaurus = "C listings; High level languages; Object-oriented programming; Program interpreters", } http://www.txbobsc.com/misc/bob-article/bob-article.html http://www.txbobsc.com/misc/bob-article/bob-article.html It shouldn't be excused. Every feature is the potential for an equal or larger detractor.
- BrendanEich 4y agoWhat "breaks" when types are the same? The strings do not have the same contents.
- aflag 4y agoI'm referring to the article about PHP. Even the strings being different, they compare to true.
- BrendanEich 3y agoThanks, I should have checked context and figured it was PHP. I met Rasmus in 2015 while in Taipei. We got on fine, two old C/Unix hackers. PHP has evolved a lot but I have to say some of its quirks make me slightly less ashamed of JS's quirks ;-).