Introducing Play Framework Java Web Application Development Second Edition Prem Kumar Karunakaran - Experience the full ebook by downloading it now
Introducing Play Framework Java Web Application Development Second Edition Prem Kumar Karunakaran - Experience the full ebook by downloading it now
com
https://textbookfull.com/product/introducing-play-framework-
java-web-application-development-second-edition-prem-kumar-
karunakaran/
OR CLICK HERE
DOWLOAD EBOOK
https://textbookfull.com/product/learn-java-for-web-development-
modern-java-web-development-layka-vishal/
textbookfull.com
https://textbookfull.com/product/methodologies-and-application-issues-
of-contemporary-computing-framework-jyotsna-kumar-mandal/
textbookfull.com
https://textbookfull.com/product/building-web-apps-with-wordpress-
wordpress-as-an-application-framework-brian-messenlehner/
textbookfull.com
https://textbookfull.com/product/pyside-gui-application-development-
second-edition-gopinath-jaganmohan/
textbookfull.com
Introducing Maven A Build Tool for Today s Java Developers
Second Edition Balaji Varanasi
https://textbookfull.com/product/introducing-maven-a-build-tool-for-
today-s-java-developers-second-edition-balaji-varanasi/
textbookfull.com
https://textbookfull.com/product/java-ee-development-with-eclipse-
second-edition-ram-kulkarni/
textbookfull.com
https://textbookfull.com/product/introducing-bootstrap-4-create-
powerful-web-applications-using-bootstrap-4-5-second-edition-joerg-
krause/
textbookfull.com
https://textbookfull.com/product/pro-typescript-application-scale-
javascript-development-second-edition-fenton/
textbookfull.com
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.
Further References
Play Framework official docs: www.playframework.com/
Google groups for Play:
https://groups.google.com/forum/#!forum/play-
framework
Questions related to Play:
http://stackoverflow.com/tags/playframework
Ebeans: www.avaje.org/
Twirl: https://github.com/playframework/twirl
Table of Contents
Chapter 1:Getting Started with Play 2
Getting Ready
Installation
Prerequisites
Installing sbt
Installing conscript
Installing Giter8
Setting Up Play
Using Play Example Projects
Using sbt
Creating Your First Project
app
conf
build.sbt
project
public
lib
test
Configuring Play to Work with Your Preferred IDE
Setting Up in Eclipse
Setting Up in IntelliJ
Hello World Application
Configuration
Controller and View
Testing Play Applications
Testing Views
Testing Controllers
Chapter 2:Build System
Scala Build Tool/Simple Build Tool
Core Principles
Benefits of sbt
Project Structure
Using sbt
Setting Definition
Resolvers
Complete build.sbt
Complete plugins.sbt
Quick Recap of SBT Commands
Chapter 3:Play Controllers and HTTP Routing
MVC Programming Model
Model
View
Controller
HTTP Routing
Static Definition
Dynamic Parts in a URL
Passing Fixed Values
Optional Parameters
Application Configuration Using application.conf
Controllers
Finishing the Bookshop Controller
saveComment Method
Testing the saveComment Action
Models
Scoped Objects
Session Scope
Flash Scope
Chapter 4:Play Views and Templating with Scala
Composite Views
Designing a General Template
Code Snippets Templating Basics
Comments
Template Parameters
Import Statement
Iterating a List
Iterating a Map
If Blocks
Escaping Dynamic Contents
Chapter 5:Concurrency and Asynchronous Programming
What Is Concurrency?
Executor
Example 1:Using Runnable
Example 2:Using Callable
Asynchronous Programming with Play
Writing an Asynchronous App
Configuring Asynchronous Scheduled Jobs
Akka Basics
Chapter 6:Web Services, JSON, and XML
Consuming Web Services
Processing Large Responses
Handling JSON
Consuming JSON Request
Producing a JSON Response
Handling XML
Example 1:Simple XML Parsing
Example 2:XML Parsing Using JAXB
Chapter 7:Accessing Databases
Configuring Database Support
Working with an ORM
ORM Concepts
Key Terms
Relationship Direction
Configuring JPA
Using Ebean in Play
Ebean Query
Common Select Query Constructs in Ebean
Using RawSql
Relationships in Ebean
Chapter 8:Complete Example
Chapter 9:Using Play Modules
Creating a Module
Third-Party Modules
Chapter 10:Application Settings and Error Handling
Filters
Action Composition
Error Handlers
Client Errors
Server Errors
How Global Settings Were Done Before Play 2.6.x
Chapter 11:Working with Cache
Configuring Caffeine
Adding Caffeine to a Project
Configuring EhCache
Using the Cache API
Chapter 12:Production Deployment
Configuring Apache httpd for Play
Load Balancing Using mod_proxy_balancer
Configuring Play with Nginx
Index
About the Author
Prem Kumar Karunakaran
is an enterprise architect with about 20 years of industry experience.
He holds a M.Tech in Software Systems from BITS Pilani and a
bachelor’s degree in electronics engineering from Cochin University of
Science and Technology. He is also an Oracle Certified Java Enterprise
Edition Master. He was involved in the architecture and design of many
cutting-edge products used by clients around the globe. He has worked
with organizations such as Infosys and IBS as an architect and has
worked in many projects spanning airlines, logistics, travel, and retail
domain. He is passionate about Java, Machine Learning, BigData
processing and Cloud and loves to learn new technologies; he
contributes his time to open source initiatives as well.
About the Technical Reviewer
Satheesh Madhavan
has nearly 20 years of experience in the software industry and
currently serves as a digital consultant in one of India’s largest IT firms.
He has experience working in Java and JEE technologies in providing
enterprise solutions under various capacities. His qualifications
include an M.S in software systems from BITS Pilani and a B.Tech in
chemical engineering from the University of Kerala. His hobbies
include reading fiction and non-fiction, Philately, technical blogs and
podcasts, and astrophysics and pure sciences.
© Prem Kumar Karunakaran 2020
P. K. Karunakaran, Introducing Play Framework
https://doi.org/10.1007/978-1-4842-5645-9_1
After reading the introductory section on Play 2, you should now have an idea of the capabilities of Play
Framework and how it can accelerate Java web development. This chapter is about
Installing Play Framework
Setting up Play Framework on your machine
Configuring Play Framework
Creating the first sample project
Setting up the IDE
Getting Ready
All you need is a browser and Internet connectivity. You can install Play on a wide variety of operating
systems, including Microsoft Windows, Linux, and Mac. The operating system should have Java installed.
Installation
Play just needs the Play jars available at runtime to work, hence you can include the Play jars in any
application using Maven or any such build tool.
But the recommended way to use Play is to install it using either sbt or Gradle because Play provides
a better development experience when using sbt or Gradle.
Prerequisites
Play 2.x requires JDK 1.8 or later to be installed on the machine. Please note that JRE is not enough; you
need JDK Version 8 or higher. You should ensure that the PATH variable points to the JDK bin directory
and that javac and Java are accessible from everywhere.
You can check this by typing javac -version in the command prompt or shell and verify that the
version is 1.8 or above.
You can get Java SE from the Oracle website at
www.oracle.com/technetwork/java/javase/downloads/index.html.
Play also works with Open JDK version 1.8 and above. But you should make sure that any dependency
you use in the project is compatible with the Open JDK.
Installing sbt
sbt (Scala build tool) is available for all OS versions at the scala-sbt website at www.scala-
sbt.org/download.html. Please follow the instructions in the installation guide at www.scala-
sbt.org/1.x/docs/Setup.html to install sbt.
Installing conscript
To install Play using sbt, you need to install conscript. Please follow the instructions at
www.foundweekends.org/conscript/setup.html to install conscript. The instructions are
available for Mac, Linux, and Windows.
The cross-platform installation using a jar is simple. Download the conscript jar from the
foundweekends Maven release repo (https://dl.bintray.com/foundweekends/maven-
releases/org/foundweekends/conscript/conscript_2.11/0.5.2/conscript_2.11-
0.5.2-proguard.jar) and run the following from the command prompt:
This will start a splash screen and will install conscript. Ignore any error related to not finding ‘cs.’
Typically, conscript will get installed in the C:\Users\username\.conscript folder in Windows,
where username is the home folder of the logged-in user in Windows. This location will be shown in the
splash screen.
Now let’s set up the environment variables for conscript:
CONSCRIPT_HOME is where conscript will download various files. For example, in Windows, it will
be C:\Users\username\.
PATH is your OS’s path variable. This will make the command cs available from everywhere.
Installing Giter8
After installing conscript, Giter8 can be installed using conscript itself. Giter8 is a command-line tool to
generate files and directories from templates published on GitHub or any other git repository.
Go to a command prompt and type
cs foundweekends/giter8
This will download and install Giter8. More details of the installation is available from the
foundweekends website for Giter8 (www.foundweekends.org/giter8/setup.html).
Setting Up Play
There are multiple ways to install Play. Let’s look at the two most common ways:
Using Play example projects: Use any of the example projects provided by Lightbend Tech Hub
(https://developer.lightbend.com/start/?group=play).
Using sbt: This approach depends on Giter8 templates for sbt. This method creates a fresh Play
project without any example code. This is the preferred mode for a clean, lean project structure.
3. Click the “Create a project for me” button (this will download the example project to your system).
Note that the last part of the message (f50b441db70fa47676ba) might be different for you
but that is okay. You are now good to go and you will see the prompt as
[play-scala-seed] $
[play-scala-seed] $ run
7. Go to http://localhost:9000. If all is good, you should see the Play documentation displayed
in the browser.
Now let’s see how to install a Play example project using Java.
1. Go to https://developer.lightbend.com/start/?group=play.
3. Click the “Create a project for me” button (this will download the example project to your system).
6. This will download all the dependencies and perform the build. Please note that it might take a while
to download all the dependencies.
[play-java-hello-world-tutorial] $
[play-java-hello-world-tutorial] $ run
Using sbt
Now you’ll learn how to install Play using sbt to get the basic Play application structure and dependent
jars but not the example projects.
To use sbt to create a Play project, the following needs to be completed:
1. Install SBT.
2. Install conscript.
3. Install Giter8.
You can find instructions for installing the above software in the Installation section of this chapter.
Once the above software is installed, you can proceed with creating a Play project using sbt. Play
supports Java and Scala as programming languages, so I will show examples for both using sbt.
Provide the project name and organization, and the project will get created.
You have now learned multiple ways to install a Play project for both Scala and Java:
Using Play examples
Using sbt
In this book, I use Java as the programming language for Play, so when you create your first project (a
bookshop) in the next section, you will be using sbt and the Java seed.
For the organization name, you can give another domain name if you want to do so.
Go to the directory where you created project. For instance, in my machine, the project directory is
E:\workarea\bookshop.
Let’s look at the folder structure and its relevance in the overall project organization. See Figure 1-2.
app
The app folder contains all your server-side source files. This includes all your Java code, Scala code,
dynamic Scala HTML templates, database access-related code, etc. By default, Play creates two folders,
controllers and views, inside the app folder. The names are self-explanatory. The controllers
folder holds your controller classes and views holds the dynamic screens (the HTML and Scala code
snippets).
You are free to create subdirectories inside the app folder for better organization of your files. For
example, you can create a models folder to hold all your ORM mapped POJOs, a folder named helper to
hold your helper classes, etc.
Most of the project will have the following structure under the app folder:
app
└ assets: Compiled asset sources
└ stylesheets: For CSS source code (less CSS sources)
└ javascripts: Typically this is the folder where coffeescript sources are placed.
└ controllers: Application controllers
└ models: Application business layer
└ views: Templates
conf
The conf folder holds the configurations used by the Play application. It contains all the HTTP
mappings, orm configurations, environmental variables, logging, etc.
Basically, the conf directory contains configuration and internationalization files, whereas the app
folder has a subdirectory for its model definitions.
The most important files in this directory are
application.conf: The main configuration file for the application, it contains standard
configuration parameters.
routes: Maps HTTP URL paths to methods in the controller. Handles all HTTP routing configurations.
logback: Play uses logback for all logging configuration and this is the file you need to change to
configure logback.
build.sbt
Play’s build configuration is defined in two places: the build.sbt file in the project root and two files
found inside the /project folder. The build.sbt files contain the build configuration.
project
The project folder contains project build configurations:
plugins.sbt: Defines the sbt plugins used by this project
build.properties: Contains the sbt versions to use to build your app and related sbt build
information.
I will discuss more about sbt going forward. A basic understanding of sbt is good when you work
with Play.
public
The public folder hosts all static files like Javascripts, images, and CSS style sheets that are directly
served by the web server. The public folder has three subfolders, images, javascripts, and
stylesheets, for storing these assets:
public
└ stylesheets: CSS files (.css extension)
└ javascripts: JavaScript files (.js files)
└ images: Images
lib
The lib folder is not created by default. But you can create this folder and put any jar into it. All jars in
this folder will be added to the application class path. It’s ideal for including third-party dependencies
that need to be managed out of the Play build system.
test
The test folder is a holder for storing all unit and functional test cases.
Setting Up in Eclipse
As an example, let’s configure Play for Eclipse. To use Play with Eclipse, you need to first integrate
sbteclipse to your project. To do this, open plugins.sbt (project/plugins.sbt) and add the
following:
You want to compile the project before you run the eclipse command to generate the eclipse import
settings for the bookshop project. The manual way is to run sbt compile first and then do the
generate eclipse project part. But you can do it in a better and automated way; you can instruct it to run
compilation first whenever you generate eclipse project settings. For this, open the build.sbt file and
add the following:
Please note the above is only for Java projects. If you have Scala sources, then you should use Scala
IDE instead of the regular Eclipse IDE.
Save the build.sbt file and go to the sbt prompt by taking a command prompt, moving to the
project root directory (E:\workarea\bookshop) and typing sbt.
This initializes the sbt prompt. This can take few minutes to complete because sbt will download the
plugins and all related dependencies. Once the sbt prompt gets initialized, you should see the prompt as
[bookshop] $
Type eclipse with-source=false and press Enter. If you need all the source jars of the
dependencies, you can issue eclipse with-source=true instead.
After the successful execution of the above command, start eclipse and import the project. See Figure
1-3.
Figure 1-3 Import Wizard
1. Open Eclipse.
4. Click Finish.
Setting Up in IntelliJ
Importing a Play project to Intellij is pretty straightforward. The only precondition is that the Scala
plugin for Intellij should be installed, even when using Java as the language. This is because the Scala
plugin for Intellij is required to resolve the sbt dependencies. So go ahead and install the Scala plugin for
Intellij if you have not done so. Open Intellij and go to File ➤ Settings ➤ Plugins and search for Scala in
the Marketplace tab. From the plugins listed, select the Scala plugin from JetBrains and click Install. See
Figure 1-4.
Figure 1-4 Importing the Scala plugin
After installing the Scala plugin, import the bookshop Play project to IntelliJ. See Figure 1-5.
4. Choose sbt.
5. Click Finish.
Wait for the build to sync and you will see that the project is imported to Intellij.
(If the server started, use Enter to stop, and go back to the console.)
You can even combine the commands together to start Play by using
sbt run
Figure 1-6 Application console
Open the browser and access http://localhost:9000/ to access the home page. See Figure 1-
7.
Configuration
Go to the conf folder and open the routes file. This is where all the URL mappings of the project need
to be defined. You will examine URL mappings and routes configuration in detail in the next chapter.
When you open up the routes file, you should see an entry like this:
GET / controllers.HomeController.index
This means the root of the application points to the index method defined in the
HomeController class.
If you type localhost:portnumber in the browser, the request will be routed to the index
method defined in the app/controllers/HomeController.java file.
This is how Play routes the URL paths or URL patterns to the specific methods of the controller
classes.
Open the HomeController.java file and you can see the method
This method returns a Twirl template file and this template file generates the HTML output. Open the
index.scala.html file found inside the views folder. Let’s examine the contents of this file to
understand what is happening in it.
@()
@main("Welcome to Play") {
<h1>Welcome to Play!</h1>
}
Before we take a look at each element, it is important to understand what Twirl is and how it can be
used.
What is Twirl?
Twirl is the template engine developed for Play Framework. But it can also be used outside the Play
environment. By default, Twirl is included as part of Play but if there is a need to use Twirl outside
Play, then the sbt plugin for Scala can be installed. For example adding the below entry in the
plugins.sbt file will make Twirl available to any sbt-based project:
Template files must be named {name}.scala.{ext} where ext can be html, js, xml, or txt.
The templates can be used to generate various types of markup like HTML, XML, or TXT and are
totally decoupled from the controller. Various kinds of markup can be plugged in as needed.
The Twirl template is just a normal text file that contains small blocks of Scala code. Templates
help to create composite views and help in a component-based view generation.
The @ character marks the beginning of the dynamic code in the template. Chapter 4 of this book
provides detailed explanation of views and Twirl templates.
For the time being, let’s understand what is defined in the index.scala.html file:
@main("Welcome to Play") {
<h1>Welcome to Play!</h1>
}
@main("Welcome to Play") calls another template, main.scala.html and passes it the page
title “Welcome to Play” and the HTML content in the second parameter, enclosed within the {}.
Hence you can infer that main template file should take two parameters: a string for the title and
HTML content as the second parameter.
Open the main.scala.html to validate this. The file starts with @(title: String)
(content: Html); this is just like any normal method that accepts two parameters.
@*
* This template is called from the `index` template. This template
* handles the rendering of the page header and body tags. It takes
* two arguments, a `String` for the title of the page and an `Html`
* object to insert into the body of the page.
*@
<!DOCTYPE html>
<html lang="en">
<head>
@* Here's where we render the page title `String`. *@
<title>@title</title>
<link rel="stylesheet" media="screen"
href="@routes.Assets.versioned("stylesheets/main.css")">
<link rel="shortcut icon" type="image/png"
href="@routes.Assets.versioned("images/favicon.png")">
</head>
<body>
@* And here's where we render the `Html` object containing
* the page content. *@
@content
<script src="@routes.Assets.versioned("javascripts/main.js")"
type="text/javascript"></script>
</body>
</html>
The title string is inserted to HTML <title> using @title and HTML content using @content
markup.
Now you know the different elements and how they are wired together. Let’s take this further by
writing a new action and a view.
Let’s create an entry for the Hello World method:
Save the routes file. The next step is to code your controller to handle the request.
package controllers;
import play.mvc.*;
import views.html.*;
import java.time.LocalDate;
/**
* This controller contains an action to handle HTTP requests
* to the application's home page.
*/
public class HomeController extends Controller {
/**
* An action that renders an HTML page with a welcome message.
* The configuration in the <code>routes</code> file means that
* this method will be called when the application receives a
* <code>GET</code> request with a path of <code>/</code>.
*/
public Result index() {
return ok(views.html.index.render());
}
}
}
Let’s examine the HomeController class in detail to understand what is happening in it. First of
all, it extends from play.mvc.Controller. When you write a new controller, make sure you extend
from play.mvc.Controller.
You’ve seen the index method before: it is pretty simple and it just has a single line. But it does a lot
of smart things. The ok() method is closely related to HTTP status 200, or the success response. If you
want to return a HTTP not found, you can use the notFound method. This is the beauty of Play; it
closely resembles HTTP protocol and there is no need for any fancy code to convert your exceptions to
corresponding HTTP status codes. You can code and talk the language of HTTP.
The ok() method returns the HTML output generated by the render method, defined in the view
named index. You’ve seen this view in index.scala.html. Views in Play use Scala and follow the
naming convention of “viewname.scala.html”. This file gets compiled by the Play compiler into the
corresponding Java class, which can be directly used in the controller. This ensures type safety and less
bugs. Remember that in other frameworks like struts or Spring MVC, you typically return a string as view
name and the framework resolves that to a file. In Play, there is no need for that. The views are
straightaway available as Java class files and you can ensure compile-time type safety.
Since you have already added the routes entry for the hello method, let’s proceed with adding the
controller method and create the view.
View
Create a new file inside the app/views folder and name it hello.scala.html and add the following
contents:
@(message: String)
<!DOCTYPE html>
<html lang="en">
<head>
<title>Hello World </title>
</head>
<body>
<h1> @message </h1>
</body>
</html>
This template takes a single parameter and places that inside the HTML <h1> tags.
Controller
Now edit the HomeController:
package controllers;
import play.mvc.*;
import views.html.*;
import java.time.LocalDate;
/**
* This controller contains an action to handle HTTP requests
* to the application's home page.
*/
public class HomeController extends Controller {
/**
* An action that renders an HTML page with a welcome message.
* The configuration in the <code>routes</code> file means that
* this method will be called when the application receives a
* <code>GET</code> request with a path of <code>/</code>.
*/
public Result index() {
return ok(views.html.index.render());
}
public Result hello() {
return ok(views.html.hello.render("Today is "+LocalDate.now()));
}
}
http://localhost:9000/hello
You will see the message “Today is” and the current date. See Figure 1-8.
Just change any HTML code in the view and refresh the browser. Play will perform on-the-fly
compilation and render the view.
body {
background: black;
}
h1,h2 {
color: white;
}
@(message: String)
@main("Hello World") {
<h2>@message</h2>
}
You want a common theme across the web application and all pages should inherit the site wide
settings as is. You don’t want to scatter the site-wide definitions across all pages, so put all common
settings like header, footer, style sheet definitions, JavaScript inclusions, etc. in a single file; that is what
main.scala.html is used for. It defines the common elements applicable to all pages.
The main.scala.html file is converted by Play into a method equivalent and can be invoked from
other pages using its name. The name doesn’t include the .scala.html part. For instance,
Discovering Diverse Content Through
Random Scribd Documents
sense, who saw the folly and the waste of time in all this, and could
warn others against it. The perceiving our own weaknesses enables
us to give others excellent advice, but it does not teach us to reform
them ourselves. ‘Physician, heal thyself!’ is the hardest lesson to
follow. Nobody knew better than our artist that repose is necessary
to great efforts, and that he who is never idle, labours in vain!
Another error is to spend one’s life in procrastination and
preparations for the future. Persons of this turn of mind stop at the
threshold of art, and accumulate the means of improvement, till they
obstruct their progress to the end. They are always putting off the
evil day, and excuse themselves for doing nothing by commencing
some new and indispensable course of study. Their projects are
magnificent, but remote, and require years to complete or to put
them in execution. Fame is seen in the horizon, and flies before
them. Like the recreant boastful knight in Spenser, they turn their
backs on their competitors, to make a great career, but never return
to the charge. They make themselves masters of anatomy, of
drawing, of perspective: they collect prints, casts, medallions, make
studies of heads, of hands, of the bones, the muscles; copy pictures;
visit Italy, Greece, and return as they went. They fulfil the proverb,
‘When you are at Rome, you must do as those at Rome do.’ This
circuitous, erratic pursuit of art can come to no good. It is only an
apology for idleness and vanity. Foreign travel especially makes men
pedants, not artists. What we seek, we must find at home or
nowhere. The way to do great things is to set about something, and
he who cannot find resources in himself or in his own painting-room,
will perform the grand tour, or go through the circle of the arts and
sciences, and end just where he began!
The same remarks that have been here urged with respect to an
application to the study of art, will, in a great measure, (though not
in every particular) apply to an attention to business: I mean, that
exertion will generally follow success and opportunity in the one, as
it does confidence and talent in the other. Give a man a motive to
work, and he will work. A lawyer who is regularly feed, seldom
neglects to look over his briefs: the more business, the more
industry. The stress laid upon early rising is preposterous. If we have
any thing to do when we get up, we shall not lie in bed, to a certainty.
Thomson the poet was found late in bed by Dr. Burney, and asked
why he had not risen earlier. The Scotchman wisely answered, ‘I had
no motive, young man!’ What indeed had he to do after writing the
Seasons, but to dream out the rest of his existence, unless it were to
write the Castle of Indolence[10]!
ESSAY VII
ON LONDONERS AND COUNTRY PEOPLE
I do not agree with Mr. Blackwood in his definition of the word
Cockney. He means by it a person who has happened at any time to
live in London, and who is not a Tory—I mean by it a person who has
never lived out of London, and who has got all his ideas from it.
The true Cockney has never travelled beyond the purlieus of the
Metropolis, either in the body or the spirit. Primrose-hill is the
Ultima Thule of his most romantic desires; Greenwich Park stands
him in stead of the Vales of Arcady. Time and space are lost to him.
He is confined to one spot, and to the present moment. He sees every
thing near, superficial, little, in hasty succession. The world turns
round, and his head with it, like a round-about at a fair, till he
becomes stunned and giddy with the motion. Figures glide by as in a
camera obscura. There is a glare, a perpetual hubbub, a noise, a
crowd about him; he sees and hears a vast number of things, and
knows nothing. He is pert, raw, ignorant, conceited, ridiculous,
shallow, contemptible. His senses keep him alive; and he knows,
inquires, and cares for nothing farther. He meets the Lord Mayor’s
coach, and without ceremony treats himself to an imaginary ride in
it. He notices the people going to court or to a city-feast, and is quite
satisfied with the show. He takes the wall of a Lord, and fancies
himself as good as he. He sees an infinite quantity of people pass
along the street, and thinks there is no such thing as life or a
knowledge of character to be found out of London. ‘Beyond Hyde
Park all is a desart to him.’ He despises the country, because he is
ignorant of it, and the town, because he is familiar with it. He is as
well acquainted with St. Paul’s as if he had built it, and talks of
Westminster Abbey and Poets’ Corner with great indifference. The
King, the House of Lords and Commons are his very good friends. He
knows the members for Westminster or the City by sight, and bows
to the Sheriffs or the Sheriffs’ men. He is hand and glove with the
Chairman of some Committee. He is, in short, a great man by proxy,
and comes so often in contact with fine persons and things, that he
rubs off a little of the gilding, and is surcharged with a sort of second-
hand, vapid, tingling, troublesome self-importance. His personal
vanity is thus continually flattered and perked up into ridiculous self-
complacency, while his imagination is jaded and impaired by daily
misuse. Every thing is vulgarised in his mind. Nothing dwells long
enough on it to produce an interest; nothing is contemplated
sufficiently at a distance to excite curiosity or wonder. Your true
Cockney is your only true leveller. Let him be as low as he will, he
fancies he is as good as any body else. He has no respect for himself,
and still less (if possible) for you. He cares little about his own
advantages, if he can only make a jest at yours. Every feeling comes
to him through a medium of levity and impertinence; nor does he
like to have this habit of mind disturbed by being brought into
collision with any thing serious or respectable. He despairs (in such a
crowd of competitors) of distinguishing himself, but laughs heartily
at the idea of being able to trip up the heels of other people’s
pretensions. A Cockney feels no gratitude. This is a first principle
with him. He regards any obligation you confer upon him as a
species of imposition, a ludicrous assumption of fancied superiority.
He talks about everything, for he has heard something about it; and
understanding nothing of the matter, concludes he has as good a
right as you. He is a politician; for he has seen the Parliament House:
he is a critic; because he knows the principal actors by sight—has a
taste for music, because he belongs to a glee-club at the West End,
and is gallant, in virtue of sometimes frequenting the lobbies at half-
price. A mere Londoner, in fact, from the opportunities he has of
knowing something of a number of objects (and those striking ones)
fancies himself a sort of privileged person; remains satisfied with the
assumption of merits, so much the more unquestionable as they are
not his own; and from being dazzled with noise, show, and
appearances, is less capable of giving a real opinion, or entering into
any subject than the meanest peasant. There are greater lawyers,
orators, painters, philosophers, poets, players in London, than in any
other part of the United Kingdom: he is a Londoner, and therefore it
would be strange if he did not know more of law, eloquence, art,
philosophy, poetry, acting, than any one without his local
advantages, and who is merely from the country. This is a non
sequitur; and it constantly appears so when put to the test.
A real Cockney is the poorest creature in the world, the most
literal, the most mechanical, and yet he too lives in a world of
romance—a fairy-land of his own. He is a citizen of London; and this
abstraction leads his imagination the finest dance in the world.
London is the first city on the habitable globe; and therefore he must
be superior to every one who lives out of it. There are more people in
London than any where else; and though a dwarf in stature, his
person swells out and expands into ideal importance and borrowed
magnitude. He resides in a garret or in a two pair of stairs’ back
room; yet he talks of the magnificence of London, and gives himself
airs of consequence upon it, as if all the houses in Portman or in
Grosvenor Square were his by right or in reversion. ‘He is owner of
all he surveys.’ The Monument, the Tower of London, St. James’s
Palace, the Mansion House, White-Hall, are part and parcel of his
being. Let us suppose him to be a lawyer’s clerk at half-a-guinea a
week: but he knows the Inns of Court, the Temple Gardens, and
Gray’s-Inn Passage, sees the lawyers in their wigs walking up and
down Chancery Lane, and has advanced within half-a-dozen yards of
the Chancellor’s chair:—who can doubt that he understands (by
implication) every point of law (however intricate) better than the
most expert country practitioner? He is a shopman, and nailed all
day behind the counter: but he sees hundreds and thousands of gay,
well-dressed people pass—an endless phantasmagoria—and enjoys
their liberty and gaudy fluttering pride. He is a footman—but he
rides behind beauty, through a crowd of carriages, and visits a
thousand shops. Is he a tailor—that last infirmity of human nature?
The stigma on his profession is lost in the elegance of the patterns he
provides, and of the persons he adorns; and he is something very
different from a mere country botcher. Nay, the very scavenger and
nightman thinks the dirt in the street has something precious in it,
and his employment is solemn, silent, sacred, peculiar to London! A
barker in Monmouth Street, a slop-seller in Radcliffe Highway, a
tapster at a night-cellar, a beggar in St. Giles’s, a drab in Fleet-Ditch,
live in the eyes of millions, and eke out a dreary, wretched, scanty, or
loathsome existence from the gorgeous, busy, glowing scene around
them. It is a common saying among such persons that ‘they had
rather be hanged in London than die a natural death out of it any
where else’—Such is the force of habit and imagination. Even the eye
of childhood is dazzled and delighted with the polished splendour of
the jewellers’ shops, the neatness of the turnery ware, the festoons of
artificial flowers, the confectionery, the chemists’ shops, the lamps,
the horses, the carriages, the sedan-chairs: to this was formerly
added a set of traditional associations—Whittington and his Cat, Guy
Faux and the Gunpowder Treason, the Fire and the Plague of
London, and the Heads of the Scotch Rebels that were stuck on
Temple Bar in 1745. These have vanished, and in their stead the
curious and romantic eye must be content to pore in Pennant for the
scite of old London-Wall, or to peruse the sentimental mile-stone
that marks the distance to the place ‘where Hickes’s Hall formerly
stood!’
The Cockney lives in a go-cart of local prejudices and positive
illusions; and when he is turned out of it, he hardly knows how to
stand or move. He ventures through Hyde Park Corner, as a cat
crosses a gutter. The trees pass by the coach very oddly. The country
has a strange blank appearance. It is not lined with houses all the
way, like London. He comes to places he never saw or heard of. He
finds the world is bigger than he thought for. He might have dropped
from the moon, for any thing he knows of the matter. He is mightily
disposed to laugh, but is half afraid of making some blunder.
Between sheepishness and conceit, he is in a very ludicrous situation.
He finds that the people walk on two legs, and wonders to hear them
talk a dialect so different from his own. He perceives London
fashions have got down into the country before him, and that some
of the better sort are dressed as well as he is. A drove of pigs or cattle
stopping the road is a very troublesome interruption. A crow in a
field, a magpie in a hedge, are to him very odd animals—he can’t tell
what to make of them, or how they live. He does not altogether like
the accommodations at the inns—it is not what he has been used to
in town. He begins to be communicative—says he was ‘born within
the sound of Bow-bell,’ and attempts some jokes, at which nobody
laughs. He asks the coachman a question, to which he receives no
answer. All this is to him very unaccountable and unexpected. He
arrives at his journey’s end; and instead of being the great man he
anticipated among his friends and country relations, finds that they
are barely civil to him, or make a butt of him; have topics of their
own which he is as completely ignorant of as they are indifferent to
what he says, so that he is glad to get back to London again, where he
meets with his favourite indulgences and associates, and fancies the
whole world is occupied with what he hears and sees.
A Cockney loves a tea-garden in summer, as he loves the play or
the Cider-Cellar in winter—where he sweetens the air with the fumes
of tobacco, and makes it echo to the sound of his own voice. This
kind of suburban retreat is a most agreeable relief to the close and
confined air of a city life. The imagination, long pent up behind a
counter or between brick walls, with noisome smells, and dingy
objects, cannot bear at once to launch into the boundless expanse of
the country, but ‘shorter excursions tries,’ coveting something
between the two, and finding it at White-conduit House, or the
Rosemary Branch, or Bagnigge Wells. The landlady is seen at a bow-
window in near perspective, with punch-bowls and lemons disposed
orderly around—the lime-trees or poplars wave overhead to ‘catch
the breezy air,’ through which, typical of the huge dense cloud that
hangs over the metropolis, curls up the thin, blue, odoriferous
vapour of Virginia or Oronooko—the benches are ranged in rows, the
fields and hedge-rows spread out their verdure; Hampstead and
Highgate are seen in the back-ground, and contain the imagination
within gentle limits—here the holiday people are playing ball; here
they are playing bowls—here they are quaffing ale, there sipping tea
—here the loud wager is heard, there the political debate. In a
sequestered nook a slender youth with purple face and drooping
head, nodding over a glass of gin toddy, breathes in tender accents
—‘There’s nought so sweet on earth as Love’s young dream;’ while
‘Rosy Ann’ takes its turn, and ‘Scots wha hae wi’ Wallace bled’ is
thundered forth in accents that might wake the dead. In another part
sit carpers and critics, who dispute the score of the reckoning or the
game, or cavil at the taste and execution of the would-be Brahams
and Durusets. Of this latter class was Dr. Goodman, a man of other
times—I mean of those of Smollett and Defoe—who was curious in
opinion, obstinate in the wrong, great in little things, and inveterate
in petty warfare. I vow he held me an argument once ‘an hour by St.
Dunstan’s clock,’ while I held an umbrella over his head (the friendly
protection of which he was unwilling to quit to walk in the rain to
Camberwell) to prove to me that Richard Pinch was neither a fives-
player nor a pleasing singer. ‘Sir,’ said he, ‘I deny that Mr. Pinch
plays the game. He is a cunning player, but not a good one. I grant
his tricks, his little mean dirty ways, but he is not a manly antagonist.
He has no hit, and no left-hand. How then can he set up for a
superior player? And then as to his always striking the ball against
the side-wings at Copenhagen-house, Cavanagh, sir, used to say,
“The wall was made to hit at!” I have no patience with such pitiful
shifts and advantages. They are an insult upon so fine and athletic a
game! And as to his setting up for a singer, it’s quite ridiculous. You
know, Mr. H——, that to be a really excellent singer, a man must lay
claim to one of two things; in the first place, sir, he must have a
naturally fine ear for music, or secondly, an early education,
exclusively devoted to that study. But no one ever suspected Mr.
Pinch of refined sensibility; and his education, as we all know, has
been a little at large. Then again, why should he of all other things be
always singing “Rosy Ann,” and “Scots wha hae wi’ Wallace bled,” till
one is sick of hearing them? It’s preposterous, and I mean to tell him
so. You know, I’m sure, without my hinting it, that in the first of
these admired songs, the sentiment is voluptuous and tender, and in
the last patriotic. Now Pinch’s romance never wandered from behind
his counter, and his patriotism lies in his breeches’ pocket. Sir, the
utmost he should aspire to would be to play upon the Jews’ harp!’
This story of the Jews’ harp tickled some of Pinch’s friends, who gave
him various hints of it, which nearly drove him mad, till he
discovered what it was; for though no jest or sarcasm ever had the
least effect upon him, yet he cannot bear to think that there should
be any joke of this kind about him, and he not in the secret: it makes
against that knowing character which he so much affects. Pinch is in
one respect a complete specimen of a Cockney. He never has any
thing to say, and yet is never at a loss for an answer. That is, his
pertness keeps exact pace with his dulness. His friend, the Doctor,
used to complain of this in good set terms.—‘You can never make any
thing of Mr. Pinch,’ he would say. ‘Apply the most cutting remark to
him, and his only answer is, “The same to you, sir.” If Shakespear
were to rise from the dead to confute him, I firmly believe it would be
to no purpose. I assure you, I have found it so. I once thought indeed
I had him at a disadvantage, but I was mistaken. You shall hear, sir. I
had been reading the following sentiment in a modern play—“The
Road to Ruin,” by the late Mr. Holcroft—“For how should the soul of
Socrates inhabit the body of a stocking-weaver?” This was pat to the
point (you know our friend is a hosier and haberdasher) I came full
with it to keep an appointment I had with Pinch, began a game,
quarrelled with him in the middle of it on purpose, went up stairs to
dress, and as I was washing my hands in the slop-basin (watching my
opportunity) turned coolly round and said, “It’s impossible there
should be any sympathy between you and me, Mr. Pinch: for as the
poet says, how should the soul of Socrates inhabit the body of a
stocking-weaver?” “Ay,” says he, “does the poet say so? then the
same to you, sir!” I was confounded, I gave up the attempt to
conquer him in wit or argument. He would pose the Devil, sir, by his
“The same to you, sir.”’ We had another joke against Richard Pinch,
to which the Doctor was not a party, which was, that being asked
after the respectability of the Hole in the Wall, at the time that
Randall took it, he answered quite unconsciously, ‘Oh! it’s a very
genteel place, I go there myself sometimes!’ Dr. Goodman was
descended by the mother’s side from the poet Jago, was a private
gentleman in town, and a medical dilettanti in the country, dividing
his time equally between business and pleasure; had an
inexhaustible flow of words, and an imperturbable vanity, and held
‘stout notions on the metaphysical score.’ He maintained the free
agency of man, with the spirit of a martyr and the gaiety of a man of
wit and pleasure about town—told me he had a curious tract on that
subject by A. C. (Anthony Collins) which he carefully locked up in his
box, lest any one should see it but himself, to the detriment of their
character and morals, and put it to me whether it was not hard, on
the principles of philosophical necessity, for a man to come to be
hanged? To which I replied, ‘I thought it hard on any terms!’ A
knavish marker, who had listened to the dispute, laughed at this
retort, and seemed to assent to the truth of it, supposing it might one
day be his own case.
Mr. Smith and the Brangtons, in ‘Evelina,’ are the finest possible
examples of the spirit of Cockneyism. I once knew a linen-draper in
the City, who owned to me he did not quite like this part of Miss
Burney’s novel. He said, ‘I myself lodge in a first floor, where there
are young ladies in the house: they sometimes have company, and if I
am out, they ask me to lend them the use of my apartment, which I
readily do out of politeness, or if it is an agreeable party, I perhaps
join them. All this is so like what passes in the novel, that I fancy
myself a sort of second Mr. Smith, and am not quite easy at it!’ This
was mentioned to the fair Authoress, and she was delighted to find
that her characters were so true, that an actual person fancied
himself to be one of them. The resemblance, however, was only in
the externals; and the real modesty of the individual stumbled on the
likeness to a city coxcomb!
It is curious to what a degree persons, brought up in certain
occupations in a great city, are shut up from a knowledge of the
world, and carry their simplicity to a pitch of unheard of
extravagance. London is the only place in which the child grows
completely up into the man. I have known characters of this kind,
which, in the way of childish ignorance and self-pleasing delusion,
exceeded any thing to be met with in Shakespear or Ben Jonson, or
the old comedy. For instance, the following may be taken as a true
sketch. Imagine a person with a florid, shining complexion like a
plough-boy, large staring teeth, a merry eye, his hair stuck into the
fashion with curling-irons and pomatum, a slender figure, and a
decent suit of black—add to which the thoughtlessness of the school-
boy, the forwardness of the thriving tradesman, and the plenary
consciousness of the citizen of London—and you have Mr. Dunster
before you, the fishmonger in the Poultry. You shall hear how he
chirps over his cups, and exults in his private opinions. ‘I’ll play no
more with you,’ I said, ‘Mr. Dunster—you are five points in the game
better than I am.’ I had just lost three half-crown rubbers at cribbage
to him, which loss of mine he presently thrust into a canvas pouch
(not a silk purse) out of which he had produced just before, first a
few halfpence, then half a dozen pieces of silver, then a handfull of
guineas, and lastly, lying perdu at the bottom, a fifty pound Bank-
Note. ‘I’ll tell you what,’ I said, ‘I should like to play you a game at
marbles’—this was at a sort of Christmas party or Twelfth Night
merry-making. ‘Marbles!’ said Dunster, catching up the sound, and
his eye brightening with childish glee, ‘What! you mean ring-taw?’
‘Yes.’ ‘I should beat you at it, to a certainty. I was one of the best in
our school (it was at Clapham, sir, the Rev. Mr. Denman’s, at
Clapham, was the place where I was brought up) though there were
two others there better than me. They were the best that ever were.
I’ll tell you, sir, I’ll give you an idea. There was a water-butt or
cistern, sir, at our school, that turned with a cock. Now suppose that
brass-ring that the window-curtain is fastened to, to be the cock, and
that these boys were standing where we are, about twenty feet off—
well, sir, I’ll tell you what I have seen them do. One of them had a
favourite taw (or alley we used to call them) he’d take aim at the cock
of the cistern with this marble, as I may do now. Well, sir, will you
believe it? such was his strength of knuckle and certainty of aim, he’d
hit it, turn it, let the water out, and then, sir, when the water had run
out as much as it was wanted, the other boy (he’d just the same
strength of knuckle, and the same certainty of eye) he’d aim at it too,
be sure to hit it, turn it round, and stop the water from running out.
Yes, what I tell you is very remarkable, but it’s true. One of these
boys was named Cock, and t’other Butler.’ ‘They might have been
named Spigot and Fawcett, my dear sir, from your account of them.’
‘I should not mind playing you at fives neither, though I’m out of
practice. I think I should beat you in a week: I was a real good one at
that. A pretty game, sir! I had the finest ball, that I suppose ever was
seen. Made it myself, I’ll tell you how, sir. You see, I put a piece of
cork at the bottom, then I wound some fine worsted yarn round it,
then I had to bind it round with some packthread, and then sew the
case on. You’d hardly believe it, but I was the envy of the whole
school for that ball. They all wanted to get it from me, but lord, sir, I
would let none of them come near it. I kept it in my waistcoat pocket
all day, and at night I used to take it to bed with me and put it under
my pillow. I couldn’t sleep easy without it.’
The same idle vein might be found in the country, but I doubt
whether it would find a tongue to give it utterance. Cockneyism is a
ground of native shallowness mounted with pertness and conceit. Yet
with all this simplicity and extravagance in dilating on his favourite
topics, Dunster is a man of spirit, of attention to business, knows
how to make out and get in his bills, and is far from being hen-
pecked. One thing is certain, that such a man must be a true
Englishman and a loyal subject. He has a slight tinge of letters, with
shame I confess it—has in his possession a volume of the European
Magazine for the year 1761, and is an humble admirer of Tristram
Shandy (particularly the story of the King of Bohemia and his Seven
Castles, which is something in his own endless manner) and of Gil
Blas of Santillane. Over these (the last thing before he goes to bed at
night) he smokes a pipe, and meditates for an hour. After all, what is
there in these harmless half-lies, these fantastic exaggerations, but a
literal, prosaic, Cockney translation of the admired lines in Gray’s
Ode to Eton College:—
‘What idle progeny succeed
To chase the rolling circle’s speed
Or urge the flying ball?’
A man shut up all his life in his shop, without any thing to interest
him from one year’s end to another but the cares and details of
business, with scarcely any intercourse with books or opportunities
for society, distracted with the buzz and glare and noise about him,
turns for relief to the retrospect of his childish years; and there,
through the long vista, at one bright loop-hole, leading out of the
thorny mazes of the world into the clear morning light, he sees the
idle fancies and gay amusements of his boyhood dancing like motes
in the sunshine. Shall we blame or should we laugh at him, if his eye
glistens, and his tongue grows wanton in their praise?
None but a Scotchman would—that pragmatical sort of personage,
who thinks it a folly ever to have been young, and who instead of
dallying with the frail past, bends his brows upon the future, and
looks only to the mainchance. Forgive me, dear Dunster, if I have
drawn a sketch of some of thy venial foibles, and delivered thee into
the hands of these Cockneys of the North, who will fall upon thee and
devour thee, like so many cannibals, without a grain of salt!
If familiarity in cities breeds contempt, ignorance in the country
breeds aversion and dislike. People come too much in contact in
town: in other places they live too much apart, to unite cordially and
easily. Our feelings, in the former case, are dissipated and exhausted
by being called into constant and vain activity; in the latter they rust
and grow dead for want of use. If there is an air of levity and
indifference in London manners, there is a harshness, a moroseness,
and disagreeable restraint in those of the country. We have little
disposition to sympathy, when we have few persons to sympathise
with: we lose the relish and capacity for social enjoyment, the
seldomer we meet. A habit of sullenness, coldness, and misanthropy
grows upon us. If we look for hospitality and a cheerful welcome in
country places, it must be in those where the arrival of a stranger is
an event, the recurrence of which need not be greatly apprehended,
or it must be on rare occasions, on ‘some high festival of once a year.’
Then indeed the stream of hospitality, so long dammed up, may flow
without stint for a short season; or a stranger may be expected with
the same sort of eager impatience as a caravan of wild beasts, or any
other natural curiosity, that excites our wonder and fills up the
craving of the mind after novelty. By degrees, however, even this last
principle loses its effect: books, newspapers, whatever carries us out
of ourselves into a world of which we see and know nothing, becomes
distasteful, repulsive; and we turn away with indifference or disgust
from every thing that disturbs our lethargic animal existence, or
takes off our attention from our petty, local interests and pursuits.
Man, left long to himself, is no better than a mere clod; or his
activity, for want of some other vent, preys upon himself, or is
directed to splenetic, peevish dislikes, or vexatious, harassing
persecution of others. I once drew a picture of a country-life: it was a
portrait of a particular place, a caricature if you will, but with certain
allowances, I fear it was too like in the individual instance, and that it
would hold too generally true. See Round Table, vol. ii. p. 116.
If these then are the faults and vices of the inhabitants of town or
of the country, where should a man go to live, so as to escape from
them? I answer, that in the country we have the society of the groves,
the fields, the brooks, and in London a man may keep to himself, or
chuse his company as he pleases.
It appears to me that there is an amiable mixture of these two
opposite characters in a person who chances to have past his youth
in London, and who has retired into the country for the rest of his
life. We may find in such a one a social polish, a pastoral simplicity.
He rusticates agreeably, and vegetates with a degree of sentiment. He
comes to the next post-town to see for letters, watches the coaches as
they pass, and eyes the passengers with a look of familiar curiosity,
thinking that he too was a gay fellow in his time. He turns his horse’s
head down the narrow lane that leads homewards, puts on an old
coat to save his wardrobe, and fills his glass nearer to the brim. As he
lifts the purple juice to his lips and to his eye, and in the dim solitude
that hems him round, thinks of the glowing line—
‘This bottle’s the sun of our table’—
another sun rises upon his imagination; the sun of his youth, the
blaze of vanity, the glitter of the metropolis, ‘glares round his soul,
and mocks his closing eye-lids.’ The distant roar of coaches in his
ears—the pit stare upon him with a thousand eyes—Mrs. Siddons,
Bannister, King, are before him—he starts as from a dream, and
swears he will to London; but the expense, the length of way deters
him, and he rises the next morning to trace the footsteps of the hare
that has brushed the dew-drops from the lawn, or to attend a
meeting of Magistrates! Mr. Justice Shallow answered in some sort
to this description of a retired Cockney and indigenous country-
gentleman. He ‘knew the Inns of Court, where they would talk of
mad Shallow yet, and where the bona robas were, and had them at
commandment: aye, and had heard the chimes at midnight!’
It is a strange state of society (such as that in London) where a
man does not know his next-door neighbour, and where the feelings
(one would think) must recoil upon themselves, and either fester or
become obtuse. Mr. Wordsworth, in the preface to his poem of the
‘Excursion,’ represents men in cities as so many wild beasts or evil
spirits, shut up in cells of ignorance, without natural affections, and
barricadoed down in sensuality and selfishness. The nerve of
humanity is bound up, according to him, the circulation of the blood
stagnates. And it would be so, if men were merely cut off from
intercourse with their immediate neighbours, and did not meet
together generally and more at large. But man in London becomes,
as Mr. Burke has it, a sort of ‘public creature.’ He lives in the eye of
the world, and the world in his. If he witnesses less of the details of
private life, he has better opportunities of observing its larger masses
and varied movements. He sees the stream of human life pouring
along the streets—its comforts and embellishments piled up in the
shops—the houses are proofs of the industry, the public buildings of
the art and magnificence of man; while the public amusements and
places of resort are a centre and support for social feeling. A
playhouse alone is a school of humanity, where all eyes are fixed on
the same gay or solemn scene, where smiles or tears are spread from
face to face, and where a thousand hearts beat in unison! Look at the
company in a country-theatre (in comparison) and see the coldness,
the sullenness, the want of sympathy, and the way in which they turn
round to scan and scrutinise one another. In London there is a
public; and each man is part of it. We are gregarious, and affect the
kind. We have a sort of abstract existence; and a community of ideas
and knowledge (rather than local proximity) is the bond of society
and good-fellowship. This is one great cause of the tone of political
feeling in large and populous cities. There is here a visible body-
politic, a type and image of that huge Leviathan the State. We
comprehend that vast denomination, the People, of which we see a
tenth part daily moving before us; and by having our imaginations
emancipated from petty interests and personal dependence, we learn
to venerate ourselves as men, and to respect the rights of human
nature. Therefore it is that the citizens and freemen of London and
Westminster are patriots by prescription, philosophers and
politicians by the right of their birth-place. In the country, men are
no better than a herd of cattle or scattered deer. They have no idea
but of individuals, none of rights or principles—and a king, as the
greatest individual, is the highest idea they can form. He is ‘a species
alone,’ and as superior to any single peasant as the latter is to the
peasant’s dog, or to a crow flying over his head. In London the king is
but as one to a million (numerically speaking), is seldom seen, and
then distinguished only from others by the superior graces of his
person. A country ’squire or a lord of the manor is a greater man in
his village or hundred!
ESSAY VIII
ON THE SPIRIT OF OBLIGATIONS
The two rarest things to be met with are good sense and good-
nature. For one man who judges right, there are twenty who can say
good things; as there are numbers who will serve you or do friendly
actions, for one who really wishes you well. It has been said, and
often repeated, that ‘mere good-nature is a fool:’ but I think that the
dearth of sound sense, for the most part, proceeds from the want of a
real, unaffected interest in things, except as they react upon
ourselves; or from a neglect of the maxim of that good old
philanthropist, who said, ‘Nihil humani a me alienum puto.’ The
narrowness of the heart warps the understanding, and makes us
weigh objects in the scales of our self-love, instead of those of truth
and justice. We consider not the merits of the case, or what is due to
others, but the manner in which our own credit or consequence will
be affected; and adapt our opinions and conduct to the last of these
rather than to the first. The judgment is seldom wrong where the
feelings are right; and they generally are so, provided they are warm
and sincere. He who intends others well, is likely to advise them for
the best; he who has any cause at heart, seldom ruins it by his
imprudence. Those who play the public or their friends slippery
tricks, have in secret no objection to betray them.
One finds out the folly and malice of mankind by the impertinence
of friends—by their professions of service and tenders of advice—by
their fears for your reputation and anticipation of what the world
may say of you; by which means they suggest objections to your
enemies, and at the same time absolve themselves from the task of
justifying your errors, by having warned you of the consequences—by
the care with which they tell you ill-news, and conceal from you any
flattering circumstance—by their dread of your engaging in any
creditable attempt, and mortification, if you succeed—by the
difficulties and hindrances they throw in your way—by their
satisfaction when you happen to make a slip or get into a scrape, and
their determination to tie your hands behind you, lest you should get
out of it—by their panic-terrors at your entering into a vindication of
yourself, lest in the course of it, you should call upon them for a
certificate to your character—by their lukewarmness in defending, by
their readiness in betraying you—by the high standard by which they
try you, and to which you can hardly ever come up—by their
forwardness to partake your triumphs, by their backwardness to
share your disgrace—by their acknowledgment of your errors out of
candour, and suppression of your good qualities out of envy—by
their not contradicting, or by their joining in the cry against you, lest
they too should become objects of the same abuse—by their playing
the game into your adversaries’ hands, by always letting their
imaginations take part with their cowardice, their vanity, and
selfishness against you; and thus realising or hastening all the ill
consequences they affect to deplore, by spreading abroad that very
spirit of distrust, obloquy, and hatred which they predict will be
excited against you!
In all these pretended demonstrations of an over-anxiety for our
welfare, we may detect a great deal of spite and ill-nature lurking
under the disguise of a friendly and officious zeal. It is wonderful
how much love of mischief and rankling spleen lies at the bottom of
the human heart, and how a constant supply of gall seems as
necessary to the health and activity of the mind as of the body. Yet
perhaps it ought not to excite much surprise that this gnawing,
morbid, acrimonious temper should produce the effects it does,
when, if it does not vent itself on others, it preys upon our own
comforts, and makes us see the worst side of every thing, even as it
regards our own prospects and tranquillity. It is the not being
comfortable in ourselves, that makes us seek to render other people
uncomfortable. A person of this character will advise you against a
prosecution for a libel, and shake his head at your attempting to
shield yourself from a shower of calumny—It is not that he is afraid
you will be nonsuited, but that you will gain a verdict! They caution
you against provoking hostility, in order that you may submit to
indignity. They say that ‘if you publish a certain work, it will be your
ruin’—hoping that it will, and by their tragical denunciations,
bringing about this very event as far as it lies in their power, or at any
rate, enjoying a premature triumph over you in the mean time. What
I would say to any friend who may be disposed to foretell a general
outcry against any work of mine, would be to request him to judge
and speak of it for himself, as he thinks it deserves—and not by his
overweening scruples and qualms of conscience on my account, to
afford those very persons whose hostility he deprecates the cue they
are to give to party-prejudice, and which they may justify by his
authority.
Suppose you are about to give Lectures at a Public Institution,
these friends and well-wishers hope ‘you’ll be turned out—if you
preserve your principles, they are sure you will.’ Is it that your
consistency gives them any concern? No, but they are uneasy at your
gaining a chance of a little popularity—they do not like this new
feather in your cap, they wish to see it struck out, for the sake of your
character—and when this was once the case, it would be an
additional relief to them to see your character following the same
road the next day. The exercise of their bile seems to be the sole
employment and gratification of such people. They deal in the
miseries of human life. They are always either hearing or foreboding
some new grievance. They cannot contain their satisfaction, if you
tell them any mortification or cross-accident that has happened to
yourself; and if you complain of their want of sympathy, they laugh
in your face. This would be unaccountable, but for the spirit of
perversity and contradiction implanted in human nature. If things go
right, there is nothing to be done—these active-minded persons grow
restless, dull, vapid,—life is a sleep, a sort of euthanasia—Let them
go wrong, and all is well again; they are once more on the alert, have
something to pester themselves and other people about; may
wrangle on, and ‘make mouths at the invisible event!’ Luckily, there
is no want of materials for this disposition to work upon, there is
plenty of grist for the mill. If you fall in love, they tell you (by way of
consolation) it is a pity that you do not fall downstairs and fracture a
limb—it would be a relief to your mind, and shew you your folly. So
they would reform the world. The class of persons I speak of are
almost uniform grumblers and croakers against governments; and it
must be confessed, governments are of great service in fostering their
humours. ‘Born for their use, they live but to oblige them.’ While
kings are left free to exercise their proper functions, and poet-
laureates make out their Mittimus to Heaven without a warrant, they
will never stop the mouths of the censorious by changing their
dispositions; the juices of faction will ferment, and the secretions of
the state be duly performed! I do not mind when a character of this
sort meets a Minister of State like an east-wind round a corner, and
gives him an ague-fit; but why should he meddle with me? Why
should he tell me I write too much, and say that I should gain
reputation if I could contrive to starve for a twelvemonth? Or if I
apply to him for a loan of fifty pounds for present necessity, send me
word back that he has too much regard for me, to comply with my
request? It is unhandsome irony. It is not friendly, ’tis not
pardonable.[11]
I like real good-nature and good-will, better than I do any offers of
patronage or plausible rules for my conduct in life. I may suspect the
soundness of the last, and I may not be quite sure of the motives of
the first. People complain of ingratitude for benefits, and of the
neglect of wholesome advice. In the first place, we pay little attention
to advice, because we are seldom thought of in it. The person who
gives it either contents himself to lay down (ex cathedrâ) certain
vague, general maxims, and ‘wise saws,’ which we knew before; or,
instead of considering what we ought to do, recommends what he
himself would do. He merely substitutes his own will, caprice, and
prejudices for ours, and expects us to be guided by them. Instead of
changing places with us (to see what is best to be done in the given
circumstances), he insists on our looking at the question from his
point of view, and acting in such a manner as to please him. This is
not at all reasonable; for one man’s meat, according to the old adage,
is another man’s poison. And it is not strange, that starting from
such opposite premises, we should seldom jump in a conclusion, and
that the art of giving and taking advice is little better than a game at
cross-purposes. I have observed that those who are the most inclined
to assist others are the least forward or peremptory with their advice;
for having our interest really at heart, they consider what can, rather
than what cannot be done, and aid our views and endeavour to avert
ill consequences by moderating our impatience and allaying
irritations, instead of thwarting our main design, which only tends to
make us more extravagant and violent than ever. In the second place,
benefits are often conferred out of ostentation or pride, rather than
from true regard; and the person obliged is too apt to perceive this.
People who are fond of appearing in the light of patrons will perhaps
go through fire and water to serve you, who yet would be sorry to
find you no longer wanted their assistance, and whose friendship
cools and their good-will slackens, as you are relieved by their active
zeal from the necessity of being further beholden to it. Compassion
and generosity are their favourite virtues; and they countenance you,
as you afford them opportunities for exercising them. The instant
you can go alone, or can stand upon your own ground, you are
discarded as unfit for their purpose.
This is something more than mere good-nature or humanity. A
thoroughly good-natured man, a real friend, is one who is pleased at
our good-fortune, as well as prompt to seize every occasion of
relieving our distress. We apportion our gratitude accordingly. We
are thankful for good-will rather than for services, for the motive
than the quantum of favour received—a kind word or look is never
forgotten, while we cancel prouder and weightier obligations; and
those who esteem us or evince a partiality to us are those whom we
still consider as our best friends. Nay, so strong is this feeling, that
we extend it even to those counterfeits in friendship, flatterers and
sycophants. Our self-love, rather than our self-interest, is the master-
key to our affections.
I am not convinced that those are always the best-natured or the
best-conditioned men, who busy themselves most with the distresses
of their fellow-creatures. I do not know that those whose names
stand at the head of all subscriptions to charitable institutions, and
who are perpetual stewards of dinners and meetings to encourage
and promote the establishment of asylums for the relief of the blind,
the halt, and the orphan poor, are persons gifted with the best
tempers or the kindliest feelings. I do not dispute their virtue, I
doubt their sensibility. I am not here speaking of those who make a
trade of the profession of humanity, or set their names down out of
mere idle parade and vanity. I mean those who really enter into the
details and drudgery of this sort of service, con amore, and who
delight in surveying and in diminishing the amount of human
misery. I conceive it possible, that a person who is going to pour oil
and balm into the wounds of afflicted humanity, at a meeting of the
Western Dispensary, by handsome speeches and by a handsome
donation (not grudgingly given) may be thrown into a fit of rage that
very morning, by having his toast too much buttered, may quarrel
with the innocent prattle and amusements of his children, cry ‘Pish!’
at every observation his wife utters, and scarcely feel a moment’s
comfort at any period of his life, except when he hears or reads of
some case of pressing distress that calls for his immediate
interference, and draws off his attention from his own situation and
feelings by the act of alleviating it. Those martyrs to the cause of
humanity, in short, who run the gauntlet of the whole catalogue of
unheard-of crimes and afflicting casualties, who ransack prisons, and
plunge into lazar-houses and slave-ships as their daily amusement
and highest luxury, must generally, I think (though not always), be
prompted to the arduous task by uneasy feelings of their own, and
supported through it by iron nerves. Their fortitude must be equal to
their pity. I do not think Mr. Wilberforce a case in point in this
argument. He is evidently a delicately-framed, nervous, sensitive
man. I should suppose him to be a kind and affectionately disposed
person in all the relations of life. His weakness is too quick a sense of
reputation, a desire to have the good word of all men, a tendency to
truckle to power and fawn on opinion. But there are some of these
philanthropists that a physiognomist has hard work to believe in.
They seem made of pasteboard, they look like mere machines: their
benevolence may be said to go on rollers, and they are screwed to the
sticking-place by the wheels and pulleys of humanity:
‘If to their share some splendid virtues fall,
Look in their face, and you forget them all.’
They appear so much the creatures of the head and so little of the
heart, they are so cold, so lifeless, so mechanical, so much governed
by calculation, and so little by impulse, that it seems the toss-up of a
halfpenny, a mere turn of a feather, whether such people should
become a Granville Sharp, or a Hubert in ‘King John,’ a Howard, or a
Sir Hudson Lowe!
‘Charity covers a multitude of sins.’ Wherever it is, there nothing
can be wanting; wherever it is not, all else is vain. ‘The meanest
peasant on the bleakest mountain is not without a portion of it (says
Sterne), he finds the lacerated lamb of another’s flock,’ &c. (See the
passage in the Sentimental Journey.) I do not think education or
circumstances can ever entirely eradicate this principle. Some
professions may be supposed to blunt it, but it is perhaps more in
appearance than in reality. Butchers are not allowed to sit on a jury
for life and death; but probably this is a prejudice: if they have the
destructive organ in an unusual degree of expansion, they vent their
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