3 ms·
Let's say you have some data, perhaps some of it is from an SQL database, some from files, some from NoSQL. In Clojure there is a small set of data structures,
by djpowell 14y ago
Let's say you have some data, perhaps some of it is from an SQL database, some from files, some from NoSQL. In Clojure there is a small set of data structures, and a unified lazy sequence abstraction that can bring all of these together. You've got a huge standard library of functions for manipulating sequences and maps, rather than having to write your own one-off functions for working with custom OO classes.
Perhaps you want to do some processing on the data and convert it to JSON. Immutability and lazy sequences let you work from the problem towards the solution by layering small reusable functions over your data to get it to where you want it. And you can do this without it being hopelessly inefficient.
Another advantage that is easy to overlook is the environment. The ideal Clojure environment is an editor or IDE that is backed with a REPL. You can write a bit of code in your editor, perhaps assign some test data to a variable, and then with a couple of keystrokes, send the code to the REPL and see it working in a live environment. Perhaps your function isn't quite right, no problem, fix it, a couple more key-strokes and try it again. Writing code incrementally in this way has a similar effect to test-driven development. You are writing small pieces of code and the code is being tested as you develop it (albeit only informally).