100% found this document useful (2 votes)
22 views68 pages

Modern Systems Programming with Scala Native: Write Lean, High-Performance Code without the JVM 1st Edition Richard Whaling download

Modern Systems Programming with Scala Native by Richard Whaling is a comprehensive guide to writing high-performance code without the JVM, focusing on the Scala Native framework. The book covers foundational concepts of systems programming, including input/output, memory management, and building servers, while also introducing modern programming practices. It is designed for developers looking to enhance their skills in low-level programming and functional programming using Scala.

Uploaded by

lozzimarlyzn
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
100% found this document useful (2 votes)
22 views68 pages

Modern Systems Programming with Scala Native: Write Lean, High-Performance Code without the JVM 1st Edition Richard Whaling download

Modern Systems Programming with Scala Native by Richard Whaling is a comprehensive guide to writing high-performance code without the JVM, focusing on the Scala Native framework. The book covers foundational concepts of systems programming, including input/output, memory management, and building servers, while also introducing modern programming practices. It is designed for developers looking to enhance their skills in low-level programming and functional programming using Scala.

Uploaded by

lozzimarlyzn
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 68

Modern Systems Programming with Scala Native:

Write Lean, High-Performance Code without the


JVM 1st Edition Richard Whaling download

https://textbookfull.com/product/modern-systems-programming-with-
scala-native-write-lean-high-performance-code-without-the-
jvm-1st-edition-richard-whaling/

Download more ebook from https://textbookfull.com


We believe these products will be a great fit for you. Click
the link to download now, or visit textbookfull.com
to discover even more!

Parallel programming for modern high performance


computing systems Czarnul

https://textbookfull.com/product/parallel-programming-for-modern-
high-performance-computing-systems-czarnul/

Learn Python Programming A beginner s guide to learning


the fundamentals of Python language to write efficient
high quality code Romano

https://textbookfull.com/product/learn-python-programming-a-
beginner-s-guide-to-learning-the-fundamentals-of-python-language-
to-write-efficient-high-quality-code-romano/

Get Programming with Scala MEAP V05 Daniela Sfregola

https://textbookfull.com/product/get-programming-with-scala-
meap-v05-daniela-sfregola/

Get Programming with Scala MEAP V05 Daniela Sfregola

https://textbookfull.com/product/get-programming-with-scala-
meap-v05-daniela-sfregola-2/
Writing High Performance NET Code Ben Watson Et Al.

https://textbookfull.com/product/writing-high-performance-net-
code-ben-watson-et-al/

Functional Programming in C#: How to write better C#


code 1st Edition Enrico Buonanno

https://textbookfull.com/product/functional-programming-in-c-how-
to-write-better-c-code-1st-edition-enrico-buonanno/

Learning concurrent programming in Scala learn the art


of building intricate modern scalable and concurrent
applications using Scala Second Edition Prokopec

https://textbookfull.com/product/learning-concurrent-programming-
in-scala-learn-the-art-of-building-intricate-modern-scalable-and-
concurrent-applications-using-scala-second-edition-prokopec/

Lean System Management for Leaders A New Performance


Management Toolset 1st Edition Richard E. Mallory

https://textbookfull.com/product/lean-system-management-for-
leaders-a-new-performance-management-toolset-1st-edition-richard-
e-mallory/

Biota Grow 2C gather 2C cook Loucas

https://textbookfull.com/product/biota-grow-2c-gather-2c-cook-
loucas/
Early Praise for Modern Systems Programming with Scala Native

If you’re interested in writing more performant, low-level code in a JVM environ-


ment, look no further than Scala Native. This book will show you how to harness
its power to create lightning-fast software.
➤ Andy Keffalas
Lead Software Engineer

If you think the only way to do systems programming is with C, think again! Scala
Native is full of comparable features that enable us to implement the same appli-
cations C is known for, but in a modern way. Reading this book is really an eye
opener that systems programming is not really a thing of the past, but is something
that is actually cool.
➤ Zulfikar Dharmawan
Software Engineer

Modern Systems Programming with Scala Native is a gentle but thorough introduc-
tion to systems programming. Even if you are new to Scala Native, you can benefit
from reading this book.
➤ Gábor László Hajba
Senior Consultant

This book provides a great (re)introduction to the fundamental, close-to-the-metal


programming concepts in a way that those of us using higher-level languages
don’t deal with directly.
➤ Justin Nauman
Senior Systems Engineer
Modern Systems Programming with Scala Native is an excellent guide to applying
modern systems’ technologies and functional programming to service development.
Richard clearly demonstrates how Scala Native effectively models the concepts
and supports a high-quality implementation.
➤ Corey O’Connor
Founder, GLNGN, LLC
Modern Systems Programming
with Scala Native
Write Lean, High-Performance Code without the JVM

Richard Whaling

The Pragmatic Bookshelf


Raleigh, North Carolina
Many of the designations used by manufacturers and sellers to distinguish their products
are claimed as trademarks. Where those designations appear in this book, and The Pragmatic
Programmers, LLC was aware of a trademark claim, the designations have been printed in
initial capital letters or in all capitals. The Pragmatic Starter Kit, The Pragmatic Programmer,
Pragmatic Programming, Pragmatic Bookshelf, PragProg and the linking g device are trade-
marks of The Pragmatic Programmers, LLC.
Every precaution was taken in the preparation of this book. However, the publisher assumes
no responsibility for errors or omissions, or for damages that may result from the use of
information (including program listings) contained herein.
Our Pragmatic books, screencasts, and audio books can help you and your team create
better software and have more fun. Visit us at https://pragprog.com.

The team that produced this book includes:


Publisher: Andy Hunt
VP of Operations: Janet Furlow
Executive Editor: Dave Rankin
Development Editor: Katharine Dvorak
Copy Editor: L. Sakhi MacMillan
Indexing: Potomac Indexing, LLC
Layout: Gilson Graphics

For sales, volume licensing, and support, please contact [email protected].

For international rights, please contact [email protected].

Copyright © 2020 The Pragmatic Programmers, LLC.

All rights reserved. No part of this publication may be reproduced, stored in a retrieval system,
or transmitted, in any form, or by any means, electronic, mechanical, photocopying, recording,
or otherwise, without the prior consent of the publisher.

ISBN-13: 978-1-68050-622-8
Encoded using the finest acid-free high-entropy binary digits.
Book version: P1.0—January 2020
Contents

Acknowledgments . . . . . . . . . . . ix
Foreword . . . . . . . . . . . . . . xi
Preface . . . . . . . . . . . . . . xiii

Systems Programming in the Twenty-First Century . . . xix

Part I — Foundations of Systems Programming


1. The Basics: Input and Output . . . . . . . . . 3
Working with Output 3
Working with Input 10
Case Study: Google NGrams 18
What’s Next 23

2. Arrays, Structs, and the Heap . . . . . . . . 25


The Stack and the Heap 25
Structs, Arrays, and Sorting 30
Sorting an Array 35
Aggregation at Scale 38
What’s Next 43

3. Writing a Simple HTTP Client . . . . . . . . 45


Defining Terms 45
Working with TCP 48
Making a TCP Connection 53
Testing Network Code with Netcat 57
Introducing HTTP 58
Implementing HTTP 61
Testing Our Code 65
What’s Next 67
Contents • vi

4. Managing Processes: A Deconstructed Shell . . . . . 69


Running a Program 70
Introducing exec 70
What Went Wrong? 73
Introducing Concurrency with fork() and wait() 73
Supervising Multiple Processes 77
Working with Pipes 79
What’s Next 84

5. Writing a Server the Old-Fashioned Way . . . . . . 85


Understanding How a Server Works 85
Building Our Server 90
Creating a Minimum Viable Server 92
Handling HTTP 94
Performance Testing with Gatling 95
What’s Next 99

Part II — Modern Systems Programming


6. Doing I/O Right, with Event Loops . . . . . . . 103
Blocking and Polling 103
Introducing libuv 105
Working with Asynchronous TCP Sockets 111
Building an Asynchronous HTTP Server 121
What’s Next 129

7. Functions and Futures: Patterns for Distributed Services . 131


Designing an Asynchronous API 131
Introducing Futures 132
Implementing Futures 134
Implementing an ExecutionContext 135
Futures and Promises 138
Introducing libcurl 139
Asynchronous curl 144
What’s Next 153

8. Streaming with Pipes and Files . . . . . . . . 155


Looking at Streams, Files, and Descriptors 155
Streaming Pipe Input in libuv 156
Streaming File Input in libuv 161
Streaming File Output in libuv 164
Contents • vii

Stream Processors 168


What’s Next 174

9. Durability: An Embedded Key-Value Database with LMDB . 177


Introducing Embedded Storage 178
Defining LMDB Concepts 178
Working with the LMDB API 180
Serialization and Deserialization with JSON 184
Putting LMDB on the Web 186
What’s Next 189

10. Services: Encapsulation and Abstraction for Modern


Designs . . . . . . . . . . . 191
Services and Distributed Systems 191
Parsing, Revisited 193
Moving from Server to Service 198
Implementing an Idiomatic Service DSL 203
Integrations and Ecosystems 206
The Way Forward 209

A1. Setting Up the Environment . . . . . . . . 211


Running Scala Native on Mac OS 211
Why Use Containers? 212
Installing and Configuring Docker 213
Running Scala Native in Docker 214

Index . . . . . . . . . . . . . . 217
Acknowledgments
This book is only possible because of the people who’ve helped me along the way:

My friends and my family, who have graciously allowed this project to consume
my spare hours and attention over the last two years.

My employers at Spantree Technology Group and M1 Finance, who have


supported my writing and speaking generously and cheerfully, despite all the
disruptions it has caused.

Brian MacDonald at The Pragmatic Bookshelf, who approached me out of the


blue with this opportunity and coached me through the proposal process that
made this book happen.

My editor, Katharine Dvorak, who has been a constant cheerleader through


all of the ups and downs of taking this book from an idea to a finished thing.
Without her support and hard work, this book could never have been finished.

My thoughtful and attentive technical reviewers:

Hillel Wayne, Jan Goyvaerts, Zulfikar Dharmawan, Andy Keffalas, Rod Hilton,
Justin Nauman, Eric Richardson, Corey O’Connor, and Gábor László Hajba.

Writing a book about systems programming with correct, tested, portable


code is an immense challenge, and it wouldn’t be possible without their time,
care, and attention to detail.

The beta readers of this book, who have likewise provided a wealth of detailed
feedback.

Scala Native’s tight-knit community of open-source contributors: David


Bouyssié, Mike Samsonov, Eric K. Richardson and Lee Tibbert, who have
done so much work on Scala Native’s standard library, and beyond, to support
this community; Lorenzo Gabriele, who has done so much for the async
ecosystem in Scala Native, and made critical insights that improved the second
half of this book; and Paweł Cejrowski, whose work on libcurl far outpaces
my own.

report erratum •
Acknowledgments •x

The broader Scala community, and especially the friends I’ve found there: I
can’t name them all here, but Jorge Vicente Cantero, Andy Hamilton, Heather
Miller, Lars Hupel, Seth Tisue, Travis Brown, Natan Silnitsky, and Ólafur Páll
Geirsson have all been a huge part of my journey with Scala, and I couldn’t
have gotten here without them.

My good friends in other technical communities, who have provided a perspec-


tive and sounding board as I have developed all of this material, especially
Hillel Wayne, Alex Koppel, and Bryan Vanderhoof.

And finally, I have to give my thanks to Denys. Scala Native has been a huge
and positive part of my life for the last two years, and I am endlessly grateful
to him for everything he has done to make this all possible.

report erratum •
Foreword
Systems programming is a broad field that includes topics as diverse as
operating systems, memory management, drivers, and direct access to hard-
ware through programming using assembly language.

A key distinguishing characteristic that underlies this domain is the ability


to program at the level of abstraction that is most appropriate for the problem
at hand. Naturally, some problems require one to intimately understand
concepts that are usually hidden by modern languages, such as working with
unmanaged memory.

I am excited about Modern Systems Programming with Scala Native as it covers


modern systems programming through the lens of the Scala programming
language. The book builds up from foundational concepts, such as pointers
and manual memory management. It walks through direct interoperability
with both traditional C APIs and modern native libraries.

As you progress through the book, you are going to dive deeper into the world
of lower-level programming. Even though the domain might seem intimidating
at first, the gradual delivery of the key insights makes the whole process
completely seamless.

Richard Whaling has been at the forefront of building the async I/O story for
the Scala Native ecosystem. He is spearheading the adoption of libuv as the
avenue for next-generation high-performance async I/O in Scala. In addition
to the many great talks he has given on the topic over the years, this book
provides another opportunity to learn from his experience.

Denys Shabalin
Author of Scala Native

report erratum •
Preface
If you’ve ever been frustrated by the many layers of abstraction between your
code and the machine it runs on, you’re looking at the right book. Over the
coming chapters, I’ll show you how you can use Scala Native to build efficient,
modern programs from the ground up, focusing on practical use cases like
REST clients, microservices, and bulk data processing. With Scala Native,
you don’t have to choose between elegant code and bare-metal performance.

Who This Book Is For


This book is for anyone who wants to learn how to build real software from
scratch with a cutting-edge language. Maybe you learned Scala or Clojure on
the job, but want to learn more about how to work “close to the metal” in a
functional language. Maybe you’re an enthusiast and want to write smaller,
lightweight Scala programs that perform on tiny, near-embedded Linux sys-
tems. Or maybe you’re a devops engineer with a strong Java background,
who is just learning Scala, and you want to write strongly typed, testable code
that doesn’t impose the runtime penalties of the JVM. In other words, this
book is for the folks who are my peers and colleagues in the Scala and greater
JVM-language community.

I’ve tried my hardest to make this book accessible to folks with no prior sys-
tems programming experience—you’ll learn about arrays, pointers, and the
rest, as we go along.

All the code is in Scala, but we won’t be using the advanced Scala techniques
you might find in a functional programming text. When we do use intermedi-
ate-level techniques like implicits, I’ll call them out.

That said, a few days’ worth of experience with Scala is highly recommended.
If you’re totally new to Scala, there are a lot of great resources online. The
official Tour of Scala1 is a great place to start, and if you want to go deeper,

1. https://docs.scala-lang.org/tour/tour-of-scala.html

report erratum •
Preface • xiv

Dave Gurnell’s and Noel Welsh’s Creative Scala2 or Martin Odersky’s Func-
tional Programming Principles in Scala3 online course are both excellent re-
sources. Pragmatic Scala4 by Venkat Subramaniam offers a great, approachable
book-length treatment, as does Scala for the Impatient5 by Cay Horstmann.
Programming in Scala,6 by Martin Odersky, Lex Spoon, and Bill Venners, is
the official book by the author of the language, and is a great, thorough refer-
ence guide, but make sure you get the third edition—the second and first
editions are significantly out of date now.

What’s In This Book


This book is designed as a series of projects that introduce the fundamental
and powerful techniques of systems programming, one by one. Each chapter
es an important topic in systems programming, and in the spirit of
adventure, we may not always take the most direct route to our destination.
Sometimes it’s best to make a few mistakes, or do things by hand a few times
before we skip ahead to the “right answer.”

The work will all pay off, though. As you progress and master more and more
techniques, you will gradually put the pieces together into something greater
than the sum of its parts. And by the end, not only will you have the code for
a lightweight, asynchronous microservice framework, you’ll also be able to
write one yourself if you don’t like the way I did it.

The book is divided into two parts:

Part I dives into the fundamental techniques of systems programming using


the basic facilities that UNIX-based operating systems have had since the
1980s. Unlike traditional systems programming books, however, networking
is introduced early. For a modern programmer, working with remote services
over HTTP is more relevant and practical than local file I/O. I then introduce
process-based concurrency and parallelism. Although most Scala programmers
will be more familiar with threads, processes are a powerful technique that
distinguishes Scala Native from most other programming languages, and
they’re a great, safe introduction to asynchronous programming. We then
look at combining these techniques to build a minimalist HTTP server and

2. https://www.creativescala.org/creative-scala.html
3. https://www.coursera.org/learn/progfun1
4. https://pragprog.com/book/vsscala2/pragmatic-scala
5. https://horstmann.com/scala
6. https://www.artima.com/shop/programming_in_scala_3ed

report erratum • discuss


Working with the Code • xv

measure its performance with a simple stress test. However, we also look at
the limits of these traditional techniques.

In Part II, we’ll put the “modern” in “modern systems programming.” From
this point on, all of our code will be fully asynchronous, building upon the
capabilities of the event loop library, libuv. Working with an industrial-strength
C library like this, we’ll introduce new complexities to our code, but it also
gives Scala Native a chance to truly shine. With libuv, we’ll revisit our HTTP
server, introduce idiomatic Scala concurrency techniques, and learn how to
work with durable data stores. Then, when we put those components together,
we’ll have built a framework for solving real-world problems. I’m skeptical of
buzzwords, but the low overhead and light footprint of Scala Native code
really does put JVM-based “microservices” to shame.

Working with the Code


All the code in this book has been tested with Scala Native 0.4.0-M2, Scala
2.11.12, and sbt 0.13.15 on Mac OS X and Linux (via Docker). You can get
detailed instructions on how to set up a Scala Native development environment
for Mac, Windows, or Linux in Appendix 1, Setting Up the Environment, on
page 211. Since slight environment differences can be disruptive to low-level
programs, I recommend using Docker on your preferred development machine,
and the examples in the text reflect that.

A Note on Versions
Scala Native is rapidly evolving. The example code in this chapter,
as well as all other code in this book, is written for the most recent
version of Scala Native available, 0.4.0-M2. To ensure forward
compatibility, all of the sbt projects include a compatibility shim
file; to use with a newer version, just remove the shim!

You may also notice all the code is for Scala 2.11. When Scala 2.12
and 2.13 become available for Scala Native, I’ll update the code
files as well. You can download the latest version of the sample
code on the pragprog.com website (https://pragprog.com/book/rwscala).

How the Code Is Organized


You can download the source code used in this book from the book’s web
page at pragprog.com.7 If you’re reading the electronic version of this book,

7. https://pragprog.com/titles/rwscala/source_code

report erratum •
Preface • xvi

you can click the box above the code excerpts to download that source code
directly. Or, if you use the Docker environment, you’ve already got it.

The code is organized by chapter, and within each chapter, the code is organized
into individual projects, each with its own folder. Each project is a self-contained
codebase, designed to be built by sbt,8 the standard Scala build tool.

One important note if you’re trying to modify the code: sometimes, for concise
presentation, I will not show import statements and outer object Main wrappers
in the code printed in the book. For example, have a look at this snippet:
import scalanative.unsafe._

object Main {
def main(args:Array[String]:Unit = {
// invoking various functions here
???
}

def helperFunction(arg1:Int, arg2:String) = ???


}

It may be displayed as:


def main(args:Array[String]:Unit = {
// invoking various functions here
???
}

def helperFunction(arg1:Int, arg2:String) = ???

However, all the code files that you download and use are fully functional
and complete. If you’re interested in modifying my examples, definitely start
with the files.

About Text Editors


Although there’s no one standard for text editors when it comes to Scala,
there are many options. Because Scala Native is still relatively new, the sup-
port for it is imperfect in complex IDEs. I instead recommend a plain text
editor with good support for Scala syntax, like VSCode, Atom, emacs, or vi.
Part of the beauty of starting from scratch is that we don’t have to deal with
giant Java dependencies with hundreds of classes—our code will be lean
enough to write without sophisticated editor assistance. That said, I’ve found
that the Metals plugin9 for VSCode offers a good balance of common-sense
help in an unobtrusive way.

8. https://www.scala-sbt.org
9. https://scalameta.org/metals

report erratum •
Online Resources • xvii

Online Resources
You’ll definitely want to keep tabs on the book’s web page at pragprog.com10
for all the latest code and updates. And if you find any errata, there’s a place
to let me know about it.11 I’ve also created a dedicated chat room on Gitter.12
If you have any problems building or running the code in the book, or just
want to hang out and chat, come on by! I also highly recommend perusing
Scala Native’s official site,13 and referring to the Scala Native source code on
Github14 for the occasional deep dive.

With those resources in hand, it’s time to get started!

10. https://pragprog.com/book/rwscala
11. https://pragprog.com/titles/rwscala/errata
12. https://gitter.im/scala-native-book/community
13. https://scala-native.readthedocs.io
14. https://github.com/scala-native/scala-native

report erratum •
Systems Programming
in the Twenty-First Century
Why learn systems programming in the twenty-first century? It’s a fair ques-
tion. When I learned C at the turn of the century, low-level languages like C
and C++ were already falling out of favor and being rapidly supplanted by
high-level languages such as Ruby and Java. In the intervening years that
trend has only accelerated, with functional programming languages such as
Clojure, Elixir, Elm, Haskell, and Scala becoming more prominent, and C
receding even further from day-to-day relevance.

And yet, C remains at the heart of modern computing: it’s in our operating
systems, our network stack, our language implementations, our virtual
machines, and our web browsers. When performance is critical and resources
are constrained, we still fall back on the techniques of low-level programming.

However, in this book, I’ll show you that you don’t have to choose between
the ergonomics of modern languages and the performance of systems program-
ming. With Scala Native, you get to have both.

What Is Systems Programming?


As a working definition, systems programming is the art of writing code while
remaining aware of the properties and limitations of the machine that will
run it. For all the complexity of modern software, computers are still surpris-
ingly simple devices at the machine-code level.

We can identify five fundamental data structures for working on bare metal:

• Primitive data types—integers, floating-point numbers, and raw bytes that


can be directly represented in machine code.

• Low-level byte strings—a way of representing textual data of variable


length directly in a computer’s memory.

report erratum •
Systems Programming in the Twenty-First Century • xx

• Structs—a compound data type that arranges named fields in memory in


a fixed way.

• Array layout—data of the same type that are arranged in a grid-like


fashion, one after another.

• Pointers—a numeric representation of the location in memory of some


other piece of data.

These five data structures are profoundly interrelated. In this book, I’ll introduce
them gradually through a series of real-world examples. As you attain more
proficiency, the deep connections between these concepts will let you write
simple, powerful programs that vastly outperform what you can achieve with
regular JVM Scala.

Even if you rarely write low-level code, the knowledge and insight you attain
from learning systems programming pays dividends; essential everyday tasks,
like tuning and debugging systems, interpreting complex error messages, and
predicting the performance characteristics of complex systems, become much
easier and more accurate when you have a solid knowledge of the fundamental
principles by which computers operate.

That said, this isn’t an eat-your-vegetables guide to systems programming.


I’m excited to write a systems programming book now, because of the new
possibilities created by recent developments in cloud computing and distribut-
ed systems technology.

Moving Toward Modern Systems Programming


The enterprise IT world is prone to buzzwords, but the rapid adoption of
Linux container technology in recent years has been genuinely transformative.
Having access to a simple format for packaging and deploying applications,
containers, and Docker in particular, has radically altered the day-to-day
workflow of working developers.

Best of all, the broad adoption of container technology has also eliminated
one of the chief pain points of traditional systems programming: portability.
Getting a typical C codebase to compile for the first time on a new development
machine could often take days, and handling incompatibilities between differ-
ent UNIX variants such as Mac OS X, Linux, and Solaris littered code with
opaque macros and cryptic bugs. In contrast, Docker containers provide a
reliable, Linux-flavored execution environment for any programming language

report erratum •
Why Scala Native? • xxi

that can run on any recent Windows, Mac OS, or Linux development machine.
By giving us access to reproducible builds and uniform deployments, contain-
ers truly put the “modern” in “modern systems programming.”

The other critical change that distinguishes new-style systems programming


from what you’d find in a C textbook is the overwhelming emphasis on network
programming in a modern cloud environment. Whereas classic systems pro-
gramming books focus on file input and output (I/O), many programs written
for cloud deployment will communicate over one of a few network protocols,
and might never write to a file at all. That’s why this book puts practical network
programming front and center. You’ll learn how TCP sockets work and how
to write an HTTP client and server from scratch. By the end of the book, you
will have designed and built a powerful, lightweight framework for RESTful
microservices.

But that’s enough hype from me. Before we dive into the foundations of sys-
tems programming, let’s roll up our sleeves, write some code, and take a look
at Scala Native in action.

Why Scala Native?


Scala Native is an ahead-of-time machine code compiler for the Scala program-
ming language. It can take a Scala program, with traits, objects, garbage
collection, and other advanced features of Scala, and translate it down to the
same kind of executable machine code that a C compiler would output.

But that’s not all. On top of Scala’s support for object-oriented and functional
programming, Scala Native adds powerful capabilities for working much
closer to bare metal. In particular, it provides access to OS-level I/O and
networking APIs, system-level shared libraries, and C-style memory manage-
ment. With these techniques, we can often replace C code in performance-
critical applications. And Scala’s capacity for clean abstraction means that
we can make low-level programs more elegant and readable than ever before.

At its best, Scala Native can simultaneously exhibit both modern programming
techniques and a close affinity for the underlying hardware. This expressive
clarity also makes Scala Native a great way to learn systems programming
for the first time.

To start, let’s set up a Scala Native project. We’ll do so much as we would set
up a simple Scala project: by creating a new folder (let’s call ours my_code/hello/)
with three files. The first file is a build.sbt file that describes our project:

report erratum •
Systems Programming in the Twenty-First Century • xxii

InputAndOutput/hello/build.sbt
name := "hello"
enablePlugins(ScalaNativePlugin)

scalaVersion := "2.11.8"
scalacOptions ++= Seq("-feature")
nativeMode := "debug"
nativeGC := "immix"

The second is a hello.scala file that contains our code:


InputAndOutput/hello/hello.scala
object main {
def main(args:Array[String]) {
println("hello, world!")
}
}

And the third is a project/plugins.sbt file that imports the actual Scala Native
plugin:
InputAndOutput/hello/project/plugins.sbt
addSbtPlugin("org.scala-native" % "sbt-scala-native" % "0.4.0-M2")

Much like a regular Scala program, when you enter the command, sbt run, the
Scala build tool (sbt)1 builds the project for you. After it’s fully compiled, you
should see the expected output of the program, like this:
$ sbt run
[warn] Executing in batch mode.
[warn] For better performance, hit [ENTER] to switch to interactive mode,
[warn] or consider launching sbt without any commands, or explicitly
[warn] passing 'shell'
[info] Loading project definition from /root/project-build/project
[info] Set current project to sn-mem-hacks
[info] (in build file:/root/project-build/)
[info] Compiling 1 Scala source to
[info] /root/project-build/target/scala-2.11/classes...
[info] 'compiler-interface' not yet compiled for Scala 2.11.8. Compiling...
[info] Compilation completed in 13.051 s
[info] Linking (2352 ms)
[info] Discovered 1267 classes and 9344 methods
[info] Optimizing (5002 ms)
[info] Generating intermediate code (1015 ms)
[info] Produced 39 files
[info] Compiling to native code (2272 ms)
[info] Linking native code (153 ms)
hello, world
[success] Total time: 28 s, completed Mar 13, 2018 5:11:03 PM

1. https://www.scala-sbt.org

report erratum •
What Makes Scala Native Different • xxiii

This is exactly what we would expect from a regular Scala program: the code
we used is identical to a Hello, World in standard Scala, and the build config-
uration has only added a single plugin to support Scala Native. This is good
news. Scala Native is 100% Scala—it’s not a variant or a new version. It’s
simply a plugin that gives the language some additional capabilities.

What Makes Scala Native Different


So far, you’ve seen that Scala Native can be easy to use. In many cases, it
works as a drop-in replacement for mainstream JVM Scala. But what can it
do for us that JVM Scala can’t?

Smaller Footprint
To see some of Scala Native’s more exceptional functionality, run sbt nativeLink.
You should see output like this:
$ sbt nativeLink
[info] Loading project definition from ...
[info] Set current project to sn-word-sorter (in build file:...
[info] Compiling 1 Scala source to ...
[info] Discovered 1279 classes and 9445 methods
[info] Optimizing (4418 ms)
[info] Generating intermediate code (961 ms)
[info] Produced 37 files
[info] Compiling to native code (2072 ms)
[info] Linking native code (308 ms)
[success] Total time: 17 s, completed Jan 21, 2018 4:25:58 PM

If you look in your build directory at target/scala-2.11, you’ll see a 4.2MB exe-
cutable file called hello-minimal-out. This file is a native binary—it consists of
immediately executable CPU instructions plus headers, symbol tables, and
other metadata to allow your operating system to load it and run it.

You should also see a 4.2MB file at target/scala-2.11/hello-minimal-out. That’s our


program! You can run it on its own just by typing ./target/scala-2.11/hello-minimal-
out. You can copy it, move it around, and in many cases copy it to another
computer intact. This file contains executable machine code: binary CPU
instructions that your OS can load into memory and run without a virtual
machine or interpreter.

In contrast, if you were to package up a standard JVM Scala Hello, World


project, the output is a 5.5MB file called hello-minimal-assembly-0.1-SNAPSHOT.jar.
Unlike our native binary, a .jar file cannot be directly executed—instead, it
must be executed by a Java Virtual Machine (JVM). Combined, the size of a

report erratum •
Systems Programming in the Twenty-First Century • xxiv

JVM and an application JAR is often close to 100MB for a small app, and can
rapidly increase for larger projects with complex dependencies.

Faster Startup
There’s another, even more important difference. If we time the execution of
both versions of our program, we’ll see this:
$ time java -jar ./target/scala-2.11/hello_jvm-assembly.jar
hello, world!

real 0m0.350s
user 0m0.368s
sys 0m0.038s

$ time ./target/scala-2.11/hello_out
hello, world!

real 0m0.024s
user 0m0.021s
sys 0m0.003s

This is already an exciting result! Scala Native runs our Hello, World program
in about 20 milliseconds, while our JVM program takes almost twenty times
longer—close to half of a second—to print a string out to the console. Here
we’re seeing the impact of the JVM. A Java Virtual Machine is itself a large,
complex program that takes time to set up and shut down, and we have to
go through that process every time our tiny Scala program runs. In contrast,
our native binary is a file containing machine code. Our OS can just load it
into memory, point the CPU at the main method, and let it run.

Before we go any further, though, it’s worth taking a step back and asking,
When does performance matter?

For a command-line tool that a developer runs a few times an hour, a differ-
ence in startup time is a nice quality-of-life improvement. But when you’re
dealing with big data, high-throughput networking, or heavy-duty I/O, effi-
ciency is critical; improving performance or reducing resource usage can save
serious amounts of money and make it possible to tackle new, harder problem
domains. That level of performance isn’t always necessary; there are plenty
of problems that are easily solved by higher-level programming languages.
But throughout this book, we’re going to keep our focus on areas where this
kind of performance can make a difference. As a result, we’re going to rapidly
move from Hello, World to seriously big data.

Let’s dive in by exploring the foundations of systems programming, starting


with input and output.

report erratum •
Part I

Foundations of Systems Programming


CHAPTER 1

The Basics: Input and Output


Lots of ways exist to get data in and out of a program. Files, networks, and
databases all serve this purpose in different ways, and you’ll learn about all of
them later on in the book. In this chapter, we’ll look at the standard input and
standard output streams all UNIX processes have. As you gain proficiency in
lower-level input and output (I/O), you’ll learn to write programs that perform
more like a C program than a Scala program. You’ll also become acquainted
with pointers and strings, two of the key concepts of systems programming.

Later in this chapter, we’ll start to work through a real-world use case that
showcases the dramatic performance benefits to be had from taking a bare-
metal approach to a seemingly simple problem. Using the Google Books
NGrams dataset, we’ll implement a variety of simple algorithms that can
process this large data file efficiently. In doing so, we’ll gain comfort with the
essential concepts of systems programming: primitive types, pointers, strings,
structs, and arrays.

Working with Output


You may already be familiar with STDOUT, or standard output, if you’ve
worked with scripting languages like Perl, Python, or Ruby. In fact, we’ve
already used it in the Systems Programming in the Twenty-First Century, on
page xix. The “system console” that Scala’s println writes to is none other than
STDOUT. We can access it directly by importing Scala Native’s stdio object,
which includes the standard file descriptors as well as the C functions that
we’ll need to make use of them.

Introducing printf
Throughout this book, when I introduce a new function I’ll present its signa-
ture and then its inputs, outputs, and effects. Most of the functions

report erratum • discuss


Chapter 1. The Basics: Input and Output •4

I’ll present are provided by the operating system or the C standard library.
In any modern operating system, access to all hardware functions, including
displaying text on a screen, is protected. Because your computer will have
many programs running on it all the time, each program is isolated both from
the hardware and from all other programs. To have any kind of effect on the
outside world, including printing a line of text to the screen, your program
has to ask the OS to do it for you.

Standard Functions and System Calls


Modern operating systems expose their capabilities as system
calls, or syscalls for short, but neither C programs nor Scala Native
programs can invoke system calls directly. Instead, the C standard
library provides wrapper functions that can pass arguments to
the OS on our behalf.

Not all stdlib functions invoke system calls, however; I’ll make a
note of the exceptions as we proceed.

To start, let’s take a quick look at the definition of printf, a C function with
similar capabilities to println:
def printf(format: CString, args: CVararg*): CInt = extern

printf can take one or more arguments: the first will always be a format string,
containing a template with special placeholders, followed by zero or more
additional arguments—one argument per placeholder in the format. This is
a bit unusual and slightly error-prone. The Scala compiler won’t protect you
if you give printf the wrong number or type of arguments, but it’s a decent
replacement for println, and it can be fast.

First, let’s quickly rewrite the Hello, World program we wrote in the introduc-
tory chapter to see how much it changes when we use printf. With printf, it looks
like this:
InputAndOutput/hello_native/hello.scala
import scala.scalanative.unsafe._
import scala.scalanative.libc._

object Main {
def main(args:Array[String]):Unit = {
stdio.printf(c"hello native %s!\n",c"world")
}
}

report erratum •
Working with Output •5

Notice two differences here. First, we’re using the C printf function from the
native.stdio package. We aren’t passing any arguments yet, so we don’t have
any additional arguments or placeholders in the format string.

Second, the string itself now looks like this: c"hello, world\n". This is a CString lit-
eral. There are some big differences between a CString and the regular Scala
String class you may be used to. A CString is better thought of as an unsafe,
mutable byte buffer, with few frills or methods, which can make CStrings very
difficult to work with; however, they also support a few low-level operations
that are impossible with Scala-style Strings, which will make some exciting
performance gains possible.

Learning More about CStrings


With printf, we can explore some of the properties of a CString. In addition to
using the %s format to display the content of a string, we’ll also be using %p
to display its address, meaning the location in memory where the string is
stored. Memory addresses are typically represented as hexadecimal numbers,
such as 0x12345678. We’ll also use the strlen function, which returns the
length of a string, and the sizeof function, which returns the number of bytes
of memory occupied by a variable of a given type:
def strlen(str: CString): CSize = extern
def sizeof[T](implicit tag: Tag[T]): CSize = undefined

Both of these are good examples of standard C functions that are not provided
as syscalls by the OS—instead, strlen simply examines the contents of memory
without help from the OS, whereas sizeof is implemented entirely by the com-
piler, before our program even runs. You might also notice the implicit tag
parameter on sizeof; although Scala’s implicit syntax features can have a
somewhat intimidating reputation, our use of them in this book will be
mostly straightforward. And in this particular case, Tag is actually a special
value generated by the Scala Native compiler with type metadata, which means
we don’t have to instantiate or pass it at all.

With these methods, we can run some experiments on the CString literal that
we used before:
InputAndOutput/cstring_experiment_1/cstring_experiment_1.scala
import scala.scalanative.unsafe._
import scala.scalanative.libc._

report erratum •
Chapter 1. The Basics: Input and Output •6

object Main {
def main(args:Array[String]):Unit = {
val str:CString = c"hello, world"
val str_len = string.strlen(str)
stdio.printf(c"the string '%s' at address %p is %d bytes long\n",
str, str, str_len)
stdio.printf(c"the CString value 'str' itself is %d bytes long\n",
sizeof[CString])

for (offset <- 0L to str_len) {


val chr:CChar = str(offset)
stdio.printf(c"""the character '%c' is %d bytes long and has binary
value %d\n""", chr, sizeof[CChar], chr)
}
}
}

And if we run this code, we get this:


$ ./target/scala-2.11/cstring_experiment_1-out
the string 'hello, world' at address 0x55e525a2c944 is 12 bytes long
the CString value 'str' itself is 8 bytes long
'h' is 1 bytes long and has binary value 104
'e' is 1 bytes long and has binary value 101
'l' is 1 bytes long and has binary value 108
'l' is 1 bytes long and has binary value 108
'o' is 1 bytes long and has binary value 111
',' is 1 bytes long and has binary value 44
' ' is 1 bytes long and has binary value 32
'w' is 1 bytes long and has binary value 119
'o' is 1 bytes long and has binary value 111
'r' is 1 bytes long and has binary value 114
'l' is 1 bytes long and has binary value 108
'd' is 1 bytes long and has binary value 100
'' is 1 bytes long and has binary value 0

We can learn a lot from this program, so it’s worth taking a little time to
unpack. The most important point to observe is the difference between the
length of the string, which is 12 characters long, and the size of the string
variable, which is 8 bytes long. So how do we fit a 12-character string in an
8-byte variable?

The answer isn’t necessarily obvious, but there’s a clue in the address value
if you can read hexadecimal numbers. Because the address 0x55e525a2c944
consists of 16 characters in a hexadecimal representation, we know that the
address is exactly 8 bytes wide as well. In fact, it’s a 64-bit unsigned integer.

report erratum •
Working with Output •7

This is no coincidence. If you look at the basic type definitions in the scalana-
tive.native package, you’ll see that CString is defined as a type alias, like so:

type CString = Ptr[CChar]

and that CChar itself is defined as this:


type CChar = Byte

But what about this Ptr[T] type? It’s defined in the same package, but the
implementation is mostly abstract, so some explanation is in order.

Working with Pointers


A Ptr[T] is a pointer, or a reference to a value of some type T. Pointers are vari-
ables that contain the address of data somewhere else in the computer’s
memory. In other words, if we have a variable like val char_pointer:Ptr[CChar], we
know that char_pointer is the location of a CChar somewhere else in memory. We
can retrieve the value of the character itself by dereferencing it, or looking up
the address. In Scala Native, we dereference a pointer with the ! operator, like
val char_value:CChar = !char_pointer. But when we use a pointer on the left-hand
side of assignment, like in !char_pointer = char_value, we are instead storing a
value into the location denoted by the pointer.

Pointers are one of the most fundamental concepts of low-level programming;


we’ll use them directly to move data around in memory and when designing
our own memory-management strategies, but we’ll also use them to manipulate
other forms of structured data like arrays, structs, and as we’ve seen, C-style
strings. Most important, we can also treat pointers themselves as a primitive
data type: in a modern computer with a 64-bit address space, the address of
any given byte is a 64-bit unsigned integer.

By exploiting the representation of pointers as integers, we can perform a


variety of useful tasks very efficiently; for example, in our previous piece of
example code, the string index lookup operation str(offset) is performed with
pointer arithmetic, and we can implement it ourselves if we want to have a
better idea of how pointers work. Our goal is to calculate the address of any
character in a string, as long as we know the address of the first character.
To do this, we need to understand a little more about how strings are laid
out in memory.

C-style strings are always laid out one byte after another in a single contiguous
region of memory. That means if the first byte of the string is at address 0x8880,

report erratum •
Discovering Diverse Content Through
Random Scribd Documents
The Project Gutenberg eBook of The Shadow of Life
This ebook is for the use of anyone anywhere in the United States
and most other parts of the world at no cost and with almost no
restrictions whatsoever. You may copy it, give it away or re-use it
under the terms of the Project Gutenberg License included with this
ebook or online at www.gutenberg.org. If you are not located in the
United States, you will have to check the laws of the country where
you are located before using this eBook.

Title: The Shadow of Life

Author: Anne Douglas Sedgwick

Release date: June 17, 2013 [eBook #42965]


Most recently updated: October 23, 2024

Language: English

Credits: Produced by Chuck Greif and the Online Distributed


Proofreading Team at http://www.pgdp.net (This file was
produced from images available at The Internet Archive)

*** START OF THE PROJECT GUTENBERG EBOOK THE SHADOW OF


LIFE ***
The Shadow of Life
PART I
I, II, III, IV, V, VI.
PART II
I, II, III, IV, V, VI, VII, VIII, IX, X, XI, XII.
PART III
I, II, III, IV, V, VI, VII, VIII, IX, X.

The Shadow of
Life
BY
Anne Douglas
Sedgwick
AUTHOR OF “THE RESCUE,” “THE
CONFOUNDING OF
CAMELIA,” “PATHS OF JUDGEMENT,”
ETC.

NEW YORK
The Century Co.
1906

Copyright, 1906, by
The Century Co.
———
Published February, 1906

THE DE VINNE PRESS


THE SHADOW OF LIFE

PART I

THE SHADOW OF LIFE


I
LSPETH GIFFORD was five years old when she went to live at
Kirklands. Her father, an army officer, died in her babyhood, and
her mother a few years later. The uncle and aunts in Scotland, all
three much her mother’s seniors, were the child’s nearest
relatives.
To such a little girl death had meant no more than a bewildered
loneliness, but the bewilderment was so sharp, the loneliness so aching, that
she cried herself into an illness. She had seen her dead mother, the sweet,
sightless, silent face, familiar yet amazing, and more than any fear or
shrinking had been the suffocating mystery of feeling herself forgotten and
left behind. Her uncle Nigel, sorrowful and grave, but so large and kind that
his presence seemed to radiate a restoring warmth, came to London for her
and a fond nurse went with her to the North, and after a few weeks the
anxious affection of her aunts Rachel and Barbara built about her, again, a
child’s safe universe of love.
Kirklands was a large white house and stood on a slope facing south,
backed by a rise of thickly wooded hill and overlooking a sea of heathery
moorland. It was a solitary but not a melancholy house. Lichens yellowed
the high-pitched slate roof and creepers clung to the roughly “harled” walls.
On sunny days the long rows of windows were golden squares in the
illumined white, and, under a desolate winter sky, glowed with an inner
radiance.
In the tall limes to the west a vast colony of rooks made their nests; and
to Eppie these high nests, so dark against the sky in the vaguely green
boughs of spring or in the autumn’s bare, swaying branches, had a weird,
fairy-tale charm. They belonged neither to the earth nor to the sky, but
seemed to float between, in a place of inaccessible romance, and the clamor,
joyous yet irritable, at dawn and evening seemed full of quaint, strange
secrets that only a wandering prince or princess would have understood.
Before the house a round of vivid green was encircled by the drive that
led through high stone gates to the moorland road. A stone wall, running
from gate to gate, divided the lawn from the road, and upon each pillar a
curiously carved old griffin, its back and head spotted with yellow lichens,
held stiffly up, for the inspection of passers-by, the family escutcheon. From
the windows at the back of the house one looked up at the hilltop, bare but
for a group of pine-trees, and down into a deep garden. Here, among
utilitarian squares of vegetable beds, went overgrown borders of flowers—
bands of larkspurs, lupins, stocks, and columbines. The golden-gray of the
walls was thickly embroidered with climbing fruit-trees, and was entirely
covered, at one end of the garden, by a small snow-white rose, old-
fashioned, closely petaled; and here in a corner stood a thatched summer-
house, where Eppie played with her dolls, and where, on warm summer
days, the white roses filled the air with a fragrance heavy yet fresh in its
wine-like sweetness. All Eppie’s early memories of Kirklands centered
about the summer-house and were mingled with the fragrance of the roses.
Old James, the gardener, put up there a little locker where her toys were
stored, and shelves where she ranged her dolls’ dishes. There were rustic
seats, too, and a table—a table always rather unsteady on the uneven
wooden floor. The sun basked in that sheltered, windless corner, and, when
it rained, the low, projecting eaves ranged one safely about with a silvery
fringe of drops through which one looked out over the wet garden and up at
the white walls of the house, crossed by the boughs of a great, dark pine-
tree.
Inside the house the chief room was the fine old library, where, from
long windows, one looked south over the purples and blues of the
moorland. Books filled the shelves from floor to ceiling—old-fashioned
tomes in leather bindings, shut away, many of them, behind brass gratings
and with all the delightful sense of peril connected with the lofty upper
ranges, only to be reached by a courageous use of the library steps.
Here Uncle Nigel gave Eppie lessons in Greek and history every
morning, aided in the minor matters of her education by a submissive
nursery governess, an Englishwoman, High Church in doctrine and
plaintive in a country of dissent.
A door among the book-shelves led from the library into the morning-
room or boudoir, where Aunt Rachel and Aunt Barbara sewed, read,
dispensed small charities and lengthy advice to the village poor—a cheerful
little room in spite of its northern aspect and the shadowing trunk of the
great pine-tree just outside its windows. It was all faded chintzes, gilt
carvings, porcelain ornaments in corner cabinets; its paper was white with a
fine gilt line upon it; and even though to Eppie it had sad associations with
Bible lessons and Sunday morning collects, it retained always its aspect of
incongruous and delightful gaiety—almost of frivolity. Sitting there in their
delicate caps and neatly appointed dresses, with their mild eyes and
smoothly banded hair, Aunt Rachel and Aunt Barbara gathered a picture-
book charm—seemed to count less as personalities and more as ornaments.
On the other side of the hall, rather bare and bleak in its antlered
spaciousness, were the dining-and smoking-rooms, the first paneled in
slightly carved wood, painted white, the last a thoroughly modern room,
redolent of shabby comforts, with deep leather chairs, massive mid-century
furniture, and an aggressively cheerful paper.
The drawing-room, above the library, was never used—a long, vacant
room, into which Eppie would wander with a pleasant sense of trespassing
and impertinence; a trivial room, for all the dignity of its shrouded shapes
and huge, draped chandelier. Its silver-flecked gray paper and oval gilt
picture-frames recalled an epoch nearer and uglier than that of the grave
library and sprightly boudoir below, though even its ugliness had a charm.
Eppie was fond of playing by herself there, and hid sundry secrets under the
Chinese cabinet, a large, scowling piece of furniture, its black lacquered
panels inlaid with mother-of-pearl. Once it was a quaintly cut cake, neatly
sealed in a small jeweler’s box, that she thrust far away under it; and once a
minute china doll, offspring of a Christmas cracker and too minute for
personality, was swaddled mummy fashion in a ribbon and placed beside
the box. Much excitement was to be had by not looking to see if the secrets
were still there and in hastily removing them when a cleaning threatened.
The day-nursery, afterward the school-room, was over the dining-room,
and the bedrooms were at the back of the house.
The Carmichaels were of an ancient and impoverished family, their
estates, shrunken as they were, only kept together by careful economy, but
there was no touch of dreariness in Eppie’s home. She was a happy child,
filling her life with imaginative pastimes and finding on every side objects
for her vigorous affections. Her aunts’ mild disciplines weighed lightly on
her. Love and discipline were sundered principles in the grandmotherly
administration, and Eppie soon learned that the formalities of the first were
easily evaded and to weigh the force of her own naughtiness against it.
Corporal punishment formed part of the Misses Carmichael’s conception of
discipline, but though, on the rare occasions when it could not be escaped,
Eppie bawled heart-rendingly during the very tremulous application, it was
with little disturbance of spirit that she endured the reward of transgression.
At an early age she understood very clearly the simple characters around
her. Aunt Rachel and Aunt Barbara were both placid, both pious, both full
of unsophisticated good works, both serenely acquiescent in their lots. In
Aunt Barbara, indeed, placidity was touched with wistfulness; she was the
gentler, the more yielding of the two. Aunt Rachel could be inspired with
the greater ruthlessness of conscientious conviction. It was she who insisted
upon the letter of the law in regard to the Sunday collect, the Sunday
church-going, who mingled reproof with her village charities, who could
criticize with such decision the short-comings, doctrinal and domestic, of
Mr. MacNab, minister of the little established church that stood near the
village. Aunt Barbara was far less assured of the forms of things; she
seemed to search and fumble a little for further, fuller outlets, and yet to
have found a greater serenity. Aunt Rachel was fond of pointing out to her
niece such facts of geology, botany, and natural history in general as the
country life and her own somewhat rudimentary knowledge suggested to
her as useful; Aunt Barbara, on the contrary, told pretty, allegorical tales
about birds and flowers—tales with a heavy cargo of moral insinuation, to
which, it must be confessed, Eppie listened with an inner sense of stubborn
realism. It was Aunt Barbara who sought to impress upon her that the
inclusive attribute of Deity was love, and who, when Eppie asked her where
God was, answered, “In your heart, dear child.” Eppie was much puzzled
by anatomical considerations in reflecting upon this information. Aunt
Rachel, with clear-cut, objective facts from Genesis, was less mystifying to
inquisitive, but pagan childhood. Eppie could not help thinking of God as
somewhat like austere, gray-bearded old James, the gardener, whose
vocation suggested that pictorial chapter in the Bible, and who, when he
found her one day eating unripe fruit, warned her with such severity of
painful retribution.
The aunts spent year after year at Kirklands, with an infrequent trip to
Edinburgh. Neither had been South since the death of the beloved younger
sister. Uncle Nigel, the general, older than either, was russet-faced, white-
haired, robust. He embodied a sound, well-nurtured type and brought to it
hardly an individual variation. He taught his niece, re-read a few old books,
followed current thought in the “Quarterly” and the “Scotsman,” and wrote
his memoirs, that moved with difficulty from boyhood, so detailed were his
recollections and so painstaking his recording of inessential fact.
For their few neighbors, life went on as slowly as for the Carmichaels.
The Carstons of Carlowrie House were in touch with a larger outside life:
Sir Alec Carston was member for the county; but the inmates of Brechin
House, Crail Hill, and Newton Lowry were fixtures. These dim personages
hardly counted at all in young Eppie’s experience. She saw them gathered
round the tea-table in the library when she was summoned to appear with
tidy hair and fresh frock: stout, ruddy ladies in driving-gloves and boat-
shaped hats; dry, thin young ladies in hard-looking muslins and with frizzed
fringes; a solid laird or two. They were vague images in her world.
People who really counted were the village people, and on the basis of
her aunts’ charitable relationship Eppie built up for herself with most of
them a tyrannous friendship. The village was over two miles away; one
reached it by the main road that ran along the moor, past the birch-woods,
the tiny loch, and then down a steep bit of hill to the handful of huddled
gray roofs. There was the post-office, the sweet-shop with its dim, small
panes, behind which, to Eppie’s imagination, the bull’s-eyes and toffee and
Edinburgh rock looked, in their jars, like odd fish in an aquarium; there was
the carpenter’s shop, the floor all heaped with scented shavings, through
which one’s feet shuffled in delightful, dry rustlings; there the public-house,
a lurid corner building, past which Miss Grimsby always hurried her over-
interested young charge, and there the little inn where one ordered the
dusty, lurching, capacious old fly that conveyed one to the station, five
miles away. Eppie was far more in the village than her share of her aunts’
charities at all justified, and was often brought in disgrace from sheer
truancy. The village babies, her dolls, and Robbie, her Aberdeen terrier,
were the realities at once serious and radiant of life. She could do for them,
love them as she would. Her uncle and aunts and the fond old nurse were
included in an unquestioning tenderness, but they could not be brought
under its laws, and their independence made them more remote.
Remote, too, though by no means independent, and calling forth little
tenderness, were her cousins, who spent part of their holidays each summer
at Kirklands. They were English boys, coming from an English school, and
Eppie was very stanchly Scotch. The Graingers, Jim and Clarence, were
glad young animals. They brought from a home of small means and
overflowing sisters uncouth though not bad manners and an assured
tradition of facile bullying. The small Scotch cousin was at first seen only in
the light of a convenience. She was to be ignored, save for her few and
rudimentary uses. But Eppie, at eight years old, when the Graingers first
came, had an opposed and firmly established tradition. In her own domain,
she was absolute ruler, and not for a moment did her conception of her
supremacy waver. Her assurance was so complete that it left no room for
painful struggle or dispute. From helpless stupor to a submission as
helpless, the cousins fell by degrees to a not unhappy dependence. Eppie
ran, climbed, played, as good a boy as either; and it was she who organized
games, she who invented wonderful new adventures, all illumined by
thrilling recitatives while in progress, she who, though their ally, and a
friendly one, was the brains of the alliance, and, as thinker, dominated.
Brains, at their age, being rudimentary in the young male, Eppie had some
ground for her consciousness of kindly disdain. She regarded Jim and
Clarence as an animated form of toy, more amusing than other toys because
of possibilities of unruliness, or as a mere audience, significant only as a
means for adding to the zest of life. Clarence, the younger, even from the
first dumb days of reconstruction, was the more malleable. He was formed
for the part of dazzled subjection to a strong and splendid despotism. Eppie
treated her subject races to plenty of pomp and glory. Clarence listened,
tranced, to her heroic stories, followed her leadership with docile, eager
fidelity, and finally, showing symptoms of extreme romanticism, declared
himself forever in love with her. Eppie, like the ascendant race again, made
prompt and shameless use of the avowed and very apparent weakness. She
bartered rare and difficult favors for acts of service, and on one occasion—a
patch of purple in young Clarence’s maudlin days—submitted, with a stony
grimace, to being kissed; for this treasure Clarence paid by stealing down to
the forbidden public-house and there buying a bottle of beer which Eppie
and Jim were to consume as robbers in a cave,—Clarence the seized and
despoiled traveler. Eppie was made rather ill by her share of the beer, but,
standing in a bed-gown at her window, she called to her cousins, in the
garden below, such cheerful accounts of her malady, the slight chastisement
that Aunt Rachel had inflicted, and her deft evasion of medicines, that her
luster was heightened rather than dimmed by the disaster. Jim never owned,
for a moment, to there being any luster. He was a square-faced boy, with
abrupt nose, and lips funnily turning up at the corners, yet funnily grim,—
most unsmiling of lips. He followed Eppie’s lead with the half-surly look of
a slave in bondage, and seemed dumbly to recognize that his own unfitness
rather than Eppie’s right gave her authority. He retaliated on Clarence for
his sense of subjection and cruelly teased and scoffed at him. Clarence,
when pushed too far, would appeal to Eppie for protection, and on these
occasions, even while she sheltered him, a strange understanding seemed to
pass between her and the tormentor as though, with him, she found
Clarence ludicrous. Jim, before her stinging reproofs, would stand tongue-
tied and furious, but, while she stung him, Eppie liked the sullen culprit
better than the suppliant victim.

II
HEN Eppie was ten years old, she heard one day that a boy, a new
boy, was coming to spend the spring and summer—a boy from
India, Gavan Palairet. His mother and her own had been dear
friends, and his father, as hers had been, was in the army; and
these points of contact mitigated for Eppie the sense of exotic strangeness.
Eppie gathered that a cloud rested upon Mrs. Palairet, and the boy,
though exotic, seemed to come from the far, brilliant country with his
mother’s cloud about him.
“Ah, poor Fanny!” the general sighed over the letter he read at the
breakfast-table. “How did she come to marry that brute! It will be a heart-
breaking thing for her to send the boy from her.”
Eppie, listening with keen interest, gathered further, from the
reminiscent talk that went on between the sisters and brother, that Mrs.
Palairet, for some years of her boy’s babyhood, lived in England; then it had
been India and the effort to keep him near her in the hills, and now his
delicacy and the definite necessity of schooling had braced her to the
parting. The general said, glancing with fond pride at his niece, that Eppie
would be a fine playmate for him and would be of great service in cheering
him before his plunge into school. Fanny had begged for much gentleness
and affection for him. Apparently the boy was as heartbroken as she.
Eppie had very little diffidence about her own powers as either playmate
or cheerer: she was well accustomed to both parts; but her eagerness to
sustain and amuse the invalid was touched with a little shyness. The sad boy
from India—her heart and mind rushed out in a hundred plans of welcome
and consolation; but she suspected that a sad boy from India would require
subtler methods than those sufficing for a Jim or a Clarence. From the first
moment of hearing about him she had felt, as if instinctively, that he would
not be at all like Jim and Clarence.
He came on a still, sunny spring day. The general went to meet him at
the station, and while he was gone Eppie made excitement endurable by
vigorous action. Again and again she visited the fresh little room
overlooking the hills, the garden, the pine-tree boughs, standing in a
thoughtful surveyal of its beauties and comforts or darting off to add to
them. She herself chose the delightful piece of green soap from the store-
cupboard and the books for the table; and she gathered the daffodils in the
birch-woods, filling every vase with them, so that the little room with its
white walls and hangings of white dimity seemed lighted by clusters of
pale, bright flames.
When the old fly rumbled at last through the gates and around the drive,
Miss Rachel and Miss Barbara were in the doorway, and Eppie stood before
them on the broad stone step, Robbie beside her.
Eppie was a lithe, sturdy, broad-shouldered child, with russet, sun-
streaked hair, dark yet radiant, falling to her waist. She had a pale, freckled
face and the woodland eyes of a gay, deep-hearted dog. To-day she wore a
straight white frock, and her hair, her frock, dazzled with sunlight. No more
invigorating figure could have greeted a jaded traveler.
That it was a very jaded traveler she saw at once, while the general
bundled out of the fly and handed rugs, dressing-cases, and cages to the
maid, making a passage for Gavan’s descent. The boy followed him, casting
anxious glances at the cages, and Eppie’s eyes, following his, saw tropical
birds in one and in the other a quaint, pathetic little beast—a lemur-like
monkey swaddled in flannel and motionless with fear. Its quick, shining
eyes met hers for a moment, and she looked away from them with a sense
of pity and repulsion.
Gavan, as he ascended the steps, looked at once weary, frightened, and
composed. He had a white, thin face and thick black hair—the sort of face
and hair, Eppie thought, that the wandering prince of one of her own stories,
the prince who understood the rooks’ secrets, would have. He was dressed
in a long gray traveling-cloak with capes. The eager welcome she had in
readiness for him seemed out of place before his gentle air of self-
possession, going as it did with the look of almost painful shrinking. She
was a little at a loss and so were the aunts, as she saw. They took his hand in
turn, they smiled, they murmured vague words of kindness; but they did not
venture to kiss him. He did not seem as little a boy as they had expected.
The same expression of restraint was on Uncle Nigel’s hearty countenance.
The sad boy was frozen and he chilled others.
He was among them now, in the hall, his cages and rugs and boxes about
him, and, with all the cheery bustling to and fro, he must feel himself
dreadfully alone. Eppie, too, was chilled and knew, indeed, the childish,
panic impulse to run away, but her imagination of his loneliness was so
strong as to nerve quite another impulse. Once she saw him as so desolate
she could not hesitate. With resolute gravity she took his hand, saying, “I
am so glad that you have come, Gavan,” and, as resolutely and as gravely,
she kissed him on the cheek. He flushed so deeply that for a moment all her
panic came back with the fear that she had wounded his pride; but in a
moment he said, glancing at her, “You are very kind. I am glad to be here,
too.”
His pride was not at all wounded. Eppie felt that at all events the worst
of the ice was broken.
“May I feed your animals for you while you rest?” she asked him, as,
with Aunt Barbara, they went up-stairs to his room. Gavan carried the lemur
himself. Eppie had the birds in their cage.
“Thanks, so much. It only takes a moment; I can do it. My monkey
would be afraid of any one else,” he answered, adding, “The journey has
been too much for him; he has been very strange all day.”
“He will soon get well here,” said Eppie, encouragingly—“this is such a
healthy place. But Scotland will be a great change from India for him,
won’t it?”
“Very great. I am afraid he is going to be ill.” And again Gavan’s eye
turned its look of weary anxiety upon the lemur.
But his anxiety did not make him forget his courtesy. “What a beautiful
view,” he said, when they reached his room, “and what beautiful flowers!”
“I have this view, too,” said Eppie. “The school-room has the view of the
moor; but I like this best, for early morning when one gets up. You will see
how lovely it is to smell the pine-tree when it is all wet with dew.”
Gavan agreed that it must be lovely, and looked out with her at the blue-
green boughs; but even while he looked and admired, she felt more courtesy
than interest.
They left him in his room to rest till tea-time, and in the library Aunt
Rachel and Aunt Barbara exclaimed over his air of fragility.
“He is fearfully tired, poor little fellow,” said the general; “a day or two
of rest will set him up.”
“He looks a very intelligent boy, Nigel,” said Miss Rachel, “but not a
cheerful disposition.”
“How could one expect that from him now, poor, dear child!” Aunt
Barbara expostulated. “He has a beautiful nature, I am sure—such a
sensitive mouth and such fine eyes.”
And the general said: “He is wonderfully like his mother. I am glad to
see that he takes after Claude Palairet in nothing.”
Eppie asked if Captain Palairet were very horrid and was told that he
was, with the warning that no intimation of such knowledge on her part was
to be given to her new playmate; a warning that Eppie received with some
indignation. No one, she was sure, could feel for Gavan as she did, or know
so well what to say and what not to say to him.
She was gratified to hear that he was not to go down to dinner but was to
share the school-room high-tea with her and Miss Grimsby. But in the wide
school-room, ruddy with the hues of sunset and hung with its maps and its
childish decorations of Caldecott drawings and colored Christmas
supplements from the “Graphic,”—little girls on stairs with dogs, and
“Cherry Ripe,”—he was almost oppressively out of place. Not that he
seemed to find himself so. He made, evidently, no claims to maturity. But
Eppie felt a strange sense of shrunken importance as she listened to him
politely answering Miss Grimsby’s questions about his voyage and giving
her all sorts of information about religious sects in India. She saw herself
relegated to a humbler rôle than any she had conceived possible for herself.
She would be lucky if she succeeded in cheering at all this remote person; it
was doubtful if she could ever come near enough to console. She took this
first blow to her self-assurance very wholesomely. Her interest in the sad
boy was all the keener for it. She led him, next morning, about the garden,
over a bit of the moor, and into the fairyland of the birch-woods—their
young green all tremulous in the wind and sunlight. And she showed him,
among the pines and heather, the winding path, its white, sandy soil laced
with black tree-roots, that led to the hilltop. “When you are quite rested, we
will go up there, if you like,” she said. “The burn runs beside this path
almost all the way—you can’t think how pretty it is; and when you get to
the top you can see for miles and miles all about, all over the moors, and the
hills, away beyond there, and you can see two villages besides ours, and
such a beautiful windmill.”
Gavan, hardly noticing the kind little girl, except to know that she was
kind, assented to all her projects, indifferent to them and to her.
A day or two after his arrival, he and Eppie were united in ministering to
the dying lemur. The sad creature lay curled up in its basket, motionless,
refusing food, only from time to time stretching out a languid little hand to
its master; and when Gavan took it, the delicate animal miniature lay inert
in his. Its eyes, seeming to grow larger and brighter as life went, had a
strange look of question and wonder.
Eppie wept loudly when it was dead; but Gavan had no tears. She
suspected him of a suffering all the keener and that his self-control did not
allow him the relief of emotion before her. She hoped, at least, to be near
him in the formalities of grief, and proposed that they should bury the lemur
together, suggesting a spot among birch-trees and heather where some
rabbits of her own were interred. When she spoke of the ceremony, Gavan
hesitated; to repulse her, or to have her with him in the task of burial, were
perhaps equally painful to him. “If you don’t mind, I think I would rather do
it by myself,” he said in his gentle, tentative way.
Eppie felt her lack of delicacy unconsciously rebuked. She recognized
that, in spite of her most genuine grief, the burial of the lemur had held out
to her some of the satisfactory possibilities of a solemn game. She had been
gross in imagining that Gavan could share in such divided instincts. Her
tears fell for her own just abasement, as well as for the lemur, while she
watched Gavan walking away into the woods—evidently avoiding the
proximity of the rabbits—with the small white box under his arm.
The day after this was Sunday, a day of doom to Eppie. It meant that
morning recitation of hymn and collect in the chintz and gilt boudoir and
then the bleak and barren hours in church. Even Aunt Barbara’s mildness
could, on this subject, become inflexible, and Aunt Rachel’s aspect
reminded Eppie of the stern angel with the flaming sword driving frail,
reluctant humanity into the stony wilderness. A flaming sword was needed.
Every Sunday saw the renewal of her protest, and there were occasions on
which her submission was only extorted after disgraceful scenes. Eppie
herself, on looking back, had to own that she had indeed disgraced herself
when she had taken refuge under her bed and lain there, her hat all bent, her
fresh dress all crumpled, fiercely shrieking her refusal; and disgrace had
been deeper on another day when she had actually struck out at her aunts
while they mutely and in pale indignation haled her toward the door. It was
dreadful to remember that Aunt Barbara had burst into tears. Eppie could
not forgive herself for that. She had a stoic satisfaction in the memory of the
smart whipping that she had borne without a whimper, and perhaps did not
altogether repent the heavier slap she had dealt Aunt Rachel; but the
thought of Aunt Barbara’s tears—they had continued so piteously to flow
while Aunt Rachel whipped her—quelled physical revolt forever. She was
older now, too, and protest only took the form of dejection and a hostile
gloom.
On this Sunday the gloom was shot with a new and, it seemed, a most
legitimate hope. Boys were usually irreligious; the Grainger cousins
certainly were so: they had once run away on Sunday morning. She could
not, to be sure, build much upon possible analogies of behavior between
Gavan and the Graingers; yet the facts of his age and sex were there:
normal, youthful manliness might be relied upon. If Gavan wished to
remain it seemed perfectly probable that the elders might yield as a matter
of course, and as if to a grown-up guest. Gavan was hardly treated as a child
by any of them.
“You are fond of going to church, I hope, Gavan,” Aunt Rachel said at
breakfast. The question had its reproof for Eppie, who, with large eyes, over
her porridge, listened for the reply.
“Yes, very,” was the doom that fell.
Eppie flushed so deeply that Gavan noticed it. “I don’t mind a bit not
going if Eppie doesn’t go and would like to have me stay at home with her,”
he hastened, with an almost uncanny intuition of her disappointment, to
add.
Aunt Rachel cast an eye of comprehension upon Eppie’s discomfited
visage. “That would be a most inappropriate generosity, my dear Gavan.
Eppie comes with us always.”
Gavan still looked at Eppie, who, with downcast eyes, ate swiftly.
“Now I’ll be bound that she has been wheedling you to get her off,
Gavan,” said the general, with genial banter. “She is a little rebel to the
bone. She knows that it’s no good to rebel, so she put you up to pleading for
her”; and, as Gavan protested, “Indeed, indeed, sir, she didn’t,” he still
continued, “Oh, Eppie, you baggage, you! Isn’t that it, eh? Didn’t you hope
that you could stay with him if he stayed behind?”
“Yes, I did,” Eppie said, without contrition.
“She didn’t tell me so,” said Gavan, full of evident sympathy for Eppie’s
wounds under this false accusation.
She repelled his defense with a curt, “I would have, if it would have
done any good.”
“Ah, that’s my brave lassie,” laughed the general; but Aunt Rachel ended
the unseemly exposure with a decisive, “Be still now, Eppie; we know too
well what you feel about this subject. There is nothing brave in such
naughtiness.”
Gavan said no more; from Eppie’s unmoved expression he guessed that
such reproofs did not cut deep. He joined her after breakfast as she stood in
the open doorway, looking out at the squandered glories of the day.
“Do you dislike going to church so much?” he asked her. The friendly
bond of his sympathy at the table would have cheered her heart at another
time; it could do no more for her now than make frankness easy and a
relief.
“I hate it,” she answered.
“But why?”
“It’s so long—so stupid.”
Gavan loitered about before her on the door-step, his hands in his
pockets. Evidently he could find no ready comment for her accusation.
“Every one looks so silly and so sleepy,” she went on. “Mr. MacNab is
so ugly. Besides, he is an unkind man: he whips his children all the time;
not whippings when they deserve it—like mine,”—Gavan looked at her,
startled by this impersonally just remark,—“he whips them because he is
cross himself. Why should he tell us about being good if he is as ill-
tempered as possible? And he has a horrid voice,—not like the village
people, who talk in a dear, funny way,—he has a horrid, pretend voice. And
you stand up and sit down and have nothing to do for ages and ages. I don’t
see how anybody can like church.”
Gavan kicked vaguely at the lichen spots.
“Do you really like it?”
“Yes,” he answered, with his shy abruptness.
“But why? It’s different, I know, for old people—I don’t suppose that
they mind things any longer; but I don’t see how a boy, a young boy”—and
Eppie allowed herself a reproachful emphasis—“can possibly like it.”
“I’m used to it, you see, and I don’t think of it in your way at all.” Gavan
could not speak to this funny child of its sacred associations. In church he
had always felt that he and his mother had escaped to a place of reality and
peace. He entered, through his love for her, into the love of the sense of
sanctuary from an ominous and hostile world. And he was a boy with a
deep, sad sense of God.
“But you don’t like it,” said the insistent Eppie.
“I more than like it.”
She eyed him gravely. “I suppose it is because you are so grown up. Yet
you are only four years older than I am. I wonder if I will ever get to like it.
I hope not.”
“Well, it will be more comfortable for you if you do,—since you have to
go,” said Gavan, with his faint, wintry smile.
She felt the kindness of his austere banter, and retorting, “I’d rather not
be comfortable, then,” joined him in the sunlight on the broad, stone step,
going on with quite a sense of companionship: “Only one thing I don’t so
much mind—and that is the hymns. I am so glad when they come that I
almost shout them. Sometimes—I’m telling you as quite a secret, you know
—I shout as loud as I possibly can on purpose to disturb Aunt Rachel. I
know it’s wrong, so don’t bother to tell me so; besides, it’s partly because I
really like to shout. But I always do hope that some day they may leave me
at home rather than have me making such a noise. People often turn round
to look.”
Gavan laughed.
“You think that wicked no doubt?”
“No, I think it funny, and quite useless, I’m sure.”
After all, Gavan wasn’t a muff, as a boy fond of church might have been
suspected of being.
Yet after the walk through the birch-woods and over a corner of moor to
the bare little common where the church stood, and when they were all
installed in the hard, familiar pew, a new and still more alienating
impression came to her—alienating yet fascinating. A sense of awe crept
over her and she watched Gavan in an absorbed, a dreamy wonder.
Eppie only associated prayers with a bedside; they were part of the toilet,
so to speak—went in with the routine of hair-and tooth-brushing and having
one’s bath. To pray in church, if one were a young person, seemed a
mystifying, almost an abnormal oddity. She was accustomed to seeing in
the sodden faces of the village children an echo to her own wholesome
vacuity. But Gavan really prayed; that was evident. He buried his face in his
arms. He thought of no one near him.
It was Eppie’s custom to vary the long monotony of Mr. MacNab’s
dreary, nasal, burring voice by sundry surreptitious occupations, such as
drawing imaginary pictures with her forefinger upon the lap of her frock,
picking out in the Bible all the words of which her aunts said she could only
know the meaning when she grew up, counting the number of times that
Mr. MacNab stiffly raised his hand in speaking, seeing how often she could
softly kick the pew in front of her before being told to stop; and then there
was the favorite experiment suggested to her by the advertisement of a soap
where, after fixing the eyes upon a red spot while one counted thirty, one
found, on looking at a blank white space, that the spot appeared
transformed, ghost-like and floating, to a vivid green. Eppie’s fertile
imagination had seen in Mr. MacNab’s thin, red face a substitute for the
spot, and most diverting results had followed when, after a fixed stare at his
countenance, one transferred him, as it were, to the pages of one’s prayer-
book. To see Mr. MacNab dimly hovering there, a green emanation, made
him less intolerable in reality: found, at least, a use for him. This discovery
had been confided to the Graingers, and they had been grateful for it. And
when all else failed and even Mr. MacNab’s poor uses had palled, there was
one bright moment to look forward to in the morning’s suffocating tedium.
Just before the sermon, Uncle Nigel, settling himself in his corner, would
feel, as if absently, in his waistcoat pocket and then slip a lime-drop into her
hand. The sharply sweet flavor filled her with balmy content, and could,
with discretion in the use of the tongue, be prolonged for ten minutes.
But to-day her eyes and thoughts were fixed on Gavan; and when the
lime-drop was in her mouth she crunched it mechanically and heedlessly:
how he held his prayer-book, his pallid, melancholy profile bent above it,
how he sat gravely listening to Mr. MacNab, how he prayed and sang. Only
toward the end of the sermon was the tension of her spirit relieved by
seeing humanizing symptoms of weariness. She was sure that he was
hearing as little as she was—his thoughts were far away; and when he put
up a hand to hide a yawn her jaws stretched themselves in quick sympathy.
Gavan’s eyes at this turned on her and he smiled openly and delightfully at
her. Delightfully; yet the very fact of his daring to smile made him more
grown up than ever. Such maturity, such strange spiritual assurance, could
afford lightnesses. He brought with him, into the fresh, living world outside,
his aura of mystery.
Eppie walked beside her uncle and still observed Gavan as he went
before them with the aunts.
“How do you like your playmate, Eppie?” the general asked.
“He isn’t a playmate,” Eppie gravely corrected him.
“Not very lively? But a nice boy, eh?”
“I think he is very nice; but he is too big to care about me.”
“Nonsense; he’s but three years older.”
“Four, Uncle Nigel. That makes a great deal of difference at our ages,”
said Eppie, wisely.
“Nonsense,” the general repeated. “He is only a bit down on his luck;
he’s not had time to find you out yet. To-morrow he joins you in your Greek
and history, and I fancy he’ll see that four years’ difference isn’t such a
difference when it comes to some things. Not many chits of your age are
such excellent scholars.”
“But I think that we will always be very different,” said Eppie, though at
her uncle’s commendation her spirits had risen.

III
REEK and history proved, indeed, a bond. The two children,
during the hours in the library, met on a more equal footing, for
Gavan was backward with his studies. But the question of
inequality had not come up in Gavan’s consciousness. “I’m only
afraid that I shall bore her,” he hastened, in all sincerity, to say when the
general appealed to a possible vanity in him by hoping that he didn’t mind
being kind to a little girl and going about with her. “She’s the only
companion we have for you, you see. And we all find her very good
company, in spite of her ten years.”
And at this Gavan said, with a smile that protested against any idea that
he should not find her so: “I’m only afraid that I’m not good company for
any one. She is a dear little girl.”
It was in the wanderings over the moors and in the birch-woods and up
the hillside, where Eppie took him to see her views, that the bond really
drew to closeness. Here nature and little Eppie seemed together to thaw
him, to heal him, to make him unconsciously happy. A fugitive color
dawned in his wasted cheeks; a fragile gaiety came to his manner. He began
to find it easy to talk, easy to be quite a little boy. And once he did talk,
Gavan talked a great deal, quickly, with a sort of nervous eagerness. There
grew, in Eppie’s mind, a vast mirage-like picture of the strange land he
came from: the great mountains about their high summer home; the blue-
shadowed verandas; the flowers he and his mother grew in the garden; the
rides at dawn; the long, hot days; the gentle, softly moving servants, some
of whom he loved and told her a great deal about. Then the crowds, the
swarming colors of the bazaars in the great cities.
“No, no; don’t wish to go there,” he said, taking his swift, light strides
through the heather, his head bent, his eyes looking before him—he seldom
looked at one, glanced only; “I hate it,—more than you do church!” and
though his simile was humorous he didn’t laugh with it. “I hate the thought
of any one I care about being there.” He had still, for Eppie, his mystery,
and she dimly felt, too, that his greater ease with her made more apparent
his underlying sadness; but the sense of being an outsider was gone, and she
glowed now at the implication that she was one he cared about.
“It’s vast and meaningless,” said Gavan, who often used terms curiously
unboyish. “I can’t describe it to you. It’s like a dream; you expect all the
time to wake up and find nothing.”
“I know that I should never love anything so much as Scotland—as
heather and pines and sky with clouds. Still, I should like to see India. I
should like to see everything that there is to be seen—if I could be sure of
always coming back here.”
“Ah, yes, if one could be sure of that.”
“I shall always live here, Gavan,” said Eppie, feeling the skepticism of
his “if.”
“Well, that may be so,” he returned, with the manner that made her
realize so keenly the difference that was more than a matter of four years.
She insisted now: “I shall live here until I am grown up. Then I shall
travel everywhere, all over the world—India, Japan, America; then I shall
marry and come back here to live and have twelve children. I don’t believe
you care for children as I do, Gavan. How they would enjoy themselves
here, twelve of them all together—six boys and six girls.”
Gavan laughed. “Well, I hope all that will come true,” he assented. “Why
twelve?”
“I don’t know; but I’ve always thought of there being twelve. I would
like as many as possible, and one could hardly remember the names of
more. I don’t believe that there are more than twelve names that I care for.
But with twelve we should have a birthday-party once a month, one for
each month. Did you have birthday-cakes in India, Gavan, with candles for
your age?”
“Yes; my mother always had a cake for my birthday.” His voice, in
speaking of his mother, seemed always to steel itself, as though to speak of
her hurt him. Eppie had felt this directly, and now, regretting her allusion,
said, “When is your birthday, Gavan?” thinking of a cake with fifteen
candles—how splendid!—to hear disappointingly that the day was not till
January, when he would have been gone—long since.
On another time, as they walked up the hillside, beside the burn, she
said: “I thought you were not going to like us at all, when you first came.”
“I was horribly afraid of you all,” said Gavan. “Everything was so
strange to me.”
“No, you weren’t afraid,” Eppie objected—“not really afraid. I don’t
believe you are ever really afraid of people.”
“Yes, I am—afraid of displeasing them, trying them in some way. And I
was miserable on that day, too, with anxiety about my poor monkey. I’m
sorry I seemed horrid.”
“Not a bit horrid, only very cold and polite.”
“I didn’t realize things much. You see—“ Gavan paused.
“Yes, of course; you weren’t thinking of us. You were thinking of—what
you had left.”
“Yes,” he assented, not looking at her.
He went on presently, turning his eyes on her and smiling over a sort of
alarm at his own advance to personalities: “You weren’t horrid. I remember
that I thought you the nicest little girl I had ever seen. You were all that I
did see—standing there in the sun, with a white dress like Alice in
Wonderland and with your hair all shining. I never saw hair like it.”
“Do you think it pretty?” Eppie asked eagerly.
“Very—all those rivers of gold in the dark.”
“I am glad. I think it pretty, too, and nurse is afraid that I am vain, I
think, for she always takes great pains to tell me that it is striped hair and
that she hopes it may grow to be the same color when I’m older.”
“I hope not,” said Gavan, gallantly.
Many long afternoons were spent in the garden, where Eppie initiated
him into the sanctities of the summer-house. Gavan’s sense of other
people’s sanctities was wonderful. She would never have dreamed of
showing her dolls to her cousins; but she brought them out and displayed
them to Gavan, and he looked at them and their appurtenances carefully,
gravely assenting to all the characteristics that she pointed out. So kind,
indeed, so comprehending was he, that Eppie, a delightful project dawning
in her mind, asked: “Have you ever played with dolls? I mean when you
were very little?”
“No, never.”
“I’ve always had to play by myself,” said Eppie, “and it’s rather dull
sometimes, having to carry on all the conversations alone.” And with a rush
she brought out, rather aghast at her own hardihood, “I suppose you
couldn’t think of playing with me?”
Gavan, at this, showed something of the bashful air of a young bachelor
asked to hold a baby, but in a moment he said, “I shouldn’t mind at all,
though I’m afraid I shall be stupid at it.”
Eppie flushed, incredulous of such good fortune, and almost reluctant to
accept it. “You really don’t mind, Gavan? Boys hate dolls, as a rule, you
know.”
“I don’t mind in the least,” he laughed. “I am sure I shall enjoy it. How
do we begin? You must teach me.”
“I’ll teach you everything. You are the very kindest person I ever knew,
Gavan. Really, I wouldn’t ask you to if I didn’t believe you would like it
when once you had tried it. It is such fun. And now we can make them do
all sorts of things, have all sorts of adventures, that they never could have
before.” She suspected purest generosity, but so trusted in the enchantments
he was to discover that she felt herself justified in profiting by it. She placed
in his hand Agnes, the fairest of all the dolls, golden-haired, blue-eyed.
Agnes was good, and her own daughter, Elspeth, named after herself, was
bad. “As bad as possible,” said Eppie. “I have to whip her a great deal.”
Gavan, holding his charge rather helplessly and looking at Elspeth, a doll
of sturdier build, with short hair, dark eyes, and, for a doll, a mutinous face,
remarked, with his touch of humor, “I thought you didn’t approve of
whipping.”
“I don’t,—not real children, or dolls either, except when they are really
bad. Mr. MacNab whips his all the time, and they are not a bit bad, really, as
Elspeth is.” And Elspeth proceeded to demonstrate how really bad she was
by falling upon Agnes with such malicious kicks and blows that Gavan, in
defense of his own doll, dealt her a vigorous slap.
“Well done, Mr. Palairet; she richly deserves it! Come here directly, you
naughty child,” and after a scuffling flight around the summer-house,
Elspeth was secured, and so soundly beaten that Gavan at last interceded for
her with the ruthless mother.
“Not until she says that she is sorry.”
“Oh, Elspeth, say that you are sorry,” Gavan supplicated, while he
laughed. “Really, Eppie, you are savage. I feel as if you were really hurting
some one. Please forgive her now; Agnes has, I am sure.”
“I hurt her because I love her and want her to be a good child. She will
come to no good end when she grows up if she cannot learn to control her
temper. What is it I hear you say, Elspeth?”
Elspeth, in a low, sullen voice that did not augur well for permanent
amendment, whispered that she was sorry, and was led up, crestfallen, to
beg Agnes’s pardon and to receive a reconciling kiss.
The table was then brought out and laid. Eppie had her small store of
biscuits and raisins, and Elspeth and Agnes were sent into the garden to
pick currants and flowers. To Agnes was given the task of making a
nosegay for the place of each guest. There were four of these guests, bidden
to the feast with great ceremony: three, pink and curly, of little
individuality, and the fourth a dingy, armless old rag-doll, reverently
wrapped in a fine shawl, and with a pathetic, half-obliterated face.
“Very old and almost deaf,” Eppie whispered to Gavan. “Everybody
loves her. She lost her arms in a great fire, saving a baby’s life.”
Gavan was entering into all the phases of the game with such spirit,
keeping up Agnes’s character for an irritating perfection so aptly that Eppie
forgot to wonder if his enjoyment were as real as her own. But suddenly the
doorway was darkened, and glancing up, she saw her uncle’s face, long-
drawn with jocular incredulity, looking in upon them. Then, and only then,
under the eyes of an uncomprehending sex, did the true caliber of Gavan’s
self-immolation flash upon her. A boy, a big boy, he was playing dolls with
a girl; it was monstrous; as monstrous as the general’s eyes showed that he
found it. Stooping in his tall slightness, as he assisted Agnes’s steps across
the floor, he seemed, suddenly, a fairy prince decoyed and flouted. What
would Uncle Nigel think of him? She could almost have flung herself
before him protectingly.
The general had burst into laughter. “Now, upon my word, this is too bad
of you, Eppie!” he cried, while Gavan, not abandoning his hold on Agnes’s
arm, turned his eyes upon the intruder with perfect serenity. “You are the
most unconscionable little tyrant. You kept the Grainger boys under your
thumb; but I didn’t think you could carry wheedling or bullying as far as
this. Gavan, my dear boy, you are too patient with her.”
Eppie stood at the table, scarlet with anger and compunction. Gavan had
raised himself, and, still holding Agnes, looked from one to the other.
“But she hasn’t bullied me; she hasn’t wheedled me,” he said. “I like it.”
“At your age, my dear boy! Like doll-babies!”
“Indeed I do.”
“This is the finest bit of chivalry I’ve come across for a long time. The
gentleman who jumped into the lions’ den for his mistress’s glove was
hardly pluckier. Drop that ridiculous thing and come away. I’ll rescue you.”
“But I don’t want to be rescued. I really am enjoying myself. It’s not a
case of courage at all,” Gavan protested.
This was too much. He should not tarnish himself to shield her, and
Eppie burst out: “Nonsense, Gavan. I asked you to. You are only doing it
because you are so kind, and to please me. It was very wrong of me. Put her
down as Uncle Nigel says.”
“There, our little tyrant is honest, at all events. Drop it, Gavan. You
should see the figure you cut with that popinjay in your arms. Come, you’ve
won your spurs. Come away with me.”
But Gavan, smiling, shook his head. “No, I don’t want to, thanks. I did it
to please her, if you like; but now I do it to please myself. Playing with
dolls is a most amusing game,—and you are interrupting us at a most
interesting point,” he added. He seemed, funnily, doll and all, older than the
general as he said it. Incredulous but mystified, Uncle Nigel was forced to
beat a retreat, and Gavan was left confronting his playmate.
“Why did you tell him that you enjoyed it?” she cried. “He’ll think you
unmanly.”
“My dear Eppie, he won’t think me unmanly at all. Besides, I don’t care
if he does.”
“I care.”
“But, Eppie, you take it too hard. Why should you care? It’s only funny.
Why shouldn’t we amuse ourselves as we like? We are only children.”
“You are much more than a child. Uncle Nigel thinks so, too, I am sure.”
“All the more reason, then, for my having a right to amuse myself as I
please. And I am a child, for I do amuse myself.”
Eppie stood staring out rigidly at the blighted prospect, and he took her
unyielding hand. “Poor Elspeth is lying on her face. Do let us go on. I want
you to hear what Agnes has to say next.”
She turned to him now. “I don’t believe a word you say. You only did it
for me. You are only doing it for me now.”
“Well, what if I did? What if I do? Can’t I enjoy doing things for you?
And really, really, Eppie, I do think it fun. I assure you I do.”
“I think you are a hero,” Eppie said solemnly, and at this absurdity he
burst into his high, shrill laugh, and renewed his supplications; but
supplications were in vain. She refused to let him play with her again. He
might do things for the dolls,—yes, she reluctantly consented to that at last,
—he might take the part of robber or of dangerous wild beast in the woods,
but into domestic relations, as it were, he should not enter with them; and
from this determination Gavan could not move her.
As far as his dignity in the eyes of others went, he might have gone on
playing dolls with her all summer; Eppie realized, with surprise and relief,
that Gavan’s assurance had been well founded. Uncle Nigel, evidently, did
not think him unmanly, and there was no chaffing. It really was as he had
said, he was so little a child that he could do as he chose. His dignity
needed no defense.
But though the doll episode was not to be repeated, other and more equal
ties knit her friendship with Gavan. Wide vistas of talk opened from their
lessons, from their readings together. As they rambled through the heather
they would talk of the Odyssey, of Plutarch’s Lives, of nearer great people
and events in history. Gavan listened with smiling interest while Eppie
expressed her hatreds and her loves, correcting her vehemence, now and
then, by a reference to mitigatory circumstance. Penelope was one of the
people she hated. “See, Gavan, how she neglected her husband’s dog while
he was away—let him starve to death on a dunghill.”
Gavan surmised that the Homeric Greeks had little sense of
responsibility about dogs.
“They were horrid, then,” said Eppie. “Dear Argos! Think of him trying
to wag his tail when he was dying and saw Ulysses; he was horrid, too, for
he surely might have just stopped for a moment and patted his head. I’m
glad that Robbie didn’t live in those times. You wouldn’t let Robbie die on a
dunghill if I were to go away!”
“No, indeed, Eppie!” Gavan smiled.
“I think you really love Robbie as much as I do, Gavan. You love him
more than Uncle Nigel does. One can always see in people’s eyes how
much they love a dog. That fat, red Miss Erskine simply feels nothing for
them, though she always says ‘Come, come,’ to Robbie. But her eyes are
like stones when she looks at him. She is really thinking about her tea, and
watching to see that Aunt Rachel puts in plenty of cream. I suppose that
Penelope looked like her, when she used to see Argos on the dunghill.”
Robbie was plunging through the heather before them and paused to
look round at them, his delicate tongue lapping in little pants over his teeth.
“Darling Robbie,” said Gavan. “Our eyes aren’t like stones when we
look at you! See him smile, Eppie, when I speak to him. Wouldn’t it be
funny if we smiled with our ears instead of with our mouths.”
Gavan, after a moment, sighed involuntarily and deeply.
“What is the matter?” Eppie asked quickly, for she had grown near
enough to ask it. And how near they were was shown after a little silence,
by Gavan saying: “I was only wishing that everything could be happy at
once, Eppie. I was thinking about my mother and wishing that she might be
here with you and me and Robbie.” His voice was steadied to its cold quiet
as he said it, though he knew how safe from any hurt he was with her. And
she said nothing, and did not look at him, only, in silence, putting a hand of
comradeship on his shoulder while they walked.

IV
NCE a week, on the days of the Indian mail, Eppie’s
understanding hovered helplessly about Gavan, seeing pain for
him and powerless to shield him from it. Prayers took place in the
dining-room ten minutes before breakfast, and with the breakfast
the mail was brought in, so that Gavan’s promptest descent could not secure
him a solitary reading of the letter that, Eppie felt, he awaited with
trembling eagerness.
“A letter from India, Gavan dear,” Miss Rachel, the distributer of the
mail would say. “Tell us your news.” And before them all, in the midst of
the general’s comments on politics, crops, and weather, the rustling of
newspapers, the pouring of tea, he was forced to open and read his letter
and to answer, even during the reading, the kindly triviality of the questions
showered upon him. “Yes, thank you, very well indeed. Yes, in Calcutta.
Yes, enjoying herself, I think, thanks.” His pallor on these occasions, his
look of hardened endurance, told Eppie all that it did not tell the others. And
that his eagerness was too great for him to wait until after breakfast, she
saw, too. A bright thought of rescue came to her at last. On the mornings
when the Indian mail was due, she was up a good hour before her usual
time. Long before the quaint, musical gong sounded its vague, blurred
melody for prayers, she was out of the house and running through the birch-
woods to the village road, where, just above the church, she met the
postman. He was an old friend, glad to please the young lady’s love of
importance, and the mail was trusted to her care. Eppie saved all her speed
for the return. Every moment counted for Gavan’s sheltered reading. She
felt as if, her back to its door, she stood before the sheltered chamber of
their meeting, guarding their clasp and kiss, sweet and sorrowful, from alien
eyes. Flushed, panting, she darted up to his room, handing his letter in to
him, while she said in an easy, matter-of-fact tone, “Your mail, Gavan.”
Gavan, like the postman, attributed his good luck to Eppie’s love of
importance, and only on the third morning discovered her manœuver.
He came down early himself to get his own letter, found that the mail
had not arrived, and, strolling disappointedly down the drive, was almost
knocked down by Eppie rushing in at the gate. She fell back, dismayed at
the revelation that must force the fullness of her sympathy upon him—
almost as if she herself glanced in at the place of meeting.
“I’ve got the letters,” she said, leaning on the stone pillar and recovering
her breath. “There’s one for you.” And she held it out.
But for once Gavan’s concentration seemed to be for her rather than for
the letter. “My mother’s letter?” he said.
She nodded.
“It was you, then. I wondered why they came so much earlier.”
“I met the postman; he likes to be saved that much of his walk.”
“You must have to go a long way to get them so early. You went on
purpose for me, I think.”
Looking aside, she now had to own: “I saw that you hated reading them
before us all. I would hate it, too.”
“Eppie, my dearest Eppie,” said Gavan. Glancing at him, she saw tears
in his eyes, and joy and pride flamed up in her. He opened the letter and
read it, walking beside her, his hand on her shoulder, showing her that he
did not count her among “us all.”
After that they went together to meet the postman, and, unasked, Gavan
would read to her long pieces from what his mother said.
It was a few weeks later, on one of these days, that she knew, from his
face while he read, and from his silence, that bad news had come. He left
her at the house, making no confidence, and at breakfast, when he came
down to it later, she could see that he had been struggling for self-mastery.
This pale, controlled face, at which she glanced furtively while they did
their lessons in the library, made her think of the Spartan boy, calm over an
agony. Even the general noticed the mechanical voice and the pallor and
asked him if he were feeling tired this morning. Gavan owned to a
headache.
“Off to the moors directly, then,” said the general; “and you, too, Eppie.
Have a morning together.”
Eppie sat over her book and said that perhaps Gavan would rather go
without her; but Gavan, who had risen, said quickly that he wanted her to
come. “Let us go to the hilltop,” he said, when they were outside in the
warm, scented sunlight.
They went through the woods, where the burn ran, rippling loudly, and
the shadows were blue on the little, sandy path that wound among pines and
birches. Neither spoke while they climbed the gradual ascent. They came
out upon the height that ran in a long undulation to the far lift of mountain
ranges. Under a solitary group of pines they sat down.
The woods of Kirklands were below them, and then the vast sea of
purple, heaving in broad, long waves to the azure, intense and clear, of the
horizon. The wind sighed, soft and shrill, through the pines above them, and
far away they heard a sheep-bell tinkle. Beyond the delicate miniature of
the village a wind-mill turned slow, gray sails. The whole world, seemed a
sunlit island floating in the circling blue. Robbie sat at their feet, alert,
upright, silhouetted against the sky.
“Robbie, Robbie,” said Gavan, gently, as he leaned forward and stroked
the dog’s back. Eppie, too, stroked with him. The silence of his unknown
grief weighed heavily on her heart and she guessed that though for him the
pain of silence was great, the pain of speech seemed greater.
He presently raised himself again, clasping both hands about his knees
and looking away into the vast distance. His head, with its thick hair, its
fine, aquiline nose and delicately jutting chin, made Eppie think, vaguely, of
a picture she had seen of a young Saint Sebastian, mutely enduring arrows,
on a background of serene sky. With the thought, the silence became
unendurable; she strung herself to speak. “Tell me, Gavan,” she said, “have
you had bad news?”
He cast her a frightened glance, and, looking down, began to pull at the
heather. “No, not bad news, exactly.”
Eppie drew a breath of dubious relief. “But you are so unhappy about
something.”
Gavan nodded.
“But why, if it’s not bad news?”
After a pause he said, and she knew, with all the pain of it, what the
relief of speaking must be: “I guess at things. I always feel if she is hiding
things.”
“Perhaps you are only imagining.”
“I wish I could think it; but I know not. I know what is happening to
her.”
He was still wrenching away at the heather, tossing aside the purple
sprays with their finely tangled sandy roots. Suddenly he put his head on his
knees, hiding his face.
“Oh, Gavan! Oh, don’t be so unhappy,” Eppie whispered, drawing near
him, helpless and awe-struck.
“How can I be anything but unhappy when the person I care most for is
miserable—miserable, and I am so far from her?” His shoulders heaved;
she saw that he was weeping.
Eppie, at first, gazed, motionless, silent, frozen with a child’s quick fear
of demonstrated grief. A child’s quick response followed. Throwing her
arms around him, she too burst into tears.
It was strange to see how the boy’s reserves melted in the onslaught of
this hot, simple sympathy. He turned to her, hiding his face on her shoulder,
and they cried together.
“I didn’t want to make you unhappy, too,” Gavan said at last in a
weakened voice. His tears were over first and he faintly smiled as he met
Robbie’s alarmed, beseeching eyes. Robbie had been scrambling over them,
scratching, whining, licking their hands and cheeks in an exasperation of
shut-out pity.
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!

textbookfull.com

You might also like