# Programming Languages in the Wild 1) For discussion, you chose the programming language: Clojure 2) This language is: General Purpose 3) Is this language Turing complete?: Yes ## Uses 4) For what killer app, projects, or historical reason is this language best known or used ?: Clojure was originally designed by Rich Hickey to solve real problems he faced when building concurrent apps in the wild. He wanted a language with the following features: a Lisp, designed for functional programming, leverages an established platform, and built for the future of horizontal scale computing. No language satisfying these requirements existed prior to Clojure, so he built a language with these features in mind. The result is a immutable by default functional Lisp that leverages the power of the JVM. 5) Is the answer to 4, which the language is known for, due to language features, community support or libraries, or something else?: Language features are a large part of its reputation. He designed a lisp that uses immutable structures by default, but added a first class support for common structures (maps, vectors, and sets) not typically included in lisp languages. Suprisingly, these data structures are still fast and performant while staying immutable. Though language features are important, libraries and tooling are probably the biggest benefit. It is almost trivial to create a new project, mix clojure and java dependencies, and use both seamlessly within your project. 6) As a programmer, what is easy to do in the language?: The following example, takes the square of all a trees leaves and sums them together. Here the tree is represented by a nested list. ``` (->> (flatten `(1 (2 3) (4 (7 -1)))) (map #(* % %)) (reduce #(+ %1 %2) 0)) ``` Note that this code will work on any nested data structure, be it a list, vector, or a set. Also note though the code looks like as if it takes three passes over the leaves, it only takes one as each function (flatten, map, and reduce) returns a lazy sequence thus fusing the computation together. Another thing to notice is how simply higher order functions are created. The expression `#(* % %)` creates the square function. All of these are much more difficult to do in an imperative language like C or Java. 7) What does the method to do the answer to 6 look like in general purpose languages like c or java?: In C or Java one would manually have to go through and grab all the leaves out of the tree. This would be different depending on how the tree is represented. Then given the leaves one would simply use a for loop to square and add them up. 8) Does the programmer have to give up anything to gain the benefits of this language?: Yes, there are tradeoffs with any programming language. To some, the benefits of macros that allow many powerful extensions of LISP come at the cost of forcing the user to deal with the ugliness of parentheses everywhere. Again, this is subjective, but is clearly a tradeoff. Another cost is slower performance due to boxing/unboxing of objects and immutability by default when compared to a language like C. To a large extent these can be mitigated, but then we lose a lot of the guarentees that Clojure usually offers.