-3

It seems to me that Java was the computing language that could be used anywhere and JavaScript was the scripting language for the web and things stayed that way for a long while. There are countless articles about how Java is not JavaScript and vice-versa but they are often quite old.

JavaScript has started to move towards typing(TypeScript, etc.), lower level functions(devices, array buffers, WebGL, Bluetooth, etc.), compiling, other areas(Node.js, v8/Rhino outside of the web). The syntax of both Java and JavaScript seem to also be learning from each other.

I am more knowledgeable in JavaScript so would need more of a Java perspective but are Java and JavaScript converging and if so in what way could Java be at an advantage over JavaScript?

closed as primarily opinion-based by Rein Henrichs, gnat, Christophe, Doc Brown, Thomas Junk Aug 14 '17 at 7:19

Many good questions generate some degree of opinion based on expert experience, but answers to this question will tend to be almost entirely based on opinions, rather than facts, references, or specific expertise. If this question can be reworded to fit the rules in the help center, please edit the question.

6

I wouldn't say Java and JavaScript are converging.

JavaScript does have type extensions, but I wouldn't say it's because of Java. I think it has more to do with JavaScript being used in applications where it's desirable to have checked types. Additionally, static typing is not a JavaScript language feature and is unlikely to be. You must use a different language (e.g. TypeScript) that adds typing. JavaScript can be run outside of browsers on most devices, but so can many languages. Most languages have API for the "low level functions" you described.

Java has functional features, but I wouldn't say it's because of JavaScript but because functional programming is becoming increasingly popular. I haven't seen any signs that Java will support dynamic typing in the future.

Yes, languages do share ideas and change over time, but Java and JavaScript are still vastly different in syntax, typing and paradigm.

  • Thank you for your answer. "static typing is not a JavaScript language feature and unlikely to be" - There is talk of this and similar functionality being added to es7, what will make it in though is hard to say but the discussions itself I think show that this is hard to know yet. – Damien Golding Aug 14 '17 at 8:22
  • "Most languages have API for the "low level functions" you described" - I think this is far more important for JavaScript over other languages though for the reason that JavaScript is the only programming language that commonly runs in client browsers. – Damien Golding Aug 14 '17 at 8:25
  • "JavaScript can be run outside of browsers on most devices, but so can many languages" + "Java has functional features, but I wouldn't say it's because of JavaScript but because functional programming is becoming increasingly popular" - valid points but are not evidence against my question. – Damien Golding Aug 15 '17 at 3:35
5

It seems to me that Java was the computing language that could be used anywhere and JavaScript was the scripting language for the web and things stayed that way for a long while.

Actually, that is not true.

JavaScript (actually, it was still called LiveScript back then) was released by Netscape in Navigator for client scripting and in Live Server for server-side scripting at around the same time (only a couple of weeks apart), whereas Java was originally designed as a scripting language for interactive TVs.

So, it is exactly the other way around: JavaScript was always intended as a general-purpose language, whereas Java was intended as a client-side language.

Why did Sun pay money to Netscape to include Java in Navigator? Why did Sun pay money to Netscape to rename the language to JavaScript? It was because they realized that JavaScript was threatening Java.

There are countless articles about how Java is not JavaScript and vice-versa but they are often quite old.

Yes, but nothing has changed.

JavaScript has started to move towards typing(TypeScript, etc.),

No, it hasn't. There was an effort of getting types into the language in the ill-fated ECMAScript 4, but that was (rightfully) abandoned, and it is unlikely that ECMAScript will get types in the near future. TypeScript is a different language, precisely because ECMAScript won't get types in the near future.

lower level functions(devices, array buffers, WebGL, Bluetooth, etc.),

Like I said, JavaScript was always intended as a general-purpose language.

compiling,

I am not sure what you mean by that. Yes, ECMAScript is a good language for writing compilers in, but that is because of its Scheme and Self heritage, not because of a "convergence with Java".

other areas(Node.js, v8/Rhino outside of the web).

Again, JavaScript was always intended that way, and this is nothing new. Microsoft has shipped a JavaScript interpreter for building desktop applications as part of the OS since Windows XP, I think, and JScript.NET (a superset of JavaScript) for server-side scripting for over a decade.

The Jesusonic audio effects engine (by Justin Frankel, the author of Winamp, now part of the REAPER Digital Audio Workstation) has used JavaScript for writing audio FX since at least 2004.

The syntax of both Java and JavaScript seem to also be learning from each other.

Well, Brandon Eich originally designed LiveScript with Scheme syntax and semantics extended with an object system based on NewtonScript, Act-1, and Scheme. He was then ordered to change the syntax so it looks "like a real language" (by which his superiors meant C++ and Java), so it is no coincidence that JavaScript has similarities with Java. But that is not because of convergence.

I am more knowledgeable in JavaScript so would need more of a Java perspective but are Java and JavaScript converging and if so in what way could Java be at an advantage over JavaScript?

The main difference between the two is that ECMAScript has a very small standard library. This makes it easy to adapt it to different niches, but you have to do the "adapting" first. (E.g. Ryan Dahl writing his own I/O library for Node.js.)

Java, OTOH, has a very large standard library. This allows it to be applied to different niches without adapting, but you always have to carry around the 90% that you're not using, and it always doesn't quite exactly fit.

  • Thank you for your detailed answer. Although I am aware of a good deal said here, I wasn't aware of things like LiveScript and Java as a scripting language for TVs. Regarding things like TypeScript not being part of JavaScript, well technically yes, but there is also a trend towards using these kinds of things recently. Whether it is in the language or not becomes irrelevant when it becomes an almost defacto standard to use it. When I refer to compiling, I am referring to building with babel, sass, webpack, etc. – Damien Golding Aug 14 '17 at 7:47
  • I was aware that this would be a touchy question even though I don't really know why. I am fully aware neither language is going to vanish. It is not the libraries that I am concerned about although the difference in size of the standard library is an interesting point, it is the distinguishing strengths surrounding what is possible that I am concerned about. "Like I said, JavaScript was always intended as a general-purpose language." - Intention may be one thing but reality is another. It is a lot easier to run near native level code on many devices recently. – Damien Golding Aug 14 '17 at 8:03
  • 1
    @DamienGolding I think you got my point. To expand upon it, there is a general movement towards multi-paradigm programming. You see this in Java with the addition of functional elements to the language. We'll likely see more overlap in many languages as designers work on how to bring these elements together in a coherent way. I think the languages that do this the best will win out in the long run. So in one sense, I think you are right there is some convergence, there's just no real reason to pick these two examples in lieu of the others. – JimmyJames Aug 15 '17 at 13:23
  • 1
    @DamienGolding: There was a desire to make ECMAScript more like Java in the ECMAScript 4 timeframe. ECMAScript 4 had classes and static types. And it was rightfully abandoned for two reasons: 1) it was not ECMAScript any more. It didn't look and feel like ECMAScript, it felt like Java. 2) Mixing prototype-based delegation and class-based inheritance, and mixing static and dynamic typing was (and still is) an open research topic, and you don't do research in a language specification committee, period. Pretty much every thing the committee has done since ES4, has been more or less doing … – Jörg W Mittag Aug 17 '17 at 9:23
  • 1
    … things differently than Java. Concurrency and Parallelism are based on Promises and Processes, not Threads, and come from Functional Programming. Reflection is based on Mirrors and Proxies, not Smalltalk-style, and comes from Self and E. Encapsulation is based on Closures, not Types, and comes from Scheme. Security is based on Capabilities and comes from E. Generators come from CLU via Python. None of those things exist in Java. I really don't see how they are converging. – Jörg W Mittag Aug 17 '17 at 9:30

Not the answer you're looking for? Browse other questions tagged or ask your own question.