简体   繁体   中英

What's the reason behind to include a engine in Java to run JavaScript?

To let JavaScript able to run in server-side?

If it's justified, what's the advantage? and any good application for such use?

There are lots of possible reasons. Here's a blog post by Steve Yegge (of Google) explaining why he was looking into using Mozilla Rhino (which later because javax.script ).

According to the Rhino site:

It is typically embedded into Java applications to provide scripting to end users.

So I guess that's one good reason. Other things I've read include doing it because you have some complex language that you want to run on either the browser or the server, and you don't want to write it twice (as here ).

Generally speaking, that's a lot of complexity, and generally speaking, complexity is bad.

I haven't seen any applications in the wild, but as a proof of concept it's pretty nice. Traditionally Java to the layperson has meant a fused combo of the language and the VM, with few other languages implemented for the platform outside academia. But I think now people are starting to innovate with languages targetted at the JVM, possibly as a result of the features introduced by C#.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM