Bydividing large applications into separate self-contained units, Microservices are a great step toward reducing complexity and increasing flexibility. Spring Microservices in Action, Second Edition teaches you how to build microservice-based applications using Java and the Spring platform. This second edition is fully updated for the latest version of Spring, with expanded coverage of API routing with Spring Cloud Gateway, logging with the ELK stack, metrics with Prometheus and Grafana, security with the Hashicorp Vault, and modern deployment practices with Kubernetes and Istio.
Building and deploying microservices can be easy in Spring! Libraries like Spring Boot, Spring Cloud, and Spring Cloud Gateway reduce the boilerplate code in REST-based services. They provide an effective toolbox to get your microservices up and running on both public and private clouds.
The second edition brings a much needed update to Clojure 1.6, whereas the first edition covered Clojure 1.2. In the process, the chapters about a few external libraries, which have been meanwhile replaced by others or have become obsolete, have been removed and replaced through a broader and renewed focus on Java-Clojure interoperability, testament to the attention that Clojure has been since receiving from a broader programmers community, which includes many non-Java programmers.
Clojure in Action aims to provide a complete and detailed coverage of Clojure, without forgetting the JVM ecosystem it lives in, and it does so in a somewhat agile package where, most notably, no unneeded duplication of information is to be found. The book takes an interesting approach to sample code, which in a number of cases comes directly from Clojure standard library, e.g. when discussion Clojure macro system, so they are as close as possible to Clojure real code; in other cases, examples try to build abstractions that complement existing abstractions in Clojure, such as when discussing polymorphism and protocols.
The book contains eleven chapters, which cover the language from the ground up, starting with its building blocks, such as data structures, functions, conditionals, namespaces, etc., then gradually moving to more advanced topics such as multimethods, macros, protocols, etc. Two final chapters are devoted to two specific, highly-relevant topics: how to use Clojure in a test-driven development setting, which dwells upon unit testing, stubbing, and mocking; how to use write advanced macros and domain specific languages (DSLs).
Francis Avila: The basic motivation behind the book is to help programmers from more mainstream programming backgrounds (Java, C#, Python, Ruby, JavaScript, etc) learn Clojure and its core philosophical tenants: careful management of state and time, immutability by default, pure functional transformations of data as much as possible, and manipulating code as data. When the first edition was written these ideas were fringe and Amit Rathore was essentially a voice in the wilderness trying to draw attention to the advantages Clojure offers. Those who were interested in Clojure overwhelmingly came from a Java background and had large Java ecosystems to support, but wanted a better tool to manage that complexity.
The immediate concern of the second edition is to update the book to reflect changes in Clojure 1.6. (The first edition was written to target Clojure 1.2.) But also in the intervening years the programming landscape has changed: immutability and functional programming are no longer completely strange ideas (especially to practitioners of dynamically-typed languages) and more programmers outside the Java world are starting to become curious about Clojure. The necessity of this book now is introducing a wider audience of programmers to Clojure. Ironically, this means becoming something of an apologist for Java and the JVM, which is unfamiliar to (and regarded with some skepticism by) programmers from dynamic language backgrounds. I know because I was one of those programmers!
I eventually discovered a company in my area was hiring Clojure developers, so I applied and began working at Breeze in mid 2012. Breeze is a small Electronic Health Record company based in Louisiana which uses Clojure and ClojureScript almost exclusively.
InfoQ: Your book targets developers with no experience in Clojure or any other functional language. What advice would you give them when reading this book? What should they expect? What should they not expect?
Francis: The most important advice I can give is to keep a Clojure REPL running as you read and try things out as you think of them or have questions. Poke at the edge cases and see what happens. The code in the book is available for download (neatly arranged into namespaces by chapter) if you want to save on some typing. This process is much smoother if you can use an editor or IDE with an integrated REPL, such as Cursive (IntelliJ IDEA), LightTable, or Proto REPL (Atom). With an editor-integrated REPL you can edit into a file or buffer and automatically re-evaluate, re-define, and test (i.e. poke at) your code as you go instead of copy-pasting into a command line.
However, this book is not going to familiarize you with the large ecosystem of Clojure libraries and system-level patterns that are out there today. The first edition made a more earnest attempt to do this, but this is the kind of information that ages very quickly. Many of those libraries have either changed a lot since then or have been supplanted by better techniques. Rather than update those sections we have scaled them back and concentrated more on developing a core competency in Clojure and keeping library dependencies to a minimum.
Making immutability the default assumption in the entire Clojure ecosystem has enormous multiplier effects on other Clojure features which by themselves would be merely OK. For example, the core functional programming constructs provided by Clojure (map, reduce, etc) make it easy to build simple, data-centric transformation pipelines, but lots of languages have them now. (Even Java!) But this approach really sings when combined with immutable data structures because you can freely and confidently re-arrange and inspect the data in your pipelines without worrying about propagating accidental mutations.
InfoQ: Your book gives plentiful coverage to macro programming and to DSLs. This makes for a somewhat more advanced material. Could you explain why you decided to include such more advanced material?
InfoQ: You also mention how Clojure can help minimizing accidental complexity. Could you give some practical examples of this? What is accidental complexity and how can Clojure minimize it?
InfoQ: What would be the areas of the language where a new programmer, say someone coming from an imperative background, should put more emphasis? What is likely to be the hardest skill to learn and how to do it best?
The book is available both in electronic or printed format, and its style is well demonstrated in two chapters that are freely available for download: Introducing Clojure, and chapter 8, More on Functional Programming.
Francis Avila has been developing for the web for the past eight years. For the past four years he been writing Clojure and ClojureScript professionally, on the front and back end, at Breeze, a small medical software company which uses Clojure exclusively. He lives with his wife and two-year-old daughter in Lafayette, Louisiana.
3a8082e126