Path: csiph.com!au2pb.net!feeder.erje.net!1.eu.feeder.erje.net!weretis.net!feeder1.news.weretis.net!news.solani.org!.POSTED!not-for-mail From: "Christoph M. Becker" Newsgroups: comp.lang.javascript,comp.lang.java.programmer Subject: Re: questions re Javascript Date: Thu, 3 Sep 2015 00:43:09 +0200 Organization: solani.org Lines: 68 Message-ID: References: <2b531f48-fff9-4c73-a116-22a3f110e919@googlegroups.com> <020920150828500988%timstreater@greenbee.net> NNTP-Posting-Host: 95.89.143.88 Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Trace: solani.org 1441233785 17374 95.89.143.88 (2 Sep 2015 22:43:05 GMT) X-Complaints-To: abuse@news.solani.org NNTP-Posting-Date: Wed, 2 Sep 2015 22:43:05 +0000 (UTC) User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:38.0) Gecko/20100101 Thunderbird/38.2.0 X-User-ID: eJwFwQkBACAIBLBK/BxxFKR/BDfX4Oi08DBf36U8GAnWJw8l3ABoIs+TUig2r/RcLhsqlQ8P8xCC In-Reply-To: Cancel-Lock: sha1:8O6HT68ySe/ACAJTSSxXTXGb4WM= Xref: csiph.com comp.lang.javascript:28604 comp.lang.java.programmer:32471 Stefan Ram wrote: > Tim Streater writes: >> Javascript has nothing to do with Java except for having a similar >> sounding name. > > There are so many similiarities between the two languages, > that I can't name them all. For example, in both Java and > JavaScript, > > 2 + "x" > > gives »"2x"«, Does that really work in Java? Most certainly the following won't: int x = 2; String y = "x"; x + y; > while in many other languages it does not. > In both Java and JavaScript, the modulo operator »%« can be > used for doubles, Well, JavaScript has only "doubles" (actually, Numbers), but no integers (I'm deliberately ignoring asm.js), so there's no point in defining an modulo operator that wouldn't work with "doubles". > while in many other languages, it cannot. > Both have »instanceof« with a similar meaning, while other > languages do not. Counter-examples: C#, PHP. > In both languages »x == x« is false, when > x is NaN. What is enforced by IEEE 754. > And there are so many more similarities. And this > is no surprise, as Brendan Eich, the creator of JavaScript, > tells us: > > »The diktat from upper engineering management was that > the language must "look like Java".« > > I have read this sentence »Javascript has nothing to do with > Java except for having a similar sounding name« so often. > One copies it from the other. But not one stops to think! > Or to read. If one knows just a little bit about Java and > JavaScript, it is obvious that they have so much in common. Of course, JavaScript and Java have much in common. Mostly, that JavaScript's syntax was designed to resembles Java's, even though early versions of JavaScript and Java were *very* different. Early versions of Java didn't even have closures (a basic building block of all but the most trivial JavaScript scripts), and JavaScript doesn't have classes until recently (and AFAIK these "classes" are still only a thin wrapper over the more versatile prototypal inheritance). Comparing JavaScript with Java is like comparing apples with oranges (yes, both have a lot of similarities…). I consider somewhat recent versions of PHP to be more similar to Java than JavaScript is, for instance. -- Christoph M. Becker