100% found this document useful (2 votes)
33 views

Developing Web Applications with Apache MySQL memcached and Perl 1 Original Edition Patrick Galbraith download pdf

Applications

Uploaded by

seniacerda28
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
100% found this document useful (2 votes)
33 views

Developing Web Applications with Apache MySQL memcached and Perl 1 Original Edition Patrick Galbraith download pdf

Applications

Uploaded by

seniacerda28
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 50

Download the full version of the ebook at ebookname.

com

Developing Web Applications with Apache MySQL


memcached and Perl 1 Original Edition Patrick
Galbraith

https://ebookname.com/product/developing-web-applications-
with-apache-mysql-memcached-and-perl-1-original-edition-
patrick-galbraith/

OR CLICK BUTTON

DOWNLOAD EBOOK

Download more ebook instantly today at https://ebookname.com


Instant digital products (PDF, ePub, MOBI) available
Download now and explore formats that suit you...

Beginning PHP Apache MySQL web development Michael K.


Glass

https://ebookname.com/product/beginning-php-apache-mysql-web-
development-michael-k-glass/

ebookname.com

Sams Teach Yourself PHP MySQL and Apache All in One Julie
C. Meloni

https://ebookname.com/product/sams-teach-yourself-php-mysql-and-
apache-all-in-one-julie-c-meloni/

ebookname.com

Web Graphics Perl TK Best of the Perl Journal 1st Edition


Jon Orwant Ph.D.

https://ebookname.com/product/web-graphics-perl-tk-best-of-the-perl-
journal-1st-edition-jon-orwant-ph-d/

ebookname.com

Voices Postgraduate Perspectives on Inter disciplinarity


1st Edition Kathryn Vincent

https://ebookname.com/product/voices-postgraduate-perspectives-on-
inter-disciplinarity-1st-edition-kathryn-vincent/

ebookname.com
Introduction to Probability and Statistics for Engineers
and Scientists Third Edition Sheldon M. Ross

https://ebookname.com/product/introduction-to-probability-and-
statistics-for-engineers-and-scientists-third-edition-sheldon-m-ross/

ebookname.com

Which contract choosing the appropriate building contract


Sixth Edition Lupton

https://ebookname.com/product/which-contract-choosing-the-appropriate-
building-contract-sixth-edition-lupton/

ebookname.com

1 001 Best Slow Cooker Recipes The Only Slow Cooker


Cookbook You ll Ever Need Sue Spitler

https://ebookname.com/product/1-001-best-slow-cooker-recipes-the-only-
slow-cooker-cookbook-you-ll-ever-need-sue-spitler/

ebookname.com

The Everything Guide To Writing A Book Proposal Insider


Advice On How To Get Your Work Published Everything 3rd
Edition Schneider
https://ebookname.com/product/the-everything-guide-to-writing-a-book-
proposal-insider-advice-on-how-to-get-your-work-published-
everything-3rd-edition-schneider/
ebookname.com

Recursive Macroeconomic Theory Third Edition Lars


Ljungqvist

https://ebookname.com/product/recursive-macroeconomic-theory-third-
edition-lars-ljungqvist/

ebookname.com
Tarascon Pediatric Emergency Pocketbook 7th Edition
Mahajan

https://ebookname.com/product/tarascon-pediatric-emergency-
pocketbook-7th-edition-mahajan/

ebookname.com
Developing Web Applications with Perl,
memcached, MySQL® and Apache
Foreword . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xxv
Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xxvii
Chapter 1: LAMMP, Now with an Extra M . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1
Chapter 2: MySQL . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15
Chapter 3: Advanced MySQL . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 85
Chapter 4: Perl Primer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 163
Chapter 5: Object-Oriented Perl. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 211
Chapter 6: MySQL and Perl . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 245
Chapter 7: Simple Database Application . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 285
Chapter 8: memcached . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 313
Chapter 9: libmemcached . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 359
Chapter 10: Memcached Functions for MySQL . . . . . . . . . . . . . . . . . . . . . . . . . . . . 383
Chapter 11: Apache . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 417
Chapter 12: Contact List Application . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 503
Chapter 13: mod_perl . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 565
Chapter 14: Using mod_perl Handlers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 601
Chapter 15: More mod_perl . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 633
Chapter 16: Perl and Ajax . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 707
Chapter 17: Search Engine Application . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 739
Appendix A: Installing MySQL . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 793
Appendix B: Configuring MySQL . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 811
Index . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 831
Developing Web Applications with Perl,
memcached, MySQL® and Apache

Patrick Galbraith

Wiley Publishing, Inc.


®
Developing Web Applications with Perl, memcached, MySQL and Apache
Published by
Wiley Publishing, Inc.
10475 Crosspoint Boulevard
Indianapolis, IN 46256
www.wiley.com
Copyright © 2009 by Wiley Publishing, Inc., Indianapolis, Indiana
Published simultaneously in Canada

ISBN: 978-0-470-41464-4

Manufactured in the United States of America


10 9 8 7 6 5 4 3 2 1

No part of this publication may be reproduced, stored in a retrieval system or transmitted in any form or by any
means, electronic, mechanical, photocopying, recording, scanning or otherwise, except as permitted under Sections
107 or 108 of the 1976 United States Copyright Act, without either the prior written permission of the Publisher, or
authorization through payment of the appropriate per-copy fee to the Copyright Clearance Center, 222 Rosewood
Drive, Danvers, MA 01923, (978) 750-8400, fax (978) 646-8600. Requests to the Publisher for permission should be
addressed to the Permissions Department, John Wiley & Sons, Inc., 111 River Street, Hoboken, NJ 07030, (201)
748-6011, fax (201) 748-6008, or online at http://www.wiley.com/go/permissions.
Limit of Liability/Disclaimer of Warranty: The publisher and the author make no representations or warranties with
respect to the accuracy or completeness of the contents of this work and specifically disclaim all warranties, including
without limitation warranties of fitness for a particular purpose. No warranty may be created or extended by sales or
promotional materials. The advice and strategies contained herein may not be suitable for every situation. This work
is sold with the understanding that the publisher is not engaged in rendering legal, accounting, or other professional
services. If professional assistance is required, the services of a competent professional person should be sought.
Neither the publisher nor the author shall be liable for damages arising herefrom. The fact that an organization or
Web site is referred to in this work as a citation and/or a potential source of further information does not mean that
the author or the publisher endorses the information the organization or Web site may provide or recommendations
it may make. Further, readers should be aware that Internet Web sites listed in this work may have changed or
disappeared between when this work was written and when it is read.
For general information on our other products and services please contact our Customer Care Department within the
United States at (877) 762-2974, outside the United States at (317) 572-3993 or fax (317) 572-4002.

Library of Congress Control Number: 2009927343


Trademarks: Wiley, the Wiley logo, Wrox, the Wrox logo, Wrox Programmer to Programmer, and related trade dress
are trademarks or registered trademarks of John Wiley & Sons, Inc. and/or its affiliates, in the United States and
other countries, and may not be used without written permission. MySQL is a registered trademark of MySQL AB.
All other trademarks are the property of their respective owners. Wiley Publishing, Inc., is not associated with any
product or vendor mentioned in this book.

Wiley also publishes its books in a variety of electronic formats. Some content that appears in print may not be
available in electronic books.
To my wonderful wife, Ruth, whom I have known for 27 years and who has stood by me while writing
this book, even when I couldn’t give her the time she deserved. Also, to my dear friend Krishna,
who gave me inspiration every day.
Credits
Acquisitions Editor Vice President and Executive Group
Jenny Watson Publisher
Richard Swadley
Project Editor
Maureen Spears Vice President and Executive Publisher
Barry Pruett
Technical Editor
John Bokma Associate Publisher
Jim Minatel
Production Editor
Rebecca Coleman Project Coordinator, Cover
Lynsey Stanford
Copy Editor
Sara E. Wilson Proofreader
Corina Copp, Word One
Editorial Manager
Mary Beth Wakefield Indexer
Robert Swanson
Production Manager
Tim Tate
About the Author
Patrick Galbraith lives up in the sticks of southwestern New Hampshire near Mt. Monadnock with
his wife, Ruth. Since 1993, he has been using and developing open source software. He has worked on
various open source projects, including MySQL, Federated storage engine, Memcached Functions for
MySQL, Drizzle, and Slashcode, and is the maintainer of DBD::mysql. He has worked at a number of
companies throughout his career, including MySQL AB, Classmates.com, OSDN/Slashdot. He currently
works for Lycos. He is also part owner of a wireless broadband company, Radius North, which provides
Internet service to underserved rural areas of New Hampshire. His web site, which comes by way of a
5.8GHz Alvarion access unit up in a pine tree, is http://patg.net.

About the Technical Editor


John Bokma is a self-employed Perl programmer and consultant from the Netherlands. He has been
working professionally in software development since 1994, moving his primary focus more and
more toward the Perl programming language. John and his wife, Esmeralda, currently live in the
state of Veracruz, Mexico, with their daughter Alice. John’s other two children, Jim and Laurinda,
live with their mother in New Zealand. For more information or to contact John, visit his web site at
http://johnbokma.com/.
Acknowledgments

One weekend in 1993, I had the chance to go on a getaway to San Diego. Instead, I opted to stay home
and download, onto 26 floppies, Slackware Linux, which I promptly installed onto my Packard Bell 386.
I could never get the built-in video card to work with X, so I ended up buying a separate video card and
had to edit my XConfig file to get it to work. How much more interesting this was to do than editing a
config.sys and an autoexec.bat! From then on, I was hooked. I worked at Siemens Ultrasound Group in
Issaquah, Washington, at the time. An engineer there named Debra, when asked what was a good thing
to learn, said something I’ll never forget: ‘‘Learn Perl.’’ Debra — you were right!

I always wanted to be a C++ graphics programmer. That didn’t happen because of this thing called the
World Wide Web. I remember Ray Jones and Randy Bentson of Celestial Software showing me a program
called Mosaic, which allowed you to view text over the Internet. Images would be launched using XV.
Everywhere I worked, I had to write programs that ran on the Web, which required me to write CGI in
Perl. So much for my goal of being a C++ programmer — but I consider this a great trade for a great
career. (I did eventually get to write C++ for MySQL!)

I would first like to thank my editor, Maureen Spears, who is not only a great editor, but also a friend.
She gave me much-needed encouragement throughout the writing of this book.

A special thanks goes to John Bokma for his meticulous attention to detail and great knowledge of
Perl — particularly with regard to Perl programming style and convention that I didn’t realize had
changed over the last several years. I was somewhat set in my ways!

Thank you to Jenny Watson, who gave me the opportunity to write this book in the first place!

Thanks to Monty Widenius for creating MySQL and for being a mentor as well as a good friend, and
thanks, Monty, for looking over Chapters 1, 2, and 3! Thanks also to Brian Aker for being another great
mentor and friend, as well as being a software-producing machine with a scrolling page full of open
source software projects that he’s created, including Drizzle and libmemcached. Thanks to Sheeri Kritzer
for her encouragement and for listening to me — she finished her book not too long before I finished
mine, so she understood completely what I was going through.

I’d like to thank my friend, Wes Moran, head of design for Sourceforge, for providing the nice, clean,
simple HTML design I used for many of the examples in this book.

Thanks to Eric Day for his excellent input and review of chapters pertaining to Gearman.

A special thanks to Joaquı́n Ruiz of Gear 6, who provided a lot of input on Chapter 1, as well as Jeff
Freund of Clickability and Edwin Desouza and Jimmy Guerrero of Sun, who put me in touch with others
and were great sources of memcached information.

I would like to thank my current colleagues at Lycos, and former colleagues at Grazr and MySQL, as
well as the team members of Drizzle, for their part in my professional development, which gave me the
ability to write this book. Thanks also to anyone I forgot to mention!
Acknowledgments
Finally, I would like to thank the entire Open Source community. My life would not be the same without
open source software.

There’s a verse in an ancient book, the Bhagavad Gita, that aptly describes how people like Monty
Widenius, Linus Torvalds, Larry Wall, Brian Aker and other leaders within the Open Source community
inspire the rest of us:

‘‘Whatever action a great man performs, common men follow. And whatever standards he sets by exemplary acts,
all the world pursues.’’

x
Contents

Foreword xxv
Introduction xxvii

Chapter 1: LAMMP, Now with an Extra M 1


Linux 2
Apache 3
MySQL 4
memcached 5
Gear6 6
Clickability 6
GaiaOnline 7
How memcached Can Work for You 7
Perl 8
Other Technologies 10
Sphinx 10
Gearman 11
The New Picture 11
The Future of Open-Source Web Development and Databases 12
Projects to Watch! 13
Summary 13
Chapter 2: MySQL 15
How CGI and PHP Changed the Web Dramatically 15
About MySQL 16
MySQL Programs 19
Client Programs 20
Utility Programs 25
MySQL Daemon and Startup Utilities 27
Working with Data 28
Creating a Schema and Tables 29
Inserting Data 35
Querying Data 38
Updating Data 50
Deleting Data 52
Contents
Replacing Data 56
INSERT ... ON DUPLICATE KEY UPDATE 57
Operators 58
Functions 59
Using Help 70
User-Defined Variables in MySQL 72
MySQL Privileges 74
MySQL Access Control Privilege System 75
MySQL Global System User 75
MySQL System Schema Grant Tables 76
Account Management 80
Summary 84
Chapter 3: Advanced MySQL 85
SQL Features 85
Stored Procedures and Functions 86
Triggers 94
Views 102
User Defined Functions 105
Storage Engines 111
Commonly Used Storage Engines 112
Storage Engine Abilities 113
Using Storage Engines 113
MyISAM 115
InnoDB 118
Archive 123
The Federated Storage Engine 125
Tina/CSV Storage Engine 130
Blackhole Storage Engine 132
Replication 133
Replication Overview 133
Replication schemes 134
Replication Command Options 137
Setting Up Replication 139
Searching Text 148
When to Use Sphinx 161
Summary 162
Chapter 4: Perl Primer 163
What Exactly Is Perl? 163
Perl Primer 165

xii
Contents
Perl Data Types 165
Scalars 165
Arrays 167
Hashes 167
File Handles 168
Type Globs 168
Subroutines 168
Variable Usage 168
References 169
Scalar Usage 173
Array Usage and Iteration 174
Working with Hashes 179
Writing to Files 184
STDOUT and STDERR 184
File Handles to Processes 185
Subroutines 186
Variable Scope 189
Packages 192
Perl Modules 193
Writing a Perl Module 194
@ISA array 197
Documenting Your Module 197
Making Your Module Installable 201
Testing 201
Adding a MANIFEST file 204
CPAN 205
Regex One-Liners 206
Storing Regular Expressions in Variables 207
Regex Optimizations 208
Perl 6 Tidbits 208
Summary 210

Chapter 5: Object-Oriented Perl 211


About Object Orientation 212
Object Orientation in Perl 213
Writing a Perl Class 213
Adding Methods 217
On-Demand Method Manifestation Using AUTOLOAD 221
Other Methods 231
Making Life Easier: Moose 240
Summary 244

xiii
Exploring the Variety of Random
Documents with Different Content
Trade and industry, I say, owed their establishment to the
ambition of princes, who supported and favoured the plan in the
beginning, principally with a view to enrich themselves, and thereby
to become formidable to their neighbours. But they did not discover,
until experience taught them, that the wealth they drew from such
fountains was but the overflowing of the spring; and that an
opulent, bold, and spirited people, having the fund of the prince’s
wealth in their own hands, have it also in their own power, when it
becomes strongly their inclination, to shake off his authority. The
consequence of this change has been the introduction of a more
mild, and a more regular plan of administration. The money
gatherers are become more useful to princes, than the great lords;
and those who are fertile in expedients for establishing public credit,
and for drawing money from the coffers of the rich, by the
imposition of taxes, have been preferred to the most wise and most
learned counsellors.
As this system is new, no wonder if it has produced phenomena
both new and surprizing. Formerly, the power of Princes was
employed to destroy liberty, and to establish arbitrary subordination;
but in our days, we have seen those who have best comprehended
the true principles of the new plan of politics, arbitrarily limiting the
power of the higher classes, and thereby applying their authority
towards the extension of public liberty, by extinguishing every
subordination, other than that due to the established laws.
The fundamental maxim of some of the greatest ministers, has
been to restrain the power of the great lords. The natural inference
that people drew from such a step, was, that the minister thereby
intended to make every thing depend on the prince’s will only. This I
do not deny. But what use have we seen made of this new
acquisition of power? Those who look into events with a political
eye, may perceive several acts of the most arbitrary authority
exercised by some late European sovereigns, with no other view
than to establish public liberty upon a more extensive bottom. And
although the prerogative of some princes be increased considerably
beyond the bounds of the antient constitution, even to such a
degree as perhaps justly to deserve the name of usurpation; yet the
consequences resulting from the revolution, cannot every where be
said, upon the whole, to have impaired what I call public liberty. I
should be at no loss to prove this assertion from matters of fact, and
by examples, did I think it proper: it seems better to prove it from
reason.
When once a state begins to subsist by the consequences of
industry, there is less danger to be apprehended from the power of
the sovereign. The mechanism of his administration becomes more
complex, and, as was observed in the introduction to the first book,
he finds himself so bound up by the laws of his political oeconomy,
that every transgression of them runs him into new difficulties.
I only speak of governments which are conducted systematically,
constitutionally, and by general laws; and when I mention princes, I
mean their councils. The principles I am enquiring into, regard the
cool administration of their government; it belongs to another
branch of politics, to contrive bulwarks against their passions, vices
and weaknesses, as men.
I say, therefore, that from the time states have begun to be
supported by the consequences of industry, the plan of
administration has become more moderate; has been changing and
refining by degrees; and every change, as has been often observed,
must be accompanied with inconveniencies.
It is of governments as of machines, the more they are simple,
the more they are solid and lasting; the more they are artfully
composed, the more they become useful; but the more apt they are
to be out of order.
The Lacedemonian form may be compared to the wedge, the
most solid and compact of all the mechanical powers. Those of
modern states to watches, which are continually going wrong;
sometimes the spring is found too weak, at other times too strong
for the machine: and when the wheels are not made according to a
determined proportion, by the able hands of a Graham, or a Julien le
Roy, they do not tally well with one another; then the machine
stops, and if it be forced, some part gives way; and the workman’s
hand becomes necessary to set it right.
CHAP. XIV.
Security, Ease and Happiness, no inseparable Concomitants of Trade and Industry.

The republic of Lycurgus represents the most perfect plan of


political oeconomy, in my humble opinion, anywhere to be met with,
either in antient or modern times. That it existed cannot be called in
question, any more than that it proved the most durable of all those
established among the Greeks; and if at last it came to fail, it was
more from the abuses which gradually were introduced into it, than
from any vice in the form.
The simplicity of the institution made the solidity of it; and had the
Lacedemonians at all times adhered to the principles of their
government, and spirit of their constitution, they might have perhaps
subsisted to this very day.
My intention, in this chapter, is not to enter into a critical
disquisition concerning the mechanism of every part of the Spartan
republic; but to compare the general plan of Lycurgus’s political
oeconomy with the principles we have been laying down.
Of this plan we have a description in the life of that legislator
written by Plutarch, one of the most judicious authors to be met with
in any age.
This historian flourished at least 800 years after the institution of
the plan he describes. A plan never reduced into a system of written
laws, but stamped at first upon the minds of the Spartans by the
immediate authority of the gods, which made them submit to the
most violent revolution that perhaps ever took place in any nation,
and which they supported for so many ages by the force of
education alone.
As the whole of Lycurgus’s laws was transmitted by tradition only,
it is not to be supposed, that the description Plutarch, or indeed any
of the antients, have given us of this republic, can be depended on
with certainty as a just representation of every part of the system
laid down by that great statesman. But on the other hand, we may
be very sure, that as to the outlines of the institution, we have them
transmitted to us in all their purity; and, in what relates to my
subject, I have no occasion to launch out into any particulars which
may imply the smallest controversy, as to the matter of fact.
Property among the Lacedemonians, at the time when Lycurgus
planned his institution, was very unequally divided: the consequence
of which, says our historian, was to draw many poor people into the
city, where the wealth was gathered into few hands; that is,
according to our language, the luxury of the rich, who lived in the
city, had purged the lands of useless mouths, and the instability of
the government had rendered industry precarious, which must have
opened the door to general distress among all the lower classes.
The first step our legislator took, was to prepare the spirit of the
people, so as to engage them to submit to a total reform, which
could not fail of being attended with innumerable inconveniencies.
For this purpose he went to Delphi, without having communicated
his design to any body. The Pythia declared him to be the darling of
the gods, and rather a god than a man; and publicly gave out, that
Apollo had delivered to him alone the plan of a republic which far
exceeded every other in perfection.
What a powerful engine was this in the hands of a profound
politician, who had travelled over the world with a previous intention
to explore the mysteries of the science of government! and what
advantages did such an authentic recommendation, coming directly
(as was believed) from the voice of the Divinity, give him over a
superstitious people, in establishing whatever form of government
he thought most proper!
The sagacious Lacedemonian did not, however, entirely depend
upon the blind submission of his countrymen to the dictates of the
oracle; but wisely judged that some preparatory steps might still be
necessary. He communicated, therefore, his plan, first to his friends,
and then by degrees to the principal people of the state, who
certainly never could have been brought to relish an innovation so
prejudicial to their interest, had it not been from the deepest
reverence and submission to the will of the gods. Assured of their
assistance, he appeared in the market place, accompanied by his
party, all in arms; and having imposed respect, he laid the
foundation of his government by the nomination of a senate.
Whatever regards any other object than his plan of political
oeconomy, shall be here passed over in silence. It is of no
consequence to my inquiry, where the supreme power was vested: it
is sufficient to know that there was an authority in the state
sufficient to support the execution of his plan.
He destroyed all inequality at one stroke. The property of all the
lands of the state was thrown together, and became at the disposal
of the legislator. Every branch of industry was proscribed to the
citizens. And a monied interest was made to disappear, by the
introduction of iron coin. The lands he divided into equal lots,
according to the number of citizens.
Thus all were rendred entirely equal in point of fortune, as neither
wealth, industry, or lands, could give a superiority to any body. From
this part of the plan I conclude, that Lycurgus discovered the utter
insufficiency of an agrarian law for establishing equality among the
individuals of a state, without proscribing, at the same time, both
wealth and industry. A circumstance which seems to have escaped
every other statesman in antient times, as well as the modern
patrons of equality and simplicity of manners. The lands were
cultivated by the Helotes, who were nourished from them, and who
were obliged to deliver the surplus, that is, a determined quantity of
fruits, to the proprietor of the lot. Every necessary mechanic art was
likewise exercised by this body of slaves.
By this distribution, the produce of the earth (that is every article
of nourishment) came free and without cost to every individual of
the state. The Spartan landlords were rather overseers of the slaves,
and collectors of the public subsistence, than direct proprietors of
the soil which produced it. For although every man was fed from his
own lands, and provided his own portion, yet this portion was
regulated, and was to be consumed in public; and any one who
pretended to eat alone, or before he came to the public hall, was
held in the utmost contempt.
Their cloathing was the most simple possible, perfectly alike, and
could be purchased for a small value. This frugality produced no bad
effect; because no man lived by his industry. Arts, as has been said,
were exercised by the Helotes, the property of private citizens; and if
such masters as entertained manufacturing slaves gained by that
traffic (as some must do) every method of profiting of their superior
riches was cut off.
The Spartans were continually together, they had nothing to do
but to divert themselves; and their amusements were mostly martial
exercises. The regulations of these numerous assemblies (which
were compared, with great elegance and justness, to swarms of
bees) cut off all outward marks of distinction. There was not a
possibility for luxury to introduce itself, either in eating, drinking,
cloathing, furniture, or any other expence.
Here then was a whole nation fed and provided for gratuitously;
there was not the least occasion for industry; the usefulness of
which we have shewn principally to consist in its proving an
expedient for procuring for the necessitous, what the Spartans found
provided for them without labour.
Under such circumstances we may conclude, from the principles
we have laid down, that a people thus abundantly nourished, must
have multiplied exceedingly. And so no doubt they did. But the
regulation of the lots permitted no more than a fixt number of
citizens. Whenever, therefore, numbers were found to exceed this
standard, the supernumeraries were dismissed, and sent to form
colonies. And when the Helotes increased too much, and thereby
began to rise above the proportion of the labour required of them, in
order to prevent the consuming the food of their masters, which
they had among their hands, and thereby becoming idle, licentious,
and consequently dangerous to the state, it was permitted to
destroy them by way of a military exercise, conducted by stratagem
and address; arts which this people constantly preferred in war, to
labour, strength, and intrepidity.
This appears a very barbarous custom, and I shall not offer any
thing as an apology for it, but the ferocity of the manners of those
times. Abstracting from the cruelty, the restraining the numbers of
that class within certain limits, was absolutely necessary. The
Lacedemonian slaves were in many respects far happier than those
of other nations. They were in reality a body of farmers, which paid
a certain quantity of fruits out of every lot; to wit, 70 medimni of
barley: their numbers were not recruited from abroad, as elsewhere,
but supported by their own propagation; consequently there was an
absolute necessity either to prevent the over multiplication of them,
or to diminish an income proportioned exactly to the necessities of
the state: and what expedient could be fallen upon? They were
slaves, and therefore could not be inrolled in the number of citizens;
they could not be sold to strangers, for money which was forbid; and
they were of no use to industry. No wonder then if the fierceness of
the manners of those days permitted the inhuman treatment they
received; which, however, Plutarch is far from attributing to the
primitive institution of Lycurgus. Besides, when we see that the
freemen themselves were obliged to quit the country the moment
their numbers exceeded a certain standard, it was not to be
expected, that useless slaves should be permitted to multiply at
discretion.
From this sketch of Lycurgus’s political oeconomy, we find the
state abundantly provided with every necessary article; an effectual
stop put to vicious procreation among the citizens; and a corrective
for the over multiplication of the slaves. The next care of a
statesman is to regulate the employment of a people.
Every freeman in the state was bred up from his infancy to arms.
No family care could prevent him from serving the state as a soldier;
his children were no load upon him; it was the business of the
Helotes to supply them with provisions; of the servants in town to
prepare these, and the public tables were always ready furnished.
The whole youth of Sparta was educated not as the children of their
parents, but of the state. They imbibed the same sentiments of
frugality, temperance, and love of simplicity. They exercised the
same employment, and were occupied in the same way in every
respect. The simplicity of Lycurgus’s plan, rendered this a practicable
scheme. The multiplicity and variety of employments among us,
makes it absolutely necessary to trust the parents with the education
of their children; whereas in Sparta, there were not two
employments for a free man; there was neither orator, lawyer,
physician, or politician, by profession to be found. The institutions of
their lawgiver were constantly inculcated by the old upon the minds
of the young; every thing they heard or saw, was relative to war.
The very gods were represented in armour, and every precept they
were taught, tended to banish superfluity, and to establish
moderation and hard living.
The youth were continually striving together in all military
exercises; such as boxing and wrestling. To keep up, therefore, a
spirit of emulation, and to banish animosity at the same time, sharp,
satirical expressions were much encouraged; but these were always
to be seasoned with something gracious or polite. The grave
demeanour likewise, and down-cast look which they were ordered to
observe in the streets, and the injunction of keeping their hands
within their robes, might very naturally be calculated to prevent
quarrels, and especially blows, at times when the authority of a
public assembly could not moderate the vivacity of their passions. By
these arts, the Spartans lived in great harmony in the midst of a
continual war.
Under such regulations a people must enjoy security from foreign
attacks; and certainly the intention of the legislator never was to
extend the limits of Laconia by conquest. What people could ever
think of attacking the Lacedemonians, where nothing but blows
could be expected?
They enjoyed ease in the most supreme degree; they were
abundantly provided with every necessary of life; although, I
confess, the enjoyment of them in so austere a manner, would not
be relished by any modern society. But habit is all in things of this
kind. A course meal to a good stomach, has more relish than all the
delicacies of the most exquisite preparation to a depraved appetite;
and if sensuality be reckoned among the pleasures of life, enough of
it might have been met with in the manners of that people. It does
not belong to my subject to enter into particular details on this head.
But the most rational pleasure among men, the delightful
communication of society, was here enjoyed to the utmost extent.
The whole republic was continually gathered together in bodies, and
their studies, their occupations, and their amusements, were the
same. One taste was universal; and the young and the old being
constantly together, the first under the immediate inspection and
authority of the latter, the same sentiments were transmitted from
generation to generation. The Spartans were so pleased, and so
satisfied with their situation, that they despised the manners of
every other nation. If this does not transmit an idea of happiness, I
am at a loss to form one. Security, ease, and happiness, therefore,
are not inseparable concomitants of trade and industry.
Lycurgus had penetration enough to perceive the weak side of his
institution. He was no stranger to the seducing influence of luxury;
and plainly foresaw, that the consequences of industry, which
procures to mankind a great variety of new objects of desire, and a
wonderful facility in satisfying them, would easily root out the
principles he had endeavoured to instil into his countrymen, if the
state of simplicity should ever come to be sophisticated by foreign
communications. He affected, therefore, to introduce several
customs which could not fail of disgusting and shocking the delicacy
of neighbouring states. He permitted the dead to be buried within
the walls; the handling of dead bodies was not reckoned pollution
among the Lacedemonians. He forbade bathing, so necessary for
cleanliness in a hot country: and the coarseness and dirtiness of
their cloaths, and sweat from their hard exercises, could not fail to
disgust strangers from coming among them. On the other hand,
nothing was found at Sparta which could engage a stranger to wish
to become one of their number. And to prevent the contagion of
foreign customs from getting in, by means of the citizens
themselves, he forbade the Spartans to travel; and excluded from
any employment in the state, those who had got a foreign
education. Nothing but a Spartan breeding could have fitted a
person to live among them.
The theft encouraged among the Lacedemonians was calculated
to make them artful and dextrous; and contained not the smallest
tincture of vice. It was generally of something eatable, and the
frugality of their table, prompted them to it; while on the other
hand, their being exposed to the like reprisals, made them watchful
and careful of what belonged to themselves; and the pleasure of
punishing an unsuccessful attempt, in part indemnified them for the
trouble of being constantly upon their guard. A Lacedemonian had
nothing of any value that could be stolen; and it is the desire and
intention of making unlawful gain, which renders theft either criminal
or scandalous.
The hidden intercourse between the Spartans and their young
wives was, no doubt, calculated to impress upon the minds of the
fair sex, the wide difference there is between an act of immodesty,
and that of simply appearing naked in the public exercises; two
things which we are apt to confound, only from the impression of
our own customs. I am persuaded that many a young person has
felt her modesty as much hurt by taking off her handkerchief, the
first time she appeared at court, as any Lacedemonian girl could
have done by stripping before a thousand people; yet both her
reason and common sense, must make her sensible of the difference
between a compliance with a custom in a matter of dress, and a
palpable transgression against the laws of her honour, and the
modesty of her sex.
I have called this Lacedemonian republic a perfect plan of political
oeconomy; because it was a system, uniform and consistent in all its
parts. There, no superfluity was necessary, because there was no
occasion for industry, to give bread to any body. There, no
superfluity was permitted, because the moment the limits of the
absolutely necessary are transgressed, the degrees of excess are
quite indeterminate, and become purely relative. The same thing
which appears superfluity to a peasant, appears necessary to a
citizen; and the utmost luxury of this class, frequently does not
come up to what is thought the mere necessary for one in a higher
rank. Lycurgus stopt at the only determined frontier, the pure
physical necessary. All beyond this was considered as abusive.
The only things in commerce among the Spartans were,
1mo. What might remain to them of the fruits of their lot, over
their own consumption; and 2do. The work of the slaves employed
in trades. The numbers of these could not be many, as the timber of
their houses was worked only with the saw and ax; and every utensil
was made with the greatest simplicity. A small quantity, therefore, of
iron coin, as I imagine, must have been sufficient for carrying on the
circulation at Sparta. The very nature of their wants must, as I have
said, terminate all their commerce, in the exchange of their surplus-
food of their portions of land, with the work of the manufacturing
slaves, who must have been fed from it.
As the Lacedemonians had no mercantile communication with
other nations, the iron coin was no more than a bank note of no
intrinsic value, as I suppose, but a middle term introduced for
keeping accounts, and for facilitating barter. An additional argument
for this opinion of the coin being of no intrinsic value, is, that it is
said to have been rendred unserviceable for other uses, by being
slaked in vinegar. In order consequently to destroy, as they
imagined, any intrinsic value which might therein otherwise remain.
If this coin, therefore, was made of an extraordinary weight, it must
have been entirely with a political view of discouraging commerce
and circulation, an institution quite consistent with the general plan,
and nowise a consequence of the baseness of the metal of which it
was made: a small quantity of this, with the stamp of public
authority for its currency and value, would have answered every
purpose equally well.
Let me now conclude this chapter by an illustration of the subject,
which will still more clearly point out the force of the principles upon
which this Lacedemonian republic was established.
Were any Prince in Europe, whose subjects, I shall suppose, may
amount to six millions of inhabitants, one half employed in
agriculture, the other half employed in trade and industry, or living
upon a revenue already acquired; were such a Prince, I say,
supposed to have authority sufficient to engage his people to adopt
a new plan of oeconomy, calculated to secure them against the
designs of a powerful neighbour, who, I shall suppose, has formed
schemes of invading and subduing them.
Let him engage the whole proprietors of land to renounce their
several possessions: or if that supposition should appear too absurd,
let him contract debts to the value of the whole property of the
nation; let the land-tax be imposed at twenty shillings in the pound,
and then let him become bankrupt to the creditors. Let the income
of all the lands be collected throughout the country for the use of
the state; let all the luxurious arts be proscribed; and let those
employed in them be formed, under the command of the former
land proprietors, into a body of regular troops, officers and soldiers,
provided with every thing necessary for their maintenance, and that
of their wives and families at the public expence. Let me carry the
supposition farther. Let every superfluity be cut off; let the peasants
be enslaved, and obliged to labour the ground with no view of profit
to themselves, but for simple subsistence; let the use of gold and
silver be proscribed; and let all these metals be shut up in a public
treasure. Let no foreign trade, and very little domestic be
encouraged, but let every man, willing to serve as a soldier, be
received and taken care of; and those who either incline to be idle,
or who are found superfluous, be sent out of the country. I ask,
what combination, among the modern European Princes, would
carry on a successful war against such a people? What article would
be wanting to their ease, that is, to their ample subsistence? Their
happiness would depend upon the temper of their mind. And what
country could defend themselves against the attack of such an
enemy? Such a system of political oeconomy, I readily grant, is not
likely to take place: but if ever it did, would it not effectually dash to
pieces the whole fabric of trade and industry, which has been
forming for so many years? And would it not quickly oblige every
other nation to adopt, as far as possible, a similar conduct, from a
principle of self-preservation.

CHAP. XV.
A general View of the Principles to be attended to by a Statesman, who resolves to
establish Trade and Industry upon a lasting footing.
The two preceding chapters I have introduced purposely to serve
as a relaxation to the mind, like a farce between the acts of a
serious opera. I now return to the place where I broke off my
subject, at the end of the twelfth chapter.
It is a great assistance to memory, now and then to assemble our
ideas, after certain intervals, in going through an extensive subject.
No part of it can be treated of with distinctness, without banishing
combinations; and no part of it can be applied to practice, or
adapted to any plan, without attending to combinations almost
infinite.
For this reason nothing can appear more inconsistent than the
spirit which runs through some parts of this book, if compared with
that which prevailed in the first. There luxury was looked on with a
favourable eye, and every augmentation of superfluity was
considered as a method of advancing population. We were then
employed in drawing mankind, as it were, out of a state of idleness,
in order to increase their numbers, and engage them to cultivate the
earth. We had no occasion to divide them into societies having
separate interests, because the principles we treated of were
common to all. We therefore considered the industrious, who are the
providers, and the luxurious, who are the consumers, as children of
the same family, and as being under the care of the same father.
We are now engaged in a more complex operation; we represent
different societies animated with a different spirit; some given to
industry and frugality, others to dissipation and luxury. This creates
separate interests among nations, and every one must be supposed
under the government of a statesman, who is wholly taken up in
advancing the good of those he governs, though at the expence of
other societies which lie round him.
This presents a new idea, and gives birth to new principles. The
general society of mankind treated of in the first book, is here in a
manner divided into two. The industrious providers are supposed to
live in one country, the luxurious consumers in another. The
principles of the first book remain here in full vigour. Luxury still
tends as much as ever to the advancement of industry; the
statesman’s business is only to remove the seat of it from his own
country. When that can be accomplished without detriment to
industry at home, he has an opportunity of joining all the
advantages of antient simplicity, to the wealth and power which
attend upon the luxury of modern states. He may preserve his
people in sobriety, and moderation as to every expence, as to every
consumption, and make them enjoy, at the same time, riches and
superiority over all their neighbours.
Such would be the state of trading nations, were they only
employed in supplying the wants or extravagant consumption of
strangers; and did they not insensibly adopt the very manners with
which they strive to inspire others.
As often, therefore, as we suppose a people applying themselves
to the advancement of foreign trade, we must simplify our ideas, by
dismissing all political combinations of other circumstances; that is to
say, we must suppose the spirit universal, and then point out the
principles which influence the success of it.
We must encourage oeconomy, frugality, and a simplicity of
manners, discourage the consumption of every thing that can be
sold out of the country, and excite a taste for superfluity in
neighbouring nations. When such a system can no more be
supported to its full extent, by the scale of foreign demand
becoming positively lighter; then in order to set the balance even
again, without taking any thing out of the heavy scale, and to
preserve and give bread to those who have enriched the state, an
additional home consumption, proportioned to the deficiency of
foreign demand, must be encouraged. For were the same simplicity
of manners still kept up, the infallible consequence would be a
forced restitution of the balance, by the distress, misery, and at last
extinction of the supernumerary workmen.
I must therefore, upon such occasions, consider the introduction
of luxury, or superfluous consumption, as a rational and moral
consequence of the deficiency of foreign trade.
I am, however, far from thinking that the luxury of every modern
state, is only in proportion to such failure; and I readily admit, that
many examples may be produced where the progress of luxury, and
the domestic competitions with strangers who come to market, have
been the cause both of the decline and extinction of their foreign
trade; but as my business is chiefly to point out principles, and to
shew their effects, it is sufficient to observe, that in proportion as
foreign trade declines, either a proportional augmentation upon
home consumption must take place, or a number of the industrious,
proportioned to the diminution of former consumption, must
decrease. By the first, what I call a natural restitution of the balance
is brought about, from the principles above deduced; by the second,
what I call a forced one.
Here then is an example, where the introduction of luxury may be
a rational and prudent step of administration; and as long as the
progress of it is not accelerated from any other principle, but that of
preserving the industrious, by giving them employment, the same
spirit, under the direction of an able statesman, will soon throw
industry into a new channel, better calculated for reviving foreign
trade, and for promoting the public good, by substituting the call of
foreigners in place of that of domestic luxury.
I hope, from what I have said, the political effects of luxury, or the
consumption of superfluity, are sufficiently understood. These I have
hitherto considered as advantageous only to those classes who are
made to subsist by them; I reserve for another occasion the pointing
out how they influence the imposition of taxes, and how the abuse
of consumption in the rich may affect the prosperity of a state.
So soon as all foreign trade comes to a stop, without a scheme for
recalling it, and that domestic consumption has filled up its place in
consuming the work, and giving bread to the industrious, we find
ourselves obliged to reason again upon the principles of the first
book. The statesman has once more both the producers and the
consumers under his care. The consumers can live without
employment, the producers cannot. The first seldom have occasion
for the statesman’s protection; the last constantly stand in need of
it. There is a perpetual fluctuation in the balance between these two
classes, from which a multitude of new principles arise; and these
render the administration of government infinitely more difficult, and
require superior talents in the person who is at the helm. I shall here
only point out the most striking effects of the fluctuation and
overturn of this new balance, which in the subsequent chapters shall
be more fully illustrated.
1mo. In proportion as the consumers become extravagant, the
producers become wealthy; and when the former become
bankrupts, the latter fill their place.
2do. As the former become frugal and oeconomical, the latter
languish; when those begin to hoard, and to adopt a simple life,
these are extinguished: all extremes are vicious.
3tio. If the produce of industry consumed in a country, surpass the
income of those who do not work, the balance due by the
consumers must be paid to the suppliers by a proportional alienation
of their funds. This vibration of the balance, gives a very correct idea
of what is meant by relative profit and loss. The nation here loses
nothing by the change produced.
4to. When, on the other hand, the annual produce of industry
consumed in a country, does not amount to the value of the income
of those who do not work, the balance of income saved, must either
be locked up in chests, made into plate, lent to foreigners, or fairly
exported as the price of foreign consumption.
5to. The scales stand even when there is no balance on either
side; that is, when the domestic consumption is just equivalent to
the annual income of the funds. I do not pretend to decide at
present whether this exact equilibrium marks the state of perfection
in a country where there is no foreign trade, (of which we are now
treating) or whether it be better to have small vibrations between
the two scales; but I think I may say, that all subversions of the
balance on either side cannot fail to be hurtful, and therefore should
be prevented.
Let this suffice at present, upon a subject which shall be more
fully treated of afterwards. Let us now fix our attention upon the
interests of a people entirely taken up in the prosecution of foreign
trade. So long as this spirit prevails, I say, it is the duty of a
statesman to encourage frugality, sobriety, and an application to
labour in his own people, and to excite in foreign nations a taste for
superfluities as much as possible.
While a people are occupied in the prosecution of foreign trade,
the mutual relations between the individuals of the state, will not be
so intimate as when the producers and consumers live in the same
society; such trade implies, and even necessarily creates a chain of
foreign dependencies; which work the same effect, as when the
mutual dependence subsisted among the citizens. Now the use of
dependencies, I have said, is to form a band of society, capable of
making the necessitous subsist out of the superfluities of the rich,
and to keep mankind in peace and harmony with one another.
Trade, therefore, and foreign communications, form a new kind of
society among nations; and consequently render the occupation of a
statesman more complex. He must, as before, be attentive to
provide food, other necessaries and employment for all his people;
but as the foreign connections make these very circumstances
depend upon the entertaining a good correspondence with
neighbouring nations, he must acquire a proper knowledge of their
domestic situation, so as to reconcile, as much as may be, the
interests of both parties, by engaging the strangers to furnish
articles of the first necessity, when the precious metals cannot be
procured; and to accept, in return, the most consumable
superfluities which industry can invent. And, last of all, he must
inspire his own people with a spirit of emulation in the exercise of
frugality, temperance, oeconomy, and an application to labour and
ingenuity. If this spirit of emulation is not kept up, another will take
place; for emulation is inseparable from the nature of man; and if
the citizens are not made to vie with one another, in the practice of
moderation, the wealth they must acquire, will soon make them vie
with strangers, in luxury and dissipation.
While a spirit of moderation prevails in a trading nation, it may
rest assured, that in as far as it excels the nations with whom it
corresponds in this particular, so far will it increase the proportion of
its wealth, power, and superiority, over them. These are lawful
pursuits among men, when purchased by success in so laudable an
emulation.
If it be said, that superfluity, intemperance, prodigality, and
idleness, qualities diametrically opposite to the former, corrupt the
human mind, and lead to violence and injustice; is it not very wisely
calculated by the Author of all things, that a sober people, living
under a good government, should by industry and moderation,
necessarily acquire wealth, which is the best means of warding off
the violence of those with whom they are bound in the great society
of mankind? And is it not also most wisely ordained, that in
proportion as a people contract vicious habits, which may lead to
excess and injustice, the very consequence of their dissipation
(poverty) should deprive them of the power of doing harm? But such
reflections seem rather to be too great a refinement on my subject,
and exceed the bounds of political oeconomy.
When we treat of a virtuous people applying to trade and industry,
let us consider their interest only, in preserving those sentiments;
and examine the political evil of their falling off from them. When we
treat of a luxurious nation, where the not-working part is given to
excesses in all kinds of consumption, and the working part to labour
and ingenuity, in order to supply them, let us examine the
consequences of such a spirit, with respect to foreign trade: and if
we find, that a luxurious turn in the rich is prejudicial thereto, let us
try to discover the methods of engaging the inhabitants to correct
their manners from a motive of self-interest. These things premised,
I shall now give a short sketch of the general principles upon
which a system of foreign trade may be established and preserved
as long as possible, and of the methods by which it may be again
recovered, when, from the natural advantages and superior ability of
administration in rival nations, (not from vices at home) a people
have lost for a time every advantage they used to draw from their
foreign commerce.
The first general principle is to employ, as usefully as possible, a
certain number of the society, in producing objects of the first
necessity, always more than sufficient to supply the inhabitants; and
to contrive means of enabling every one of the free hands to procure
subsistence for himself, by the exercise of some species of industry.
These first objects compassed, I consider the people as
abundantly provided with what is purely necessary; and also with a
surplus prepared for an additional number of free hands, so soon as
a demand can be procured for their labour. In the mean time, the
surplus will be an article of exportation; but no sooner will demand
come from abroad, for a greater quantity of manufactures than
formerly, than such demand will have the effect of gradually
multiplying the inhabitants up to the proportion of the surplus above
mentioned, provided the statesman be all along careful to employ
these additional numbers, which an useful multiplication must
produce, in supplying the additional demand: then with the
equivalent they receive from strangers, they will at the same time
enrich the country, and purchase for themselves that part of the
national productions which had been permitted to be exported, only
for want of a demand for it at home.
He must, at the same time, continue to give proper
encouragement to the advancement of agriculture, that there may
be constantly found a surplus of subsistence (for without a surplus
there can never be enough) this must be allowed to go abroad, and
ought to be considered as the provision of those industrious hands
which are yet unborn.
He must cut off all foreign competition, beyond a certain standard,
for that quantity of subsistence which is necessary for home
consumption; and, by premiums upon exportation, he must
discharge the farmers of any superfluous load, which may remain
upon their hands when prices fall too low. This important matter
shall be explained at large in another place, when we come to treat
of the policy of grain.
If natural causes should produce a rise in the price of subsistence,
which cannot be brought down by extending agriculture, he must
then lay the whole community under contribution, in order to
indemnify those who work for strangers, for the advance upon the
price of their food; or he must indemnify the strangers in another
way, for the advance in the price of manufactures.
He must consider the manufactures of superfluity, as worked up
for the use of strangers, and discourage all domestic competition for
them, by every possible means.
He must do what he can, constantly to proportion the supply to
the demand made for them; and when the first necessarily comes to
exceed the latter, in spight of all his care, he must then consider
what remains over the demand, as a superfluity of the strangers;
and for the support of the equal balance between work and demand,
he must promote the sale of them even within the country, under
certain restrictions, until the hands employed in such branches
where a redundancy is found, can be more usefully set to work in
another way.
He must consider the advancement of the common good as a
direct object of private interest to every individual, and by a
disinterested administration of the public money, he must plainly
make it appear that it is so.
From this principle flows the authority, vested in all governments,
to load the community with taxes, in order to advance the prosperity
of the state. And this object can be nowise better obtained than by
applying the amount of them to the keeping an even balance
between work and demand. Upon this the health of a trading state
principally depends.
If the failure of foreign demand be found to proceed from the
superior natural advantages of other countries, he must double his
diligence to promote luxury among his neighbours; he must support
simplicity at home; he must increase his bounties upon exportation;
and his expence in relieving manufactures, when the price of their
industry falls below the expence of their subsistence.
While these operations are conducted with coolness and
perseverance, while the allurements of the wealth acquired do not
frustrate the execution, the statesman may depend upon seeing
foreigners return to his ports, so soon as their own dissipation, and
want of frugality, come to compensate the advantages which nature
had given them over their frugal and industrious neighbours.
If this plan be pursued, foreign trade will increase in proportion to
the number of inhabitants; and domestic luxury will serve only as an
instrument in the hands of the statesman to increase demand when
the home supply becomes too great for foreign consumption. In
other words, the rich citizens will be engaged to consume what is
superfluous, in order to keep the balance even in favour of the
industrious, and in favour of the nation.
The whole purport of this plan is to point out the operation of
three very easy principles.
The first, That in a country entirely taken up with the object of
promoting foreign trade, no competition should be allowed to come
from abroad for articles of the first necessity, and principally for
food, so as to raise prices beyond a certain standard.
The second, That no domestic competition should be allowed
upon articles of superfluity, so as to raise prices beyond a certain
standard.
The third, That when these standards cannot be preserved, and
that from natural causes, prices get above them, public money must
be thrown into the scale to bring prices to the level of those of
exportation.
The greater the extent of foreign trade in any nation, the lower
these standards must be kept; the less the extent of it, the higher
they may be allowed to rise. Consequently,
Were no man in a nation employed in producing the necessaries of
life, but every man in supplying articles of foreign consumption, the
prices of necessaries might be allowed to fall as low as possible.
There would be no occasion for a standard in favour of those who
live by producing them.
Were no man in the state employed in supplying strangers, the
prices of superfluities might be allowed to rise as high as possible,
and a standard would also become useless, as the sole design of it is
to favour exportation.
But as neither of these suppositions can ever take place, and as in
every nation there is a part employed in producing, and a part in
consuming, and that it is only the surplus of industry which can be
exported; a standard is necessary for the support of the reciprocal
interests of both parties at home; and the public money must be
made to operate only upon the price of the surplus of industry so as
to make it exportable, even in cases where the national prices upon
home consumption have got up beyond the standard. Let me set
this matter in another light, the better to communicate an idea
which I think a little obscure.
Were food and other necessaries the pure gift of nature in any
country, I should have laid it down as a principle to discourage all
foreign competition for them, either below or above any certain
standard; because in this case the lower the price the better, since
no inconveniency could result from thence to any industrious person.
But when the production of these is in itself a manufacture, or an
object of industry, a certain standard must be kept up in favour of
those who live by producing them.
On the other hand, as to the manufactures of superfluity, domestic
competition should be discouraged, beyond a certain standard, in
order that prices may not rise above those offered by foreigners; but
it might be encouraged below the standard, in order to promote
consumption and give bread to manufacturers. But were there no
foreign demand at all, there would be no occasion for any standard,
and the nation’s wealth would thereby only circulate in greater or
less rapidity in proportion as prices would rise or fall. The study of
the balance between work and demand, would then become a
principal object of attention in the statesman, not with a view to
enrich the state, but in order to preserve every member of it in
health and vigour. On the other hand, the object of a standard
regards foreign trade, and the acquisition of new wealth, at the
expence of other nations. The rich, therefore, at home must not be
allowed to increase their consumption of superfluities beyond the
proportion of the constant supply; because these being intended for
strangers, the only way of preventing them from supplying
themselves, is to prevent prices from getting up beyond the
standard, at which strangers can produce them.
Farther, were every one of the society in the same pursuit of
industry, there would be no occasion for the public to be laid under
contribution for advancing the general welfare; but as there is a part
employed in enriching the state, by the sale of their work to
strangers, and a part employed in making these riches circulate at
home, by the consumption of superfluities, I think it is a good
expedient to throw a part of domestic circulation into the public
coffers; that when the consequences of private wealth come
necessarily to raise prices, a statesman may be enabled to defray
the expence of bounties upon that part which can be exported, and
thereby enable the nation to continue to supply foreigners at the
same price as formerly.
The farther these principles can be carried into execution, the
longer a state will flourish; and the longer she will support her
superiority. When foreign demand begins to fail, so as not to be
recalled, either industry must decline, or domestic luxury must
begin. The consequences of both may be easily guessed at, and the
principles which influence them shall be particularly examined in the
following chapter.

CHAP. XVI.
Illustration of some Principles laid down in the former Chapter, relative to the
advancement and support of foreign Trade.

I am now to give an illustration of some things laid down, I think,


in too general terms in the former chapter, relating to that species of
trade which is carried on with other nations.
I have constantly in view to separate and distinguish the principles
of foreign trade, from those which only influence the advancement
of an inland commerce, and a brisk circulation: operations which
produce very different effects, equally meriting the attention of a
statesman.
The very existence of foreign trade, implies a separate interest
between those nations who are found on the opposite side of the
mercantile contract, as both endeavour to make the best bargain
possible for themselves. These transactions imply a mutual
dependence upon one another, which may either be necessary or
contingent. It is necessary, when one of the nations cannot subsist
without the assistance of the other, as is the case between the
province of Holland, and those countries which supply it with grain;
or contingent, when the wants of a particular nation cannot be
supplied by their own inhabitants, from a want of skill and dexterity,
only.
Wherever, therefore, one nation finds another necessarily
depending upon her for particular branches of traffic, there is a
certain foundation for foreign trade; where the dependence is
contingent, there is occasion for management, and for the hand of
an able statesman.
The best way to preserve every advantage, is, to examine in how
far they are necessary, and in how far they are only contingent, to
consider in what respect the nation may be most easily rivalled by
her neighbours, and in what respect she has natural advantages
which cannot be taken from her.
The natural advantages are chiefly to be depended on: France, for
example, can never be rivalled in her wines. Other countries may
enjoy great advantages from their situation, mines, rivers, sea ports,
fishing, timber, and certain productions proper to the soil. If you
abstract from these natural advantages, all nations are upon an
equal footing as to trade. Industry and labour are no properties
attached to place, any more than oeconomy and sobriety.
This proposition may be called in question, upon the principles of
M. de Montesquieu, who deduces the origin of many laws, customs,
and even religions, from the influence of the climate. That great man
reasoned from fact and from experience, and from the power and
tendency of natural causes, to produce certain effects when not
checked by other circumstances; but in my method of treating this
subject, I suppose these causes never to be allowed to produce their
natural and immediate effects, when such effects would be followed
by a political inconvenience: because I constantly suppose a
statesman at the head of government, who makes every
circumstance concur in promoting the execution of the plan he has
laid down.
1mo. If a nation then has formed a scheme of being long great
and powerful by trade, she must first apply closely to the
manufacturing every natural produce of the country. For this purpose
a sufficient number of hands must be employed: for if hands be
found wanting, the natural produce will be exported without
receiving any additional value from labour; and so the consequences
of this natural advantage will be lost.
The price of food, and all necessaries for manufacturers, must be
found at an easy rate.
And, in the last place, if oeconomy and sobriety in the workmen,
and good regulations on the part of the statesman, are not kept up,
the end will not be obtained: for if the manufacture, when brought
to its perfection, does not retain the advantages which the
manufacturer had in the beginning, by employing the natural
produce of the country; it is the same thing as if the advantage had
not existed. I shall illustrate this by an example.
I shall suppose wool to be better, more plentiful, and cheaper, in
one country than in another, and two nations rivals in that trade. It
is natural that the last should desire to buy wool of the first, and
that the other should desire to keep it at home, in order to
manufacture it. Here then is a natural advantage which the first
country has over the latter, and which cannot be taken from her. I
shall suppose that subsistence is as cheap in one country as in the
other; that is to say, that bread and every other necessary of life is
at the same price. If the workmen of the first country (by having
been the founders of the cloth manufacture, and by having had, for
a long tract of years, so great a superiority over other nations, as to
make them, in a manner, absolutely dependent upon them for
cloths) shall have raised their prices from time to time; and if, in
consequence of large profits, long enjoyed without rivalship, these
have been so consolidated with the real value, by an habitual
greater expence in living, which implies an augmentation of wages;
that country may thereby lose all the advantages it had from the low
price and superior quality of its wool. But if, on the other hand, the
workmen in the last country work less, be less dextrous, pay
extravagant prices for wool at prime cost, and be at great expence
in carriage; if manufactures cannot be carried on successfully, but by
public authority, and if private workmen be crushed with excessive
taxes upon their industry; all the accidental advantages which the
last country had over the first, may come to be more than balanced,
and the first may regain those which nature first had given her. But
this should by no means make the first country rest secure. These
accidental inconveniencies found in the last may come to cease; and
therefore the only real security of the first for that branch, is the
cheapness of the workmanship.
2do. In speaking of a standard, in the last chapter, I established a
distinction between one regulated by the height of foreign demand,
and another kept as low as the possibility of supplying the
manufacture can admit. This requires a little explanation.
It must not here be supposed that a people will ever be brought
from a principle of public spirit, not to profit of a rise in foreign
demand; and as this may proceed from circumstances and events
which are entirely hid from the manufacturers, such revolutions are
unavoidable. We must therefore restrain the generality of our
proposition, and observe, that the indispensible vibrations of this
foreign demand do no harm; but that the statesman should be
constantly on his guard to prevent the subversion of the balance, or
the smallest consolidation of extraordinary profits with the real
value. This he will accomplish, as has been observed, by multiplying
hands in those branches of exportation, upon which profits have
risen. This will increase the supply, and even frustrate his own
people of extraordinary gains, which would otherwise terminate in a
prejudice to foreign trade.
A statesman may sometimes, out of a principle of benevolence,
perhaps of natural equity towards the classes of the industrious, as
well as from sound policy, permit larger profits, as an
encouragement to some of the more elegant arts, which serve as an
ornament to a country, establish a reputation for taste and
refinement in favour of a people, and thereby make strangers prefer
articles of their production, which have no other superior merit than
the name of the country they come from: but even as to these, he
ought to be upon his guard, never to allow them to rise so high, as
to prove an encouragement to other nations, to establish a
successful rivalship.
3tio. The encouragement recommended to be given to the
domestic consumption of superfluities, when foreign demand for
them happens to fall so low as to be followed with distress in the
workmen, requires a little farther explanation.
If what I laid down in the last chapter be taken literally, I own it
appears an absurd supposition, because it implies a degree of public
spirit in those who are in a capacity to purchase the superfluities, no
where to be met with, and at the same time a self-denial, in
discontinuing the demand, so soon as another branch of foreign
trade is opened for the employment of the industrious, which
contradicts the principles upon which we have founded the whole
scheme of our political oeconomy.
I have elsewhere observed, that were revolutions to happen as
suddenly as I am obliged to represent them, all would go into
confusion.
What, therefore, is meant in this operation comes to this, that
when a statesman finds, that the natural taste of his people does not
lead them to profit of the surplus of commodities which lie upon
hand, and which were usually exported, he should interpose his
authority and management in such a way as to prevent the distress
of the workmen, and when, by a sudden fall in a foreign demand,
this distress becomes unavoidable, without a more powerful
interposition, he should then himself become the purchaser, if others
will not; or, by premiums or bounties on the surplus which lies upon
hand, promote the sale of it at any rate, until the supernumerary
hands can be otherwise provided for. And although I allow that the
rich people of a state are not naturally led, from a principle either of
public spirit or self-denial, to render such political operations
effectual to promote the end proposed, yet we cannot deny, that it is
in the power of a good governor, by exposing the political state of
certain classes of the people, to gain upon men of substance to
concur in schemes for their relief; and this is all I intend to
recommend in practice. My point of view is to lay down the
principles, and I never recommend them farther than they are
rendered possible in execution, by preparatory steps, and by
properly working on the spirit of the people.
CHAP. XVII.
Symptoms of Decay in foreign Trade.

If manufacturers are found to be without employment, we are not


immediately to accuse the statesman, or conclude this to proceed
from a decay of trade, until the cause of it be inquired into. If upon
examination it be found, that for some years past food has been at a
higher rate than in neighbouring countries, the statesman may be to
blame: for it is certain, that a trading nation, by turning part of her
commerce into a proper channel, may always be able to establish a
just balance in this particular. And though it be not expedient in
years of scarcity to bring the price of grain very low, yet it is
generally possible to raise the price of it in all rival nations, which,
with regard to the present point, is the same thing.
If this want of employment for manufacturers do not proceed from
the high prices of living, but for want of commissions from the
merchants, the causes of this diminution of demand must be
examined into. It may be accidental, and happen from causes which
may cease in a little time, and trade return to flourish as before. It
may also happen upon the establishment of new undertakings in
different places of the country, from which, by reason of some
natural advantage, or a more frugal disposition in the workmen, or
from the proximity of place, markets may be supplied, which
formerly were furnished by those industrious people who are found
without employment. In these last suppositions, the distress of the
manufacturers does not prove any decay of trade in general, but, on
the contrary, may contribute to destroy the bad effects of
consolidated profits, by obliging those who formerly shared them, to
abandon the ease of their circumstances, and submit a-new to a
painful industry, in order to procure subsistence. When such
revolutions are sudden, they prove hard to bear, and throw people
into great distress. It is partly to prevent such inconveniencies, that
we have recommended the lowest standard possible, upon articles
of exportation.
Two causes there are, which very commonly mark a decline of
trade, to wit; 1. When foreign markets, usually supplied by a trading
nation, begin to be furnished, let it be in the most trifling article, by
others, not in use to supply them. Or, 2. When the country itself is
furnished from abroad with such manufactures as were formerly
made at home.
These circumstances prove one of two things, either that there are
workmen in other countries, who, from advantages which they have
acquired by nature, or by industry and frugality, finding a demand
for their work, take the bread out of the mouths of those formerly
employed, and deprive them of certain branches of their foreign
trade: or, that these foreign workmen, having profited of the
increased luxury and dissipation of the former traders, have begun
to supply the markets with certain articles of consumption, the
profits upon which being small, are, without much rivalship,
insensibly yielded up to them by the workmen of the other trading
nation, who find better bread in serving their own wealthy
countrymen.
Against the first cause of decline, I see no better remedy than
patience, as I have said already, and a perseverance in frugality and
oeconomy, until the unwary beginners shall fall into the
inconveniencies generally attending upon wealth and ease.
The second cause of decline is far more difficult to be removed.
The root of it lies deep, and is ingrafted with the spirit and manners
of the whole people, high and low. The lower classes have
contracted a taste for superfluity and expence, which they are
enabled to gratify, by working for their countrymen; while they
despise the branches of foreign trade as low and unprofitable. The
higher classes again depend upon the lower classes, for the
gratification of a thousand little trifling desires, formed by the taste
of dissipation, and supported by habit, fashion, and a love of
expence.

You might also like