0% found this document useful (0 votes)
11 views

Getting Started with Meteor js JavaScript Framework 2nd Edition Learn to develop powerful web applications in minutes with Meteor Isaac Strack - Download the full ebook set with all chapters in PDF format

The document promotes the second edition of 'Getting Started with Meteor.js JavaScript Framework' by Isaac Strack, which teaches readers to develop web applications quickly using Meteor. It includes links to download the book and other related ebooks, along with details about the author and the book's content structure. The book covers installation, reactive programming, templates, data handling, application structure, and deployment.

Uploaded by

wakkascelcom
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
11 views

Getting Started with Meteor js JavaScript Framework 2nd Edition Learn to develop powerful web applications in minutes with Meteor Isaac Strack - Download the full ebook set with all chapters in PDF format

The document promotes the second edition of 'Getting Started with Meteor.js JavaScript Framework' by Isaac Strack, which teaches readers to develop web applications quickly using Meteor. It includes links to download the book and other related ebooks, along with details about the author and the book's content structure. The book covers installation, reactive programming, templates, data handling, application structure, and deployment.

Uploaded by

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

Visit https://ebookultra.

com to download the full version and


explore more ebooks

Getting Started with Meteor js JavaScript


Framework 2nd Edition Learn to develop powerful
web applications in minutes with Meteor Isaac
Strack

_____ Click the link below to download _____


https://ebookultra.com/download/getting-started-with-
meteor-js-javascript-framework-2nd-edition-learn-to-
develop-powerful-web-applications-in-minutes-with-
meteor-isaac-strack/

Explore and download more ebooks at ebookultra.com


Here are some suggested products you might be interested in.
Click the link to download

Getting Started with Grunt The JavaScript Task Runner 1st


Edition Jaime Pillora

https://ebookultra.com/download/getting-started-with-grunt-the-
javascript-task-runner-1st-edition-jaime-pillora/

Getting Started with Kubernetes 2nd Edition Jonathan Baier

https://ebookultra.com/download/getting-started-with-kubernetes-2nd-
edition-jonathan-baier/

Getting Started with OpenShift 1st Edition Steven Pousty

https://ebookultra.com/download/getting-started-with-openshift-1st-
edition-steven-pousty/

Getting Started with Arduino 1st Edition Massimo Banzi

https://ebookultra.com/download/getting-started-with-arduino-1st-
edition-massimo-banzi/
Getting Started with SAPUI5 1st Edition Miroslav Antolovic

https://ebookultra.com/download/getting-started-with-sapui5-1st-
edition-miroslav-antolovic/

Getting Started with Electronic Projects 1st Edition


Pretty

https://ebookultra.com/download/getting-started-with-electronic-
projects-1st-edition-pretty/

Getting Started with Processing 1st Edition Casey Reas

https://ebookultra.com/download/getting-started-with-processing-1st-
edition-casey-reas/

Getting Started with Dwarf Fortress Learn to play the most


complex video game ever made 1st Edition Peter Tyson

https://ebookultra.com/download/getting-started-with-dwarf-fortress-
learn-to-play-the-most-complex-video-game-ever-made-1st-edition-peter-
tyson/

Learning the Yahoo User Interface library Develop your


next generation web applications with the YUI JavaScript
development library 1st Edition Dan Wellman
https://ebookultra.com/download/learning-the-yahoo-user-interface-
library-develop-your-next-generation-web-applications-with-the-yui-
javascript-development-library-1st-edition-dan-wellman/
Getting Started with Meteor js JavaScript Framework
2nd Edition Learn to develop powerful web applications
in minutes with Meteor Isaac Strack Digital Instant
Download
Author(s): Isaac Strack
ISBN(s): 9781785285547, 1785285548
File Details: PDF, 6.93 MB
Year: 2015
Language: english
www.it-ebooks.info
Getting Started with Meteor.js
JavaScript Framework
Second Edition

Learn to develop powerful web applications in


minutes with Meteor

Isaac Strack

BIRMINGHAM - MUMBAI

www.it-ebooks.info
Getting Started with Meteor.js JavaScript Framework
Second Edition

Copyright © 2015 Packt Publishing

All rights reserved. No part of this book may be reproduced, stored in a retrieval
system, or transmitted in any form or by any means, without the prior written
permission of the publisher, except in the case of brief quotations embedded in
critical articles or reviews.

Every effort has been made in the preparation of this book to ensure the accuracy
of the information presented. However, the information contained in this book is
sold without warranty, either express or implied. Neither the author, nor Packt
Publishing, and its dealers and distributors will be held liable for any damages
caused or alleged to be caused directly or indirectly by this book.

Packt Publishing has endeavored to provide trademark information about all of the
companies and products mentioned in this book by the appropriate use of capitals.
However, Packt Publishing cannot guarantee the accuracy of this information.

First published: December 2012


Second edition: June 2015

Production reference: 2290615

Published by Packt Publishing Ltd.


Livery Place
35 Livery Street
Birmingham B3 2PB, UK.

ISBN 978-1-78528-554-7

www.packtpub.com

www.it-ebooks.info
Credits

Author Copy Editor


Isaac Strack Jasmine Nadar

Reviewers Project Coordinator


Netanel Gilad Izzat Contractor
Flávio Juvenal da Silva Junior
Arthur Pham Proofreader
Safis Editing

Commissioning Editor
Veena Pagare Indexer
Tejal Daruwale Soni

Acquisition Editors
Subho Gupta Graphics
Jason Monteiro
James Jones

Production Coordinator
Content Development Editor
Manu Joseph
Anish Sukumaran

Cover Work
Technical Editor
Manu Joseph
Menza Mathew

www.it-ebooks.info
About the Author

Isaac Strack is a design technologist and STEM education advocate, currently


working as a solutions consultant for Adobe Systems. With more than 15 years of
experience in management information systems and web and creative technologies,
Isaac has a strong background in modern web application development. He is the
author of the Packt Publishing book Meteor Cookbook and the Packt Publishing video
series Learning Meteor Application Development; he also assisted recently as a technical
reviewer for another Packt Publishing book named Building Single-page Web Apps
with Meteor. He holds a patent for online fraud detection and is a co-captain of the
Salt Lake City Meteor Meetup group. He is an experienced lecturer/speaker. Isaac
regularly mentors others at boot camps, training events, and conferences, such as
UtahJS, DevMountain Meteor Day, NMC Summer Conference, Adobe workshops/
events, and the Consumer Electronics Show (CES).

A huge thank you to my family, especially my mom, who have


loved me despite instead of because. A shout out to my amazing
daughters, without whom I wouldn't be long for this world.
Sunshine, Monkey, Boogers, Pig, this one is for you.

www.it-ebooks.info
About the Reviewers

Netanel Gilad is an enthusiastic developer with expertise in web development.


He loves to learn everything, from new web development frameworks to setting
up a Continuous Integration environment to creating the ultimate application
architecture. He has led a team and worked on a mission-critical C2 web application
with high-performance requirements and an emphasis on UX. Netanel is currently
working on multiple web-related projects and is a coauthor of the popular Meteor
package angular-meteor, which brings the worlds of Angular and Meteor together.

Flávio Juvenal da Silva Junior is a Brazilian software developer. He works


at Vinta Software Studio (http://www.vinta.com.br), a software shop that uses
state-of-the-art tools such as Django or Meteor to build web and mobile products
from the backend to UX.

He believes that programming is a mix of art and engineering; therefore, the


programmer has the right to choose the best tools (such as Meteor) to transform
clients' expectations into elegant solutions.

Arthur Pham has been working for Thomson Reuters as a lead quantitative
engineer since 2006. He has spent many years designing and implementing
derivative pricing models and still loves to learn new programming languages
such as F#, C++, Python, Flex/ActionScript, C#, Ruby, and JavaScript.

He currently lives in New York, USA, and can be contacted on twitter at @arthurpham.

www.it-ebooks.info
www.PacktPub.com

Support files, eBooks, discount offers, and more


For support files and downloads related to your book, please visit www.PacktPub.com.

Did you know that Packt offers eBook versions of every book published, with PDF
and ePub files available? You can upgrade to the eBook version at www.PacktPub.
com and as a print book customer, you are entitled to a discount on the eBook copy.
Get in touch with us at [email protected] for more details.

At www.PacktPub.com, you can also read a collection of free technical articles,


sign up for a range of free newsletters and receive exclusive discounts and offers
on Packt books and eBooks.
TM

https://www2.packtpub.com/books/subscription/packtlib

Do you need instant solutions to your IT questions? PacktLib is Packt's online digital
book library. Here, you can search, access, and read Packt's entire library of books.

Why subscribe?
• Fully searchable across every book published by Packt
• Copy and paste, print, and bookmark content
• On demand and accessible via a web browser

Free access for Packt account holders


If you have an account with Packt at www.PacktPub.com, you can use this to access
PacktLib today and view 9 entirely free books. Simply use your login credentials for
immediate access.

www.it-ebooks.info
Table of Contents
Preface v
Chapter 1: Setup and Installation 1
Installing using curl 2
Loading an example application 3
Selecting your file's location 4
Loading the example application 4
Starting the example application 4
Previewing the application 5
Help! I made too many changes! 6
Making code changes 6
Changing from Leaderboard to Yay Science! 7
Summary 10
Chapter 2: Reactive Programming…It's Alive! 11
Creating the Lending Library 11
Creating the base application 12
Creating a Collection 14
Having fun with the browser console 15
Adding some data 17
Displaying collections in HTML 18
Cleaning up 22
Creating a reaction 25
Multiple clients 27
Summary 28

[i]

www.it-ebooks.info
Table of Contents

Chapter 3: Why Meteor Rocks! 29


Modern web applications 29
The origin of the web app (client/server) 30
The rise of the machines (MVC) 30
The browser grows up 32
A giant Meteor appears! 33
Data On The Wire 33
Latency Compensation 34
Full Stack Reactivity 37
Let's create some templates 40
Summary 46
Chapter 4: Templates 47
A new HTML template 47
Gluing it all together 51
Displaying items 51
Additional view states 54
Adding events 57
Model updates 61
Style updates 64
Summary 66
Chapter 5: Data – Meteor Style! 67
Document-oriented storage 67
Why not use a relational database? 68
MongoDB 69
Using direct commands 70
Broadcasting changes 73
Configuring publishers 74
Turning off autopublish 74
Listing Categories 75
Listing items 79
Checking your streamlined data 80
Summary 81

[ ii ]

www.it-ebooks.info
Table of Contents

Chapter 6: Application Structure – Client, Server,


and Public (oh my!) 83
The client and server folders 83
The public folder 88
The security and accounts 90
Removing insecure 90
Adding an admin account 91
Granting admin permissions 94
Customizing results 97
Modifying Meteor.publish() 97
Adding owner privileges 99
Enabling multiple users 100
Summary 101
Chapter 7: Packaging and Deploying 103
Third-party packages 103
Finding the available packages 104
Bundling your application 107
Deploying your application to Meteor's servers 107
Updating Meteor's servers 108
Using your own hostname 109
Deploying your application to a custom server 109
The server setup 109
Installing and configuring MUP 110
Deploying your app using MUP 112
Summary 114
Index 115

[ iii ]

www.it-ebooks.info
www.it-ebooks.info
Preface
We live in amazing times. Advances in medicine, communication, physics, and
all other scientific fields provide us with opportunities to create things that were
literally impossible to create only a short while ago.

Yet, we aren't easily amazed. Moore's law has not only affected how fast our
computers are, it has significantly increased our expectations as well. We've
come to expect wondrous advances, and therefore, what was once amazing has
become…well…expected. It's a rare thing, indeed, to find something that takes
us by surprise—something that renews that childhood sense of wonder we all
secretly want back because it was stolen from us.

Well, get ready to regain some of that wonder. A dedicated group of computer
scientists, who were determined to make something wondrous, have created a
new JavaScript framework called Meteor. You may be thinking, "A new JavaScript
framework? That's nothing special." And, if that's all Meteor is, you'd be correct.
However, fortunately for you, that's not the end of the story.

Meteor is a reactive, simple, and powerful application platform, capable of producing


sophisticated, robust web and mobile applications with just a few lines of code.

In the context of modern web applications, it is state-of-the-art. Using established,


proven development design patterns, Meteor takes all the mundane parts of building
an app and does them all for you. Therefore, you get to focus on building a solid
application without getting bogged down with the usual time-wasting activities,
such as writing yet another database interface or learning a new templating engine.

[v]

www.it-ebooks.info
Preface

And the best part is, it's simple to learn, amazingly simple! You will see an
application come to life right before your eyes, and when you look back at the
number of lines of code it took to create and compare it to the traditional methods
of development, you may actually find yourself saying "wow" or "how did they
do that?"

This book will walk you through the major features of Meteor and show you
how to create an application from scratch. By the end of the book, you will have
created a working, useful application, and you will have a solid understanding of
what makes Meteor different. This may sound like hyperbole, but if you're open
to the idea that something innovative and unexpected can qualify as amazing,
then prepare to be amazed!

What this book covers


Chapter 1, Setup and Installation, gets you up and running with Meteor in just a few
minutes, and you'll see how quickly and easily you can build a fully functional and
useful application.

Chapter 2, Reactive Programming…It's Alive!, teaches you all about reactive


programming, and how you can leverage reactivity in Meteor to create amazing
responsive applications.

Chapter 3, Why Meteor Rocks!, helps you to gain an understanding of the design
patterns that Meteor uses and see examples of these powerful patterns in action.

Chapter 4, Templates, teaches you about Meteor Templates in depth and uses
templates to lay the groundwork for your Lending Library application.

Chapter 5, Data – Meteor Style!, helps you to discover how Meteor handles data,
making an enterprise-level application incredibly simple and robust. Implement
Meteor's data handling quickly and effectively in your application.

Chapter 6, Application Structure – Client, Server, and Public (oh my!), shows you what
changes you can make to the default configuration to make your application more
secure, extensible, and user-friendly.

Chapter 7, Packaging and Deploying, helps you to become an expert on Meteor's


packaging system, including how to include many popular third-party frameworks.
You will learn how to deploy a Meteor application to your developer, testing, and
production environments.

[ vi ]

www.it-ebooks.info
Preface

What you need for this book


To run the examples in the book, the following software will be required:

• Operating systems:
°° Mac OS X 10.7 (Lion) and above versions
°° Linux x86 or x86_64 architectures
°° Windows 7 and above versions

• Meteor:
°° Meteor version 1.1 or above

The following table will guide you to sites that contain more information:

# Software Name URL


1 Mac OS X http://www.apple.com
2 Linux http://www.debian.org
http://www.redhat.com
3 Windows https://www.microsoft.com
4 Meteor https://www.meteor.com/install

Who this book is for


This book is for an application developer, designer, or an analyst with a decent
understanding of HTML and JavaScript who wants to learn about Meteor and
the new movement inside the JavaScript community towards full-stack web and
mobile applications.

If you are looking for a step-by-step approach to understand how and when to
use one of the most popular and innovative application development frameworks,
this book is for you.

Conventions
In this book, you will find a number of styles of text that distinguish between
different kinds of information. Here are some examples of these styles, and an
explanation of their meaning.

Code words in text are shown as follows: "The WebElement class also supports
find methods to find child elements."

[ vii ]

www.it-ebooks.info
Preface

A block of code is set as follows:


<form name="loginForm">
<label for="username">UserName: </label> <input type="text"
class="username" /></br>
<label for="password">Password: </label> <input
type="password" class="password" /></br>
<input name="login" type="submit" value="Login" />
</form>

When we wish to draw your attention to a particular part of a code block, the
relevant lines or items are set in bold:
//Locate all the Checkbox which are checked by calling jQuery
find() method.
//find() method returns elements in array
List<WebElement> elements = (List<WebElement>)
js.executeScript("return jQuery.find(':checked')");

Any command-line input or output is written as follows:


mvn clean test

New terms and important words are shown in bold. Words that you see on
the screen, in menus or dialog boxes for example, appear in the text like this:
"Right-click to open the pop-up menu and select the Inspect element option."

Warnings or important notes appear in a box like this.

Tips and tricks appear like this.

Reader feedback
Feedback from our readers is always welcome. Let us know what you think about
this book—what you liked or may have disliked. Reader feedback is important for
us to develop titles that you really get the most out of.

To send us general feedback, simply send an e-mail to [email protected],


and mention the book title through the subject of your message.

If there is a topic that you have expertise in and you are interested in either writing
or contributing to a book, see our author guide on www.packtpub.com/authors.
[ viii ]

www.it-ebooks.info
Preface

Customer support
Now that you are the proud owner of a Packt book, we have a number of things
to help you to get the most from your purchase.

Downloading the example code


You can download the example code files for all Packt books you have purchased
from your account at http://www.packtpub.com. If you purchased this book
elsewhere, you can visit http://www.packtpub.com/support and register to have
the files e-mailed directly to you.

Errata
Although we have taken every care to ensure the accuracy of our content, mistakes
do happen. If you find a mistake in one of our books—maybe a mistake in the text or
the code—we would be grateful if you would report this to us. By doing so, you can
save other readers from frustration and help us improve subsequent versions of this
book. If you find any errata, please report them by visiting http://www.packtpub.
com/support, selecting your book, clicking on the errata submission form link, and
entering the details of your errata. Once your errata are verified, your submission
will be accepted and the errata will be uploaded to our website, or added to any list
of existing errata, under the Errata section of that title.

Piracy
Piracy of copyright material on the Internet is an ongoing problem across all media.
At Packt, we take the protection of our copyright and licenses very seriously. If you
come across any illegal copies of our works, in any form, on the Internet, please
provide us with the location address or website name immediately so that we can
pursue a remedy.

Please contact us at [email protected] with a link to the suspected


pirated material.

We appreciate your help in protecting our authors, and our ability to bring you
valuable content.

Questions
You can contact us at [email protected] if you are having a problem with
any aspect of the book, and we will do our best to address it.

[ ix ]

www.it-ebooks.info
www.it-ebooks.info
Setup and Installation
Under the hood, Meteor is really just a bunch of files and scripts, which are designed
to make the building of a web application easier. That's a terrible way to describe
something so elegant, but it helps us to better understand what we're using.

After all, Mila Kunis is really just a bunch of tissue wrapped around bone, with
some vital organs inside. I know you hate me now for that description, but you
get the point. She's beautiful. So is Meteor. But it doesn't do us any good to just
leave it at that. If we want to reproduce that type of beauty on our own, we have
to understand what's really going on.

So, files and scripts… We're going to walk you through how to get the Meteor package
properly installed on your Linux or Mac OS X system, and then see the package of files
and scripts in action.

Windows is now officially supported (Yay!) so you can follow along


using the new Windows installation if you would like. Information
can be found at https://www.meteor.com/install.

In this chapter, you will learn the following topics:

• Downloading and installing Meteor via curl


• Loading an example application
• Making changes and watching Meteor in action

[1]

www.it-ebooks.info
Setup and Installation

Installing using curl


There are several ways to install a package of files and scripts. You can manually
download and transfer files, you can use a pretty installation wizard/package with
lots of Next buttons, or you can do what real developers do and use the command
line. It puts hair on your chest. Which, now that I think about it, may not be a very
desirable thing. Okay, no hair; we lied. But still, you want to use the command line,
trust us. Trust the people that just lied to you.

curl (or cURL if you want to get fancy) is a command-line tool used to transfer
files and run scripts using standard URL locations. You probably already knew that,
or you probably don't care. Either way, we've described it and we're now moving on
to using it.

Open a terminal window or the command line, and enter the following command:
curl https://install.meteor.com/ | sh

This will install Meteor on your system. curl is the command to go and fetch the
script. https://install.meteor.com is the URL/location of the script, and sh is,
of course, the location of the script interpreter "Shell", which will run the script.

Once you've run this script, assuming you have an Internet connection and the
proper permissions, you will see the Meteor package downloaded and installed:

[2]

www.it-ebooks.info
Chapter 1

The key thing that we're looking for in the preceding installation text is the launcher
script location:
Writing a launcher script to /usr/local/bin/meteor

This location could vary depending on whether you're running this script in Linux
or Mac OS X, but it puts Meteor into a location where you can then access the Meteor
script from anywhere else. This will become important in a minute. For now, let's see
what kind of friendly message we get when the Meteor installation is finished:
To get started fast:

$ meteor create ~/my_cool_app


$ cd ~/my_cool_app
$ meteor

Or see the docs at:

docs.meteor.com

Great! You've successfully installed Meteor, and you're on your way to create your
first Meteor web application!

You should bookmark http://docs.meteor.com,


an invaluable reference moving forward.

Loading an example application


The wonderful people at Meteor have included several example applications,
which you can quickly create and play with; these help you to get a better idea
of what Meteor is capable of.

We want to use the simplest possible example, just to get an idea of how Meteor
works, so we will be creating the leaderboard example. We'll be using the command
line again. This is awesome news if you still have it open! If not, open a terminal
window and follow these steps.

[3]

www.it-ebooks.info
Setup and Installation

Selecting your file's location


So that we can remember where they are later, we'll put all the files for this book in
the ~/Documents/Meteor folder. We will create this folder as follows:
$ mkdir ~/Documents/Meteor

Now, we need to get to that directory. Use the following command:


$ cd ~/Documents/Meteor

Loading the example application


We can now use the Meteor create command with the --example parameter to
create a local copy of the leaderboard example application:
$ meteor create –-example leaderboard

As with the Meteor installation itself, the create command script has a friendly
success message:
leaderboard: created.
To run your new app:
cd leaderboard
meteor

There are even instructions on what to do next. How handy! Let's go ahead and do
what our good command-line friend is telling us.

Starting the example application


To start up a Meteor application, we need to be in the application directory itself.
This is because Meteor looks for the startup files, HTML, and JavaScript that are
needed to run the application. These are all found in the application folder, so let's
go there:
$ cd leaderboard

This puts us in the ~/Documents/Meteor/leaderboard folder, and we're ready to


run the application:
$ meteor

[4]

www.it-ebooks.info
Chapter 1

Yes, that's it. Meteor takes care of everything for us; it reads all the files and scripts,
and sets up the HTTP listener:
[[[[[ ~/Documents/Meteor/leaderboard ]]]]]

Running on: http://localhost:3000/

We can now take the URL we've been given (http://localhost:3000/) and check
out the example application in a web browser.

Previewing the application


Open your favorite web browser (we'll be using Chrome, but any modern, updated
browser will work) and navigate to http://localhost:3000/.

You should see a screen with a list containing the names of scientists, similar to the
following screenshot:

[5]

www.it-ebooks.info
Setup and Installation

You can go ahead and poke around the application a bit, if you want to. Click on
Nikola Tesla's name and add 5 points to his score about 20 bajillion times, because
he deserves it. Give some love to Marie Curie because she was so radioactive that
she actually made up the word. Go nuts, friend!

Help! I made too many changes!


Do you fear change and want to reset the scores? No problem, we can start with a
clean database instance; to do this, perform the following steps:

1. Open the command line, and press Ctrl + C.


2. This stops the running application. Now, enter the following command:
$ meteor reset

3. Restart your app, and you're good to go. Just type the following command:
$ meteor

Note that the initial scores are random, so it won't look exactly like it did before.
The meteor reset command resets all the data collections and whatnot; so in a
non-random app, the command will indeed reset the app cleanly.

Making code changes


Okay, we've got our application up and running in the browser, and we now want to
see what happens when we make some code changes.

One of the best features of Meteor is reactive programming. The following extract is
taken from http://docs.meteor.com/#/full/reactivity:

Meteor embraces the concept of reactive programming. This means that you can
write your code in a simple imperative style, and the result will be automatically
recalculated whenever data changes that your code depends on.

This principle applies to code changes too, which means that any changes
that you make to the HTML, JavaScript, or database are automatically picked
up and propagated.

You don't have to restart the application or even refresh your browser. All changes
are incorporated in real time, and the application reactively accepts the changes.

Let's see an example.

[6]

www.it-ebooks.info
Chapter 1

Changing from Leaderboard to Yay Science!


As you become more familiar with Meteor, you will come to learn that you can
make changes and add files pretty much whenever you want. You don't have to
link anything up, and you certainly don't have to redeploy before you can see the
results. You get to just play around, build wonderful things, and let Meteor take
care of all the crunchy stuff.

To see what we mean, let's change the title of this application from Leaderboard to
Yay Science! because, well, yay science!

First, make sure that the application is up and running. You can do this by having
an open browser window that is pointing to http://localhost:3000/. If the
app is running, you'll see your leaderboard application. If your application isn't
running, make sure to follow the steps previously given in the Starting the example
application section.

Now, we need to open and edit the leaderboard.html file. With your favorite text/
code editor, open the leaderboard.html file under the location, ~/Documents/
Meteor/leaderboard/client/, and change title in the head section using the
following lines of code:
<head>
<title>Yay Science!</title>
</head>

Go ahead and save the file, and then look at your web browser. The page will
automatically update, and you'll see the title change. Earlier, it displayed the
word Leaderboard:

However, now, after the execution of the preceding code, the title will display our
spiffy new Yay Science! page:

[7]

www.it-ebooks.info
Setup and Installation

This is Meteor in action! It monitors any changes to files, and when it sees that a file
has changed, it tells your browser that a change has been made and that it should
refresh itself to get the latest version.

Moving forward, we're going to build an application from scratch, so we don't want
to make too many changes to this example application. However, we still want to
stay with our new theme rather than that generic old leaderboard stuff. So, to do so,
perform the following steps:

1. Back in your text editor, on about the tenth line or so, we have the title
label for our leaderboard. Make the following change to the <h1> tag:
<h1 class="title">Yay Science!</h1>

Save this change, and you'll see the change reflected in your browser.
The title in our page will now look like this:

2. Likewise, we don't give "points" to scientists. They're not trained monkeys,


dancing around for our amusement. They're scientists! We give them mad
props instead. In the <div> tag just below our title, make the following text
change:
<div class="subtitle">Select a scientist to give them props</div>

We also need to change the button text from the word points to the word
props. Towards the bottom half of the file, you'll find a <button> tag.
Change the text in that tag to the following:
<button class="inc">Give props</button>

[8]

www.it-ebooks.info
Chapter 1

Save your changes, and you will see the application update
almost immediately:

3. Just below the <button> tag, there is a message displayed if no scientist's


name is selected. It currently uses the word "players". We want to change
that to something a little more specific. To do this, make the following
change to the <div> message tag:
<div class="message">Click a name to select</div>

Save this change, and this time, refresh your browser. Not because we need
the change to take effect, but because we want to make sure no scientist is
highlighted so that we can verify our message text:

[9]

www.it-ebooks.info
Setup and Installation

Summary
Great success! In this chapter, you've successfully installed the Meteor framework,
loaded an example application, and made changes to that application by becoming
familiar with file changes and the reactive nature of Meteor.

You are now ready to start building your very own Meteor application, and learn
more about the elegant features and advantages that come from developing with
Meteor in the coming chapters.

[ 10 ]

www.it-ebooks.info
Chapter 2

Reactive Programming…
It's Alive!
As we learned in Chapter 1, Setup and Installation, Meteor operates on a reactive
programming model. This means that your templates aren't only concerned with
displaying data, but they are also listening for changes to that data so that they can
"react" to those changes. These areas of data where the templates look for changes
are called reactive contexts.

We will now start developing a Lending Library application, lay the framework for
future chapters, and use Meteor's built-in reactive model to track and propagate
changes to our application to all clients that are listening.

In this chapter, you will learn about:

• Creating your first real application


• Using reactive programming to track and automatically update changes
• Exploring and testing changes made to your data from multiple
browser windows

Creating the Lending Library


There are two kinds of people in this world—those who remember who they lent
something to and those who buy a lot of stuff twice. If you're one of the people who
is on a first-name basis with your UPS delivery driver, this application is for you!

Using Meteor, we're going to build a Lending Library. We'll keep track of all our
stuff and who we lent it to, so that the next time we can't remember where we put
our linear compression wrench, we can simply look up who we lent it to last and
get it back from them.

[ 11 ]

www.it-ebooks.info
Reactive Programming…It's Alive!

And when that same friend says, "Are you sure you lent it to me?", you can say,
"Yeah, STEVE, I'm sure I lent it to you! I see you're enjoying your digital cable,
thanks to my generous lending of said linear compression wrench. Why don't you
go find it so that I too can enjoy the benefits of digital cable in my own home!"

Okay, okay, maybe STEVE forgot too. Maybe he's a dirty liar, and he sold your
wrench to pay for his deep-fried Oreo® habit. Either way, you'll have your very
own custom Meteor app that gives you proof that you're not going crazy. And, if
he did sell it for deep-fried carnival food, at least you can make him share his stash
with you while you watch the game at his house.

Creating the base application


The first thing we want to do is create the base application, similarly to what we did
in the first chapter, and we can then expand the base application to fit our needs:

1. Start by navigating to your applications folder. This can be anywhere, but


as mentioned in our earlier chapter, we'll be working out of ~/Documents/
Meteor as our root folder:
$ cd ~/Documents/Meteor

2. Now, we create our base folder structure for our Lending Library
application:
$ meteor create LendLib

3. As usual, we'll give instructions on how to get the application up and


running. Let's go ahead and try that, just to make sure that everything was
created properly:
$ cd LendLib
$ meteor

This navigates to the Lending Library folder under ~/Documents/Meteor/


LendLib and runs the application.

[ 12 ]

www.it-ebooks.info
Chapter 2

4. Open a browser and navigate to http://localhost:3000/. You should see


the following screen:

5. Welcome to Meteor! is nice and all, but we are going to change this to
Lending Library. Open the LendLib.html file under ~/Documents/Meteor/
LendLib/ in your favorite editor. Towards the top (the sixth line or so), you'll
see the HTML code snippet that's responsible for our greeting. Go ahead and
change Welcome to Meteor! to Lending Library:
<body>
<h1>Lending Library</h1>

6. Save the change. The page will refresh and will look like the following
screenshot:

You may have noticed a reference to a template called hello, just below the
title:
{{> hello}}

This is called the template inclusion because we are including a template.


By adding this to the body of our code, we instruct Meteor to include the
template named hello and append its contents inside our <body> tag.

[ 13 ]

www.it-ebooks.info
Reactive Programming…It's Alive!

7. Let's make a change in this template as well. Edit LendLib.html and modify
the title of the hello template:
<template name="hello">
<h2>my list</h2>
<button>Click Me</button>
<p>You've pressed the button {{counter}} times.</p>
</template>

8. Save the change and your page will update as follows:

Creating a Collection
Okay, so you've just made a few small changes to static files, but what we really
want to see is some dynamic, reactive programming, and some live HTML code!

We need to attach a data source—something that will keep track of our items.
Normally, this would be quite a process indeed, but Meteor makes it easy by
supporting MongoDB, and its own client-side version called Minimongo, out
of the box.

[ 14 ]

www.it-ebooks.info
Chapter 2

To learn more about NoSQL databases (and specifically MongoDB, the


default database used inside Meteor), you can visit the following sites:

• http://en.wikipedia.org/wiki/NoSQL
• http://www.mongodb.org/
• http://www.packtpub.com/books/all?keys=mongodb

Let's create our collection. Inside the LendLib.js file under ~/Documents/Meteor/
LendLib/, we want to add the following highlighted line of code as the first line, and
then save the change:
lists = new Mongo.Collection("lists");

if (Meteor.isClient) {
...

This creates a new collection in MongoDB. Since it comes before anything else in the
LendLib.js file, the collection is available for both the client and server to see. It is
persistent, as we'll see in a moment, and once values are entered into it, they can be
retrieved by any client accessing the page.

To see this persisted object, we'll need to use the console of our web page.

Having fun with the browser console


The browser console is a debugging tool available in most modern browsers by
default, or as an add-on through plugins.

For a more in-depth tutorial on using the console in Chrome,


check out http://developer.chrome.com/extensions/
tut_debugging.html.

[ 15 ]

www.it-ebooks.info
Reactive Programming…It's Alive!

Since we're using Chrome, the console is available by default. Let's start by
performing the following steps:

1. In a browser window pointing to http://localhost:3000/, enter the


shortcut key combination command + option + I, or you can right-click
anywhere on the page and select Inspect Element:

This will open our debugging tools. We now want to get into the console.

2. Click on the Console icon found at the extreme right of the debugging
menu bar:

[ 16 ]

www.it-ebooks.info
Chapter 2

You will now have a blinking cursor, and you're ready to check out our
newly minted collection!

3. Enter the following command in the console and hit enter:


> lists

You should get a returned object that says Mongo.Collection:

Adding some data


The previous output means that our changes were accepted, and we have a new
persistent collection! It's empty, but let's do something about that:

1. Enter the following commands in the browser console to create a couple of


sample Categories:
> lists.insert({Category:"DVDs", items: [{Name:"Mission Impossible
",Owner:"me",LentTo:"Alice"}]});

> lists.insert({Category:"Tools", items: [{Name:"Linear


Compression Wrench",Owner:"me",LentTo: "STEVE"}]});

After each command, you'll get a GUID (something like


ehkGMaxmjWqqXAMdq), which is Meteor's way of telling you that the item was
saved properly.

2. Being the natural skeptics that we are, we're going to check. To do so, enter
the following command:
> lists.findOne({Category: "DVDs"});

You should then get an Object with an expandable icon next to it.

[ 17 ]

www.it-ebooks.info
Reactive Programming…It's Alive!

3. Click on this icon to expand it, and you should see something similar to the
following screenshot:

We could similarly check for our tools collection by entering the lists.
findOne({Category:"Tools"}) command, but we don't need to. This time we'll
trust that Meteor entered it correctly. We do, however, want to check to see whether
the objects are persistent. To do so, perform the following steps:

1. Refresh the web page. Your console will clear, but the Categories that we
entered have been saved in the persistent Meteor Collection, so we can check
again to see if they're hanging around.
2. Enter the following command in the console:
> lists.find({}).count();

This command finds all records in the lists collection and gives us a total
count. If everything went according to plan, you should have got back a
count of 2.

We're on our way! We've created two categories, and we have one item in each
category. We've also verified that the lists collection is being saved after each
session. Now, let's see about displaying this in our page.

Displaying collections in HTML


We're now going to see our collection come to life inside the HTML page that
we created when we initialized our project. This page will use templates that are
reactive, allowing us to have changes made to our Collection appear instantly,
without a page refresh. These types of reactive templates, where the DOM for
the page can be updated without a refresh are called Live HTML Templates.

[ 18 ]

www.it-ebooks.info
Chapter 2

To read more about Live HTML Templates, consult the Meteor


documentation at http://docs.meteor.com/#/full/
livehtmltemplates.

Let's perform the following set of steps:

1. With the LendLib.html file under ~/Documents/Meteor/LendLib/ still


open, locate the <body> tag and add a new template inclusion:
<body>
<h1>Lending Library</h1> {{> hello}}
<div id="categories-container" class="container">
{{> categories}}
</div>
</body>

This creates a new div element with the contents being filled by a template
partial named categories.

2. Now, at the very bottom of the page, add the skeleton for the categories:
<template name="categories">
</template>

This won't change the appearance of the page, but we now have a template
partial where we can list our categories.

3. Let's put in our section title within the preceding lines of code:
<template name="categories">
<div class="title">categories</div>
</template>

4. And now, let's get our categories in there:


<template name="categories">
<div class="title">categories</div>
<div id="categories">

</div>
</template>

This creates the div categories which we can then go through and list all of
our categories. If we only had one record to deal with, the code would look
like this:
<div class="category">
{{Category}}
</div>

[ 19 ]

www.it-ebooks.info
Reactive Programming…It's Alive!

5. But, we need to wrap this into a loop (in this case, an #each statement) so
that we get all the categories:
<template name="categories">
<div class="title">categories</div>
<div id="categories">
{{#each lists}}
<div class="category">
{{Category}}
</div>
{{/each}}
</div>

Notice that we are telling the template "for each record in the lists collection"
with our {{#each lists}} command, and then, "display the Category" with
{{Category}}.

6. If you save these changes and look at the web page, you will see something
like the following screenshot:

This doesn't look much different. Yes, we have our header (categories), but where
are the categories for which we just created our template?

[ 20 ]

www.it-ebooks.info
Chapter 2

There's one more step we need to complete for the categories to show up. Currently,
the template that we just created isn't pointing towards anything. In other words, we
have a lists collection, and we have a template, but we don't have the underlying
JavaScript function that hooks them together. Let's take care of this by performing
the following steps:

1. Open the LendLib.js file under ~/Documents/Meteor/LendLib/, and we


can see some Template functions:
Template.hello.helpers({ ...

...

Template.hello.events({ ...

These code chunks hook up JavaScript functions and objects to the HTML
hello template. Meteor's built-in Template object makes this possible, and
we're going to follow the same pattern, that is, to hook up our categories
template.

2. We want to declare that the categories template has a lists collection.


We do this by entering the following code, just below the Template.hello.
events() block:
Template.hello.events({
...
});
Template.categories.helpers({
lists : function(){
}
});
}

The Template declaration must be inside of the if (Meteor.


isClient){...} code block so that the client will pick up the
change and the server will ignore it.

3. We've now declared the lists collection for all the templates to use, and we
can have the function return the results from a Meteor.Collection query.
We can do that using the find() command:
lists : function(){
return lists.find({}, { sort: { Category : 1 }});
}

[ 21 ]

www.it-ebooks.info
Reactive Programming…It's Alive!

This code will find every record in the lists collection and will sort the results
by the Category (name). Save these changes, and you will now see a populated
list of categories:

Cleaning up
We're fast approaching a working application, and we want it to look super-shiny
and clean. Let's do a bit of clean up in our code and add some CSS to make things
more readable. To do this, perform the following steps:

1. We don't need the greeting anymore. So, let's get rid of it. To do this,
remove the following lines from LendLib.html and save the page:
<body>
<h1>Lending Library</h1>
{{> hello}}
<div id="categories-container" class="container">
{{> categories}}
</div>
</body>

<template name="hello">
<h2>My Library</h2>
<button>Click Me</button>
<p>You've pressed the button {{counter}} times.</p>
</template>

2. We'll keep the Template.hello declarations in LendLib.js for now, as a


reference. We'll comment them out for now and remove them later when
they're no longer needed:
/* Template.hello.helpers({
...

[ 22 ]

www.it-ebooks.info
Chapter 2

});
Template.hello.events({
...
}); */

3. Now, let's add the Twitter Bootstrap framework, which gives us a lot of style
without much effort. Using a terminal window, create a client folder in /
LendLib/:

$ mkdir ~/Documents/Meteor/LendLib/client

Download the latest Bootstrap framework at http://getbootstrap.


com/getting-started/ and extract the archive into the client
folder under ~/Documents/Meteor/LendLib/.

Since Meteor will read and use every file put into the application folder, we want to
eliminate the redundant files. We don't have to worry too much about efficiency, but
some things are just shameful and leaving that much extraneous code lying around
is right up there with enjoying deep-fried carnival food.

So, let's perform the following set of steps:

1. Navigate to the Bootstrap folder (the name will vary) using the following
command:
$ cd ~/Documents/Meteor/LendLib/client/[bootstrap]/

2. Once you've entered the folder, delete the unneeded files:


$ rm css/bootstrap-theme.c*
$ rm css/bootstrap.c*
$ rm js/npm.js
$ rm js/bootstrap.js

If you know what you're doing with Bootstrap, you can just copy
the fonts, min.js, and min.css files instead of performing the
preceding instructions.

[ 23 ]

www.it-ebooks.info
Reactive Programming…It's Alive!

After all these changes, your UI should be really clean and simple:

Let's quickly make the UI more distinct and readable. To do this, we must perform
the following set of steps:

1. In LendLib.html, let's change our header from a <div> tag to an <h2> tag,
and change the text from categories to my stuff:
<template name="categories">
<h2 class="title">my stuff</h2>

2. Let's turn categories into a pretty button group:


<div id="categories" class="btn-group">
{{#each lists}}
<div class="category btn btn-primary">
{{Category}}
</div>
{{/each}}

This gives us a distinct, clean-looking page:

[ 24 ]

www.it-ebooks.info
Chapter 2

Creating a reaction
Following the creation of our basic template and collection, and with Meteor putting
our lists collection into the reactive context, we can now proceed to watch the
reactive programming model in action.

Navigate to our Lending Library page at http://localhost:3000/ and open the


browser console window.

In the console, enter the following command:


> lists.insert({Category:"Fraggles"});

You will instantly see the page update. Note that, this time, the full page didn't
refresh! This is because, under the hood, Meteor is tracking changes to our reactive
context (in this case, the lists collection) and the template is being updated
immediately after a change is made.

Let's make a few more changes. To do this, enter the same Fraggles command
again:
> lists.insert({Category:"Fraggles"});

Just as before, a new Fraggles button will instantly appear:

But we have too many Fraggles categories now. There are a lot of Fraggles, but
unless you're some weirdo collector, you don't need two categories. So, let's remove
them. However, we can't just erase whatever we want on the client side. This is
a basic safety feature, and if we just let it happen, things could get quite chaotic.
For instance, if we tried to just remove the records using the following command:
> lists.remove({Category:"Fraggles"});

[ 25 ]

www.it-ebooks.info
Reactive Programming…It's Alive!

...then that's quite a no-no. Meteor detects stuff like this and will give us a 403 error
as follows:

There are three ways in which we can manually delete or modify records.

• The first is on the client side, by finding the ID of the record. In your browser
console, run the following command:
> lists.findOne({Category:"Fraggles"});

This will return a single record, including an _id property, similar to the
following screenshot:

If we take this _id and execute lists.remove(), the extra Fraggles


category will be removed:
> lists.remove({_id:"Jz68JR4gBbiBcbLPt"});

• The second way is to use meteor shell. In a new terminal window (keep
your app running!), navigate to ~/Documents/Meteor/LendLib/ and enter
the following command:
$ meteor shell

This will open a console that is directly connected to the server so that we can
run commands as if they were server code; for example:
> lists.remove({Category:"Fraggles"});

This will remove all categories that are named Fraggles. The meteor shell
command comes in handy when we need to run tests or debug, so keep this
command in your pocket to use when you need it.

• The final way to delete records is how we did it in the previous chapter, with
meteor reset. In fact, let's do that right now. Stop your application from
running (Ctrl + C) and execute the following command in the terminal:
$ meteor reset

[ 26 ]

www.it-ebooks.info
Chapter 2

Start Meteor again with the meteor command, and your application screen should be
nice and clean:

It would probably be good to have a couple of categories, so let's create them really
quickly. In the browser console, enter the following commands:
> lists.insert({Category:"Collectibles"});
> lists.insert({Category:"DVDs"});
> lists.insert({Category:"Tools"});

As you can see, the changes are made instantly, with no page refresh.

Multiple clients
Good things should be shared. Meteor gets this, and as we're about to see for
ourselves, the reactive programming model allows us to share updates in real time
across multiple clients.

With your Chrome web page still open to http://localhost:3000/, open a new
browser tab and navigate to the same page.

If you really want to get fancy, you can conduct this same
experiment with multiple browsers (Firefox, Opera, or Safari).
Each session will be live and reactive!

You now have two clients open, which is simulating the application being open by
different people, at different locations, with different computers. Meteor's reactive
model allows you to treat all clients in the same manner, and a change made by one
will be propagated to all the others.

With your eyes on the new second browser, type the following command into the
console of browser #1:
> lists.insert({Category:"Vinyl Records"})

[ 27 ]

www.it-ebooks.info
Reactive Programming…It's Alive!

You will notice that the change propagates to both browsers, without a page refresh:

Feel free to make any extra collections, to remove or rename them, and so on.
Experiment a little and notice how these changes can be instantly made to every
listening client. Meteor operates under a very powerful paradigm, and in the next
chapter, you'll be able to see exactly why this is such an important and disruptive
change to web application development.

Summary
In this chapter, you successfully created the framework for your new Meteor
application. You saw firsthand how quickly a new project can be created, and you
created database and template functionality with just a few lines of code. You saw
live HTML and reactive programming in action, and you are now ready to go even
deeper into the Meteor engine. You've conquered the tip of the iceberg, my friend.
Take a break, have a cold one, and get ready for even more Meteor awesomeness!

[ 28 ]

www.it-ebooks.info
Another Random Scribd Document
with Unrelated Content
CHAPTER X
Watching Rooks
In this chapter I will give a few scenes from rook life, as I have watched it
from late autumn to early spring, linking them together by a remark now
and again of a general nature, or, possibly, some theory which my
observations may have suggested to me, and seemed to illustrate. Were I
to put into general terms what I have jotted down at all times and in all
places, in the darkness before morning when the rookery slept about me,
in the dim dawn whilst it woke into life, to stream forth, later, on wings of
joy and sound, in the long day by field and moor and waste, and at
evening again, or night, when the birds swept home and sank to sleep
amidst their own sinking lullaby, I might make a smoother narrative, but
the picture would be gone. I think it better, therefore, to make a
preliminary general apology for all roughnesses and repetitions, triviality
of matter, minuteness of detail and so forth, in fact for all shortcomings,
and then to go on in faith, not in myself, indeed, but in the rooks,
believing that they will be interesting, however much I may stand in their
way.
When I speak of the rookery I do not mean the trees where the birds
build—unfortunately there are none very near me—but those where they
come to roost during the autumn and winter—true rookeries indeed if
numbers count for anything. Here, their chosen resting-place is a silent,
lonely plantation of tall funereal firs, standing shaggily tangled together,
mournful and sombre, making, when the snow has fallen but lightly—
before they are covered—a blotch of very ink upon the surrounding white.
Who could think, seeing them during the daytime, so sad and abandoned,
so utterly still, tenanted only by a few silent-creeping tits, or some
squirrel, whose pertness amidst their gloomy aisles and avenues seems
almost an affectation—who could think that each night they were so
clothed and mantled with life, that their sadness was all covered up in joy,
their silence made a babel of sound? In every one of those dark, swaying,
sighing trees, there will be a very crowd of black, noisy, joyous birds, and
strange it is that there should be more poetry in all this noise and
clamour and bustle than in their sad sombreness, deeply as that speaks
to one. The poetry of life is beyond that of death, and when the rooks
have gone the dark plantation seems to want its soul. It is Cupid and
Psyche, but under dreary, northern skies. Every evening the black,
rushing wings come in love and seem to kiss the dark branches, every
morning they kiss and part, and, between whiles, the poor longing grove
stands lifeless, dreams and waits. But how different would it seem if the
rooks were a crowd of men—nice, cheery, jovial, picturesque, civilised
men! Thank heaven, they are a crowd of rooks!
I will now quote from my journal:
"Walking over some arable land that rises gently into a slight hill, my
attention is attracted by a number of rooks hanging in the air, just above
a small clump of elm-trees on its crest. They keep alternately rising and
falling as they circle over the trees, often perching amongst them, but
soon gliding upwards from them again. A very common action is for two
to hover, one above another, getting gradually quite close together, when
both sinking, one may almost say falling, rapidly, the upper pursues the
under one, striking at it—either in jest or earnest, but probably the former
—both with beak and claws. The downward plunge would end in a long
swoop, first to right or left, and then again upwards, during which the
two would become separated and mingled with the general troop. This
action, more or less defined and perfect, was continued again and again,
and there were generally one or more pairs of birds engaged in it. The
rest rose and fell, many together, and obviously enjoying each other's
society, but without any special conjunction of two or more in a joint
manœuvre. Their descents were often of a rushing nature, and
accompanied with such sudden twists and turns as, sometimes, seemed
to amount to a complete somersault in the air—though as to this I will
not be too certain. The whole seemed the outcome of pure enjoyment,
and seen in the clear blue sky of this fine bright October morning—the
last one of the month—had a charming effect.
"A fortnight later I happened to be near some woods to which rooks were
flying from all directions, to roost, as I thought then, but afterwards I
found it was only one of their halting places. They were in countless
numbers, one great troop after another flying up from far away over the
country. The air was full of their voices, which were of a great variety and
modulation, the ordinary harsh (though pleasant) 'caw' being perhaps the
least noticeable of all. Each troop flew high, and, on coming within a
certain distance of the wood—a fair-sized field away—they suddenly
began to swoop down upon it in long sweeping curves or slants, at the
same time uttering a very peculiar burring note, which, though much
deeper and essentially rook-like in tone, at once reminded me of the well-
known sound made by the nightjar. Imagine a rook trying to 'burr' or
'churr' like a nightjar, and doing it like a rook, and you have it. Whilst
making these long downward-slanting swoops the birds would often twist
and turn in the air in an astonishing manner, sometimes even, as it
seemed to me, turning right over as a peewit does, in fact, exhibiting
powers of flight far beyond what anyone would imagine rooks to possess,
who had only seen or noticed them on ordinary occasions.
"Whilst these birds sweep down into the trees others of them settle on
the adjoining meadow-land, but they do not descend upon it in the same
way, but more steadily, though still with many a twist and turn and
whirring, whizzing evolution. Neither do they utter the strange burring
note to which I have called attention, and which is a very striking sound.
Starlings are mingled with these latter birds, flying amongst them, yet in
their own bands, and alighting with them on the meadow, where they
continue to form an imperium in imperio. Both they and the rooks
descend at one point, in a black or brown patch, but soon spread out
over the whole meadow, from which they often rise up in a cloud, and,
after flying about over it for a little, come down upon it again. At last a
vast flock of starlings—numbering, I should think, many thousands—flies
up, and, being joined by all those that were on the field, the whole
descend upon the woods, through which they disseminate themselves.
Almost immediately afterwards, the rooks, as though taking the starlings
for their guide, rise too, and fly all together to the woods. Now comes a
troop of some eighty rooks, and, shortly afterwards, another much larger
one—two or three hundred at the least—all flying high, and going steadily
onwards in one uniform direction. They are all uttering a note which is
difficult to describe, and does not at all resemble the ordinary 'caw.' It
has more the character of a chirrup, loud in proportion to the size of the
bird, but still a chirrup—or chirruppy. There is great flexibility in the
sound, which has a curious rise at the end. It seems to express
satisfaction and enjoyable social feeling, and, if so, is very expressive.
One feels, indeed, that every note uttered by rooks is expressive, and if
one does not always quite know what it expresses that is one's own fault,
or, at any rate, not theirs.
"Twenty more now pass, then twenty-seven, and, finally, another large
body of some two to three hundred—all flying in the same direction. It is
the last flight, and, shortly afterwards, the loud harsh trumpeting of
pheasants is heard in all the woods and coverts around, as they prepare
to fly up into their own roosting trees. This dove-tailing of two
accustomed things in the daily life of rooks and pheasants I have often
noticed, but it must be mere coincidence, for pheasants vary in their
hours of retirement, whilst the leisurely homeward journeying of rooks,
with pauses longer or shorter at one place or another, occupies, in winter,
most of the afternoon.
"November 27th.—By the river, this afternoon, I noticed two great
assemblages of rooks down on the meadow-land, whilst others, in large
numbers, were flying en route homewards. Of these, two would often act
in the way I have before described—that is to say, whilst flying the one
just over the other with very little space between them, both would sink
suddenly and swiftly down, the upper following the under one, and both
keeping for some time the same relative position. But besides this, two
birds would often pursue each other downwards in a different way,
descending with wide sideway sweeps through the air, from one side to
another, after the manner of a parachute, the wings being all the while
outstretched and motionless. In either case the pursuit was never
persisted in for long, and obviously it was no more than a sport or an
evolution requiring the concurrence of two birds.
"Again, two will sweep along near together, at slightly different altitudes,
with the wings outspread in the same way—that is to say, not flapping.
Then first one and afterwards the other gives a sharp wriggling twist,
seeming to lose its balance for a moment, rights itself again, and
continues to sweep on as before. Then another wriggle, a further sweep,
and so on."
Since seeing the curious manner in which ravens roll over in the air—as
described by me—I have watched the aerial gambols, as one may almost
call them, of rooks more closely. There is a certain place, not far from
where I live, where these birds make an aerial pause in their homeward
flight; for, whilst many are to be seen settled in some lofty trees of a fine
open park, others sail round and round in wide circles and high in the air,
over a wide expanse of water in the midst of it. After wheeling thus for
some time, first one and then another will descend on spread wings, very
swiftly, and with all sorts of whizzes, half-turns or tumbles, and
parachute-like motions. When watched closely through the glasses,
however, it may be seen that, very often, these rushing descents have
their origin in an action, or, rather, an attempted action, very much like
that of the raven. The idea of the latter bird is to roll over, so as to be on
its back in the air, and, by closing its wings, it is able to achieve this
without, or with hardly, any drop from the elevation at which it has been
flying. The rooks seem to try to do this too, but instead of closing the
wings, they keep them spread, as open, or almost so, as before.
Consequently, instead of just rolling over, their turn or roll to either side
sends them skimming sideways, down through the air, like a kite—a paper
one, I mean. Peewits close the wings and roll over in much the same way
as does the raven, but this is generally either preceded, or followed, by a
tremendous drop through the air, with wings more or less extended, so
that the whole has quite a different effect.
"Of the two assemblies on the ground, one is in perpetual motion, birds
constantly rising—either singly, in twos or threes, or in small parties—
from where they were, flying a little way just above the heads of their
fellows, and re-settling amongst them again. Thus no individual bird, as it
seems to me, remains where it was for long, though those in the air, at
any given moment, form but a small minority, compared with the main
body on the ground.
"But the birds composing the other great assemblage keep their places,
or, if some few rise to change them, these are not enough to give
character to the whole, or even to attract attention. It is curious to see
two such great bodies of birds close to each other, and on the same
uniform pasture-land, yet behaving so differently, the one so still, the
other in such constant activity.
"About 4 P.M. a great number of rooks rise from some trees in a small
covert near by, and fly towards those on the ground. As they approach
the first great body—which is the lively one—the birds composing it rise
up, as with one accord, and fly, not to meet them, as one might have
expected, but in the same direction as they are flying. So nicely timed,
however, is the movement, that the rising body become, in a moment,
the vanguard of the now combined troop.
"All these birds then fly together to the other assembly, and whilst about
half of their number sweep down to reinforce it, the other half continue to
fly on. The flying rooks, however, are not joined by any of those on the
ground. How curious it is that, in the first instance, the one whole body of
birds does the same thing instantaneously, and as by a common impulse,
whilst in the second, half acts in one way, and half in another, each
appearing to have no doubt or hesitation as to what it ought to do! Again,
how different is the conduct of the two field-assemblages. One rises, as
with one thought, to join the flying birds. The other, as with one thought,
remains standing. Unless, in each case, some signal of command has
been given, then what a strange community of feeling in opposite
directions is here shown. Where is the individuality that one would
expect, and what is the power that binds all the units together?
"Are rooks led by an old and experienced bird?—which is, I believe, the
popular impression, as embodied in a famous line of Tennyson, for which
one feels inclined to fight. At first sight, the rising of a whole body of
rooks (or any other birds) simultaneously, either from the ground or a
tree, might seem to be most easily explained on the theory of one bird,
recognised as the chief of the band, having in some manner—either by a
cry or by its own flight—given a signal, which was instantly obeyed by the
rest. But how—in the case of rooks—can any one note be heard by all
amidst such a babel as there often is, and how can every bird in a band
of some hundreds (or even some scores) have its eyes constantly fixed on
some particular one amongst them, that ought, indeed, on ordinary
physical and mechanical principles, to be invisible to the greater number?
If, however, to meet this latter difficulty, we suppose that only a certain
number of birds, who are in close proximity to the leader, see and obey
the signal, and that these are followed by those nearest to them, and so
on till the whole are in motion, then two other difficulties arise, neither of
which seems easy to get over. For, in the first place, the birds do not, in
many cases, appear to rise in this manner, but, as in the instances here
given, simultaneously, or, at least, with a nearer approach to it than any
process of spreading, such as here supposed, would seem to admit of;
and secondly, it is difficult to understand how, if this were the case, any
bird—or, at least, any few birds—could fly up without putting all the
others in motion. Yet, as I have mentioned, birds in twos or threes, or in
small parties, were constantly rising and flying from one place to another
in the assemblage of which they formed a part, whilst the vast majority
remained where they were, on the ground. This fact offers an equal or a
still greater difficulty, if, dismissing the idea of there being a recognised
leader, we suppose that any bird may, for the moment, become one by
taking the initiative of flight, or otherwise. And even if we assume that
any of these explanations is the correct one, in the case of a whole body
of rooks taking sudden flight, or directing their flight to any particular
place, or with any special purpose, what are we to think when half, or a
certain number of the band does one thing, and the other half another,
each, apparently, with equal spontaneity? We are met here with the same
difficulties—and perhaps in a still higher degree—as in the case of the
flocks of small birds at the stacks in winter.
"If rooks follow and obey a leader, one might expect them to do so
habitually, at least in their more important matters. The flight out from
the roosting-trees in the morning, and the flight into them again at night
are—when it is not the breeding-season—the two daily 'events' of a rook's
life. Here, then, are two subjects for special observation.
"November 30th.—At 3 P.M. I take up my position on the edge of a little
fir-plantation, a short distance from where I watched yesterday and the
last few days. My object is to watch the flights of rooks as they pass, and
try to settle if each band has a recognised leader or not. Of course it is
obvious that no one bird can lead the various bands, for these come from
over a large tract of country, whilst even those that seem most to make
one general army, fly, often at considerable intervals of time, and quite
out of sight of each other.
"A good many are already flying in the accustomed direction, but singly,
or wide apart. Each bird seems to be entirely independent.
"The first band now approaches. One rook is much in advance for some
distance. He then deviates, and is passed by the greater number of the
others, who continue on their way without regard to him.
"Another great, irregular, straggling body in which I can discern no sign
whatever of leadership. Then comes another, more compact. A rook that
at first leads by a long interval is passed by first one and then another, so
that he becomes one of the general body.
"A large band, flying very high. Two birds fly nearly parallel, at some
distance ahead.
"Two large bands, also very high. In each, one bird is a good way ahead.
The apparent leader of the second band increases his distance, curves a
good deal out of the line originally pursued, nor do the others alter their
course in accordance.
"Two other bands. In each the leader theory seems untenable. The birds
have a broadly extended front, and fly at different elevations. There is
nothing that suggests concerted movement, but, on the contrary, great
irregularity.
"In another band the apparent leader swoops down to the ground, and,
whilst only half-a-dozen or so follow him, the main body proceeds on its
way.
"Hitherto there has been a good deal of the familiar cawing noise, but,
now, a number of birds fly joyously up, hang floating in the air, make
twists and tumbles, perform antics and evolutions, and descend upon the
ground with wide parachute-like swoops from side to side, the wings
outspread and without a flap. I am first made aware of their approach by
the complete change of note. It is now the flexible, croodling, upturned
note—rising at the end, I mean—that I know not how to describe, totally
different from the 'caw,' nor do I hear a 'caw' from any of these
descending birds. It is the note of joy and sport, of joyous sport in the air,
of antics there as they sweep joyously down through it, that I now hear.
The birds that caw are flying steadily and soberly by. The 'caw' is the
steady jog-trot note of the day's daily toil and business—'Jog on, jog on,
the footpath way.'
"Another great band, of such length and straggling formation that the
birds in the latter part of it could not possibly see the leader if there were
one—or indeed, I should think, the vanguard at all. The first bird is
passed by two others, then passes one of these again, and remains the
second as long as I can see them.
"Another long flight that seems leaderless. With the 'caw' comes a note
like 'chug-a, chug-a, chug-a' (but the u more as in Spanish), and others
that I cannot transcribe. This flight goes on almost continuously—I mean
without a distinct gap dividing it from another band—for about ten
minutes, when another great multitude appears, flying at an immense
height and all abreast, as it were—that is to say, a hundred or so in a
long line of only a few birds deep. This, perhaps, would be the formation
best adapted for observing and following one bird that flew well in front,
but I can see no such one. All these birds are sailing calmly and serenely
along, giving only now and again an occasional stroke or two with the
wings. Now comes a further great assembly, in loose order, all flying in
the same direction. A characteristic of these large flights of rooks is that
their van will often pause in the air and then wheel back, circling out to
either side. The rearguard is thus checked in its advance, the birds of
either section streaming through each other, till the whole body, after
circling and hanging in the air for a little, like a black eddying snowstorm
(all at a great height), wend on again in the same direction, towards their
distant roosting-place. With the air full of the voice of the birds, there is
no caw—only the flexible, croodling, chirruppy note that has a good deal
of music in it, as well as of expression. This note, I think, is what I have
put down as 'chug-a, chug-a, chug-a.'
"There is now a continuous straggling stream, forming ever so many little
troops. The first bird of one troop tends to become the last of the one
preceding it, and the last one the leader of the troop following. Then
come numbers, flying in a very irregular and widely disseminated
formation, yet together in a certain sense. There is much of rising and
sinking and again floating upwards, of twists and twirls and sudden,
dashing swoops downwards, from side to side, like the car of a falling
balloon; two birds often pursuing each other in this way.
"And now come two great bands, one flying all abreast, as before
described, the other forming a great, irregular, quasi-circular rook-storm.
Leadership in the latter case would be an impossibility; in the former I
see no sign of it. All these birds, though at a fair height, are flapping
steadily along in the usual prosaical manner; through them, and far above
—at a very great height indeed, the highest I have yet seen, and far
beyond anything I should have imagined—I see another band gliding
smoothly, majestically on, with scarce an occasional stroke of the eagle-
spread pinions. The one black band of birds seen through the others, far,
far above them, has a curious, an inspiring effect."
Rooks, when in continued progress, either fly with a constant, steady
flapping of the wings, in a somewhat laboured way, though often fairly
fast, or they sail along with wings outspread, and flapping only from time
to time—this last, however, only when they are at a considerable height.
A crowd of rooks, indeed, in the higher regions of air present a very
different appearance to what they do when they fly about the fields, even
though at a fair height above the trees; their powers of flight in each case
seem of a very different kind. They can also soar to some extent, rising
higher and higher on outspread wings as they sweep round and round in
irregular circles—like gulls, but far less perfectly, and they have to flap the
wings more often. Add to this their downward-rushing swoops, their
twists, turns, tumbles, zig-zaggings, and all manner of erratic aerial
evolutions, and it must be conceded that the powers of flight which they
possess are beyond those with which we generally associate them in our
mind.
Seen thus, trooping homewards, in all their many moods and veins,

"Whether they take Cervantes' serious air,


Or laugh and shake in Rabelais' easy-chair,"

their flight, combined with their multitude, is full of effects. To-day their
widely extended bands were often, like so many black snowstorms filling
a great part of the sky. But at no time did I see anything resembling
leadership. "The many wintered crow that leads the clanging rookery
home" is—a lovely line. On no other occasion could I make out that rooks
obeyed or followed any recognised leader, and I came to a similar
negative conclusion in regard to the question of their employment of
sentinels. It is asserted in various works—for instance, in the latest
edition of Chambers's "Encyclopedia"—that they do post sentinels. I will
give two instances of their not doing so—as I concluded—and my
experience was the same on other occasions, which I did not think it
worth while to note.
"December 22nd.—To-day, I saw a number of rooks blackening a heap of
straw by a stack, whilst some were on the stack itself. Many were sitting
in some elms near about, but they did not appear to me to be acting the
part of sentinels. When I tried to get up to the hedge in order to watch
the rooks at the stack, through it, they flew off, a good deal later than
their friends in the trees must have seen me, and not till I was quite near.
If these had really been sentinels, they should have warned the rest,
either the instant they saw me, or at any rate, when I was obviously
approaching, but this they did not do. They were, therefore, either not
sentinels or inefficient ones." The second case, however, is more
conclusive.
"January 8th.—To-day, on my way down to the roosting-place, I pass a
number of rooks feeding in a field, and not far from the road. They are all
more or less together, there are no outposts, though of course there is, of
necessity, an outer edge to the flock. But neither on the hedge or in any
of the trees near, are there any birds to be seen. On the other side of the
field, however, and a very considerable way off, a few are sitting in some
trees. It hardly seems possible that these can act the part of sentinels at
such a distance, and even if they were much nearer, the feeding rooks
would have either to be looking at them, to see when they flew, or else,
the alarm must be given by a very loud warning note. Bearing this in
mind, I alight from my cycle, and walk along the road. The rooks, without
any dependence on sentinels far or near, note the fact, bear a wary eye,
but continue feeding. I then stop—always an alarming measure with
birds. The feeding rooks fly off to a safer distance, the ones in the trees
remain there as silent as ever, nor is there any special note uttered by any
one bird of the flock, nor anything else whatever to suggest that any
particular bird or birds is acting the part of sentinel." There is certainly no
sentinel in this case, and in matters directly affecting their safety one
might suppose that rooks, as well as other birds and beasts, would act in
a uniform manner. This, however, we can clearly see, that when there
happen to be trees, near where they are feeding, some of them will
usually, and quite naturally, be perched in them, and average human
observation and inference may have done the rest.
Rooks, I am inclined to think, are not birds that give their conscience into
keeping. Each one of them is his own sentinel.
CHAPTER XI
Watching Rooks—continued
Continuing my journal, I will now give extracts which illustrate, principally,
the return home of the rooks at night and their flying forth in the morning
—those two aspects of their daily winter life which are the most full,
perhaps, both of interest and of poetry.
"December 9th.—This afternoon at about 3.30 I find vast numbers of
rooks gathered together on a wide sweep of land, close to their roosting-
place.
"Even now—and they are being constantly reinforced—they must amount
to very many thousands, and cover several acres, in some parts standing
thickly together, in others being more spread out. There is an
extraordinary babble of sound, a chattering note and the flexible,
croodling one being conspicuous. Combats are frequent—any two birds
seem ready to enter into one at any moment—and they commence either,
apparently, by sudden mutual desire, or else by one bird fixing a quarrel
on another, which he does by walking aggressively up to him and daring
him, so to speak. In fighting they stand front to front, and then spring up
at each other—like pheasants, but grappling and pecking in the air as do
blackbirds and small birds generally. Sometimes one bird will be worsted
in the tussle, and you instantly see it on its back, striking up with claws
and beak at the other, who now bestrides it. It is easier to see this result
than to be sure as to the process by which it is arrived at—whether, for
instance, the overmatched bird falls, willy-nilly, on its back, or purposely
throws itself into that position, so as to strike up like a hawk or owl. I
think that this last may sometimes be the case, from the very accustomed
way in which rooks fight under such circumstances; but, no doubt, it
would only be done as a last resource. The rooks, however, do not seem
vindictive, and their quarrels, though spirited, are usually soon over. They
may end either by the weaker or the less acharné bird retiring, in which
case the pursuit is not very sustained or vigorous, or else by both birds,
after a short and not very rancorous bout, pausing, appearing to wonder
what they could have been thinking about, and so walking away with
mutual indifference, real or assumed. Often one bird will decline the
combat, and in this case, as far as I can see, it is not molested by the
challenger, however bullying and aggressive this one's manner may have
been. A rook coming up to another with the curious sideway swing of the
body and a general manner which seems to indicate that he thinks
himself the stronger of the two, looks a true bully.
"One rook has just found something, and, whilst standing with it in his
bill, another comes forward to dispute it with him, but the attack is half-
hearted, and seems more like a mere matter of form. Afterwards, when
the same bird has the morsel on the ground in good pick-axeing position,
a second rook advances upon him with a quick, sideway hop, looking
cunning, sardonic, diabolic, and much for which words seem totally
wanting. But this attack, though swift and vigorous, is not more
successful than the former one. The lucky rook gets off with his booty,
and has soon swallowed it. Amongst rooks, the finding of anything by any
one of them is a recognised cause of attack by any other. This is taken as
a matter of course by the bird attacked, and if he holds (and swallows)
his own, which, as he has a clear advantage, he generally does, no
resentment is manifested by him—there is not even a slight coolness after
the incident is over. If, however, the attack should be successful, then it is
very different. The annoyance is too great for the robbed bird, and he
becomes very warm indeed. He makes persistent violent rushes after the
robber, is most pertinacious, and clearly shows that kind of exasperation
which would be felt by a man under similar circumstances. It seems not
so much his own loss, as the success and triumphant bearing of the other
bird, that upsets him. He has failed where he ought to have been
successful, and of this he seems conscious.
"When one rook makes his spring into the air at another, this one will
sometimes duck down instead of also springing. The springer, then, like
'vaulting ambition,' 'o'erleaps himself and falls on the other side.' I have
just seen this. The rook that bobbed seemed to have scored a point, and
to know it, which the other one confessed shame-facedly—no,
indescribably, a rook cannot look shame-faced. The advantage was not
followed up by the successful bird, but the combat ceased, I think, in
consequence.
"I now notice a hare a little on the outside of the phalanx of rooks, at the
part of it nearest to myself. All at once he makes a little run towards them
as if charging them, and sits down, making one of their first line, and
almost, as it seems, touching two or three. After sitting here for some
while the hare makes another little run, this time right in amongst the
rooks, several of which he puts up as though on purpose—each of the
birds giving a little jump into the air with raised wings, and coming down
again. He then sits down as before, but this time all amongst them. This
he repeats several times, making little erratic gallops through the black
crowd, in curves to one side and another, and appearing to enjoy the fun
of causing rook after rook to jump up from the ground. Half-a-dozen
times he runs right at a rook that he might easily have avoided, and sits
down amongst them two or three times, again. At last, in a final gallop,
he pierces the squadron and continues on, over the land. This certainly
appeared to me to show a sense of fun, if not of humour, on the hare's
part, and as—with a few noted exceptions—it is the rarest thing to see
one species of animal take any notice of another, I was proportionately
interested.
"It is now half-past four, and for about an hour the great assemblage has
been increased by a perpetual stream of rooks, that sail up and descend
into it with joyous wheels and sweeps. For some time, too, flocks of the
birds have been flying from the ground into trees near. They fly by relays,
and from the farthest part of the troop—that is to say, from that part
which is farthest distant from the woods where they are to roost. First
one band of birds and then another rises from the outer extremity, flies
over the rest, ascending gradually, and wings its way to the trees. By
these successive flights the assemblage is a good deal shrunk, and does
not cover nearly so much ground, when the remainder—still an enormous
number—rise like a black snowdrift whirled by the wind into the air, and
circle in a dark cloud, now hardly visible in the darkening sky, above the
roosting-trees, with a wonderful babel of cries and noise of wings.
"At 4.40 this deep musical sound of innumerable crying, cawing,
clamouring throats is still continuing, and once, I think, the birds rise from
the trees into which they have sunk, and circle round them again. Now
they are in the trees once more, but the lovely cawing murmur—the hum,
as though rooks were rooky bees—still goes on.
"4.47.—It is sinking now. Much more subdued and slumberous, deliciously
soothing, a rook lullaby.
"December 11th.—A stern winter's day, the earth lightly snow-covered,
but bright and fine in the morning. At 3 P.M. I am where the rooks roost,
a plantation of fir-trees—larches—dark, gloomy and sombre, with a path,
piercing them like a shaft of light, over-arched with their boughs, silvered
now with light snow-wreaths. Just in this gloomy patch they sleep, but
with a light belt of smaller firs opposite, or with adjoining woods of oak
and beech they will have nothing to do, leaving these latter to the wood-
pigeons.

Rooks: A Winter Scene.


"At 4.30 I leave the woods and find the rooks gathered in the same place
as yesterday, but in far less numbers. Shortly, a large band flies up and
swoops down with all sorts of turns and twists, and turns right over in the
air—a striking sight, the air full of the rushing sound of their wings—a
bird-storm, a black descending whirlwind. At 4.35 the rooks all fly from
the ground into a small clump of fir-trees near. Great numbers of other
ones are flying up and settling in a plantation of small firs, fringing
another part of the field, quite filling it. The snow seems to drive them
from the ground, their conclave to-day must be held in the trees.
"They are gathering, now, from all parts, filling the trees round about the
ploughed land—now all white—flying in flocks about them, then
descending into them again.
"Still coming and coming out of the sunset, specks growing into birds.
The stern, snow-covered landscape, the red glow of the sunset, and the
black, labouring pinions against it make a fine winter scene.
"4.37.—Back at the larches, and only just in time to stand concealed
within them, before the rooks are there. All seem coming, a black, flying
multitude. They have reached the larches and fly about over them in
wide, sedate circles, coming in relays, as last night. Joyous voices—
innumerable multitudes—a torrent of wings! All in a broad, rapid,
streaming flight to the larches. They sweep, dash, circle and eddy over
them, black flashes in the deepening gloom. They sweep into them, and
the snow, swept by their wings, falls in a drizzle from the branches.
Joyous, excited cries, 'chu, chu, chac, chac.' The whole dark grove is a
cry, a music. Still other bands, they burden the air. Band after band—now
with a pause between each. They fly swiftly and steadily up, at a not
much greater height than the trees, not descending into them out of the
sky.
"A longer pause, followed by another hurrying band. And now the moon
is shining through the larches, and the black, ceaseless pinions go
hurrying across its face. Groans, moans, shrieks almost, yells amongst the
larches, all mingled and blending—but sinking now. A marvellous medley,
a wonderful hoarse harmony! Here are shoutings of triumph, chatterings
of joy, deep trills of contentment, hoarse yells of derision, deep guttural
indignations, moanings, groanings, tauntings, remonstrances, clicks,
squeaks, sobs, cachinnations, and the whole a most musical murmur.
Loud, but a murmur, a wild, noisy, clamorous murmur; but sinking now,
softening—a lullaby.

'I never heard


So musical a discord, such sweet thunder.'"

When the rooks sweep down, thus, into their roosting-trees they
frequently do so with a peculiar whirring or whizzing noise of the wings,
but although this sound is in perfect consonance with the motion which it
accompanies—insomuch that one has to use the same words to describe
each—yet it does not seem to be produced by it. At least, it bears no
relation to the height from which the birds swoop, nor—as would seem to
follow from this—with the impetus of the descent. It may be a matter of
impetus, but to me it has often seemed more as though the sound gave
the idea of impetus, or added to it, and that the sweeps were,
sometimes, just as impetuous, or even more so, when made without it.
As I observed, the birds flew to their trees at a very moderate height—not
very much, indeed, above the trees themselves—and, whilst many made
the whizzing sound, the great majority swooped down without it. It
seems, therefore, to be a special sound produced by the rooks at
pleasure, and always accompanying an excited frame of mind. First one
bird and then another gets excited, and dashes suddenly down with the
whirring or whizzing noise, so that, as the sound is not vocal, and is only
heard upon such occasions, it has all the appearance of being caused by
the quick, sudden motions of the wings. But it is possible that some
particular way of holding the quill-feathers of the wing or even tail is
required to produce it, in combination with the general movements, and
this would account for its being sometimes heard and sometimes not
heard, when these latter are identical.[21] The curious burring note is
likewise, but far less frequently, an accompaniment of these wild excited
sweepings, and this is most often the case when they are from a
considerable height. Here, again, the note bears a clear relation to the
bird's mental state, so that it would appear that the degrees of
pleasurable excitement cannot be estimated by the motions alone. The
"burr," in my opinion, when well and loudly uttered—for here, again, there
is much variety—marks the maximum of a rook's content, at any rate in a
certain direction.
[21] With regard to the above, however, I am now no longer so sure.
Je m'en doute. When the rooks descend from a height, the sound
made is often most remarkable, being that of a mighty rushing wind
filling the air.

"December 15th.—At 7 A.M. I am at the point of the road nearest to the


rookery, and I hear the sweet jangle, 'the musical confusion,' already
beginning. Not much, however—subdued and occasional—influenced,
perhaps, by the heavy morning mist that hangs over trees and earth.
After a time I walk to an oak just outside the plantation, and sit listening
to the rising hubbub—now rising, now falling. A sad, mist-hung morning,
the earth lightly snow-decked; raw and chill, but not so frostily, bitingly
cold as yesterday and before. The general intonation of the rook voice is
pleasing and musical—how much more so than the roar of an at-home as
the door is flung open, even though one has not to go through that door!
There is very great modulation and flexibility—more expression, more of a
real voice than other birds. One feels that beings producing such sounds
must be intelligent and have amiable qualities. One of the prettiest
babbles in nature!
"One catches 'qnook, qnook,' 'chuggerrer,' 'choo-oo-oo.' At intervals the
single, sudden squawk, or continued trumpeting, of a pheasant, breaks
abruptly into the sea of sound, then mingles with it. Every now and again,
too, there is a sudden increase of sound, which again sinks.
"At 7.50 the rooks are still in bed, but a pheasant—a fine cavalier—comes
running towards me over the snow. He makes a long and very fast run for
some fifty yards or so, then stops and draws himself bolt upright,
seeming to stand on tip-toe. More than upright he is—bent back, trying to
look like a soldier, but obliged to be graceful and elegant. Standing thus,
he seems on the very point of trumpeting, yet does not, and then runs on
again. He repeats this, several times, each time thinking of trumpeting,
but desisting and going on.
"At 7.58 the flight out commences. Two or three birds are a little in front,
none very prominently so, and others are catching them up and seem just
on the point of passing them when they are lost to me in the mist. There
is nothing suggesting a leader. If they were led it was not by one of
themselves, for with them and in their very fore-front two little birds were
flying, who passed with them out of sight. They were tits, I think, and in
another flight out, after one of the pauses—for the rooks fly out by relays,
like the starlings—I noticed one other, all three, I believe, being parus
cæruleus. There are quite a number of tits in the plantation and woods
adjoining, but why just three should leave it and go flying with the rooks
through the mist, over the open country, if not for the mere joy and fun
of the thing, I know not. All at once a number of the out-flying birds turn
in their flight, and swoop back, with a great rush of wings, to the
plantation. Afterwards, at intervals, there are other such returns, little
bands of the birds seeming to say, 'Oh, let's go back to bed. It's much
nicer,' and doing so. This, too, is exactly what the starlings do. The birds,
as they fly, are all vociferous, and the air is laden with a pleasant burden
of 'chug-chow, chug-chow, chug-chow. Chugger-chugger-chow. How-
chow, how-chow.' The rooks talk a kind of Chinese.
"At 8.20 the principal flight is over, but still there is a stream of birds
issuing out, and most of these are now going down on to the land. All at
once, these—that is to say, all the rooks on the ground—rise and fly to
the trees, the birds who have been sitting in them join them in the air,
they all fly about together over the trees, and then go off in two or more
bodies, and in different directions. There has been no sign of a leader, or
of leadership, in any of the flights out, or in any of the birds' actions.
"At 8.45, when no more rooks are to be seen, either flying or on the
ground, I walk through the larches, and put up a good many birds who
have remained sitting in them, instead of going out with the rest. I, then,
walk all round the plantation, and find numbers of rooks sitting in the
beech-trees that edge it on one side. Though the numbers seem small,
after watching the innumerable flights out, they may yet amount to some
hundreds. Thus, some small bodies of birds, and even some individuals,
have not been influenced by the action of the vast majority, but have sat
still whilst the rest flew forth—unless, indeed, all of them have first flown
out, and then back again; but this I do not think is the case. Two great
leading principles seem to govern all the actions of rooks—independence
and interdependence. All are influenced by all, yet all can, on any and
every occasion, withstand that influence, and think and act for
themselves.
"Sometimes the sweepsback of the birds into the trees are very curious,
seeming to indicate some unknown force at work. There is a sort of
commotion—a turmoil of some sort—causing a cessation of the regular,
orderly flight, the voice varies, there is a rush of wings, and out of this
trouble, as it were, the backward swoop is born. Then the wavering
stream—or rather a certain wavering eddy in it—flies on, and again the
voice becomes the musical 'har-char, har-char' (a better rendering than
'how-chow'), which characterises the flight out.
"It is as though a sudden surge of thought said 'Back!' and swept some
back, but a deeper, stronger surge said 'On!' and on the greater number
streamed.
"Again, the stream of flight will sometimes be interrupted by a sort of
sweeping or drifting together of a number of the birds, making an eddy in
it, as it were—an interruption and perturbation in the current, difficult to
describe, and over before one can fix the proper words to it; but
indicating some sort of emotion in the birds, a rush of feeling of some
kind, something tiresome to note, but which ought to be noted. Once,
too, I have seen a single rook flying straight back against the general
current of the stream, meeting and passing all the rest on his way to the
trees, seeming the very emblem of a fixed intent.
"These curious, pausing, and hesitating movements, in which an idea that
seems at first vague becomes, all at once, definite, seem to me to have
their origin in what may be termed collective thinking—for this gives a
better idea of the appearance of the thing than does the term thought-
transference, though that may more correctly indicate the process. The
birds do not appear to be influenced by the actions—the external signs of
thought—of each other, but numbers of them seem similarly influenced at
or about the same moment of time. In fact, they often act as though an
actual wind had swept them in this or that direction—when this cannot
have been the case, I hasten to add.
"February 10th.—A hard black frost, bitterly, bitingly cold. At 5.30 A.M. I
steal into the dark plantation, and silently take my place at the foot of
one of the tall, sighing trees. Softly as I try to move, I disturb some of the
sleeping birds, who make heavy plunges amongst the trees, or beat
about, for a little, through 'the palpable obscure' above them. But, leaning
against the trunk, I am now rock-still, and soon they settle down again,
though 'talking'—some nervous inquiry—continues a little, breaking out
first here and then there, around where I sit. I soon notice, however, that
these outbursts have no relation to my whereabouts, but take place over
the whole plantation, and I come to the conclusion that they have
nothing to do with the late disturbance, which is now, evidently,
forgotten. The night, in fact, is passing, and the rooks are beginning to be
rooks. Such noises in the utter darkness, amidst the shroud-black firs,
sound ghostly, and may, perhaps, have given rise to the idea of the night-
raven. In the winter, it must be remembered, it is night, practically, for
some time after the peasantry of any country are up and about; nor can I
conceive of any sounds more calculated to give rise to superstitious ideas
than some of those I hear about me. In the real night, too, a belated
peasant might easily get a note or two from some awakening rook, and,
both by virtue of time and place, and the actual quality of the sound—as I
can testify—it would sound very different to what he was accustomed to
in the daytime. It is probable that, in a country where ravens were
known, and inspired those superstitious feelings which they always have
inspired, such sounds, issuing out of the darkness, would be ascribed to
them, rather than to the homely rook; and here we should have the
night-raven—a bird 'frequently met with in fiction, but, apparently,
nowhere else.' Possibly, however, the raven itself may sometimes utter its
boding croak through the darkness, and ravens have been, and, in some
parts, still are, numerous.
"Gradually the plantation becomes quite a wonderful study of sounds,
there being an extraordinary variety, and some of them most remarkable.
One, that seems deep down in the throat, suggests castanets being
played there, but castanets of a very liquid kind, water-castanets, if such
there could be, but, if not, it gives the idea. This curious sound is only
uttered occasionally by some particular rook, and it recalls—perhaps is—
the well-known burring note that I have heard under such different
circumstances. If so, it can only be as a recollection that the bird utters it.
I have not the space to reason this, but, assuming it to be so, may we
not see, here, one of the alleys leading up to language? A certain sound
is uttered during the doing of a certain thing. It becomes associated in
the mind with that thing, with the doing of it, and with the state of mind
under the influence of which it is done. At first, perhaps, unconsciously,
then consciously, it is uttered when such action is recalled, and the
utterance recalls it, also, to the mind of whoever hears. Here, then, is a
certain well-understood sound conveying a certain idea or ideas—as, first,
'burr,' a particular kind of joyous flight: then, 'burr,' something as joyous
as such flight, and so, joy: and lastly, 'burr,' the actual joyous flying, the
root, therefore, of the verb 'burr,' to fly joyously, and, so, to fly. Darwin
supposes language to owe its origin 'to the imitation and modification of
various natural sounds, the voices of other animals and man's own
instinctive cries, aided by signs and gestures.' To repeat a certain sound,
that had been at first the mere mechanical adjunct of a certain act or
state, when one recalled that act or state, would be, as it seems to me,
an extremely early—perhaps the earliest—step, passing imperceptibly
from feeling into thought, and leading on to imitation. Such speculations
may be permitted one, in a dark fir-plantation, surrounded by rooks and
waiting for the morning.
"One thing, however, I record as a fact, which appears to me somewhat
curious. Though the plantation is continuous, without any break other
than the narrow path that runs through its centre, and though it is simply
crowded with rooks, every tree holding a great many, yet I notice that an
outbreak of sound in any particular part of it does not spread over the
whole, as one might have supposed that it would, but dies gradually out,
as it radiates from the point where it arose. Thus, there are zones of
sound, isolated from each other by intervening areas of silence. Just at
this moment, after I have sat, for some time, silent, and all alarm has
subsided, there is a great clamorous outburst some little way off. It must
have some special cause which I cannot divine, but this commotion does
not, any more than the lesser ones, spread itself through the packed
community, but is strictly isolated. How strange this seems! A parliament
(though I heard no nonsense talked) of lively, eminently gregarious birds,
all of which are noisy at one time or another, and from the thick of them
a storm of clamour bursts: would not one think that the birds sitting
cheek by jowl with the stormers would storm too, and so 'pass it on'?
Why should there be a periphery, and what should limit the chorus except
the bound of the plantation itself? Do crowds shout in patches? That the
clamour should cease, after a time, is, of course, natural, but why, though
it died along the road by which it travelled, should it not keep travelling
on, through all the black, serried ranks? If rooks were influenced only by
the outward manifestations of each other's emotions, one might, surely,
expect this. But now, if they were influenced more by the thought itself,
rapidly transmitted from one to another of them, then, whenever this
factor ceased, for whatever reason, to act, the birds beyond the limits of
its action might be unaffected by the cries of those who had felt its
influence, for they would have been accustomed to look for a sign from
within, and not from without. They might then hear, on some occasions,
without being impelled, though on other occasions they might choose, to
join. It may be difficult to realise such a psychical state, but that does
not, of itself, make the state impossible. Its possibility would depend upon
the reality or not of collective thinking, or thought-transference, and
observation is (or should be) our only means of deciding as to this.
"As light struggles out of the darkness, the silence is broken more and
more frequently, at some point or other of the plantation, so that the
sound is disseminated over a larger and larger space, till, for some little
while before the flight, the whole rookery seems to be talking at one and
the same time. In reality, however, there is a constant cessation and
renewal on the part of each individual bird.
"At 6.30 the sounds take a deeper and more emphatic tone. There is
more solemnity, more meaning, and the meaning grows plainer and
plainer as the asseveration becomes more and more emphatic, that 'it is,
yes is, is really, positively is, is, is, is, is the morning.'
"At 6.35 there is the light, joyous 'chug-a, chug-a, chug-a,' besides which
one catches—if one has a good ear—'hook, chook,—hook, took—hook-a-
hoo-loo—chuck, chuck, chuck, chuck, chuck, chuck,—polyglot, polyglot.'
"Then there is a question—a serious and solemnly propounded question
—'Quow-yow?' The answer—from another rook—is immediate and
undoubted—'Yow-quow.'
"There are sounds which just miss being articulate and just evade one's
efforts to write them down. It is significant that I have to use the word
'talking' to describe the rook's utterances. It is the one word; another
would sound forced and strained.
"Throughout the babel, there is a tendency for it to sink and rise in
sudden accentuations and diminishments. Now there is a diminishment,
and a bird in the tree next to mine gives a sleepy stretch out of one wing,
which has all the appearance of a yawn. But I see no other bird yawning,
nor do I notice any toilette, any preening of the feathers.
"Now, at close on 7, the flight out is preceded by a flight of the birds
inside the plantation, from one tree to another, and this passes, gradually,
into the full forth-streaming. Just above the trees, now, they pass in
endless flakes of a black and living snowstorm. Their flight is swift,
hurrying, joyous. They flap, but there are, often, long sweeps on
outspread wings, between the flaps. And ever, as they fly, they greet the
cold, stern morning with their joy-song of 'chow-how, a-chuck, a-chuck,
a-chuck, a-chuck, a-chuck-a.'
"Nearly a month later, a smaller, but still numerous, body of the birds had
chosen a new roosting-place—a clump of Scotch firs on a lonely heath,
which had stood vacant all the winter, a point interesting in itself, but
which—for the old reason—I am unable to discuss.
"March 4th.—I got to the plantation towards the end of the afternoon,
and resolved to wait there, in order to see wood-pigeons fly into it in the
evening. Not many came, but at six o'clock I saw what I thought was a
large band of them fly into an oak-tree which I had noticed just outside
the plantation, where they remained for a minute or two. They then flew
on to the plantation, sweeping over it once or twice before settling, and I
saw that they were rooks. As will be seen from this, they had hitherto
been silent. When they had settled in the trees there was some talking,
but strangely little, I thought, for rooks, and very soon afterwards there
was hardly a sound. They remained thus, for some little time. All at once,
with extraordinary suddenness, with a sound of wings so compact and
instantaneous that it was almost like the report of a gun, the whole troop
burst suddenly out of the trees, which were on the outer edge of the
plantation, flew a little way over the heath (I caught them against the
fading red of the sky), wheeled round, returned, and shot into them
again. There was a little cawing as they got back, but this soon sank, and
again there was silence. Then, in a moment, there was the same sudden
rush of wings, and the whole black cloud shot, like one bird, into the
open sky, wheeled again, and shot back, as before. This occurred nine
times in succession, at intervals of not longer, I should think, than three
or four minutes. In the later rushes the birds circled several times—flying
out again, each time, over the moor—before resettling in the trees. After
the last time they settled in a different part of the plantation. Immediately
before two of the rushes out, I heard a loud 'caw,' in rather a high-
pitched tone, from a single rook, which seemed to be the signal for the
exodus, whilst, almost immediately afterwards, there was another single
note of quite a different character—deeper and more guttural—from
either the same or another bird still in the trees, which seemed to call the
rest back again. A well understood signal-note indeed, would be the
easiest way of accounting for these sudden and extraordinarily
simultaneous flights and returns, but it was only twice out of the nine
times, that this explanation seemed tenable. On other occasions, the caw,
at starting, seemed only one of many, or did not correspond so exactly, in
point of time, with the sudden flight out, as the theory seemed to require,
whilst the deep 'quaw,' which seemed to be made by one particular rook,
who always stayed behind, and which I had at first thought called the
others back, would be heard directly after they had flown, as well as after
they had returned. Several times, too, the black cloud and thunder-storm
of wings seemed to burst out of silence itself. I came to the conclusion
that a signal-note was not the explanation. All I can say is, that—from
what cause or actuated by what impulse, I know not—some fifty to a
hundred rooks shot, as though they shared one soul, nine times in
succession, from those dark pines, circled a little over the dusky moor,
and then shot back into them again. No one, except myself, was near. It
was one of those very lonely places where, at almost any time, one can
count upon seeing no one, and, altogether, it struck me as an
extraordinary phenomenon.
"Once more, the old Greek idea of the φημη—a sudden thought,
sweeping through a crowd as a wind sweeps through a grove of trees—
seemed to me to be the only view which met the facts. But what, then, is
the φημη, and whence, or why, the impulse?
"All this time, I should say, though quite near, I was perfectly concealed,
standing against a tall pine-tree, around the trunk of which I had helped
to make a wigwam—already partly formed—of some of its own fallen and
bending branches. This, with the gloom of the plantation itself, and the
falling night, was a perfect concealment, even at a foot's pace, as will
shortly appear.
"It was just after the last return of the out-shooting birds that, looking up,
I saw what I at first supposed was they, but soon found to be another,
and a very much more numerous, band of rooks, who, as they came up,
were joined by the other ones, in the air. Now, for the first time—for the
cloud came up in silence, and, since the last flight out, there had been
silence in the plantation too—there was a tremendous clamour of voices,
filling the whole place, and then a black, whirling snowstorm of rooks
began to shoot, whirr and whizz about, over, into, through, and amongst
the fir-trees, in a most extraordinary manner. The rapidity with which they
shot about, their hurtlings, their sideway-rushing sweeps and swoops,
their quick, smooth turns and gliding zig-zags, avoiding, by miracle, each
other and the trunks of trees, was most extraordinary, whilst the whishing
noise of their wings through the air was almost frightening. The
plantation seemed to be a huge disturbed bee-hive, with great black bees
dashing angrily about it. It was a snowstorm with the flakes gone mad;
but black, a black, living bird-storm, and it produced in me a feeling of
excitement, a peculiar, almost a new, sensation, analogous, perhaps, to
what the birds themselves were feeling. What struck me and made it
more interesting, was that it was a special exhibition, a 'set thing,'
something indulged in by the birds with a peculiar pleasure in the
indulgence, something appertaining to the home-coming—the
'heimkehr'—emanating from and requiring a particular, psychical state.
This is by far the finest display of the kind I have yet seen, and I was in
the very midst of it. Considering the number of birds—there must, I think,
have been several hundreds—the speed at which they dashed about and
the smallness of the space in which so many were moving with such
violence, and so erratically, it seems wonderful that they never came into
collision, either with one another or the trunks or branches of the fir-
trees. In the plantation, when I came into it, two dead rooks were lying,
and I had also picked up a dead one in the larger roosting-place. The
keeper said it had been 'turned out,' which was vague, and then, more
definitely, that rooks sometimes died of old age. It seems not impossible,
or even improbable, that in these violent whizzings of a great number of
rooks together, amongst closely growing trees, and in the gloom of
evening fading slowly into night, accidents may, sometimes, occur. The
rooks, I should say, in their violent whizzing darts and dashes, shot down,
sometimes, to about half the height of the trees, and were, in general,
right in amongst them. This wonderful scene of bird excitement, lasted, I
should think, about ten minutes, in full action, but grew fainter as the
trees became more and more packed with birds, till, at length, all were
settled. Every tree held several. On two slender ones—not pines but
birches—just in front of me, and but a step or two off, there must have
been more than twenty. The noise and clamour, during the whole time,
was tremendous."
It is not always that rooks dash thus madly to rest. Here—on the very
next evening and at the same place—is another type of the home-
coming.
"March 5th.—A little after 5.30, a hooded crow flies into the clump of
pines. Whether it stays there for the night, with the rooks, I cannot tell,
but it does not seem to me improbable. I have seen single birds of the
former species flying amidst large bands of the latter, and they are
constantly together in the fields, where they behave, in regard to each
other, very much as though they were of the same species.
"At 6.10, which is later than the first batch of rooks came yesterday, five
birds fly over the plantation but do not go down into it.
"At 6.15 a large, united flock of, perhaps, six or seven hundred fly up
from over the ploughed land skirting the moor. They utter the 'chug-a,
chug-a' note, characteristic of the homeward flight, but quietly; there is
very little noise. Just before reaching the plantation they make a sort of
circling eddy in the air—becoming, as it were, two streams that drift
through each other—then sail on together and circle some three or four
times exactly over it, before descending into its midst. This they do
without any of the excited sweeping about of yesterday, and though, of
course, the voice of so many birds is considerable, yet, comparatively, it is
very subdued, and in a very short time—about five minutes—they all
seem settled. Before long, however, some of them, but quite an
inconsiderable number, rise and fly about over the trees again, but soon
resettle, and there is, now, a deepening silence. No one could imagine
that that little lonely clump of trees held all that great army of birds. All,
to-night, has been wonderfully decorous. There was something majestic
in the way the rooks flew up—slow-seeming yet swiftly-moving. Their
flight round, over the trees, before sinking, like night and with the night,
upon them, was a fine sombre scene—the thickening light ('light thickens
and the crow ——'), the silent, lonely-spreading moor, the gloomy trees,
and, above them, slow-circling in the dusky air, that inky cloud of life. It
was gloomy, the effect—saddening, yet with the joy of nature's sadness.
The spirit of Macbeth was in it—'Here on this blasted heath'—

'Good things of day begin to droop and drowse,


Whilst night's black agents to their prey do rouse.'

"But they sank peacefully down, and all of evil seemed to go, with their
sweet, joyous, innocent, and well-loved voices."
Here is one last picture, and I would point out that, on all these three
occasions, when the rooks slept in changed quarters, at a later time of
the year, the way in which they approached or entered the trees, and the
height at which they flew, varied, in a greater or less degree, from what it
had been before.
"March 11th.—At 6.20 a small band of rooks comes flapping along in the
usual jog-trot way, and enters the plantation. Some five minutes
afterwards a very large number sail up, flying at a great height, and
gather like a storm-cloud above it. They hang over it, then drift, circling, a
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.

Let us accompany you on the journey of exploring knowledge and


personal growth!

ebookultra.com

You might also like