JavaScript Object Programming Rinehart Martin instant download
JavaScript Object Programming Rinehart Martin instant download
download
https://textbookfull.com/product/javascript-object-programming-
rinehart-martin/
https://textbookfull.com/product/swift-3-object-oriented-
programming-gaston-c-hillar/
https://textbookfull.com/product/programming-in-c-object-
oriented-features-1st-edition-laxmisha-rai/
https://textbookfull.com/product/beginning-functional-javascript-
functional-programming-with-javascript-using-ecmascript-6-1st-
edition-anto-aravinth/
Beginning Functional JavaScript: Functional Programming
with JavaScript Using EcmaScript 6 1st Edition Anto
Aravinth
https://textbookfull.com/product/beginning-functional-javascript-
functional-programming-with-javascript-using-ecmascript-6-1st-
edition-anto-aravinth-2/
https://textbookfull.com/product/head-first-javascript-
programming-2nd-edition-a-learners-guide-to-modern-javascript-
eric-freeman/
https://textbookfull.com/product/head-first-javascript-
programming-2nd-edition-a-learners-guide-to-modern-javascript-
eric-freeman-2/
https://textbookfull.com/product/javascript-cookbook-programming-
the-web-3rd-edition-scott/
https://textbookfull.com/product/reactive-programming-with-
javascript-1st-edition-hayward-jonathan/
JavaScript Object
Programming
Martin Rinehart
JavaScript Object Programming
Copyright © 2015 by Martin Rinehart
This work is subject to copyright. All rights are reserved by the Publisher, whether the whole or part
of the material is concerned, specifically the rights of translation, reprinting, reuse of illustrations,
recitation, broadcasting, reproduction on microfilms or in any other physical way, and transmission
or information storage and retrieval, electronic adaptation, computer software, or by similar or
dissimilar methodology now known or hereafter developed. Exempted from this legal reservation are
brief excerpts in connection with reviews or scholarly analysis or material supplied specifically for
the purpose of being entered and executed on a computer system, for exclusive use by the purchaser
of the work. Duplication of this publication or parts thereof is permitted only under the provisions
of the Copyright Law of the Publisher’s location, in its current version, and permission for use must
always be obtained from Springer. Permissions for use may be obtained through RightsLink at the
Copyright Clearance Center. Violations are liable to prosecution under the respective Copyright Law.
ISBN-13 (pbk): 978-1-4842-1786-3
ISBN-13 (electronic): 978-1-4842-1787-0
Trademarked names, logos, and images may appear in this book. Rather than use a trademark
symbol with every occurrence of a trademarked name, logo, or image we use the names, logos, and
images only in an editorial fashion and to the benefit of the trademark owner, with no intention of
infringement of the trademark.
The use in this publication of trade names, trademarks, service marks, and similar terms, even if they
are not identified as such, is not to be taken as an expression of opinion as to whether or not they are
subject to proprietary rights.
While the advice and information in this book are believed to be true and accurate at the date of
publication, neither the authors nor the editors nor the publisher can accept any legal responsibility
for any errors or omissions that may be made. The publisher makes no warranty, express or implied,
with respect to the material contained herein.
Managing Director: Welmoed Spahr
Lead Editor: Jeffrey Pepper
Editorial Board: Steve Anglin, Pramila Balan, Louise Corrigan, Jonathan Gennick,
Robert Hutchinson, Celestin Suresh John, Michelle Lowman, James Markham,
Susan McDermott, Matthew Moodie, Jeffrey Pepper, Douglas Pundick,
Ben Renow-Clarke, Gwenan Spearing
Coordinating Editor: Mark Powers
Copy Editor: Kezia Endsley
Compositor: SPi Global
Indexer: SPi Global
Artist: SPi Global
Distributed to the book trade worldwide by Springer Science+Business Media New York, 233 Spring
Street, 6th Floor, New York, NY 10013. Phone 1-800-SPRINGER, fax (201) 348-4505, e-mail
[email protected], or visit www.springeronline.com. Apress Media, LLC is a California LLC
and the sole member (owner) is Springer Science + Business Media Finance Inc (SSBM Finance Inc).
SSBM Finance Inc is a Delaware corporation.
For information on translations, please e-mail [email protected], or visit www.apress.com.
Apress and friends of ED books may be purchased in bulk for academic, corporate, or promotional
use. eBook versions and licenses are also available for most titles. For more information, reference
our Special Bulk Sales–eBook Licensing web page at www.apress.com/bulk-sales.
Any source code or other supplementary materials referenced by the author in this text is available
to readers at www.apress.com/9781484217863. For detailed information about how to locate your
book’s source code, go to www.apress.com/source-code/. Readers can also access source code at
SpringerLink in the Supplementary Material section for each chapter.
Dedicated to Brendan Eich. He wrote JavaScript in 1995 giving us its
object literals and object programming.
Contents at a Glance
■
■Chapter 1: Creating Objects������������������������������������������������������������ 1
■
■Chapter 2: Object Programming��������������������������������������������������� 15
■
■Chapter 3: Inheritance Theory������������������������������������������������������ 25
■
■Chapter 4: Inheritance Practice���������������������������������������������������� 37
■
■Chapter 5: On OOP Principles������������������������������������������������������� 51
■
■Chapter 6: More Ex Nihilo Objects������������������������������������������������ 59
■
■Chapter 7: Inheritance Alternatives���������������������������������������������� 65
■
■Chapter 8: Designing for JavaScript��������������������������������������������� 83
■
■Chapter 9: On Constructors���������������������������������������������������������� 89
■
■Chapter 10: Appendices��������������������������������������������������������������� 97
Index���������������������������������������������������������������������������������������������� 107
v
Contents
■
■Chapter 1: Creating Objects������������������������������������������������������������ 1
Reasons for Objects�������������������������������������������������������������������������������� 1
Objects Do Methods������������������������������������������������������������������������������������������������� 1
Event-Driven Programming�������������������������������������������������������������������������������������� 2
Taming Exponential Complexity�������������������������������������������������������������������������������� 2
vii
■ Contents
Summary����������������������������������������������������������������������������������������������� 14
■
■Chapter 2: Object Programming��������������������������������������������������� 15
JSWindows Sample System������������������������������������������������������������������ 15
OP Removes Restrictions���������������������������������������������������������������������� 15
OP Defined��������������������������������������������������������������������������������������������� 16
Programming with Properties��������������������������������������������������������������� 16
Dot Notation������������������������������������������������������������������������������������������������������������ 16
Subscript Notation�������������������������������������������������������������������������������������������������� 17
Object Programming Examples������������������������������������������������������������� 17
Object Sum������������������������������������������������������������������������������������������������������������� 17
OP for Inheriting Prototypes����������������������������������������������������������������������������������� 19
Summary����������������������������������������������������������������������������������������������� 24
viii
■ Contents
■
■Chapter 3: Inheritance Theory������������������������������������������������������ 25
Classes�������������������������������������������������������������������������������������������������� 25
Constructors����������������������������������������������������������������������������������������������������������� 26
Instance Methods��������������������������������������������������������������������������������������������������� 26
Class (Family-Wide) Properties������������������������������������������������������������������������������ 27
Class-Based Inheritance����������������������������������������������������������������������� 27
Property Sets���������������������������������������������������������������������������������������������������������� 28
Constructing an Extending Instance����������������������������������������������������������������������� 29
Overriding Properties���������������������������������������������������������������������������������������������� 29
Inheritance Chains�������������������������������������������������������������������������������������������������� 30
Prototypal Inheritance��������������������������������������������������������������������������� 31
Inheritance vs. Composition������������������������������������������������������������������ 32
Composition in Theory�������������������������������������������������������������������������������������������� 32
Composition in JSWindows������������������������������������������������������������������������������������ 32
Summary����������������������������������������������������������������������������������������������� 35
■
■Chapter 4: Inheritance Practice���������������������������������������������������� 37
Cascading init( ) Methods for Data�������������������������������������������������������� 37
A Theoretical Example�������������������������������������������������������������������������������������������� 39
A Practical Example������������������������������������������������������������������������������������������������ 42
Prototypes for Methods������������������������������������������������������������������������� 44
Prototype Inheritance Alternatives������������������������������������������������������������������������� 46
Prototype Alternatives�������������������������������������������������������������������������������������������� 48
JSWindows Inheritance������������������������������������������������������������������������� 49
Summary����������������������������������������������������������������������������������������������� 49
ix
■ Contents
■
■Chapter 5: On OOP Principles������������������������������������������������������� 51
Ranking OOP Principles������������������������������������������������������������������������� 51
Inheritance�������������������������������������������������������������������������������������������� 52
Encapsulation���������������������������������������������������������������������������������������� 52
Access Specifiers��������������������������������������������������������������������������������������������������� 52
Closures������������������������������������������������������������������������������������������������������������������ 53
Polymorphism��������������������������������������������������������������������������������������� 53
Subtype Polymorphism������������������������������������������������������������������������������������������� 53
Parametric Polymorphism�������������������������������������������������������������������������������������� 54
Ad Hoc and Other Polymorphism���������������������������������������������������������������������������� 55
JavaScript and Polymorphism�������������������������������������������������������������������������������� 55
Summary����������������������������������������������������������������������������������������������� 62
x
■ Contents
■
■Chapter 7: Inheritance Alternatives���������������������������������������������� 65
Multiple Inheritance������������������������������������������������������������������������������ 65
Interfaces���������������������������������������������������������������������������������������������� 67
Capabilities�������������������������������������������������������������������������������������������� 68
The Window[_M[_BS]] Problem������������������������������������������������������������ 68
Mixins���������������������������������������������������������������������������������������������������� 70
Calling Capability Methods�������������������������������������������������������������������� 71
Capabilities as Constructor Properties������������������������������������������������������������������� 71
Capabilities as Single Properties���������������������������������������������������������������������������� 71
Capability Prototype Methods��������������������������������������������������������������������������������� 72
Examples����������������������������������������������������������������������������������������������� 72
Closable������������������������������������������������������������������������������������������������������������������ 73
Maskable���������������������������������������������������������������������������������������������������������������� 74
Button_sizable�������������������������������������������������������������������������������������������������������� 76
Summary����������������������������������������������������������������������������������������������� 81
■
■Chapter 8: Designing for JavaScript��������������������������������������������� 83
Use Ex Nihilo Constantly������������������������������������������������������������������������ 83
Array Literals���������������������������������������������������������������������������������������������������������� 83
Styles Objects��������������������������������������������������������������������������������������������������������� 84
Other Objects���������������������������������������������������������������������������������������������������������� 84
xi
■ Contents
■
■Chapter 9: On Constructors���������������������������������������������������������� 89
Constructor Magic��������������������������������������������������������������������������������� 89
The new Operator��������������������������������������������������������������������������������������������������� 89
The this Parameter������������������������������������������������������������������������������������������������� 90
The constructor.prototype��������������������������������������������������������������������������������������� 90
The “[[prototype]]” Property����������������������������������������������������������������������������������� 91
The Prototype’s Prototype�������������������������������������������������������������������������������������� 92
“[[prototype]]” Implies�������������������������������������������������������������������������������������������� 92
C Selected Websites������������������������������������������������������������������������������ 99
Wikipedia on Object-Oriented Programming, Class-Based
Inheritance and Prototypal Inheritance������������������������������������������������������������������ 99
The Author’s Web Site on Class-Based Inheritance
and JavaScript Programming������������������������������������������������������������������������������� 100
Other Web Sites on Class-Based Inheritance and Prototypal Inheritance������������ 100
xii
■ Contents
Index���������������������������������������������������������������������������������������������� 107
xiii
About the Author
Martin Rinehart, a self-confessed JavaScript lover, set aside work on his five-volume
frontend-engineering textbook project for long enough to write this small book on
JavaScript inheritance. He wanted to eliminate some of the massive confusion surrounding
this important subject. (Veterans of classical OOP backgrounds, and Martin is one, have to
unlearn much of what they think they “know.” Veteran JavaScripters have to stop abusing
the prototype chain.) Martin is the author of over a dozen books on programming, and of
the JSWindows system that brings a windowing UI to browser-based applications.
xv
A Note for the Implementers
JavaScript, or more exactly, the subset of JavaScript Crockford identifies as “The Good
Parts,” is a beautiful language. It is small, yet expressive. Its functional programming and
object programming gives it extraordinary depth. In nearly a half century of programming
I have used dozens of languages. Only two of them, JavaScript being one, have been
languages I’ve loved.
Today there are people working to free JavaScript from the browser, to further
empower JavaScript (WebGL, to mention a personal favorite) and to bring it up to
professional speed. My apologies to the latter group. In many ways, object programming
is the enemy of compiled speed.
So a word of encouragement and advice to our courageous implementers. First,
making JavaScript run at some reasonable fraction of C’s speed is a magnificent goal.
More power to you! (And yes, that’s self-serving. You are giving more power to all of us
who write JavaScript. We love it and we thank you for it.)
Second, removing object programming to gain speed cuts out the heart to save the
patient. Object programming is not your enemy, it is the essence of the language. Look
on it as a challenge, as the Everest of your profession. The view from the top will be
spectacular. Object programming at half the speed of C will be breathtaking.
xvii
Introduction
xix
Another Random Scribd Document
with Unrelated Content
features so as to conceal all but their ravishing eyes. And it is well that this
is so, for they plaster their faces with a composition of magnesia and the
whites of eggs that gives them a ghastly appearance, and effectually
conceals, as it ultimately destroys, the freshness and purity of their
complexions. This stuff is renewed at frequent intervals, and is never
washed off.
There is a popular prejudice against bathing. A man who has been on a
journey will not wash the dust off his face for several days after arrival,
particularly if he has come from a lower to a higher altitude, as it is
believed that the opening of the pores of the skin is certain to bring on a
fever.
While passing over a dusty road upon a hot, sultry day I dismounted at a
foaming brook, rolled up my sleeves, and commenced to bathe my head and
face and arms. The guide who was with me cried “Caramba!” in
astonishment, and tried to pull me away. When I demanded an explanation
of his extraordinary behavior he begged me for the love of the Virgin not to
wash my face, for I would certainly come down with the fever the next day.
I smiled at this remonstrance, and gave myself a refreshing bath, while he
looked on as solemnlv as if I intended to commit suicide. For an hour after,
as we travelled on, he muttered prayers to the Virgin and his patron saint to
protect me from the fever, and to-day no doubt believes that I was saved by
the interposition of Divine power in answer to his petitions. He afterwards
reproached me for not having made a vow because of my remarkable
deliverance.
COFFEE-DRYING.
and who was made commander-in-chief of the army of two hundred and
fifty men when Guardia took the Executive chair. He was a man of fine
appearance, but of dull and slow mental powers, spending most of his time
upon his hacienda, or plantation, and leaving the affairs of the State to his
secretaries, Don Jesus Maria Castro and Don Bernardo de Soto. Fernandez
died before the expiration of his term, in the spring of 1885, and was
succeeded by De Soto, a young man of whom much is expected. He was a
pet and protégé of the great Guardia, and after graduating at the University
of San José was sent to Europe to complete his education, and by a study of
the world as well as books to qualify himself to succeed his patron in the
Presidential chair. Guardia died, however, before De Soto had reached the
age that made him eligible to the Presidency, and Fernandez stepped in to
fill the interim. He conscientiously acted as a sort of trustee or executor of
Guardia’s will, and made the young man, then only twenty-seven, his
Minister of War, Education, and Public Works. When Fernandez died De
Soto assumed the Presidency, just as if he had inherited a crown, there
being no other candidate. The President has just passed his thirtieth
birthday, and commands the respect and confidence of the people.
Costa Rica was the first discovered of all the countries on this Continent,
but of its resources the least is known. The Cordilleras of the Andes pass
through the republic from the south-east to the north-west. South of Cartago
they divide into two ranges, one running up the Pacific coast, and the other
tending towards the Atlantic until it is broken off at Lake Nicaragua. These
ranges not only enclose rich valleys, in the chief of which is San José, but
along their slopes on either side are extensive tracts of land already cleared
and abounding in fertility. Along the coast are large areas of jungle and
plains of more or less extent, only slightly developed because of the
malarious atmosphere. The Pacific coast is healthier and more thickly
settled. A large prairie covers the northern part of the republic, upon which
many cattle are grazed, and it extends over the Nicaragua boundary. In the
north-eastern corner is an extensive forest, inhabited by bands of roaming
Indians, and full of the most valuable timber.
What the country needs is enterprise and capital, and these it must secure
by immigration. The population has increased somewhat during the last half
century, but entirely from natural causes, as more people have moved away
than have come in to settle. No attempt has been made by the Government
to attract immigrants until recently, for years ago the conservative element
of the population were opposed to inviting strangers into their midst. This
sentiment has, however, died out, and there is an increasing desire to do
something to call in capital and labor.
The staple products of the country are coffee, corn, sugar, cocoa,
bananas, and other tropical fruits, but only coffee and bananas are exported
in any quantity. The increase in the coffee crop has been very large, the
product in 1850 being fourteen million pounds, while in 1884 it was over
forty million. The quality is said to be superior to that grown elsewhere, and
the yield greater in proportion to the number of trees. England and France
take the greater share of the crop, the exports to the United States reaching
only eight million five hundred thousand pounds in 1884. The land is
practically free, for the Government sells it at a nominal price per acre, and
allows long time for payment. Quite a number of settlers from the United
States and the West Indies have come in recently and located on the line of
the eastern road, which is to connect Port Limon, on the Atlantic, with the
interior.
Note To Second Edition.—On the 29th and 30th of December, 1888, Costa Rica was
visited by the most destructive earthquake ever known there. Nearly all the cities and
settlements suffered more or less, but San José was almost entirely destroyed. Three-
fourths of the buildings were either shaken down or shattered beyond repair, including all
the official structures, the Capitol, the President’s residence, and the Cathedral. The loss to
the Government alone is estimated at $2,000,000, while that suffered by private individuals
was several times that amount. No official report upon the loss of life has been made, and
the estimates vary from three hundred to seven hundred and fifty.
BOGOTA.
BARRANQUILLA.
There are some fine old churches and palaces in Carthagena constructed
of stone, which show the magnificence in which the old grandees lived
when the city was a commercial metropolis. Many of them are empty now,
and others are used as tenement-houses. In the cathedral, which is one of
the largest and most elaborate to be found on the hemisphere, is a curious
object of interest. It is a magnificent marble pulpit covered with exquisite
carvings. It ranks among the most beautiful specimens of the sculptor’s art
in the world. The people of Carthagena think there is nothing under the sun
to equal it, and the story of its origin adds greatly to its value and interest.
Two or three hundred years ago the Pope, wishing to show a mark of favor
to the devout people of Colombia, ordered the construction of a marble
pulpit for the decoration of the grand cathedral at Carthagena. It was
designed and carved by the foremost artists of the day at Rome, and when
completed was with great ceremony placed on board a Spanish galley
bound for the New World. While en route the vessel was captured by
pirates, and when the boxes containing the pulpit were broken open, and
their contents found to be of no value as plunder, they were tipped
overboard. But by the interposition of the Virgin, none of the pieces sank;
and the English pirates, becoming alarmed at the miracle of the heavy
marble floating on the water, fled from the ship, leaving their booty. The
Spanish sailors got the precious cargo aboard their vessel again with great
difficulty, and started on their way; but before they reached Carthagena they
encountered a second lot of pirates, who plundered them of all the valuables
they had aboard, and burned their ship. But the saints still preserved the
pulpit; for, as the vessel and the remainder of the cargo were destroyed, the
carved marble floated away upon the surface of the water, and, being
guided by an invisible hand, went ashore on the beach outside the city to
which it was destined.
There it lay for many years, unknown and unnoticed. Finally, however, it
was discovered by a party of explorers, who recognized the value of the
carvings and took it aboard their ship en route for Spain, intending to sell it
when they reached home. But the saints still kept their eyes upon the Pope’s
offering, and sent the vessel such bad weather that the captain was
compelled to put into the port of Carthagena for repairs. There he told the
story of the marble pulpit found upon the beach, and it reached the ears of
the Archbishop. His Grace sent for the captain, informed him that the pulpit
was intended for the decoration of the cathedral, and related the story of its
construction and disappearance. The captain was an ungodly man, and
intimated that the Archbishop was attempting to humbug him. He offered to
sell the marble, and would not leave it otherwise. Having repaired the
damage of the storm, the captain started for Europe, but he was scarcely out
of the harbor when a most frightful gale struck him and wrecked his vessel,
which went to the bottom with all on board; but the pulpit, the subject of so
many divine interpositions, rose from the wreck, and one morning came
floating into the harbor of Carthagena, where it was taken in charge by the
Archbishop and placed in the cathedral for which it was intended, and
where it now stands.
Near the miraculous pulpit, in the same church, is the preserved body of
a famous saint. I forget what his name was, but he is in an excellent state of
preservation—a skeleton with dried flesh and skin hanging to the bones. He
did something hundreds of years ago which made him very sacred to the
people of Carthagena, and by the special permission of the Pope his body
was disinterred, placed in a glass case, and shipped from Rome to ornament
the cathedral of the former city, along with the miraculous pulpit. The body
is usually covered with a black pall, and is exposed only upon occasions of
great ceremony, but any one can see the preserved saint by paying a fee to
the priests. I purchased that privilege, and was shown the glass coffin
standing upon a marble pedestal. The bones are bare, except where the
brown skin, looking like jerked beef, covers them, and are a ghastly
spectacle. During a revolution at Carthagena some impious soldiers upset
the coffin and destroyed it. In the melée one of the saint’s legs was lost, or
at least the lower half of it from the knee down; but the priests replaced it
with a wax leg, plump and pink, which, lying beside the original, gives the
saint a very comical appearance.
There is much of interest to see at Carthagena, and the place has had a
most romantic and exciting history, being described at length in
“Thomson’s Seasons.” Again and again has it been sacked by the pirates, as
it was formerly the shipping-point for the product of the gold and silver
mines for which the mountains south of it have been so famous. Tons and
tons of gold and silver have been sent thence to Spain. In the times of the
viceroys the mines were worked under the direction of the Government.
One-fifth of the net product went to the King, another fifth to the Church,
while the miner was permitted to keep the remainder. The old records show
that the share of the King was several millions a year for two hundred years
or more, and that indicates how enormous the profit must have been; for the
miners and officials were no more honest in those days than now, and it is
not entirely certain that the share to which his Majesty was entitled always
reached him.
The fortifications of Carthagena surpass in extent and solidity those of
any city in the New World, and are still in good condition, although not
occupied, having been constructed without regard to expense and for all
time. The massive walls of the city are to all appearance impregnable, and
the ancient subterranean passages leading outward to the foot of the
adjacent mountains are still visible. The entrance to the magnificent harbor
is studded with ancient fortifications, which, though now unused for more
than half a century, seem almost as good as new. Formerly the city was
connected by ship-channel with the river Magdalena, at a point many
leagues above the delta, and was, therefore, in easy communication with the
fertile valleys and plateaux of the interior—the gate of commerce in time of
peace, and secure alike from protracted siege or successful assault in time
of war.
The decline of Carthagena seems to have commenced with the present
century, and to have steadily continued to within the past fifteen years,
when the commerce of the country began to revive. In the mean time the
ship-canal connecting the port with the great fluvial highway of the interior
having fallen into disuse, became filled up and overgrown with tropical
jungle; so that the few foreign trading-vessels visiting the coast sought
harborage farther up, at a place called Barranquilla, near the mouth of the
Magdalena. Barranquilla has become the chief city of commercial
importance within the United States of Colombia, and is the residence of
many of the principal merchants of the republic. It is a growing city, and
from a few houses twenty years ago it now has a population of upwards of
twenty-five thousand. Situated as it is, so near the outlet of the Magdalena
River, it is destined to increase in size and commerce, and to become to
Colombia what New York is to the United States—the great commercial
emporium of the republic; Aspinwall and Panama, free ports, being more a
highway of nations than a part of this country. To this end Barranquilla has
many things in its favor. The custom-house is located there. All the river
steamers and sailing-vessels on the Magdalena, conveying from the vast
back-lying interior to the coast the multitudinous products of the country,
start from and return to this place.
But Barranquilla has its drawbacks. As soon as it secured a little
commerce a large bar began to form at the mouth of the river, and has
grown until it has become a sand-spit which prevents the entrance of
steamers. Then a new town, called Sabanilla, was started on the spit, which
is connected with Barranquilla by a railway fourteen miles long, owned and
operated by a German company. But the harbor of Sabanilla, though now
the principal one of the republic, is neither convenient nor safe. It is
shallow, full of shifting sand-bars, and exposed to furious wind-storms;
while the new port of Barranquilla is quite inaccessible from the delta, by
reason of its treacherous sand-bars. So with the opening of the ancient
dique, or ship-channel, between Carthagena and Calamar, or the
construction of a railway between the first-named point and Barranquilla
(both of which enterprises are being agitated), Carthagena may regain her
ancient prestige and become the chief port of the republic.
Sabanilla is a most desolate place, nothing but sand, filth, and poverty;
and were it not for the sea-breeze that constantly sweeps across the barren
peninsula upon which it stands, the inhabitants could not survive. No one
lives there except a colony of cargadors, boatmen, and roustabouts, who
swarm, like so many animals, in filthy huts built of palm-leaves, and a few
saloon-keepers, who give them wine in exchange for the money they earn.
The men and women are almost naked, and the children entirely so. Perhaps
the reason for the nastiness of the place is because there is no fresh water;
but the inhabitants ought not to be excused on this account, as the beach
furnishes as fine bathing as can be found in the world, and is at their very
doors. All the fresh water used has to be brought in canoes from a point
eight miles up the river, and is sold by the dipperful: but only a moderate
quantity is necessary for consumption. Most of the inhabitants are Canary
Islanders, who monopolize the boating business along this coast; but
sprinkled among them are many Italians, and nearly every nation on earth is
represented, even China. The only laundry is run by a Chinaman, and
another is cook at a place that is used as a substitute for a hotel. The
boatmen are drunken, quarrelsome, desperate wretches; murder is frequent
among them, and fighting the chief amusement.
Barranquilla is the most modern town in
Colombia except Aspinwall, which it resembles
somewhat. It has some fine houses and quite a large
foreign colony, many of its merchants being
Germans, who live in good style, and enjoy many
comforts at an enormous cost; for flour is twenty-
five dollars a barrel and meat twenty-five cents a
pound, beer twenty-five cents a glass, and
everything else in proportion. There is nothing in
plenty but fruits and flies. The town is the capital of
the State of Sabanilla, and has a considerable
military garrison, which is important in keeping
down insurrections. During the revolution of 1885
Barranquilla was the headquarters of the
insurrectionary army, and, commanding the only
outlet from the interior, is naturally a place of
consequence, from a military as well as from a
commercial standpoint.
The great valley of the Magdalena, extending
from the Caribbean coast to the equatorial line, is
one of inexhaustible resources. Its width varies
from one hundred to one hundred and fifty miles COLOMBIAN
before gradually sloping to a point in the northern MILITARY MEN.
borders of the equator. At the mouth of the river
Cauca this valley branches off into another of less general width but of
greater elevation, and consequently possesses a more equable and temperate
climate. The river Cauca is itself navigable by a light-draught steamer as far
as Cali, a point less than eighty miles from the port of Buenaventura on the
Pacific coast. The lower valley of the Magdalena is one vast alluvial plain, a
large portion of which is subject to periodical overflow. In fact, during the
rainy season the greater portion of it is usually under water. This, however,
might be prevented, and the fertile lands reclaimed, by a system of dikes far
less expensive than those of the lower Mississippi. But in a country where
population is sparse, and Nature lavish in her bounties, such enterprises are
not usually undertaken.
The distance from Barranquilla to Honda, the head of navigation on the
Magdalena, is seven hundred and eighty miles, following the course of the
river, but in a direct line is only about one-third of that distance. The
journey by boat requires from ten to thirty days, according to the condition
of the river. In the rainy season the banks are full, and the current so strong
that the little steamers cannot make much progress; but if the moon is bright
enough to show the course, they are kept in motion night and day. In the dry
season the river is shallow, and the boats have to tie up at dark, and remain
so till daylight. Then, on nearly every voyage they run aground, and often
stick for a day or two, sometimes a week, before they can be got off.
The boats are similar to those used upon the Ohio and other rivers, with
a paddle-wheel behind, and draw only a foot or two of water even when
heavily laden, so that they can go over the bars. There are two steamboat
companies, both with United States capital; one is managed by a Mr. Joy,
and the other by a Mr. Cisneros, a naturalized Italian. During the revolution
all the boats were seized by the insurgents. Their sides were covered with
corrugated iron, so as to make them bullet-proof, a small cannon or two
mounted upon the decks, and the cabins filled with sharp-shooters. So
prepared, they were used as gun-boats, and were quite effective. Many of
them were destroyed, so that transportation facilities upon the Magdalena
are not so good as they were.
ON THE MAGDALENA.
The first two hundred miles is a continuous swamp; the next three
hundred miles is a vast plain, which is under water about two months in the
year, during the floods that follow the rainy season, but at other times is
covered with cattle, which are driven into the mountains before the floods
come.
The banks along the river were formerly occupied with profitable
plantations, which were worked by negro slaves, as neither the Spaniards
nor the native Indians could endure the climate and the mosquitoes. But
when the emancipation of the slaves took place, in 1824, the plantations
were abandoned, and have since been so overgrown with tropical vegetation
that no traces of their former cultivation exist. The negroes, who have
descended from the former slaves, have relapsed into a condition of semi-
barbarism, and while they still occupy the old estancias, lead a lazy,
shiftless, degraded life, subsisting upon fish and the fruits which grow
everywhere in wonderful profusion. Nature provides for them, and no
amount of wages can tempt them to work. A few small villages have sprung
up along the river, which are trading stations, and furnish some freight for
the steamers in the shape of fruit, poultry, eggs, cocoa-nuts, and similar
articles, which are attended to by the women of the country.
The river itself is a great natural curiosity. It flows almost directly
northward, and drains an enormous area of mountains which are constantly
covered with snow. The current is as swift as that of the Mississippi, which
it resembles, and the water, always muddy, is so full of sediment that one
can hear it striking the sides of the boat. The water will not mix with that of
the sea, and for fifty miles into the ocean it can be distinguished. In some
places it is seven or eight miles wide, at others it is scarcely more than a
hundred yards, where it has cut its way through the rolling earth. The
channel, which has never been cleared, is full of treacherous bars and snags,
which are continually shifting, and make it necessary to tie up the steamer
every night, except in times of high water during the rainy season. The
mosquitoes are monumental in size, and at some seasons of the year, when
the winds are strong and blow them from the jungles, it is almost
impossible to endure them. The officers and deck hands of the boat all wear
thick veils over their faces, and heavy buckskin gloves, awake or asleep;
and the passengers, unless similarly protected, are subject to the most
intense torment. Often the swarms are so thick that they obscure the sky,
and the sound of humming is so loud that it resembles the murmur of an
approaching storm.
COLOMBIAN ’GATORS.
Some ludicrous stories are told about adventures with the mosquitoes. I
have been solemnly assured that oftentimes when they have attacked a boat
and driven its captain and crew below, they have broken the windows of the
cabin by plunging in swarms against them, and have attempted to burst in
the doors. Although this may be somewhat of an exaggeration, it is
nevertheless true that frequently horses and cattle, after the most frightful
sufferings, have died from mosquito bites on board the vessels. Not long
ago a herd of valuable cattle were being taken from the United States to a
ranch up the Magdalena River, and became so desperate under the attacks
of the mosquitoes that they broke from their stalls, jumped into the water,
and were all drowned. Passengers intending to make the voyage always
provide themselves with protection in the shape of mosquito-bars, head-
nets, and thick gloves, and when on deck are compelled to tie their sleeves
around their wrists and their pantaloons around their ankles.
The alligators are so numerous along the banks that the same story-
tellers assert that you could step from the back of one to another, and thus
walk for miles without touching ground. They are playful creatures, and not
at all timid, but bask quietly in the sun until disturbed, when they plunge
into the river. The steamboats are always followed by schools of them, and
the passengers amuse themselves by firing at them from the deck. No
attempt has been made to kill them for profit, but if some enterprising
hunters should go to the Magdalena country and make a business of curing
and shipping alligator hides, they would find it a profitable venture.
Once or twice a day the steamboats stop for freight or fuel, which is
supplied them by the settlers, and brought on board by naked negroes.
The town of Honda, at the head of navigation, is a place of considerable
importance, and at intervals for the last quarter of a century American
companies have undertaken the construction of a railroad from it to Bogota
—a distance of seventy miles through mountains. About ten leagues of
track have been built, but those in charge have been compelled again and
again to abandon it because of the revolutions and the impossibility of
securing labor. The natives cannot be induced to work, and no wages that
the company can pay will induce immigration. But the enterprise is being
slowly extended, with the encouragement of the Government in the shape
of a concession of money and lands, and ultimately the perseverance which
conquers all things will succeed. There is also a liberal concession from the
Government to another syndicate of New York capitalists for the
construction of a railway into the Cauca valley, where are supposed to be
the richest goldmines in the world, from which the hundreds of millions
taken away by the Spaniards came.
From Honda to Bogota the journey must be made on mule-back, and it
requires four days to cover the seventy miles. Recently there has been a line
of stagecoaches established between Bogota and the town of Agrialarge,
which shortens the time a day, and the distance by saddle thirty miles. In
describing the journey Mr. Scruggs, recently United States Minister to
Colombia, says:
SABANA OF BOGOTA.
“When the vehicle finally reaches the plain, the pieces are collected and
put together by some smithy who may have learned the art from an
American or English mechanic. One scarcely knows which ought to be the
greatest marvel, the failure to manufacture all these things in a country
where woods and coal and iron ore are so abundant, or the obstacles that are
overcome in their successful importation from foreign countries.
“At the time of the Spanish conquest, in 1537, the inhabitants of this
region were the Chibchas, who, according to Quesada, numbered about
three-quarters of a million. Their form of government was essentially
patriarchal, and their habits were those of an agricultural people given to the
arts of peaceful industry. Their religion contained much to remind us of the
ancient Buddhists. It imposed none of those revolting sacrifices of human
victims which marked the rituals of the Aztecs. They had their divine
Mediata in Bohica, or Deity of Mercy. Their Chibchacum corresponded to
the Buddhist god of Agriculture. Their god of Science, as represented by
earthen images which I have examined, was almost identical with the
Buddhist god of Wisdom, as represented by the images in some of the
Chinese temples. They had also a traditional Spirit of Evil, corresponding to
Neawatha of the ancient Mexicans and to the Satan of the Hebrews. And
connected with their flood myth was a character corresponding to the
Hebrew Noah, the Greek Ducalaine, and the Mexican Cojcoj.
“The capital of the Chibchan empire was Bocata, of which Bogota is
manifestly a mere corruption. It was situated near the site of the present
Colombian capital. But their most ancient political capital was Mangueta,
near the site of the present village of Funza, on the opposite side of the
plain. Near the site of the present grand cathedral, in the heart of the present
city of Bogota, was a temple consecrated to the god of Agriculture. Here the
Emperor and his cacique, accompanied by the chief men of the country,
were wont to assemble twice a year and offer oblations to the deity who was
supposed to preside over the harvests—a ceremony not unlike the ‘moon
feasts’ celebrated to-day in many of the interior districts of China.
“The altitude of the plain above the sea-level is 8750 feet, and its mean
temperature is about 59° Fahrenheit. The atmosphere is thin, pure, and
exhilarating, but it is perhaps not conducive either to longevity or great
mental activity. A man, for instance, accustomed to eight hours’ daily
mental labor in New York or Washington will here find it impossible to
apply himself closely for more than five hours each day. If he exceeds that
limit ominous symptoms of nervous prostration will be almost sure to
follow.”
SANTA FÉ DE BOGOTA.
were repealed, the education of the children was intrusted again to the
priests, and the monks and nuns were permitted to return to the country and
reoccupy the cloisters from which they were expelled by the Liberal party
several years before. The monasteries, convents, and valuable productive
estates which had been confiscated by the Government from time to time
since 1825 were restored to the religious orders; and all the educational
institutions, including the university, themedical, law, and other scientific
schools, the learned societies, the observatory, the libraries, and museums,
were removed from the charge of the civil minister of education, placed
under the care of the archbishop, with a liberal subsidy from the public
treasury for their maintenance, and by the terms of the “concordat” devoted
forever “to the glorification and advancement of the Holy Catholic
Church.” In one or two of the seaports Protestant missionaries are getting a
foothold, but very slowly, as everything is against them. The unconquered
Indian tribes retain their peculiar religious rites.
Lately banks and bankers have multiplied to a
great extent. Paper-money, heretofore almost
unknown, is fast supplanting the coin of the
country. This places a great power in the hands of
the bankers. They are allowed to issue bills far
Welcome to our website – the ideal destination for book lovers and
knowledge seekers. With a mission to inspire endlessly, we offer a
vast collection of books, ranging from classic literary works to
specialized publications, self-development books, and children's
literature. Each book is a new journey of discovery, expanding
knowledge and enriching the soul of the reade
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.
textbookfull.com