Other Sellers on Amazon
+ $3.99 shipping
+ Free Shipping
Clojure for Domain-specific Languages Paperback – December 18, 2013
|New from||Used from|
Enter your mobile number or email address below and we'll send you a link to download the free Kindle App. Then you can start reading Kindle books on your smartphone, tablet, or computer - no Kindle device required.
To get the free app, enter your mobile phone number.
There was a problem filtering reviews right now. Please try again later.
DSLs, and yet it's a hard topic get into. A good book on the subject
is just what the Clojure ecosystem needs.
Sadly, this isn't that book.
The biggest problem is that there's hardly any content about writing
DSLs. This is a ~240 page book, and about 200 of that is just "Intro
to Clojure" stuff. That would be fine, but there are much better
introductory books out there.
Filler aside, that leaves maybe 40 pages that are actually about writing
DSLs. Sadly it's the weakest stuff in the book. It consists of two
examples of using Clojure to wrap existing Java libraries. One's a
Twitter client, the other's a wrapper around Java's Date & Calendar
classes. And there's no way around saying this - both are badly written.
It would be a terrible shame if any beginner in Clojure read this
stuff and thought it was a good way to proceed. What should be a
simple function to read a config file into a map is presented in an
overwrought, brittle and O(n^2) complex fashion. Macros are used
frequently but never appropriately. Clojure code drops down into Java
interop for no good reason at all. And the author seems to have an
obsession with dynamically-binding variables, regardless of whether
it's appropriate. I strongly suspect the writer doesn't understand
what they're for. Either way, the Twitter DSL is going to break as
soon as you do anything interesting with it, like delay the results.
So is there anything here to like? Yes, the author is quite lucid. His
technical writing reads easily. I hope he writes a book on another
topic one day - but he'll need to be far better versed in the
Chapter 1 explains what DSLs are, why and when you should use them, and how the power and flexibility of Clojure lends itself nicely to making DSLs. The chapter also shows some popular Clojure DSLs in action. It's a nice introduction.
The last three chapters of the book guide the reader in creating a Twitter DSL, unit testing that DSL, and finally making that DSL a Java-callable Clojure class. Whether or not such an application should be implemented using DSLs at all is up to the judgement of the reader. Regardless, it's a great hands-on example of how Clojure can be used to make DSLs.
My low rating is due to the fact that most of this book is useless filler that's been written about many times already. I thought Chapters 2 to 8 were completely unnecessary. These chapters are an overview of the philosophy and the features of Clojure. I skimmed them because that is not why I chose to read this book. Perhaps this information would be useful to beginners, but a novice Clojure programmer should not even be learning about DSLs yet. Besides, there are already way too many 'introduction to Clojure' books for a beginner to choose from. Instead of these chapters, I wish the book talked about macros more in depth because they are used extensively in the final chapters.
Very common saying among Lisp programmers.
And yet I read the Clojure for Domain specific Languages with great enthusiasm. It is littered with tips and ways of writing macros!
The book gives me good explanations how to write good macros. Read page 177-209 and you mastered a DSL for Twitter interaction! If you are skeptic about how magnificent Clojure is, read the chapters up to page 177, which are a great introduction for a programmer of any skill-level.
I recommend this book. It get's the job done - you get to know Clojure from the ground up and you get to know why Clojure is a good fit for a custom DSL. The narrative style is not as funny, or witty, to really enthuse the reader like P. van Linden's "Expert C" or Goetz "Java Concurrency". On the other hand, the prose is light enough to keep me eagerly reading. You will learn how to write good looking code and you will learn how to write a DSL in Clojure.
Goal: to have an understanding as to when and where to use a DSL.
A DSL is a language dedicated to solving only one type of problem. The language can't make the problem domain less complex, but it can separate the complexities of the problem for the person using the language. Generally speaking, a DSL only simplifies the nomenclature of the problem domain but never completely removes it. The same terms used to solve the problem need to persist within the language, so that the expressions can be written and understood by those familiar with that particular domain.
We should also ask ourselves if we even need a DSL when trying to solve our problems, because sometimes they add more layers of complexity than the original problem.
Design concepts are well and simply defined. My favorite part is the anti patterns part where each of them is described with do and don't examples of code.
Takes you from the beginning of downloading Emacs24 and leiningen to create a working emacs leiningen structure on your computer from configuration to shortcuts step by step.
Key concepts of Clojure are given with a few examples, but readers who are unfamiliar with Clojure better overview an intro to Clojure before diving into this chapter to maximize their understandings.
and so on...