Path: csiph.com!news.mixmin.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 01:45:49 +0200 Organization: solani.org Lines: 51 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 1441237544 30385 95.89.143.88 (2 Sep 2015 23:45:44 GMT) X-Complaints-To: abuse@news.solani.org NNTP-Posting-Date: Wed, 2 Sep 2015 23:45:44 +0000 (UTC) User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:38.0) Gecko/20100101 Thunderbird/38.2.0 X-User-ID: eJwFwQkBwDAIA0BLvKGTA03xL2F36VDcCiQiN7f2EUf6ujRVpkFnCUiDMD6bsbdtdSa2Wn8tsRGs In-Reply-To: Cancel-Lock: sha1:W75BWiD4rSRi1V7P0SnFssys4/s= Xref: csiph.com comp.lang.javascript:28607 comp.lang.java.programmer:32477 Stefan Ram wrote: > "Christoph M. Becker" writes: >> Does that really work in Java? Most certainly the following won't: >> int x = 2; >> String y = "x"; >> x + y; > > Not exactly in this wording, but essentially: > > public final class Main > { public static void main( final java.lang.String[] args ) > { final int x = 2; > final java.lang.String y = "x"; > java.lang.System.out.println( x + y ); }} /* prints: > 2x */ Interesting, thanks! Nonetheless this seems to be rather a particular convenience regarding "constants", and not a general flexibility of the type system. >> 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 > > One must not confuse the syntactic feature of function literals > (called »lambdas«) with the semantic feature of entities that > »close over« (contain) local environments (called »closures«). Thanks for the clarification. > (Possibly, the first versions of LISP had lambdas, but not > closures, too, then closures were invented to solve the > »outward funarg problem« IIRC.) IIRC, early versions of LISP where dynamically scoped (a concept I still can't really grasp, and what unfortunately is reflected by `this` in ECMAScript), whereas only later versions (most notably Common Lisp and Scheme) defaulted to lexical scoping (which is much more intuitive to me). Anyhow, I still think that Java has its main roots in C++, and JavaScript in Scheme, and as such I'd categorize Java as object-oriented, but JavaScript as functional (actually, applicative) programming language (the lines are blurred, and are becomming more blurred as time goes by, though). PS: I'm aware of Guy L. Steele's influence on Scheme, Common Lisp *and* Java. -- Christoph M. Becker