javajavascriptc++mongodbcouchdb

Why is Javascript used in MongoDB and CouchDB instead of other languages such as Java and C++?


My understanding of the JavaScript so far has been that it is a client-side language that capture events and makes a Web page dynamic.

But on reading a comparison between MongoDB and CouchDB, I noticed that both are using JS. This makes me wonder the reason behind the choice of JS over other conventional languages. I guess I am trying to understand the role of JS and its advantages over other languages.

Update

I am not asking about the languages/drivers supported by the two DBs. The comparison says

Both CouchDB and MongoDB make use of Javascript. CouchDB uses Javascript extensively including in the building of views…MongoDB also supports running arbitrary javascript functions server-side and uses javascript for map/reduce operations.

My lack of understanding pertains to why is JS being used at all for the backend work. Why is it preferred for building views in CouchDB, or for using map/reduce operations? Why were C/C++ or Java not used? What are the advantages in using JS for such backend work?

Answer

To summarize answers on the Software Engineering Stack Exchange. MongoDB and other NoSQL DBs are using SpiderMonkey to execute server-side JS functions.


Solution

  • Because it's the language they chose?

    There aren't a lot of great options for "live" evaluation (IMO): Lua, Scheme-y things, and JS are probably the best choices for C programs.

    If it had been written in Java, there is a default scripting layer "built in".