Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

In my opinion, I'd say the main difference is that Clojure tends to be a box of many tools that have very specific functionality, while Javascript tends to have fewer tools with very generic functionality.

For instance, in Javascript an object is a way of storing values, defining an identity (i.e. a mutable pointer to a value), namespacing, polymorphism and inheritance.

In Clojure, each piece of functionality is handled by a different tool. If you just want a value you can use an immutable map. If you want a changeable identity you might use an atom. Polymorphism is provided by protocols or multimethods, namespacing by namespaces and so forth.

The advantage of using discrete tools is that you can afford to specialise. Clojure has atoms, refs and agents for maintaining identity, and each has unique properties. Libraries (such as Avout) can extend this with their own systems for maintaining identity.

Javascript, along with many OOP languages, has the problem that objects are a jack of all trades, but a master of none. An object cannot handle atomic state change as well as an atom, nor handle polymorphism as well as a protocol, nor is it a good at namespacing as a Clojure namespace. By being so general-use, it can't be as good as tools that focus on doing one job.



Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: