• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Bear Bibeault
  • Devaka Cooray
  • Liutauras Vilda
  • Jeanne Boyarsky
Sheriffs:
  • Knute Snortum
  • Junilu Lacar
  • paul wheaton
Saloon Keepers:
  • Ganesh Patekar
  • Frits Walraven
  • Tim Moores
  • Ron McLeod
  • Carey Brown
Bartenders:
  • Stephan van Hulst
  • salvin francis
  • Tim Holloway

What can we not do using Java Script which we can do using Java?  RSS feed

 
Ranch Hand
Posts: 1020
2
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have a doubt. Is it possible to do everything using java script which we can do using java? If not so then what can we not do using Java Script which we can do using Java?
Thanks.
 
Saloon Keeper
Posts: 5046
134
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In what context? A web page manipulating the DOM of an HTML page? Or in a server-side embedded context? Or something else?

Looking just at the programming language both are Turing-complete, and can thus be used to compute just about everything. But that's an extremely high-level view. For a more detailed answer we'd need to know more of the context of your question.
 
author & internet detective
Posts: 38917
686
Eclipse IDE Java VI Editor
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Also, are you talking about server side JavaScript or client side JavaScript?
 
Monica Shiralkar
Ranch Hand
Posts: 1020
2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks. I mean what these 2 languages are capable of doing in programming.
 
Tim Moores
Saloon Keeper
Posts: 5046
134
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Well, as I said, principally both can be used to compute anything that can be computed with any known language. Are you familiar with the term "Turing-complete"?

If you meant a less high-level view, it goe sback to what Jeanne and I asked: in what context is the code in either language to be used? Without knowing that, the question can't be answered.
 
Monica Shiralkar
Ranch Hand
Posts: 1020
2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Java script can be used from showing a pop up message if validation for a text box fails in the UI. (Example if User enters a number in the field for name which can only be alpha numeric).

Can we show such an alert popup using java too? . I thought it is not possible with java and hence java script is used for such purpose of UI side coding. Nowday java script can also be used in server side. Then is it true that java script can do what java can do but java cannot do what javascript can do (E.g show a pop up alert on the web page)?
 
Marshal
Posts: 67164
169
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Monica Shiralkar wrote:Java script


JavaScript, not Java script.

Most browsers disable obsolete Java applets by default, It is still possible to run applets in some contexts, and with proper settings. That said, who would want to?

Of course Java cannot put up a JavaScript alert -- that's something that's built into the JavaScript bindings for the browser.

Your original question was "what can these languages do", but has morphed into "in which environments can these languages be executed" which is a bit of a different question.
 
Monica Shiralkar
Ranch Hand
Posts: 1020
2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
So we can open a JDBC connection using  JavaScript and even insert data into database using JavaScript. However I have never seen that being done in any code. That is why I am trying to understand that when to use java and when to not use java and use a JavaScript and why so?
 
Bear Bibeault
Marshal
Posts: 67164
169
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Monica Shiralkar wrote:So we can open a JDBC connection using  JavaScript



JDBC is a Java concept. I believe that there are some frameworks that mimic JDBC, but probably not the best way to go. I'd investigate native concepts.

However I have never seen that being done in any code.



What are your search terms?

That is why I am trying to understand that when to use java and when to not use java and use a JavaScript and why so?


That greatly depends on what you know, what you want to do, and the environment you want to do it in.

A small example: dealing with JSON in Java is a royal PITA, but easy in JavaScript. Same with MongoDB. So, as with many other things in software development, the answer is "it depends".
 
Monica Shiralkar
Ranch Hand
Posts: 1020
2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

A small example: dealing with JSON in Java is a royal PITA, but easy in JavaScript. Same with MongoDB. So, as with many other things in software development, the answer is "it depends".



thanks. So does it mean that every  programming language can do everything that can be done by any programming language but we have different languages because in some language some task can be done easily where as in other language some other task can be done easily?
 
Bartender
Posts: 1983
57
Eclipse IDE Google Web Toolkit Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Monica Shiralkar wrote:... programming language can do everything that can be done by any programming language ...


There is a difference between a programming language and a scripting language.

From my own understanding, a scripting language requires a host program and uses the exposed objects from that program to do something. e.g. A client side java script runs within the browser program and is allowed to manipulate the browser dom objects on the fly. It cannot do something outside that territory (e.g. reading files/database/etc...)
In a way, I feel that a scripting language is quite restricted to what it can do and is dependent on its 'host'.

Even you can write a java program that allows user to write java script on the objects that you expose to them. So, lets say you expose an object called "database" and it has a method called "saveData()", the end user can effectively write a javascript code to write data to database. But, internally, it will simply be a call to your java code.
 
Bartender
Posts: 9494
184
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Monica Shiralkar wrote:So does it mean that every programming language can do everything that can be done by any programming language


No. Two programming languages can do the same thing if they're Turing equivalent. Most programming languages however are Turing complete, and therefore also Turing equivalent. There are languages that are not Turing complete though and even if a language IS Turing complete, they can't do everything. See the halting problem.

but we have different languages because in some language some task can be done easily where as in other language some other task can be done easily?


Yes. This usually has to do with libraries and tools that are available for the language, and not the language itself.
 
Stephan van Hulst
Bartender
Posts: 9494
184
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

salvin francis wrote:There is a difference between a programming language and a scripting language.


Eh, I find the difference very trivial or arbitrary in most cases.

From my own understanding, a scripting language requires a host program and uses the exposed objects from that program to do something. e.g. A client side java script runs within the browser program and is allowed to manipulate the browser dom objects on the fly. It cannot do something outside that territory (e.g. reading files/database/etc...)


Much like a Java program runs within a JVM and uses objects exposed by the JVM and can't do anything outside of the JVM by itself?

In a way, I feel that a scripting language is quite restricted to what it can do and is dependent on its 'host'.


This is not a quality of the language. There are compilers that can translate JavaScript to native executables.
 
Bear Bibeault
Marshal
Posts: 67164
169
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Stephan van Hulst wrote:Eh, I find the difference very trivial or arbitrary in most cases.


☝☝☝ This.
 
Monica Shiralkar
Ranch Hand
Posts: 1020
2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks all.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!