(Ebook) Functional Programming Patterns in Scala and Clojure by Michael Bevilacqua-Linn ISBN 9781937785475, 1937785475 download
(Ebook) Functional Programming Patterns in Scala and Clojure by Michael Bevilacqua-Linn ISBN 9781937785475, 1937785475 download
https://ebooknice.com/product/functional-programming-patterns-in-
scala-and-clojure-5496598
https://ebooknice.com/product/functional-programming-a-pragpub-anthology-
exploring-clojure-elixir-haskell-scala-and-swift-6865222
https://ebooknice.com/product/scala-functional-programming-
patterns-55614886
https://ebooknice.com/product/functional-programming-in-scala-second-
edition-meap-v08-47503176
https://ebooknice.com/product/functional-programming-in-scala-4766266
(Ebook) Programming Scala: Scalability = Functional Programming
+ Objects by Wampler, Dean ISBN 9781492077893, 1492077895
https://ebooknice.com/product/programming-scala-scalability-functional-
programming-objects-29886228
https://ebooknice.com/product/quick-clojure-effective-functional-
programming-6730354
https://ebooknice.com/product/quick-clojure-effective-functional-
programming-14906218
https://ebooknice.com/product/programming-scala-scalability-functional-
programming-objects-animal-guide-1307710
https://ebooknice.com/product/scala-cookbook-recipes-for-object-oriented-
and-functional-programming-4449988
Download from Wow! eBook <www.wowebook.com>
Download from Wow! eBook <www.wowebook.com>
Early Praise for Functional Programming Patterns
This book is an absolute gem and should be required reading for anybody looking
to transition from OO to FP. It is an extremely well-built safety rope for those
crossing the bridge between two very different worlds. Consider this mandatory
reading.
➤ Colin Yates, technical team leader at QFI Consulting, LLP
This book sticks to the meat and potatoes of what functional programming can do
for the object-oriented JVM programmer. The functional patterns are sectioned in
the back of the book separate from the functional replacements of the object-oriented
patterns, making the book handy reference material. As a Scala programmer, I even
picked up some new tricks along the read.
➤ Justin James, developer with Full Stack Apps
This book is good for those who have dabbled a bit in Clojure or Scala but are not
really comfortable with it; the ideal audience is seasoned OO programmers looking
to adopt a functional style, as it gives those programmers a guide for transitioning
away from the patterns they are comfortable with.
➤ Rod Hilton, Java developer and PhD candidate at the University of Colorado
Michael Bevilacqua-Linn
Preface . . . . . . . . . . . . . . ix
Bibliography . . . . . . . . . . . . 231
Index . . . . . . . . . . . . . . 233
This book would have suffered greatly without a great group of technical
reviewers. My thanks to Rod Hilton, Michajlo “Mishu” Matijkiw, Venkat Sub-
ramaniam, Justin James, Dave Cleaver, Ted Neward, Neal Ford, Richard
Minerich, Dustin Campbell, Dave Copeland, Josh Carter, Fred Daoud, and
Chris Smith.
Finally, I’d like to thank Dave Thomas and Andy Hunt. Their book, The
Pragmatic Programmer, is one of the first books I read when I started my
career. It made a tremendous impact, and I’ve still got my original dog-eared,
fingerprint-covered, bruised and battered copy. In the Pragmatic Bookshelf,
they’ve created a publisher that’s truly dedicated to producing high-quality
technical books and supporting the authors who write them.
Used together, these patterns let programmers solve problems faster and in
a more concise, declarative style than with object-oriented programming alone.
If you’re using Java and want to see how functional programming can help
you work more efficiently, or if you’ve started using Scala and Clojure and
can’t quite wrap your head around functional problem-solving, this is the
book for you.
Before we dig in, I’d like to start off with a story. This story is true, though
some names have been changed to protect the not-so-innocent.
A Tale of Functional Programming
by: Michael Bevilacqua-Linn, software firefighter
The site isn’t down, but an awful lot of alarms are going off. We trace the problems to changes
someone made to a third-party API we use. The changes are causing major data problems on
our side; namely, we don’t know what the changes are and we can’t find anyone who can tell
us. It also turns out the system that talks to the API uses legacy code, and the only guy who
knows how to work on it happens to be away on vacation. This a big system: 500,000-lines-of-
Java-and-OSGI big.
Support calls are flooding in, lots of them. Expensive support calls from frustrated customers.
We need to fix the problem quickly. I start up a Clojure REPL and use it to poke around the
problem API.
My boss pokes his head into my office. “How’s it going?” he asks. “Working on it,” I say. Ten
minutes later, my grandboss pokes his head into my office. “How’s it going?” he asks. “Working
on it,” I say. Another ten minutes pass by when my great-grandboss pokes his head into my
office. “How’s it going?” he asks. “Working on it,” I say. I get a half hour of silence before the CTO
pokes his head into my office. “Working on it,” I say before he opens his mouth.
An hour passes, and I figure out what’s changed. I whip up a way to keep the data clean until
the legacy developer gets back and can put together a proper fix. I hand my little program off
to the operations team, which gets it up and running in a JVM, somewhere safe. The support
calls stop coming in, and everyone relaxes a bit.
A week or so later at an all-hands meeting, the great-grandboss thanks me for the Java program
I wrote that saved the day. I smile and say, “That wasn’t Java.”
Two of the patterns that we’ll see in this book, Pattern 21, Domain-Specific
Language, on page 218, and Pattern 15, Chain of Operations, on page 159,
contributed greatly to this story’s happy ending.
The TinyWeb extended example serves a few purposes. It will let us see how
several of the patterns we cover in this book fit together in a comprehensive
manner. We also use it to introduce the basics of Scala and Clojure. Finally,
since we’ll transform TinyWeb from Java to Scala and Clojure bit by bit, it
gives us a chance to explore how to easily integrate Java code with Scala and
Clojure.
The remainder of the book is organized into two sections. The first, Chapter
3, Replacing Object-Oriented Patterns, on page 39, describes functional
replacements for object-oriented patterns. These take weighty object-oriented
patterns and replace them with concise functional solutions.
Peter Norvig, author of the classic Lisp text Paradigms of Artificial Intelligence
Programming: Case Studies in Common Lisp [Nor92], current director of
research at Google, and all-around very smart guy, pointed out in Design
Patterns in Dynamic Languages that expressive languages like Lisp could turn
classic object-oriented patterns invisible.1
Pattern Template
The patterns are laid out using the following format, with some exceptions.
For example, a pattern that doesn’t have any other common name would not
have the Also Known As subsection, and the Functional Replacement subsec-
tions only apply to the patterns in Chapter 3, Replacing Object-Oriented Pat-
terns, on page 39.
Intent
The Intent subsection provides a quick explanation of the intent of this pattern
and the problem it solves.
Overview
Here is where you’ll find a deeper motivation for the pattern and an explanation
of how it works.
Also Known As
This subsection lists other common names for the pattern.
1. http://norvig.com/design-patterns/
Functional Replacement
Here you’ll find how to replace this pattern with functional programming
techniques—sometimes object-oriented patterns can be replaced with basic
functional language features and sometimes with simpler patterns.
Example Code
This subsection contains samples of the pattern—for object-oriented patterns,
we first show a sketch of the object-oriented solution using either class dia-
grams or a sketch of the Java code before showing how to replace them in
Clojure and Scala. Functional patterns will be shown in Clojure and Scala
only.
Discussion
This area provides a summary and discussion of interesting points about the
pattern.
Related Patterns
This provides a list of other patterns in this book that are related to the current
one.
Both Scala and Clojure run on a Java virtual machine (JVM), so they interop-
erate well with existing Java libraries and have no issues being dropped into
the JVM infrastructure. This makes them ideal to run alongside existing Java
codebases. Finally, while both Scala and Clojure have functional features,
they’re quite different from each other. Learning to use both of them exposes
us to a very broad range of functional programming paradigms.
Clojure is a modern take on Lisp. It has Lisp’s powerful macro system and
dynamic typing, but Clojure has added some new features not seen in older
Lisps. Most important is its unique way of dealing with state change by using
reference types, a software transactional memory system, and efficient
immutable data structures.
As we introduce the patterns, we’ll explore both of these languages and their
features, so this book serves as a good introduction to both Scala and Clojure.
For further detail on either language, my favorite books are Programming
Clojure [Hal09] and The Joy of Clojure [FH11] for Clojure, and Programming
Scala: Tackle Multi-Core Complexity on the Java Virtual Machine [Sub09] and
Scala In Depth [Sue12] for Scala.
From there you can jump around, pattern by pattern, as needed. The patterns
covered earlier in Chapter 3, Replacing Object-Oriented Patterns, on page 39,
and Chapter 4, Functional Patterns, on page 137, tend to be more basic than
later ones, so they’re worth reading first if you have no previous functional
experience.
A quick summary of each pattern can be found in Section 1.2, Pattern Glos-
sary, on page 4, for easy browsing. Once you’re through the introduction,
you can use it to look up a pattern that solves the particular problem you
need to solve.
Online Resources
As you work through the book, you can download all the included code files
from http://pragprog.com/titles/mbfpp/source_code. On the book’s home page at
http://pragprog.com/book/mbfpp, you can find links to the book forum and to report
errata. Also, for ebook buyers, clicking on the box above the code extracts
downloads the code for that extract for you.
Second, the functional world also has its own set of useful patterns. These
patterns focus on writing code that avoids mutability and favors a declarative
style, which helps us write simpler, more maintainable code. The two main
sections of this book cover these two sets of patterns.
You may be surprised to see the first set. Don’t the patterns we know and
love extend across languages? Aren’t they supposed to provide common
solutions to common problems regardless of what language you are using?
The answer to both questions is yes, so long as the language you are using
looks something like Java or its ancestor, C++.
That’s not to say that foreach loops are exactly equivalent to the Iterator. A
foreach won’t replace an Iterator in all cases. The problems they do address
are solved in a simpler way. Developers prefer the built-in foreach loops for the
common-sense reasons that they are less work to implement and are less
error prone.
Adding functional features and techniques adds more tools to our program-
ming toolbox, just as Java 1.5 did with its foreach loop but on a grander scale.
These tools often complement the tools we already know and love from the
object-oriented world.
The second set of patterns we cover in this book, native functional patterns,
describes the patterns that evolved out of the functional style. These functional
patterns differ from the object-oriented patterns you may be familiar with in
a few key ways. The first, and most obvious, is that functions are the primary
unit of composition, just as objects are in the object-oriented world.
Another key difference lies in the patterns’ granularity. The patterns from
Design Patterns: Elements of Reusable Object-Oriented Software [GHJV95] (one
of the original drivers of the software patterns movement) are generally tem-
plates that define a few classes and specify how they fit together. Most of
them are medium size. They often don’t concern themselves either with very
small issues that encompass just a few lines of code or with very large issues
that encompass entire programs.
The functional patterns in this book cover a much broader range, as some of
them can be implemented in a line or two of code. Others tackle very big
problems, such as creating new, miniature programming languages.
The range is in line with the book that started the patterns movement in
general, A Pattern Language [AIS77]. This book on architectural patterns
starts off with the very big “1—Independent Regions” pattern, which outlines
why the planet should be organized into political entities of about 10,000
people, and goes all the way down to “248—Soft Tile and Brick,” which explains
how to make your own bricks.
Before we dig into the various patterns in this book, let’s spend some time
getting familiar with functional programming itself.
Favor pure functions: Pure functions are functions that have no side effects.
A side effect is an action that the function does that modifies state outside
the function.
However, other problems are hard, if not impossible, to solve using strict
functional programming techniques. A compiler is a pure function. If you put
a program in, you expect to get the same machine code out every time. If you
don’t, it’s probably a compiler bug. Google’s search engine, however, is not a
pure function. If we got the same results from a Google search query every
time, we’d be stuck with a late 1990s view of the Web, which would be quite
tragic.
Scala has more support for mutable data, but immutable data is preferred.
For instance, Scala has both mutable and immutable versions of its collections
library, but the immutable data structures are imported and used by default.
This section introduces two basic types of functional features. The first type,
higher-order functions, allows us to pass functions around as first-class data.
The second, anonymous functions, allows us to write quick one-off functions
without giving them a name. These features combine to let us replace most
instances of Functional Interface very concisely.
T H E M E TA L S.
The same rational instinct which prompted man in his first efforts
at tool-making, guided him in a discriminating choice of materials;
and to this the discovery of metals, and the consequent first steps in
metallurgy and the arts, may be traced. The Bronze Age of Europe
derives its name from the predominance of relics illustrative of a
period which, though old compared with that of definite history,
belongs to a comparatively late era, characterised by many traces of
artistic skill, and of mastery in the difficult processes of smelting ores
and alloying metals. But the dawn of the metallurgic era in the New
World is marked by phases which derive their distinctive character
from two widely separated regions; and of which one supplies an
important link in the history of human progress, at best but partially
indicated in the disclosures of European archæology.
To untutored man, provided only with implements of stone, the
facilities presented by the great copper regions of Lake Superior for
the first step in the knowledge of metallurgy were peculiarly
available. The forests that flung their shadows along the shores of
that great lake were the haunts of the deer, the beaver, the bear,
and other favourite objects of the chase; the rivers and the lake
abounded with fish; and the rude hunter had to manufacture
weapons and implements out of such materials as nature placed
within his reach. The water-worn stone from the beach, patiently
ground to an edge, made his axe and tomahawk: by means of
which, with the help of fire, he could level the giants of the forest, or
detach from them the materials for his canoe and paddle, his lance,
club, or bow and arrows. The bones of the deer pointed his spear, or
were wrought into his fish-hooks; and the shale or flint was chipped
and ground into his arrow-head, after a pattern repeated with little
variation, in all countries, and in every primitive age. But besides
such materials of universal occurrence, the primeval occupant of the
shores of Lake Superior found there a stone possessed of some very
peculiar virtues. It could not only be wrought to an edge without
liability to fracture; but it was malleable, and could be hammered
out into many new and convenient shapes. This was the copper,
found in connection with the trappean rocks of that region, in
inexhaustible quantities, in a pure metallic state. In other rich
mineral regions, as in those of Cornwall and Devon, the principal
source of this metal is from ores, which require both labour and skill
to fit them for economic purposes. But in the veins of the copper
region of Lake Superior the native metal occurs in enormous masses,
weighing hundreds of tons; and loose blocks of various sizes have
been found on the lake shore, or lying detached on the surface, in
sufficient quantities to supply all the wants of the nomad hunter.
These, accordingly, he wrought into chisels and axes, armlets, and
personal ornaments of various kinds, without the use of the crucible;
and, indeed, without recognising any precise distinction between the
copper which he mechanically separated from the mass, and the
unmalleable stone or flint out of which he had been accustomed to
fashion his spear and arrow-heads. This is confirmed by philological
evidence. The root of the names for iron and copper in the
Chippewa is the same abstract term, wahbik, used only in compound
words. Thus pewahbik, iron; ozahwahbik, copper: lit. the yellow
stone; metahbik, on the bare rock; oogedahbik, on the top of a rock;
kishkahbikah, it is a precipice; etc.
The earliest references to Britain pertain exclusively to the
peninsula of Cornwall and the neighbouring islands, whither the
fleets of the Mediterranean were attracted in ages of vague
antiquity, and the traders from Gaul resorted in quest of its metallic
wealth. The mineral regions of the New World disclose some
corresponding records of its long-forgotten past; and some idea of
their present condition is indispensable for preparing the mind to
appreciate the changes wrought by time on localities which are now
being rescued once more from the wilderness. The vast inland sea,
which constitutes the reservoir of the chain of lakes whose waters
sweep over the Falls of Niagara, and find their way by the St.
Lawrence to the ocean, has been as yet so partially encroached
upon by the pioneers of modern civilisation, that the general aspect
of its shores differs but little from that which they presented to the
eye of its first European explorers in the seventeenth century: or
indeed to its Indian voyagers before the Spaniard first coasted the
island shores of the Bahamas, and opened for Europe the gates of
the West. With its wide extent of waters, covering an area of thirty-
two thousand square miles, a lengthened period of sojourn in the
regions with which it is surrounded, and many facilities for their
exploration, would be required, in order to satisfy the curiosity of the
scientific inquirer. But even a brief visit discloses much that is
interesting, and that serves at once to illustrate, and to contrast with
what comes under the observer’s notice elsewhere.
In tracing out the evidence of ancient occupation of the shores of
Lake Superior, I have, on repeated visits, coasted its shores for
hundreds of miles in canoes; and camped for weeks in some of its
least accessible wilds. The force of the evidence is slowly
appreciated, even by careful personal observation; but some
description of the ancient copper region may help the reader to
estimate the lapse of time since its forest-glades and rocky
promontories were enlivened by the presence of industrious miners.
The memorials of Time’s unceasing operations reach indeed to
periods long prior to the earliest presence of man, and present
certain lake phenomena, on a scale only conceivable by those who
have sailed on the bosom of these fresh-water seas with as
boundless a horizon as in mid-Atlantic; and who have experienced
the violence of the sudden storms to which they are liable. But while
the same broad ocean-like expanse, and the violence of their stormy
moods, characterise Ontario, Erie, Huron, and Michigan: it is only on
Lake Superior that the traveller witnesses the grandeur and wild
ruggedness of scenery commensurate with his preconceived ideas of
such inland seas. Along its northern and western shores bold cliffs
and rocky headlands frown in savage grandeur, from amid the
unbroken wastes of forest that reach to the frozen regions around
the Hudson Bay, while the gentler coast-lines of its southern shores
are varied by some of the most singular conformations, wrought out
of its rocky walls by the action of the waves. Among such rock-
formations, no features are so remarkable as those presented by a
portion of the extensive range of sandstone cliffs, which project in
jagged and picturesque masses from the southern shore, soon after
passing the Grand Sable; and to which fresh interest has been given
by the interweaving of the Algonquin legends of the locality into
Longfellow’s Indian Song of Hiawatha.
The Pictured Rocks are situated between the copper regions and
the ancient portage, which has been recently superseded by a canal
opening navigation for the largest vessels from Lake Huron to Lake
Superior. They lie in the centre of the long indentation, which,
sweeping from Keweenaw Peninsula eastward to White Fish Point,
forms the coast most distant from the northern shores of the lake.
Here the cliffs have been exposed through unnumbered ages to the
waves under the action of northerly winds; while a contemporaneous
upheaval, prolonged probably through vast periods of time, has
contributed no unimportant share in the operations by which their
striking forms have been produced. Beyond those the voyager
comes once more on rocky cliffs in the vicinity of Marquette: so
named after the Jesuit missionary by whom the upper waters of the
Mississippi were first reached two centuries ago, in 1673. Important
changes have been wrought in the interval. Mineral treasures,
undreamt of by the ancient miners, are now rewarding the industry
of the Indians’ supplanters. The iron period, with its fully developed
civilisation, is invading those forest tracks; and when I first visited
Marquette in 1855, on the bold trappean rocks which form the
landing, abraded and scratched with the glacial action of a long
superseded era, were piled the rich products of the “Jackson Iron
Mountain,” which rears its bold outline at a distance of twelve miles
from the shore. Immediately to the north of this point the
promontory of Presque Isle presents in some respects a striking
contrast to the Pictured Rocks; though, like them, also indented and
hollowed out into detached masses, and pierced with the wave-worn
caverns of older levels of shore and lake. Here the water-worn
sandstone and the igneous rocks overlie or intermingle with each
other in picturesque confusion: the symbol, as it were, of the
transition between the copper and iron eras. For it is just at Presque
Isle that the crystalline schists, with their intermingling masses of
trappean and quartz rocks, richly impregnated with the specular and
magnetic oxide of iron, pass into the granite and sandstone rocks,
which intervene between the ferriferous formations and the copper-
bearing traps of Keweenaw Point. Beyond this, the rich copper-
bearing region of the Keweenaw Peninsula stretches far into the
lake, traversed in a south-westerly direction by magnificent cliffs of
trappean rocks, presenting their perpendicular sides to the south-
east, and covered even amid the rocky débris with ancient forest-
trees. In this igneous rock are found the copper veins, which in
recent years have conferred such great commercial value on the
district of Michigan; and there I not only witnessed extensive mining
operations in progress, but have investigated evidences of the
ancient miners’ labours which prove the prolonged practice there, at
some remote period, of native metallurgic arts.
On landing at Eagle river, one of the points for shipping the
copper ores, on the west side of the Keweenaw Peninsula, the track
lies through dense forest, over a road in some parts of rough
corduroy, and in others traversing the irregular exposed surface of
the copper-bearing trap. After a time it winds through a gorge,
covered with immense masses of trap and crumbling débris, amid
which pine, and the black oak and other hard wood, have contrived
to find a sufficient soil for taking root and attaining their full
proportions; and beyond the cliffs, in a level bottom on the other
side of the trap ridge, is the Cliff Mine settlement, one of the most
important of all the mining works in operation in this region. Here I
descended a perpendicular shaft by means of ladders, to a depth of
sixty fathoms, and explored various of the levels: passing in some
cases literally through tunnels made in the solid copper. The very
abundance of the metal proves indeed, at times, an impediment to
its profitable working, owing to the labour necessarily expended in
chiselling out masses from the solid lump, to admit of their being
taken to the surface, and transported through such tracts as have
been described, to the Lake shore. The floor of the level was
strewed with copper shavings: for the extreme ductility of the native
copper precludes the application of other force than manual labour
for separating it from the parent mass. I saw also beautiful
specimens of silver, in a matrix of crystalline quartz, obtained from
this mine; and the copper of the district is stated to contain on an
average about 3·10 per cent. of silver. This is indeed by far the
richest mineral locality that has yet been wrought. In a single year
upwards of sixteen hundred tons of copper have been procured from
the Cliff Mine, and one mass was estimated to weigh eighty tons. Its
mineral wealth was known to the ancient miners; but the skill and
appliances of the modern miner give him access to veins entirely
beyond the reach of the primitive metallurgist, who knew of no
harder material for his tools than the native rock and the ductile
metal he was in search of.
At the Cliff Mine are preserved some curious specimens of
ancient copper tools found in its vicinity, but it is to the westward of
the Keweenaw Peninsula that the most extensive traces of the
aboriginal miners’ operations are seen. The copper-bearing trap,
after crossing the Keweenaw Lake, is traced onward in a south-
westerly direction till it crosses the Ontonagon river about twelve
miles from its mouth, at an elevation of upwards of three hundred
feet above the lake. At this locality the edges of the copper veins
crop out in various places, exposing the metal in irregular patches
over a considerable extent of country, many of which have been
partially wrought by the ancient miners. Here, in the neighbourhood
of the Minnesota Mine, are extensive traces of trenches and other
mining operations, which prove that they must have been carried on
for a long period. These excavations are partially filled up, and so
overgrown in the long interval between their first excavation and
their observation by recent explorers, that they scarcely attract
attention. Nevertheless some trenches have been found to measure
from eighteen to thirty feet in depth; and one of them disclosed a
detached mass of native copper, weighing upwards of six tons,
resting on an artificial cradle of black oak, partially preserved by
immersion in the water with which it had been filled. Various
implements and tools of the same metal also lay in the deserted
trench, where this huge mass had been separated from its matrix,
and elevated on the oaken frame, preparatory to its removal entire.
It appeared to have been raised about five feet, and then
abandoned, abruptly as it would seem: since even the copper tools
were found among the accumulated soil by which it had been anew
covered up. The solid mass measured ten feet long, three feet wide,
and nearly two feet thick; every projecting piece had been removed,
so that the exposed surface was left perfectly smooth, possibly by
other and ruder workers of a date subsequent to the desertion of
the mining trench by its original explorers.
The mining operations of upwards of a quarter of a century have
done much to efface the traces of the ancient works, as every
indication of them is eagerly followed up by the modern miner, as
the most promising clew to rich metalliferous deposits. But towards
the close of 1874 Mr. Davis, an experienced old miner of Lake
Superior, recovered from another ancient trench, in the same region,
a solid mass of nearly pure copper, heart-shaped, and weighing
between two and three tons. It lay at a depth of seventeen feet from
the surface, as when originally detached from its bed by the ancient
miners. Alongside of it were a number of smaller pieces, from a
single ounce to seventeen pounds in weight, evidently broken off the
large mass by the original workers of the mine. Numerous stone
mauls and hammers also, weighing from ten to thirty pounds, lay
scattered through the lower débris with which the trench was
refilled. But the absence of any copper tools seemed to point to the
final desertion of the mine, from some unknown cause, at the very
time when its resources were most available.
Attention was first directed to such traces of ancient mining
operations, by the agent of the Minnesota Mining Company in 1847.
Following up the indications of a continuous depression in the soil,
he came at length to a cavern where he found several porcupines
had fixed their quarters for hybernation; but detecting evidences of
artificial excavation, he proceeded to clear out the accumulated soil,
and not only exposed to view a vein of copper, but found in the
rubbish numerous stone mauls and hammers of the ancient
workmen. Subsequent observation brought to light excavations of
great extent, frequently from twenty-five to thirty feet deep, and
scattered over an area of several miles. The rubbish taken from
these is piled up in mounds alongside; while the trenches have been
gradually refilled with soil and decaying vegetable matter gathered
through the long centuries since their desertion; and over all, the
giants of the forest have grown, withered, and fallen to decay. Mr.
Knapp, the agent of the Minnesota Company, counted 395 annular
rings on a hemlock-tree, which grew on one of the mounds of earth
thrown out of an ancient mine. Mr. Foster also notes the great size
and age of a pine-stump which must have grown and died since the
works were deserted; and Mr. Whittlesey not only refers to living
trees upwards of three hundred years old, now flourishing in the
abandoned trenches; but he adds: “on the same spot there are the
decayed trunks of a preceding generation or generations of trees
that have arrived at maturity and fallen down from old age.” The
deserted mines are found at numerous points extending over
upwards of a hundred miles along the southern shore of the lake;
and reappear beyond it, in extensive excavations on Isle Royale. Sir
William Logan reports others observed by him on the summit of a
ridge at Maimanse, on the north shore, where the old excavations
are surrounded by broken pieces of vein-stone, with stone mauls
rudely formed from natural boulders. The extensive area over which
such works have thus been traced, the evidences of their prolonged
working, and of their still longer abandonment, all combine to force
upon the mind convictions of their remote antiquity.
At Ontonagon river I met with Captain Peck, a settler whose long
residence in the country has afforded him many opportunities of
noting the evidences of its ancient occupation. Repeated discoveries
had led him to infer the great antiquity of the works; and he
specially referred to one disclosure of ancient mining operations near
the forks of the Ontonagon river, where, at a depth of upwards of
twenty-five feet, stone mauls and other tools were found in contact
with a copper vein; in the soil above these lay the trunk of a large
cedar, and over all grew a hemlock-tree, with its roots spread
entirely above the fallen cedar, in the accumulated soil with which
the trench was filled, and indicating a growth of not less than three
centuries. But the buried cedar, which in favourable circumstances is
far more durable than the oak, represents another and longer
succession of centuries, subsequent to that protracted period during
which the deserted trench was slowly filled up with accumulations of
many winters. In another excavation a bed of clay had been formed
above the ancient flooring to the depth of a foot. On this lay the
skeleton of a deer which had stumbled in and perished there; and
over it clay, leaves, sand, and gravel had accumulated to a depth of
nineteen feet. Not only are such indications frequent throughout the
Keweenaw Peninsula, and to the westward and southward of
Ontonagon; but on Isle Royale the abandoned mines disclose still
stronger evidence of their great antiquity. The United States
Geologists remark: “Mr. E. G. Shaw pointed out to us similar
evidences of mining on Isle Royale, which can be traced lengthways
for the distance of a mile. On opening one of these pits, which had
become filled up, he found the mine had been worked through the
solid rock, to the depth of nine feet, the walls being perfectly
smooth. At the bottom he found a vein of native copper eighteen
inches thick, including a sheet of pure copper lying against the foot-
wall.” Stone hammers and wedges lay in great abundance at the
bottom of the trenches, but no metallic implements were found: a
proof perhaps that the mines of Isle Royale continued to be wrought
after their workers had been hastily compelled to abandon those on
the mainland. Mr. Shaw adopted the conclusion, from the
appearance of the wall-rocks, the multitude of stone implements,
and the material removed, that the labour of excavating the rock
must have been performed solely with such instruments, with the
aid, perhaps, of fire. But the appearance of the vein, and the extent
of the workings, furnished evidence not only of great and protracted
labour, but also of the use of other tools than those of stone.
Accumulated vegetable matter had refilled the excavations to a level
with the surrounding surface, and over this the forest extended with
the same luxuriance as on the natural soil. In this barren and rocky
region the filling up of the trenches with vegetable soil must have
been the work of many centuries; so that the whole aspect of the
deserted mines of Isle Royale confirms the antiquity ascribed to
them.
What appear to the eye of the traveller as the giants of the
primeval forest, are the growth of comparatively modern centuries,
subsequent to the era when the shores of Lake Superior rang with
the echoes of industrial toil. Two or three centuries would seem
altogether inadequate to furnish the requisite time for the most
partial accumulation of soil and decayed vegetable matter with
which the old miners’ trenches have been filled. Four centuries
thereafter are indisputably recorded by recent survivors of the
forest, independent of all traces of previous arborescent generations;
and thus in the excavations and tools of the copper regions of Lake
Superior, we look on memorials of a metallurgic industry long prior
to those closing years of the fifteenth century, in which the mineral
wealth of the New World awoke the Spanish lust for gold. An
uncertain, yet considerable interval must be assumed between the
abandonment of those ancient works, and the forest’s earliest
growth; and thus we are thrown back, at latest, into centuries
corresponding to Europe’s mediæval era for a period to which to
assign those singularly interesting traces of a lost American
civilisation.
Owing to the filling up of the abandoned mining trenches with
water, not only the copper and stone implements of the miners are
found, but examples of wooden tools and timber framing have also
been preserved, in several cases in wonderful perfection; and these
furnish interesting supplementary evidence of the character of their
industrial arts.
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.
ebooknice.com