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 the comparison between MongoDB, and CouchDB (http://www.mongodb.org/display/DOCS/Comparing+Mongo+DB+and+Couch+DB ) 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 C/C++ or Java were not used? What are the advantages in using JS for such back-end work?
Answer:To summarize answers on https://softwareengineering.stackexchange.com/q/121411/41398 . MongoDB and other NoSQL dbs are using SpiderMonkey to execute server-side JS functions. Here is the wikipedia's link to spidermonkey- http://en.wikipedia.org/wiki/SpiderMonkey_(JavaScript_engine)
PS: If somebody feels like down-voting the question, please do put a comment to explain the reason.
JavaScript is the better choice for desktop and mobile websites. Between JQuery, Angular, and React, JavaScript provides virtually endless capabilities for web programming. When a business or individual hires a programmer for a project, having an experienced developer is the key to a successful project.
JavaScript in MongoDB Although these methods use JavaScript, most interactions with MongoDB do not use JavaScript but use an idiomatic driver in the language of the interacting application. If you do not need to perform server-side execution of JavaScript code, see Disable Server-Side Execution of JavaScript.
MongoDB create databaseThe mongo tool is an interactive JavaScript shell interface to MongoDB, which provides an interface for systems administrators as well as a way for developers to test queries and operations directly with the database. We create a testdb database and insert eight documents in the cars collection.
It can insert dynamic text into HTML. JavaScript is also known as the browser's language. JavaScript(JS) is not similar or related to Java. Both the languages have a C-like syntax and are widely used in client-side and server-side Web applications, but there are few similarities only.
The issue with many languages is a lack of sandboxing (being able to do 'rm -rf /' in a map function is considered a problem), javascript, because of its browser roots, has one. Javascript is the default view server in CouchDB but the protocol is documented and other language bindings exist (Ruby, Python, etc). It also ships with a native Erlang option.
There's also an elegance to using the same language at the back-end as the front-end but CouchDB doesn't force you into a language choice, it just ships with a solid Javascript view engine.
Details on the view server protocol, and links to alternate implementations, here:
http://wiki.apache.org/couchdb/View_server
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".
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With