Programming Clojure Second Edition Stuart Halloway download
Programming Clojure Second Edition Stuart Halloway download
Halloway download
https://ebookultra.com/download/programming-clojure-second-
edition-stuart-halloway/
https://ebookultra.com/download/clojure-high-performance-jvm-
programming-1st-edition-eduardo-diaz/
https://ebookultra.com/download/advanced-perl-programming-second-
edition-simon-cozens/
https://ebookultra.com/download/programming-in-c-2-e-second-edition-
dey/
https://ebookultra.com/download/clojure-data-analysis-cookbook-1st-
edition-eric-rochester/
Clojure Cookbook 1st Edition Luke Vanderhart & Ryan
Neufeld
https://ebookultra.com/download/clojure-cookbook-1st-edition-luke-
vanderhart-ryan-neufeld/
https://ebookultra.com/download/beginning-opengl-game-programming-
second-edition-luke-luke-benstead-benstead/
https://ebookultra.com/download/c-programming-for-the-absolute-
beginner-second-edition-mark-lee/
https://ebookultra.com/download/clojure-applied-from-practice-to-
practitioner-1st-edition-ben-vandgrift/
Clojure is one of the most interesting languages out there right now, and the best
way of learning Clojure just got better. The second edition of Programming Clojure
adds up-to-date information, plenty of practical examples, and a ton of useful
tips on how to learn, work with, and succeed with Clojure.
➤ Ola Bini
Creator of Ioke language, developer, ThoughtWorks
Intimidated by Clojure? You won’t be after you read this book. Written in a clear
and enjoyable style, it teaches the language one small piece at a time in a very
accessible way.
➤ Tim Berglund
Founder and Principal, August Technology Group
The authors have charted the smoothest path yet to Clojure fluency with this
well-organized and easy-to-read book. They have a knack for creating simple
and effective examples that demonstrate how the language’s unique features
fit together.
➤ Chris Houser
Primary Clojure contributor and library author
Stuart Halloway
Aaron Bedra
Acknowledgments . . . . . . . . . . . xv
Preface . . . . . . . . . . . . . . xvii
1. Getting Started . . . . . . . . . . . . 1
1.1 Why Clojure? 2
1.2 Clojure Coding Quick Start 11
1.3 Exploring Clojure Libraries 16
1.4 Wrapping Up 20
2. Exploring Clojure . . . . . . . . . . . 21
2.1 Forms 21
2.2 Reader Macros 30
2.3 Functions 32
2.4 Vars, Bindings, and Namespaces 36
2.5 Calling Java 43
2.6 Flow Control 45
2.7 Where’s My for Loop? 48
2.8 Metadata 51
2.9 Wrapping Up 53
4. Functional Programming . . . . . . . . . 85
4.1 Functional Programming Concepts 85
4.2 How to Be Lazy 90
4.3 Lazier Than Lazy 98
4.4 Recursion Revisited 103
4.5 Wrapping Up 112
5. State . . . . . . . . . . . . . . 113
5.1 Concurrency, Parallelism, and Locking 114
5.2 Refs and Software Transactional Memory 115
5.3 Use Atoms for Uncoordinated, Synchronous Updates 122
5.4 Use Agents for Asynchronous Updates 123
5.5 Managing Per-Thread State with Vars 127
5.6 A Clojure Snake 132
5.7 Wrapping Up 141
7. Macros . . . . . . . . . . . . . . 165
7.1 When to Use Macros 165
7.2 Writing a Control Flow Macro 166
7.3 Making Macros Simpler 172
7.4 Taxonomy of Macros 177
7.5 Wrapping Up 185
8. Multimethods . . . . . . . . . . . . 187
8.1 Living Without Multimethods 187
8.2 Defining Multimethods 189
8.3 Moving Beyond Simple Dispatch 192
8.4 Creating Ad Hoc Taxonomies 194
8.5 When Should I Use Multimethods? 198
8.6 Wrapping Up 201
Index . . . . . . . . . . . . . . 257
In this second edition, Stuart and Aaron make sure to cover the language
enhancements and include a taste of what it’s like to leverage some of the
community libraries, while taking care to convey the concepts that make it
all work. The book remains an exhilarating introduction to Clojure, and I
hope it inspires you to join the community and, eventually, contribute to the
library ecosystem.
—Rich Hickey
Creator of Clojure
What is so thrilling about Stuart’s book is the extent to which he “gets” Clojure,
because the language is targeted to professional developers just like himself.
He clearly has enough experience of the pain points Clojure addresses, as
well as an appreciation of its pragmatic approach. This book is an enthusiastic
tour of the key features of Clojure, well grounded in practical applications,
with gentle introductions to what might be new concepts. I hope it inspires
you to write software in Clojure that you can look back at and say, “Not only
does this do the job, but it does so in a robust and simple way, and writing
it was fun too!”
—Rich Hickey
Creator of Clojure
Thanks to the kind folks on the Clojure mailing list1 for all their help and
encouragement.
Thanks to all the people who posted suggestions on the book’s errata page.2
Thanks to our technical reviewers for all your comments and helpful sugges-
tions, including Kevin Beam, Ola Bini, Sean Corfield, Fred Daoud, Steven
Huwig, Tibor Simic, David Sletten, Venkat Subramaniam, and Stefan Turalski.
A very special thanks to David Liebke who wrote the original content for
Chapter 6, Protocols and Datatypes, on page 143. He provided a fantastic guide
through the new ideas and this book would not be the same without his
contributions.
Thanks to Rich Hickey for creating the excellent Clojure language and fostering
a community around it.
Thanks to my wife, Joey, and my daughters, Hattie, Harper, and Mabel Faire.
You all make the sun rise.—Stuart
1. http://groups.google.com/group/clojure
2. http://www.pragprog.com/titles/shcloj2/errata
• Clojure is elegant. Clojure’s clean, careful design lets you write programs
that get right to the essence of a problem, without a lot of clutter and
ceremony.
• Clojure is Lisp reloaded. Clojure has the power inherent in Lisp but is not
constrained by the history of Lisp.
• Clojure embraces Java. Calling from Clojure to Java is direct and fast,
with no translation layer.
Many other languages cover some of the features described in the previous
list. Of all these languages, Clojure stands out. The individual features listed
earlier are powerful and interesting. Their clean synergy in Clojure is com-
pelling. We will cover all these features and more in Chapter 1, Getting Started,
on page 1.
Clojure is built on top of the Java Virtual Machine, and it is fast. This book
will be of particular interest to Java programmers who want the expressiveness
of a dynamic language without compromising on performance.
Chapter 5, State, on page 113 delves into Clojure’s concurrency model. Clojure
provides four powerful models for dealing with concurrency, plus all of the
goodness of Java’s concurrency libraries.
Chapter 6, Protocols and Datatypes, on page 143 walks through records, types,
and protocols in Clojure. These concepts were introduced in Clojure 1.2.0
and enhanced in 1.3.0.
Chapter 7, Macros, on page 165 shows off Lisp’s signature feature. Macros
take advantage of the fact that Clojure code is data to provide metaprogram-
ming abilities that are difficult or impossible in anything but a Lisp.
Chapter 9, Java Down and Dirty, on page 203 shows you how to call Java from
Clojure and call Clojure from Java. You will see how to take Clojure straight
to the metal and get Java-level performance.
Finally, Chapter 10, Building an Application, on page 227 provides a view into
a complete Clojure workflow. You will build an application from scratch,
working through solving the various parts to a problem and thinking about
simplicity and quality. You will use a set of helpful Clojure libraries to produce
and deploy a web application.
Appendix 1, Editor Support, on page 253 lists editor support options for Clojure,
with links to setup instructions for each.
All readers should begin by reading the first two chapters in order. Pay par-
ticular attention to Section 1.1, Why Clojure?, on page 2, which provides an
overview of Clojure’s advantages.
After you read the first two chapters, skip around as you like. But read
Chapter 3, Unifying Data with Sequences, on page 55 before you read Chapter
5, State, on page 113. These chapters lead you from Clojure’s immutable data
structures to a powerful model for writing correct concurrency programs.
As you make the move to longer code examples in the later chapters, make
sure you use an editor that provides Clojure indentation for you. Appendix
1, Editor Support, on page 253 will point you to common editor options. If you
can, try to use an editor that supports parentheses balancing, such as Emacs’
paredit mode or the CounterClockWise plug-in for eclipse. This feature will
be a huge help as you are learning to program in Clojure.
Regem cui omnia vivunt (the king by whom all things live) was
composed by Don Melchior Robledo, chapel master in Saragossa in
1569, the same year when Cervantes' little collection of elegiac
poems on Queen Isabel appeared.
Domine in furore tuo (Lord (rebuke) me not in thy fury) was the
composition of Don Andres Lorente, organist in Alcala de Henares,
Cervantes' birthplace. He himself probably heard it sung there in his
youth.
"B. Most Blessed Mary! But they are quiet folk, and do not carry
stilettoes.
"A. The worst is, there are neither monks nor nuns there; the
churches are few, and the walls of them as bare as if they were
hospitals; no private chapels, no altars, no crucifixion.
Poor Don Judas was terrified by the erudition of the cunning lady,
who thus got rid of him.
The collected works of this lady have been printed at the expense
of the queen. It is only seventeen or eighteen years since she
began to write, and, if we can trust the accuracy of foreign
biographers, she is now in her seventieth year. Two volumes of
selections from her works entitled The Castle and Cottage in Spain,
have appeared in an English dress.
Rustic Tales:
Don Antonio De Trueba.
"We, the young boys of the hamlet rose every Sunday with the
song of the birds, and went down to the early mass, singing
and jumping over the bushes. The elders of the families
attended the later devotions. While the fathers and grandfathers
were so occupied, I took my seat under a cherry tree opposite
the door, and had a full view of the entire vale till it approached
the shore. I was soon joined by four or five young girls with
cheeks as blooming as the cherries which hung over our beads,
or the red ribbons which bound the long braids of their hair.
They would request me to make some verses for them to sing
in the evening to the accompaniment of the basque tambourine,
when the young would be dancing, and the aged looking on in
sympathy with their enjoyment."
For ten tedious years did our poet in embryo do the duty of a
shopman by day, treat himself the to a book when be could, and
spend in study great part of the time that should be given to sleep.
Bad business or failure obliged him at the end of the time
mentioned to look out for other occupation, and since that time he
has been connected with journalism, the evenings still being
devoted to poetry and romance.
In the greater part of these tales figures the Indian, that is, one
who has spent some time in Mexico or the West Indies, and returns
to cheer or disturb the former companions of his early life. The
narratives are made up of simple village annals, loves and
jealousies, injustices and their punishments, generous deeds and
their recompenses, constancy sharply tried and victorious, unions at
the threshing floors, Sunday morning devotions, Sunday evening
recreations, troubles of good housewives with their play-loving little
boys, and all the worries and comforts and joys and griefs that
attend on the lives of those whose lot is to cultivate the earth, the
curé always filling the office of the good fairy in household tales.
Satire:
Don Jose Gonzalez De Tejada.
"But let sparkling diamonds give lustre to her tresses, and two
golden lamps hang from her ears.
"Turning the earth into a sponge with his tears, man presented
himself all dreeping at the throne of Jupiter.
.....
"'But alas! in our time she is incapable to express all that the
fruitful brain conceives and brings forth.
"'Juppy made a grimace, and the affrighted hills sunk, and the
poles trembled.
"'Well,' said the deity, always prodigal of gifts, 'I shall convert
into tongues sundry vile things of this lower world.
"'Of old shirts, of disgusting rags, I shall make gay clothes for
the press, flesh and blood for the daily paper.
"'Let your arms cease to brandish the war-like steel, and turn
inert and fat bodies of men into sieves.
"'And in order that you may attain the steepest summits, I shall
furnish your heads with pride and envy in abundance.
History:
Don Antonio Cavanilles.
The Drama:
Don Adelardo Lopez De Ayala.
Zealous as the first historian for the preservation of the heroic and
unselfish character of the genuine Hidalgo, Don Adelardo Lopez de
Ayala writes his drama of "So Much per Cent," in which he excites
unmeasured contempt for the greed of gold, and the rage of
speculation, whose visit to the old soil of chivalry the author
deprecates with all his might.
Chapter XXVIII.
The journey went on well enough the first day, but on the second,
Adelaide surprised her retinue by sending them back with the
carriage, telling them she would proceed onward with a hired
vehicle. The coachman and footman looked as if they would like to
remonstrate, but it had been proved to be somewhat dangerous to
argue with this very positive lady, accustomed to obey no will
except her own. They submitted in silence, therefore, though much
against their inclination. "Now," said Adelaide, when they had
departed, "we can enjoy the luxury of being ourselves,
unencumbered by state and trappings. Hester, do you think you can
teach Norah to call me plain 'ma'am,' for a little while, till we return
home? I am again Adelaide Godfrey, that name will tell nothing and
will enable us to act as we like, observed by any."
It was not found difficult to initiate Norah into the idea that the
great duchess wanted to lay aside her dignity for a while, for the
truth was Norah's difficulty had ever been to get herself to say
"your grace," on requisite occasions. These preliminaries settled,
the ladies proceeded on their journey, took ready furnished
lodgings in H----, and prepared to lead the quiet life of the middle
classes of society when out on a "bathing for health" excursion.
The location of the Catholic chapel was soon examined, the priest's
house communicating with it. In neat straw bonnets trimmed with
white, and plain muslin dresses, Adelaide and Hester assisted at
the daily mass. In the priest they recognized at once the Abbé
Martigni, and in the noble-featured youth who knelt by his side
Adelaide traced the likeness, now first becoming dear to her, of her
late husband. A day or two elapsed ere she could summon courage
to call at the house. At length the moment arrived for the looked-
for visit; the sisters had, however, scarcely gained entrance to the
outer court, when their attention was attracted by loud sobs from a
little boy and girl, who stood weeping as if their hearts would
break. The abbé was speaking to the woman with whom they
came; he then turned to the children, and patting them on the
heads, said tenderly: "I will come directly, my poor children." He
turned hastily away without receiving his visitors. Adelaide took the
boy's hand kindly. "What is the matter?" she asked. The boy could
not speak for weeping, but the woman answered: "His mother, my
lady, poor Biddy, shure, she has fallen from her seat, on to the
stone pavement, while she was cleaning the windows of a large
house in Queen street, and they say she must die."
·····
Our website is not just a platform for buying books, but a bridge
connecting readers to the timeless values of culture and wisdom. With
an elegant, user-friendly interface and an intelligent search system,
we are committed to providing a quick and convenient shopping
experience. Additionally, our special promotions and home delivery
services ensure that you save time and fully enjoy the joy of reading.
ebookultra.com