Frontend Reactive Architectures Explore The Future of The Frontend Using Reactive Javascript Frameworks and Libraries 1st Edition Luca Mezzalira Download
Frontend Reactive Architectures Explore The Future of The Frontend Using Reactive Javascript Frameworks and Libraries 1st Edition Luca Mezzalira Download
https://ebookbell.com/product/frontend-development-with-aspnet-core-
angular-and-bootstrap-1st-edition-simone-chiaretta-53645870
https://ebookbell.com/product/frontend-development-projects-with-
vuejs-learn-to-build-scalable-web-applications-and-dynamic-user-
interfaces-with-vue-2-raymond-camden-hugo-di-francesco-clifford-
gurney-philip-kirkbride-maya-shavin-23268256
Frontend Tooling With Gulp Bower And Yeoman Not True Pdf 1st Edition
Stefan Baumgartner
https://ebookbell.com/product/frontend-tooling-with-gulp-bower-and-
yeoman-not-true-pdf-1st-edition-stefan-baumgartner-24680268
https://ebookbell.com/product/frontend-developer-bcs-guides-to-it-
roles-dominic-myers-33362702
Frontend Vision And Multiscale Image Analysis Multiscale Computer
Vision Theory And Applications Written In Mathematics 1st Edition Prof
Dr Bart M Ter Haar Romeny Auth
https://ebookbell.com/product/frontend-vision-and-multiscale-image-
analysis-multiscale-computer-vision-theory-and-applications-written-
in-mathematics-1st-edition-prof-dr-bart-m-ter-haar-romeny-auth-4290726
https://ebookbell.com/product/frontend-architecture-a-modern-
blueprint-for-scalable-and-sustainable-design-systems-1-early-release-
micah-godbolt-5207824
https://ebookbell.com/product/front-end-drupal-designing-theming-
scripting-1st-edition-konstantin-kafer-1272948
https://ebookbell.com/product/front-end-drupal-designing-theming-
scripting-1st-edition-konstantin-kafer-1338250
https://ebookbell.com/product/frontend-development-projects-with-
vuejs-learn-to-build-scalable-web-applications-and-dynamic-user-
interfaces-with-vue-raymond-camden-22152720
Front-End Reactive
Architectures
Explore the Future of the Front-End
using Reactive JavaScript Frameworks
and Libraries
—
Luca Mezzalira
Front-End Reactive
Architectures
Explore the Future of the Front-End
using Reactive JavaScript
Frameworks and Libraries
Luca Mezzalira
Front-End Reactive Architectures
Luca Mezzalira
London, Surrey, United Kingdom
v
Table of Contents
vi
Table of Contents
Index��������������������������������������������������������������������������������������������������������������������� 183
vii
About the Author
Luca Mezzalira is a System Architect with 15 years
of experience, a Google Developer Expert on Web
Technologies, and the London Javascript community
Manager (www.londonjs.uk).
He had the opportunity to work on cutting-edge projects
for mobile, desktop, web, TVs, set-top boxes, and embedded
devices.
He is also an international speaker on Tech conferences
with over 100 talks made in less than 10 years.
Luca thinks the best way to use any programming language is mastering their
models; that’s why he spends a lot of time researching topics such as OOP, Functional
and Reactive programming.
With these skills, Luca can easily apply the best practices learned and drive any team
to success.
He is also a natural leader, delivery focused, a problem solver, and a game changer;
his passion is the driver for any activity, and he’s able to make the difference in many
circumstances.
In his spare time, Luca writes for national and international technical magazines
and editors, and he’s a technical reviewer for Apress, Manning Publications, Packt
Publishing, Pragmatic Bookshelf, and O’Reilly.
ix
About the Technical Reviewers
Antonio DeLuca is a fanatic of minimalist software development, accurate database
design, and meticulous business analysis. He is focused on functional/object paradigms
and service orientation. He has worked in various contexts and levels developing
applications for the Web as well as other purposes with JavaScript/PHP, Java/C#, and
other programming languages. He is based in London and is the Principal Software
Developer at DAZN (a division of Perform Group).
xi
Acknowledgments
I’d like to thank so many people that probably they wouldn’t fit in just a page!
I think the most important one to mention though is my girlfriend Maela that is
always here for me and she is the key to our family happiness.
Sometimes inspirations come in strange ways. I once read the story of the UFC
champion Conor McGregor: he is really an interesting guy, sometimes with an
overwhelming personality, but I think it is part of the role or mask he decided to wear.
McGregor made me think when I read this sentence:
“There’s no talent here, this is hard work. This is an obsession. Talent does not exist,
we are all equal as human beings. You could be anyone if you put in the time. You will
reach the top, and that is that. I am not talented, I am obsessed.”
To be honest, I totally agree. Everyone can be who he or she wants to be; it’s hard and
often we can be nearly there for giving up a dream, but our obsessions could really make
the difference from failing to succeeding.
Several years ago, I would have never thought I’d be able to write an entire book in
English and succeeding as a Software Architect outside my country – apparently my
obsessions won.
xiii
CHAPTER 1
What Is Reactive
Programming?
A journey of a thousand miles begins with a single step.
—Lao Tzu, Tao Te Chang
Have you ever heard about Reactive Programming or Reactive Systems? Do you think
React.js is a reactive library? Have you ever thought about why you should use Rx.JS
inside an Angular project? Is Rx.JS the new Loadash?
If at least one of these questions is often in your mind, this is exactly the right book to
find an answer!
In these pages you will have a chance to learn more about reactive programming
and reactive architecture for front-end development: a programming paradigm that
is becoming more popular, every day, in the front-end community; but these days it is
probably one of the most misunderstood and abused paradigm.
The main goal of this book is to provide a good understanding of what reactive
programming is, how to use it in our projects, and particularly how to create fully
reactive architectures for creating resilient and maintainable projects.
During this journey you will learn the following:
1
© Luca Mezzalira 2018
L. Mezzalira, Front-End Reactive Architectures, https://doi.org/10.1007/978-1-4842-3180-7_1
Chapter 1 What Is Reactive Programming?
If you are wondering if the concepts learned inside this book are applicable also on a
back-end architecture, my answer would be YES, or at least, the majority of them could be
applied to your back-end architecture too.
Bear in mind that this book will focus the attention on front-end architectures with
JavaScript, but some of the concepts illustrated should be easily portable to other back-
end programming languages such as Node.js, for instance.
This book assumes that you already have good understanding of JavaScript, in
particular ECMAScript 6 and 7 syntax; object-oriented programming; and possibly some
knowledge of functional programming, but it’s not mandatory. Let the journey begin!
2
Chapter 1 What Is Reactive Programming?
The injected object in this case is used as an interactive object, because the host
knows exactly what the contract is and how to use it.
In reactive programming instead, the hosting object will just subscribe to the injected
one, and it will react to the propagation of changes during the application lifetime.
See Figure 1-1.
Looking at the image above, we can immediately grasp the main difference between
the two approaches:
• In the interactive example, object A is aware of which methods to
call because knows exactly the B’s object contract, also if we have to
understand who has affected the state of the ingested object, we will
search across all the projects that we are interacting with.
• In the reactive one, the contract is standard and object A is reacting
to changes happened in object B, on top we are certain that any
manipulation would occur inside the injected object; therefore we
will have a stronger separation of concerns between objects.
• Because the hosting object is reacting to any value propagated inside
the object injected, our program will be up to date without the need
for implementing any additional logic.
3
Chapter 1 What Is Reactive Programming?
It’s time for a simple example before we move ahead with other concepts.
Let’s assume we have a class called Calculator with a method sum and a class
Receipt with a method print as shown in Listing 1-1.
class Calculator {
sum(a, b){
return a + b;
}
}
class Receipt {
constructor(calculator){
this.calc = calculator;
}
print(itemA, itemB){
const total = this.calc.sum(itemA, itemB);
console.log(`total receipt £${total}`);
}
}
receipt.print(pizza, beer);
4
Chapter 1 What Is Reactive Programming?
Now let’s try to implement the same example in a reactive way in Listing 1-2.
class Calculator {
constructor(itemA, itemB){
const obs = Rx.Observable.of(itemA, itemB);
const sum$ = obs.reduce((acc, item) => (acc + item));
return {
observable: sum$
}
}
}
class Receipt {
constructor(observable$){
observable$.subscribe(value => console.log(`total receipt: £${value}`))
}
As you can see in this example, the Receipt class is subscribing to an object called
observable, injected via the constructor, and all the logic of how to sum the prices
and propagate them is delegated to the Calculator class. Therefore, the Receipt class
is just reacting to a change, happening in a certain moment of the program’s lifetime,
displaying in the console the value emitted by the Calculator instance.
Another thing to highlight here is the contract between the objects: instead of
knowing exactly what method we should call, we pass an, with a default contract, and we
react when something changes inside it.
Overall, it’s a very simple example but I hope it helps you to understand the shift of
mindset we are going to have when we work with reactive programming; in the next few
chapters we will see more reactive examples like this one.
5
Chapter 1 What Is Reactive Programming?
Programming Paradigms
It’s time to spend some words on programming paradigms to shed some light on reactive
concepts and comparing them with functional and imperative programming.
Imperative Programming
Imperative programming is probably one of the most well-known programming paradigms.
Often, it’s the first paradigm that we learn for understanding how a computer
elaborates a program: it gives us all the tools for defining implementation details in
depth and specifying exactly how a program should behave step by step.
Let’s see an example of imperative programming:
class Calculator {
constructor(){
this.VAT = 22;
}
sum(...items){
let total = 0;
let i = 0;
for(i; i < items.length; i++){
total = total + items[i];
total = total + items[i] * this.VAT/100;
}
return total;
}
}
class Receipt {
constructor(calculator){
this.calc = calculator;
}
print(...items){
let total = this.calc.sum(...items);
console.log(`total receipt £${total.toFixed(2)}`);
}
}
6
Chapter 1 What Is Reactive Programming?
Similar to the example discussed before, the sum method of the calculator object is
accepting multiple arguments instead of just a couple, and we are summing all of them
and applying the VAT value calculated per item.
As you can see, we are describing the exact implementation we want to perform:
from defining a for statement in order to iterate trough the values in the array until
expressing the VAT calculation for each single item.
Basically what we are doing is focusing on any implementation detail; potentially we
could change the way we were iterating through the array’s elements and start from the
last element in the array instead of the first one or use a different variable name from “i”;
these are the levels of detail we usually handle with imperative programming.
Now it’s time to see how this example would be handled in functional and reactive
programming.
Functional Programming
Functional programming is getting more famous on a daily base. Many languages arise
embracing this paradigm and many existing languages are embracing it too for the
readability, maintainability, and testability improvements.
If you are asking yourself why Functional Programming is becoming so popular, the
answer can be found behind the concepts of this paradigm.
When we talk about Functional Programming we are talking about functions: in
particular we are talking about pure functions.
A pure function is a function that, given an argument, is always returning the same
result; it’s predictable, easy to test, and doesn’t generate any side effect inside the program.
Another important topic related to functional programming is the concept of
immutability.
7
Chapter 1 What Is Reactive Programming?
Immutability means that a specific value won’t ever change during its life cycle, but
if we need to manipulate it, we will create a new instance that contains the manipulated
version of the original object.
Even if you are not familiar with this concept or have never dealt with it, I want you to
see at least one concrete example.
Usually when you are dealing with an array and you want to iterate trough the values
and interact with them in an imperative programming way, you would write something
like this:
At this stage we have completely lost the initial values of the array called
originalArray; if we want to have a copy of the initial values, we would create a new array
that contains the modified values and then we would check that one.
In functional programming, instead, we are working by default with immutable
objects; therefore, every modification we need to apply won’t affect the original value
but will generate a new one.
Taking into consideration the previous example, we could write in a functional
programming way like this:
As you can see from these simple examples, functional programming is focused on
what you are trying to achieve more than its implementation details.
That’s a fundamental distinction compared to imperative programming. In fact, with
functional programming we are describing our program, focusing on each action; and
we need to do describe the data flow of our program more than focusing on each single
detail such as which variable we have to define for iterating an array or how to increment
the variable inside the for statement.
Another important aspect of software programming is how to deal with state
management.
8
Chapter 1 What Is Reactive Programming?
An Action is a simple object used for identifying in which state the application
should transform.
Relying to pure functions will make our code more modular and more reusable, will
create less bugs, and will suddenly become more testable!
Let’s try now to convert the previous imperative example, porting it to functional
programming. See Listing 1-3.
class Receipt {
print(total){
console.log(`total receipt £${total.toFixed(2)}`);
}
}
As we can see in the sum method implementation, we are focusing more on the
actions we want to implement more than how to apply them; therefore, first we know
that we need to calculate the VAT value for each single element (map method) and then
to sum the items for retrieving the total (reduce method).
In this implementation we don’t need to specify how we are iterating through the
array elements or specifying variables to keep the state of the iteration; we just focus on
our goal.
Another thing to notice in this implementation is how we are using functions as an
argument of other functions; this mechanism is called high-order functions and it is
another cornerstone of Functional Programming.
Obviously, Functional Programming is not just that: it is a broad topic with many
other patterns to take in consideration like currying, practical application, memoization,
and so on, but this is not the main topic of the book.
Bear in mind these concepts and possibly read a few posts online regarding them
for mastering the different implementations because being familiar with Functional
Programing will allow you to embrace Reactive Programming more easily.
If you are not used to thinking functionally, I strongly suggest peaking at a book that
describes this paradigm in your favorite language; it’s a great time investment, and you
won’t regret it.
10
Random documents with unrelated
content Scribd suggests to you:
upon the domain of private life. Expostulation and active warfare,
however, are equally useless. The carpenter-ant has no moral sense,
and is not amenable either to kindness or blows. On one occasion,
when a body of these intrusive creatures had constructed an
absurdly conspicuous brown gallery straight across the ceiling of my
drawing-room, I determined to declare open war against them, and
getting my black servant to bring in the steps and a mop, I
proceeded to demolish the entire gallery just after breakfast. It was
about twenty feet long, as well as I can remember, and perhaps an
inch in diameter. At one o'clock I returned to lunch. My black servant
pointed, with a broad grin on his intelligent features, to the wooden
ceiling. I looked up: in those three hours the carpenter-ants had
reconstructed the entire gallery, and were doubtless mocking me at
their ease, with their uplifted antennæ, under that safe shelter. I
retired at once from the unequal contest. It was clearly impossible to
go on knocking down a fresh gallery every three hours of the day or
night throughout a whole lifetime.
Ants, says Mr. Wallace, without one touch of satire, “force
themselves upon the attention of everyone who visits the tropics.”
They do, indeed, and that most pungently; if by no other method, at
least by the simple and effectual one of stinging. The majority of
ants in every nest are of course neuters, or workers, that is to say,
strictly speaking, undeveloped females, incapable of laying eggs. But
they still retain the ovipositor, which is converted into a sting, and
supplied with a poisonous liquid to eject afterwards into the wound.
So admirably adapted to its purpose is this beautiful provision of
nature, that some tropical ants can sting with such violence as to
make your leg swell and confine you for some days to your room;
while cases have even been known in which the person attacked has
fainted with pain, or had a serious attack of fever in consequence. It
is not every kind of ant, however, that can sting; a great many can
only bite with their little hard horny jaws, and then eject a drop of
formic poison afterwards into the hole caused by the bite. The
distinction is a delicate physiological one, not much appreciated by
the victims of either mode of attack. The perfect females can also
sting, but not, of course, the males, who are poor, wretched, useless
creatures, only good as husbands for the community, and dying off
as soon as they have performed their part in the world—another
beautiful provision, which saves the workers the trouble of killing
them off, as bees do with drones after the marriage flight of the
queen bee.
The blind driver-ants of West Africa are among the very few species
that render any service to man, and that, of course, only incidentally.
Unlike most other members of their class, the driver-ants have no
settled place of residence; they are vagabonds and wanderers upon
the face of the earth, formican tramps, blind beggars, who lead a
gipsy existence, and keep perpetually upon the move, smelling their
way cautiously from one camping-place to another. They march by
night, or on cloudy days, like wise tropical strategists, and never
expose themselves to the heat of the day in broad sunshine, as
though they were no better than the mere numbered British Tommy
Atkins at Coomassie or in the Soudan. They move in vast armies
across country, driving everything before them as they go; for they
belong to the stinging division, and are very voracious in their
personal habits. Not only do they eat up the insects in their line of
march, but they fall even upon larger creatures and upon big
snakes, which they attack first in the eyes, the most vulnerable
portion. When they reach a negro village the inhabitants turn out en
masse, and run away, exactly as if the visitors were English explorers
or brave Marines, bent upon retaliating for the theft of a knife by
nobly burning down King Tom's town or King Jumbo's capital. Then
the negroes wait in the jungle till the little black army has passed on,
after clearing out the huts by the way of everything eatable. When
they return they find their calabashes and saucepans licked clean,
but they also find every rat, mouse, lizard, cockroach, gecko, and
beetle completely cleared out from the whole village. Most of them
have cut and run at the first approach of the drivers; of the
remainder, a few blanched and neatly-picked skeletons alone remain
to tell the tale.
As I wish to be considered a veracious historian, I will not retail the
further strange stories that still find their way into books of natural
history about the manners and habits of these blind marauders.
They cross rivers, the West African gossips declare, by a number of
devoted individuals flinging themselves first into the water as a living
bridge, like so many six-legged Marcus Curtiuses, while over their
drowning bodies the heedless remainder march in safety to the
other side. If the story is not true, it is at least well invented; for the
ant-commonwealth everywhere carries to the extremest pitch the old
Roman doctrine of the absolute subjection of the individual to the
State. So exactly is this the case that in some species there are a
few large, overgrown, lazy ants in each nest, which do no work
themselves, but accompany the workers on their expeditions; and
the sole use of these idle mouths seems to be to attract the
attention of birds and other enemies, and so distract it from the
useful workers, the mainstay of the entire community. It is almost as
though an army, marching against a tribe of cannibals, were to place
itself in the centre of a hollow square formed of all the fattest people
in the country, whose fine condition and fitness for killing might
immediately engross the attention of the hungry enemy. Ants, in
fact, have, for the most part, already reached the goal set before us
as a delightful one by most current schools of socialist philosophers,
in which the individual is absolutely sacrificed in every way to the
needs of the community.
The most absurdly human, however, among all the tricks and habits
of ants are their well-known cattle-farming and slaveholding
instincts. Everybody has heard, of course, how they keep the
common rose-blight as milch cows, and suck from them the sweet
honey-dew. But everybody, probably, does not yet know the large
number of insects which they herd in one form or another as
domesticated animals. Man has, at most, some twenty or thirty such,
including cows, sheep, horses, donkeys, camels, llamas, alpacas,
reindeer, dogs, cats, canaries, pigs, fowl, ducks, geese, turkeys, and
silkworms. But ants have hundreds and hundreds, some of them
kept obviously for purposes of food; others apparently as pets; and
yet others again, as has been plausibly suggested, by reason of
superstition or as objects of worship. There is a curious blind beetle
which inhabits ants' nests, and is so absolutely dependent upon its
hosts for support that it has even lost the power of feeding itself. It
never quits the nest, but the ants bring it in food and supply it by
putting the nourishment actually into its mouth. But the beetle, in
return, seems to secrete a sweet liquid (or it may even be a
stimulant like beer, or a narcotic like tobacco) in a tuft of hairs near
the bottom of the hard wing-cases, and the ants often lick this tuft
with every appearance of satisfaction and enjoyment. In this case,
and in many others, there can be no doubt that the insects are kept
for the sake of food or some other advantage yielded by them.
But there are other instances of insects which haunt ants' nests,
which it is far harder to account for on any hypothesis save that of
superstitious veneration. There is a little weevil that runs about by
hundreds in the galleries of English ants, in and out among the free
citizens, making itself quite at home in their streets and public
places, but as little noticed by the ants themselves as dogs are in
our own cities. Then, again, there is a white woodlouse, something
like the common little armadillo, but blind from having lived so long
underground, which walks up and down the lanes and alleys of
antdom, without ever holding any communication of any sort with its
hosts and neighbors. In neither case has Sir John Lubbock ever seen
an ant take the slightest notice of the presence of these strange
fellow-lodgers. “One might almost imagine,” he says, “that they had
the cap of invisibility.” Yet it is quite clear that the ants deliberately
sanction the residence of the weevils and woodlice in their nests, for
any unauthorised intruder would immediately be set upon and
massacred outright. Sir John Lubbock suggests that they may
perhaps be tolerated as scavengers; or, again, it is possible that they
may prey upon the eggs or larvæ of some of the parasites to whose
attacks the ants are subject. In the first case, their use would be
similar to that of the wild dogs in Constantinople or the common
black John-crow vultures in tropical America: in the second case,
they would be about equivalent to our own cats or to the hedgehog
often put in farmhouse kitchens to keep down cockroaches.
The crowning glory of owning slaves, which many philosophic
Americans (before the war) showed to be the highest and noblest
function of the most advanced humanity, has been attained by more
than one variety of anthood. Our great English horse-ant is a
moderate slave-holder; but the big red ant of Southern Europe
carries the domestic institution many steps further. It makes regular
slave-raids upon the nests of the small brown ants, and carries off
the young in their pupa condition. By-and-by the brown ants hatch
out in the strange nest, and, never having known any other life
except that of slavery, accommodate themselves to it readily
enough. The red ant, however, is still only an occasional slaveowner;
if necessary, he can get along by himself, without the aid of his little
brown servants. Indeed, there are free states and slave states of red
ants side by side with one another, as of old in Maryland and
Pennsylvania: in the first, the red ants do their work themselves, like
mere vulgar Ohio farmers; in the second, they get their work done
for them by their industrious little brown servants, like the
aristocratic first families of Virginia before the earthquake of
emancipation.
But there are other degraded ants, whose life-history may be
humbly presented to the consideration of the Anti-Slavery Society, as
speaking more eloquently than any other known fact for the
demoralising effect of slaveowning upon the slaveholders
themselves. The Swiss rufescent ant is a species so long habituated
to rely entirely upon the services of slaves that it is no longer able to
manage its own affairs when deprived by man of its hereditary
bondsmen. It has lost entirely the art of constructing a nest; it can
no longer tend its own young, whom it leaves entirely to the care of
negro nurses; and its bodily structure even has changed, for the
jaws have lost their teeth, and have been converted into mere
nippers, useful only as weapons of war. The rufescent ant, in fact, is
a purely military caste, which has devoted itself entirely to the
pursuit of arms, leaving every other form of activity to its slaves and
dependents. Officers of the old school will be glad to learn that this
military insect is dressed, if not in scarlet, at any rate in very decent
red, and that it refuses to be bothered in any way with questions of
transport or commissariat. If the community changes its nest, the
masters are carried on the backs of their slaves to the new position,
and the black ants have to undertake the entire duty of foraging and
bringing in stores of supply for their gentlemanly proprietors. Only
when war is to be made upon neighboring nests does the thin red
line form itself into long file for active service. Nothing could be more
perfectly aristocratic than the views of life entertained and acted
upon by these distinguished slaveholders.
On the other hand, the picture has its reverse side, exhibiting clearly
the weak points of the slaveholding system. The rufescent ant has
lost even the very power of feeding itself. So completely dependent
is each upon his little black valet for daily bread, that he cannot so
much as help himself to the food that is set before him. Hüber put a
few slaveholders into a box with some of their own larvæ and pupæ,
and a supply of honey, in order to see what they would do with
them. Appalled at the novelty of the situation, the slaveholders
seemed to come to the conclusion that something must be done; so
they began carrying the larvæ about aimlessly in their mouths, and
rushing up and down in search of the servants. After a while,
however, they gave it up and came to the conclusion that life under
such circumstances was clearly intolerable. They never touched the
honey, but resigned themselves to their fate like officers and
gentlemen. In less than two days, half of them had died of hunger,
rather than taste a dinner which was not supplied to them by a
properly constituted footman. Admiring their heroism or pitying their
incapacity, Hüber, at last, gave them just one slave between them
all. The plucky little negro, nothing daunted by the gravity of the
situation, set to work at once, dug a small nest, gathered together
the larvæ, helped several pupæ out of the cocoon, and saved the
lives of the surviving slaveowners. Other naturalists have tried
similar experiments, and always with the same result. The
slaveowners will starve in the midst of plenty rather than feed
themselves without attendance. Either they cannot or will not put
the food into their own mouths with their own mandibles.
There are yet other ants, such as the workerless Anergates, in which
the degradation of slaveholding has gone yet further. These
wretched creatures are the formican representatives of those
Oriental despots who are no longer even warlike, but are sunk in
sloth and luxury, and pass their lives in eating bang or smoking
opium. Once upon a time, Sir John Lubbock thinks, the ancestors of
Anergates were marauding slaveowners, who attacked and made
serfs of other ants. But gradually they lost not only their arts but
even their military prowess, and were reduced to making war by
stealth instead of openly carrying off their slaves in fair battle. It
seems probable that they now creep into a nest of the far more
powerful slave ants, poison or assassinate the queen, and establish
themselves by sheer usurpation in the queenless nest. “Gradually,”
says Sir John Lubbock, “even their bodily force dwindled away under
the enervating influence to which they had subjected themselves,
until they sank to their present degraded condition—weak in body
and mind, few in numbers, and apparently nearly extinct, the
miserable representatives of far superior ancestors, maintaining a
precarious existence as contemptible parasites of their former
slaves.” One may observe in passing, that these wretched do-
nothings cannot have been the ants which Solomon commended to
the favorable consideration of the sluggard; though it is curious that
the text was never pressed into the service of defence for the
peculiar institution by the advocates of slavery in the South, who
were always most anxious to prove the righteousness of their cause
by most sure and certain warranty of Holy Scripture.—Cornhill
Magazine.
LITERARY NOTICES.
Episodes of My Second Life. By Antonio Gallenga (Luigi Mariotti).
English and American Experiences. Philadelphia: J. B. Lippincott
& Co.
The autobiographer in this case (for the last year has been singularly
rich in interesting autobiography) is not in any degree, at least for
Americans, an eminent and well-known personage. But, in spite of
this, his record of experience and vicissitude is full of interest, and
we may almost say fascinating. His threescore years and ten have
been crowded with events which, if not in themselves strikingly
dramatic, are at least striking in the telling, for he has all the art of
an accomplished raconteur, simple, direct and vigorous in style, and
knowing perfectly when to glide over with little stress, when to put
on his color with a vigorous and lavish brush. Mr. Gallenga (this
being his true name) was in the latter part of his life a leading
correspondent of the London Times, having achieved a high
reputation in this direction prior to the days of Dr. Russell and
Archibald Forbes. His work and position brought him into confidential
relations with many of the most important men and events of
Europe from 1840 to 1875, and he describes these in a racy fashion
which will command attention, we think.
Mr. Gallenga as a youth of twenty took part in the Italian struggle for
liberty in 1831, under the name of Luigi Mariotti. It was one of those
brief episodes of revolution with which Italy was convulsed so often
before the great final dead-lock came, which drove the hated
Sedischi from her soil. The young patriot was for a short time in
prison, but finally escaped, and lived for a while as a tutor in
Tangiers. Thence he came to America, to carve a career for himself,
and located himself in Boston in 1836. Here he speedily found
employment as teacher, lecturer and writer, and was fortunate in
securing the friendship and goodwill of the leading people of the city.
Boston was then without dispute the only literary centre of the
country, in spite of a few brilliant names in New York, and Sig.
Gallenga seems to have found congenial employment and
companionship from the outset. His reminiscences of such men as
Edward Everett, Fields, Ticknor, Prescott and others are entertaining,
and his sketch of the whole entourage of Boston society is given
with a refreshing naïveté, as well as with graceful vivacity. Among
the minor incidents which lend humor to the book is the author's
experience with a young American beauty, with whom he was in
love, and whom in his impulsive and passionate Italian way, he
clasped in his arms and kissed. He professes himself highly
astonished because the damsel was greatly enraged and ordered
him from the house, ending the acquaintance then and there. After
spending four years in America under unusually agreeable
conditions, Mr. Gallenga, who was still known under his pseudonym
of Mariotti, took ship for England, and bade a final farewell to the
country of which he speaks in such cordial and even affectionate
terms. Settling in London good luck still followed him. He secured
introductions to prominent persons, was accorded recognition at
once, and became acquainted with many of the people, both literary
and otherwise, best worth knowing in England. A great interest in
Italian affairs and literature was then the rage, and Mr. Gallenga,
who was a scholar and an able writer, found ample opportunity and
occupation in contributing to the magazines and reviews on subjects
which he discussed con amore. A book which he published gave him
repute beyond that of a mere fugitive writer, and he was fortunate in
making literature lucrative as well as honorable. His gossip about
prominent people and occurrences in London forty years ago, is very
entertaining, and he shows as much skill in throwing light on the
English life of that day as he had done in describing America. Twenty
years of literary and professorial work, were frequently broken up by
long residences in Italy, during which he sat for a time in the Italian
Parliament, and helped to pave the way for that consolidation of
Italian interests which at last led to Solferino and Magenta, and the
grand result of Italian unity. He seems to have been accorded an
important place in the councils and deliberations of his nation, and
to have been an important agent in bringing about those relations
which freed Italy from foreign domination. In 1859 our author
became connected with the Times as correspondent, and since that
time has been employed on many of the most delicate and
important commissions. He represented them in the Franco-Italian-
Austrian War, and succeeded Dr. Russell at the time of our late civil
conflict; was sent repeatedly to every part of Europe, and, for a
good while had a roving commission to write whatever he saw worth
reporting and discussing, particularly on the peoples and events of
the Mediterranean seaboard countries, from the straits of Gibraltar
to the Dardanelles. Mr. Gallenga tells his story (and he has much to
tell) with the vivacity of an Italian and with the ability of a trained
man-of-letters. A number of books, mostly on historical and political
subjects, have given him a recognized literary place aside from mere
journalism, and he reviews a long, diversified and interesting career
with an interest and satisfaction which he fully communicates to his
readers. We have rarely read a volume more packed with interesting
matter, narrated with the skill which comes of long training.
The Reality of Religion. By Henry J. Van Dyke, Jr., D.D. New York:
Charles Scribner's Sons.
Trinity College, Dublin, is about to start a new paper with the title
The Dublin University Review. The first number will appear on
February 1st, and the issue will be bi-monthly, except during the
long vacation. The paper will contain literary articles as well as
university news of every description, and will be owned by a limited
liability company.
The article on Polish history and literature in the next volume of the
“Encyclopædia Britannica” will be from the pen of Mr. Morfill, who
will also contribute the articles on the Emperor Paul, and on Peter
the Great.
An early and hitherto unknown Arabic work has lately been added to
the Museum Library. It is entitled “Kitāb al-Mohabbir”, and contains
various historical notices and traditions relating to the ancient Arabs
and to the time of Mohammed and his immediate successors. The
author, Abu Sa'id al-Hasan al-Sukkari, lived in the third century of
the Hijrah, and is well known as one of the earliest editors and
commentators of the old poets, but the present work appears
somehow to have escaped notice; it is neither mentioned in the
Fihrist, nor by Ibn Khallikan or Soyuti. The two last-named authors
state that Al-Sukkari died A.H. 275; but according to Ibn Kāni'
(Leyden Catalogue, vol. ii. p. 8) he lived on to A.H. 290. The present
work would show that the former date is decidedly wrong; for it
contains a brief sketch of the Abbasides brought down by Al-Sukkari
himself to the accession of Al-Mo'tadid, i.e., A.H. 279.
ebookbell.com