Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.java.programmer > #32471 > unrolled thread
| Started by | "Christoph M. Becker" <cmbecker69@arcor.de> |
|---|---|
| First post | 2015-09-03 00:43 +0200 |
| Last post | 2015-09-04 02:37 +0200 |
| Articles | 5 — 3 participants |
Back to article view | Back to comp.lang.java.programmer
This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by
below is the oldest one visible, not the original post.
Re: questions re Javascript "Christoph M. Becker" <cmbecker69@arcor.de> - 2015-09-03 00:43 +0200
Re: questions re Javascript "Christoph M. Becker" <cmbecker69@arcor.de> - 2015-09-03 01:45 +0200
Re: questions re Javascript Lew <lewbloch@gmail.com> - 2015-09-23 16:07 -0700
Re: questions re Javascript Arne Vajhøj <arne@vajhoej.dk> - 2015-09-03 19:57 -0400
Re: questions re Javascript "Christoph M. Becker" <cmbecker69@arcor.de> - 2015-09-04 02:37 +0200
| From | "Christoph M. Becker" <cmbecker69@arcor.de> |
|---|---|
| Date | 2015-09-03 00:43 +0200 |
| Subject | Re: questions re Javascript |
| Message-ID | <ms7u1o$guu$1@solani.org> |
Stefan Ram wrote: > Tim Streater <timstreater@greenbee.net> 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
[toc] | [next] | [standalone]
| From | "Christoph M. Becker" <cmbecker69@arcor.de> |
|---|---|
| Date | 2015-09-03 01:45 +0200 |
| Message-ID | <ms81n8$tlh$1@solani.org> |
| In reply to | #32471 |
Stefan Ram wrote:
> "Christoph M. Becker" <cmbecker69@arcor.de> 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
[toc] | [prev] | [next] | [standalone]
| From | Lew <lewbloch@gmail.com> |
|---|---|
| Date | 2015-09-23 16:07 -0700 |
| Message-ID | <7cbcc8d8-7b28-4585-b516-1a3424917b32@googlegroups.com> |
| In reply to | #32477 |
On Wednesday, September 2, 2015 at 4:45:53 PM UTC-7, Christoph M. Becker wrote:
> Stefan Ram wrote:
>
> > "Christoph M. Becker" <cmbecker69@arcor.de> 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.
It has nothing to do with constants, in quotes or not. It has to do with the string concatenation operator '+'.
Read the tutorials.
The example about which you complained didn't use constants in the concatenation expression, so how did you decide it had to do with constants?
--
Lew
[toc] | [prev] | [next] | [standalone]
| From | Arne Vajhøj <arne@vajhoej.dk> |
|---|---|
| Date | 2015-09-03 19:57 -0400 |
| Message-ID | <msamoq$9s$1@speranza.aioe.org> |
| In reply to | #32471 |
On 9/2/2015 6:43 PM, Christoph M. Becker wrote: > Stefan Ram wrote: >> Both have »instanceof« with a similar meaning, while other >> languages do not. > > Counter-examples: C#, PHP. It is not called instanceof in C#. Arne
[toc] | [prev] | [next] | [standalone]
| From | "Christoph M. Becker" <cmbecker69@arcor.de> |
|---|---|
| Date | 2015-09-04 02:37 +0200 |
| Message-ID | <msap4a$reh$1@solani.org> |
| In reply to | #32501 |
Arne Vajhøj wrote: > On 9/2/2015 6:43 PM, Christoph M. Becker wrote: >> Stefan Ram wrote: >>> Both have »instanceof« with a similar meaning, while other >>> languages do not. >> >> Counter-examples: C#, PHP. > > It is not called instanceof in C#. Oops – I've googled not thoroughly enough. Thanks for the correction. -- Christoph M. Becker
[toc] | [prev] | [standalone]
Back to top | Article view | comp.lang.java.programmer
csiph-web