What's the difference between JavaScript and Java?

What's the difference between JavaScript and Java?


Asked by: Lydia812 | Posted: 23-01-2022






Answer 1

Java and Javascript are similar like Car and Carpet are similar.

Answered by: Abigail380 | Posted: 24-02-2022



Answer 2

One is essentially a toy, designed for writing small pieces of code, and traditionally used and abused by inexperienced programmers.

The other is a scripting language for web browsers.

Answered by: Miranda769 | Posted: 24-02-2022



Answer 3

Here are some differences between the two languages:

  • Java is a statically typed language; JavaScript is dynamic.
  • Java is class-based; JavaScript is prototype-based.
  • Java constructors are special functions that can only be called at object creation; JavaScript "constructors" are just standard functions.
  • Java requires all non-block statements to end with a semicolon; JavaScript inserts semicolons at the ends of certain lines.
  • Java uses block-based scoping; JavaScript uses function-based scoping.
  • Java has an implicit this scope for non-static methods, and implicit class scope; JavaScript has implicit global scope.

Here are some features that I think are particular strengths of JavaScript:

  • JavaScript supports closures; Java can simulate sort-of "closures" using anonymous classes. (Real closures may be supported in a future version of Java.)
  • All JavaScript functions are variadic; Java functions are only variadic if explicitly marked.
  • JavaScript prototypes can be redefined at runtime, and has immediate effect for all referring objects. Java classes cannot be redefined in a way that affects any existing object instances.
  • JavaScript allows methods in an object to be redefined independently of its prototype (think eigenclasses in Ruby, but on steroids); methods in a Java object are tied to its class, and cannot be redefined at runtime.

Answered by: Catherine112 | Posted: 24-02-2022



Answer 4

Take a look at the Wikipedia link

JavaScript, despite the name, is essentially unrelated to the Java programming language, although both have the common C syntax, and JavaScript copies many Java names and naming conventions. The language was originally named "LiveScript" but was renamed in a co-marketing deal between Netscape and Sun, in exchange for Netscape bundling Sun's Java runtime with their then-dominant browser. The key design principles within JavaScript are inherited from the Self and Scheme programming languages.

Answered by: Grace762 | Posted: 24-02-2022



Answer 5

Everything.

JavaScript was named this way by Netscape to confuse the unwary into thinking it had something to do with Java, the buzzword of the day, and it succeeded.

The two languages are entirely distinct.

Answered by: Ted231 | Posted: 24-02-2022



Answer 6

enter image description here
Java is to JavaScript as ham is to hamster

Answered by: Jack874 | Posted: 24-02-2022



Answer 7

JavaScript is an object-oriented scripting language that allows you to create dynamic HTML pages, allowing you to process input data and maintain data, usually within the browser.

Java is a programming language, core set of libraries, and virtual machine platform that allows you to create compiled programs that run on nearly every platform, without distribution of source code in its raw form or recompilation.

While the two have similar names, they are really two completely different programming languages/models/platforms, and are used to solve completely different sets of problems.

Also, this is directly from the Wikipedia Javascript article:

A common misconception is that JavaScript is similar or closely related to Java; this is not so. Both have a C-like syntax, are object-oriented, are typically sandboxed and are widely used in client-side Web applications, but the similarities end there. Java has static typing; JavaScript's typing is dynamic (meaning a variable can hold an object of any type and cannot be restricted). Java is loaded from compiled bytecode; JavaScript is loaded as human-readable code. C is their last common ancestor language.

Answered by: Adelaide754 | Posted: 24-02-2022



Answer 8

In addittion to being entirely different languages, in my experience:

  • Java looks nice at first, later it gets annoying.
  • JavaScript looks awful and hopeless at first, then gradually you really start to like it.

(But this may just have more to do with my preference of functional programming over OO programming... ;)

Answered by: John643 | Posted: 24-02-2022



Answer 9

Everything. They're unrelated languages.

Answered by: Nicole152 | Posted: 24-02-2022



Answer 10

They are independent languages with unrelated lineages. Brendan Eich created Javascript originally at Netscape. It was initially called Mocha. The choice of Javascript as a name was a nod, if you will, to the then ascendant Java programming language, developed at Sun by Patrick Naughton, James Gosling, et. al.

Answered by: Anna415 | Posted: 24-02-2022



Answer 11

Like everybody's saying, they're pretty much entirely different.

However, if you need a scripting language for your Java application, Javascript is actually a really good choice. There are ways to get Javascript running in the JVM and you can access and manipulate Java classes pretty seamlessly once you do.

Answered by: Julia758 | Posted: 24-02-2022



Answer 12

They have nothing to do with each other.

Java is statically typed, compiles, runs on its own VM.

Javascript is dynamically typed, interpreted, and runs in a browser. It also has first-class functions and anonymous functions, which Java does not. It has direct access to web-page elements, which makes it useful for doing client-side processing.

They are also somewhat similar in syntax, but that's about it.

Answered by: Catherine433 | Posted: 24-02-2022



Answer 13

Don't be confused with name..
Java was created at Sun Microsystems (now Oracle).
But, JavaScript was created at Netscape (now Mozilla) in the early days of the Web, and technically, “Java-Script” is a trademark licensed from Sun Microsystems used to describe Netscape’s implementation of the language. Netscape submitted the language for standardization to ECMA (European Computer Manufacturer’s Association) and because of trademark issues, the standardized version of the language was stuck with the awkward name “ECMAScript.” For the same trademark reasons, Microsoft’s version of the language is formally known as “JScript.” In practice, just about everyone calls the language JavaScript. The real name is “ECMAScript”.

Both are fully different languages!!!

Answered by: Roman837 | Posted: 24-02-2022



Answer 14

Practically every PC in the world sells with at least one JavaScript interpreter installed on it.

Most (but not "practically all") PCs have a Java VM installed.

Answered by: Elise169 | Posted: 24-02-2022



Answer 15

A Re-Introduction to Javascript by the Mozilla team (they make Firefox) should explain it.

Answered by: Elise968 | Posted: 24-02-2022



Similar questions

java - What's the difference between Duby and Juby and why would I need either of them?

According to Charles Nutter, Duby is a static-typed language with Ruby's syntax and Java's type system. Duby supports all Ruby's literals, uses local type inference (only argument types must be declared), and runs as fast as Java (because it produces nearly identical bytecode)....


java - What's the difference between Duby and Juby and why would I need either of them?

According to Charles Nutter, Duby is a static-typed language with Ruby's syntax and Java's type system. Duby supports all Ruby's literals, uses local type inference (only argument types must be declared), and runs as fast as Java (because it produces nearly identical bytecode)....


java - What's the difference between these two below?

System.out.println(matcher.group(1)); System.out.println(matcher.group()); I like to know what's the difference between the above two codes. I get different outputs. Can anybody elaborate on this? Thanks


java - What's the difference between Jetty and Netty?

What is the main difference between Jetty and Netty? Netty is part of Jboss, but is it the default web server container? Does Netty support Servlets 3.0?


java - What's the difference between String and new String?

This question already has answers here:


java - What's the difference between # , % and $ signs in Struts tags?

I'm working with Struts 2 and when I'm accessing ValueStack variables I don't know whether to use % or # or $. I try all of them until I find the correct one. Can anybody explain what is the difference between them?


java - what's the difference between these blocks of code?

So I went over this block of code several times in a book that I'm reading: int[][] someArray = new int[size][]; for(int i=0; i<size; i++) someArray[i] = new int[size]; I don't see any difference between that and the following declaration: int[][] someArray = new int[size][size]; Did I miss anything here? Is there any reason why I should use the long...


java - What's the difference between ( and [?

What's the difference between [pattern] and (pattern)? I couldn't find it on google as it doesn't allow to type those symbols. Thanks.


java - What's the difference between jsp and jsi?

I have noticed that .jsi and .jsp files work almost the same way. So what is their purpose and how to use them correctly? in which situation to use which one?


java - what's the difference between #{} ${} and %{}?

I'm currently working with struts2, and I just don't understand what the difference is between ${var}, #{var}, and %{var} are they different scopes? what are they? I found an example of the #: <s:select label="Year" id="%{param.name}" list="#{'2010':'2010','2011':'2011','2012':'2012','2013':'2013','2014':'2014', '2015':'2015'}" val...


java - what's the difference between .out and .log file

I never bothered to find this out. Let's see I have a java web application running called "myapp" What's the difference between myapp.out and myapp.log file? .log file can be rotated according to log4j.properties setting, how about .out file? do I need to set up the rotation policy for it as well?


java - What is the difference between a Functor and the Command pattern?

I am very familiar with the Command pattern, but I don't yet understand the difference in theory between a Functor and a command. In particular, I am thinking of Java implementations. Both are basically programming "verbs" represented as objects. However, in the case of functors, as I have seen from some examples anonymous inner class implementations seem common. Can anyone out there clear this up for me nicely?


java - Difference between value and itemvalue

What is the difference between the value and itemValue attribute of the radiobutton in Jsf?


java - Difference between Oracle ATG and Struts?

Closed. This question needs to be more focused. It ...


syntax - Is there a difference between single and double quotes in Java?

Is there a difference between single and double quotes in Java?


java - What is the difference between Swing and AWT?

Can someone please explain me what's the difference between Swing and AWT? Are there any cases where AWT is more useful/advised to use than swing or vice-versa?


java - Difference between declaring variables before or in loop?

I have always wondered if, in general, declaring a throw-away variable before a loop, as opposed to repeatedly inside the loop, makes any (performance) difference? A (quite pointless) example in Java: a) declaration before loop: double intermediateResult; for(int i=0; i < 1000; i++){ intermediateResult = i; System.out.println(intermediateResult); } ...


java - Difference between break and continue statement

Can anyone tell me the difference between break and continue statements?


Difference between '.' and "." in java

Is there a difference between concatenating strings with '' and ""? For example, what is the difference between: String s = "hello" + "/" + "world"; and String s = "hello" + '/' + "world";


java - Difference between moving an Iterator forward with a for statement and a while statement

When I use an Iterator of Object I use a while loop (as written in every book learning Java, as Thinking in Java of Bruce Eckel): Iterator it=... while(it.hasNext()){ //... } but sometime i saw than instead somebody use the for loop: Iterator it=... for (Iterator it=...; it.hasNext();){ //... } I don't' understan...


java - Difference between Set and Collection in hibernate

What is the difference between using a Set or a Collection for @OneToMany or @ManyToMany properties on my hibernate entity objects? Does Hibernate map things differently depending on which one you choose?






Still can't find your answer? Check out these amazing Java communities for help...



Java Reddit Community | Java Help Reddit Community | Dev.to Java Community | Java Discord | Java Programmers (Facebook) | Java developers (Facebook)



top