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

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


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?

  • It's (reasonably) dynamic.
  • Functions can be passed around.
  • Open, embeddable implementations exist.
  • It's ubiquitous.
  • Using JSONy data model.

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".


javascript is used in couchdb only for building views and map reduce, the couchdb core was writing using erlang, javascript is used only when performance isn't so important (actually you can write your views using earlang and get a bit better performance)...why they used javascript?...

1) couchdb use json as data share format..json is really light, very fast and readable...and it use javascript..this is the biggest point..for work with json the better language obviously is javascript

2)javascript is widely adopted in the web programming world..the main target for couchdb..so..if you program in ruby,python,php,java, for web development must have some javascript's knowledge

3)if you look your view code..is should be similar to that written in java or c++, the sintax came from C...for create views you don't need OOP or interfaces....

that is!..