100% found this document useful (6 votes)
32 views62 pages

Get Reactive Programming With JavaScript 1st Edition Hayward Jonathan PDF Ebook With Full Chapters Now

Programming

Uploaded by

irolajarrar
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 (6 votes)
32 views62 pages

Get Reactive Programming With JavaScript 1st Edition Hayward Jonathan PDF Ebook With Full Chapters Now

Programming

Uploaded by

irolajarrar
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/ 62

Download the full version of the textbook now at textbookfull.

com

Reactive Programming with JavaScript 1st


Edition Hayward Jonathan

https://textbookfull.com/product/reactive-
programming-with-javascript-1st-edition-hayward-
jonathan/

Explore and download more textbook at https://textbookfull.com


Recommended digital products (PDF, EPUB, MOBI) that
you can download immediately if you are interested.

Reactive Programming with RxJS 5 Untangle your


asynchronous Javascript code 1st Edition Sergi Mansilla

https://textbookfull.com/product/reactive-programming-with-
rxjs-5-untangle-your-asynchronous-javascript-code-1st-edition-sergi-
mansilla/
textbookfull.com

RxSwift Reactive Programming with Swift 1st Edition


Florent Pillet

https://textbookfull.com/product/rxswift-reactive-programming-with-
swift-1st-edition-florent-pillet/

textbookfull.com

Reactive Programming with Angular and ngrx: Learn to


Harness the Power of Reactive Programming with RxJS and
ngrx Extensions 1st Edition Oren Farhi (Auth.)
https://textbookfull.com/product/reactive-programming-with-angular-
and-ngrx-learn-to-harness-the-power-of-reactive-programming-with-rxjs-
and-ngrx-extensions-1st-edition-oren-farhi-auth/
textbookfull.com

Nitrogen Overload Environmental Degradation Ramifications


and Economic Costs 1st Edition Brian G. Katz

https://textbookfull.com/product/nitrogen-overload-environmental-
degradation-ramifications-and-economic-costs-1st-edition-brian-g-katz/

textbookfull.com
Unlocking Blockchain on Azure: Design and Develop
Decentralized Applications Shilpa Karkeraa

https://textbookfull.com/product/unlocking-blockchain-on-azure-design-
and-develop-decentralized-applications-shilpa-karkeraa/

textbookfull.com

Advances in Medicine and Medical Research Mieczyslaw


Pokorski

https://textbookfull.com/product/advances-in-medicine-and-medical-
research-mieczyslaw-pokorski/

textbookfull.com

EU Funds in the New Member States Party Politicization


Administrative Capacities and Absorption Problems after
Accession Christian Hagemann
https://textbookfull.com/product/eu-funds-in-the-new-member-states-
party-politicization-administrative-capacities-and-absorption-
problems-after-accession-christian-hagemann/
textbookfull.com

The University as a Critical Institution 1st Edition


Rosemary Deem

https://textbookfull.com/product/the-university-as-a-critical-
institution-1st-edition-rosemary-deem/

textbookfull.com

The Greatest Comic Book of All Time: Symbolic Capital and


the Field of American Comic Books 1st Edition Bart Beaty

https://textbookfull.com/product/the-greatest-comic-book-of-all-time-
symbolic-capital-and-the-field-of-american-comic-books-1st-edition-
bart-beaty/
textbookfull.com
Artistic License: The Philosophical Problems of Copyright
and Appropriation Darren Hudson Hick

https://textbookfull.com/product/artistic-license-the-philosophical-
problems-of-copyright-and-appropriation-darren-hudson-hick/

textbookfull.com
Reactive Programming
with JavaScript

Learn the hot new frontend web framework from


Facebook – ReactJS, an easy way of developing
the V in MVC and a better approach to software
engineering in JavaScript

Jonathan Hayward

BIRMINGHAM - MUMBAI
Reactive Programming with JavaScript

Copyright © 2015 Packt Publishing

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

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

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

First published: August 2015

Production reference: 1260815

Published by Packt Publishing Ltd.


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

ISBN 978-1-78355-855-1

www.packtpub.com
Credits

Author Project Coordinator


Jonathan Hayward Mary Alex

Reviewers Proofreader
Antal Orcsik Safis Editing
Sven A Robbestad
Hibai Unzueta Indexer
Rekha Nair

Commissioning Editor
Kunal Parikh Graphics
Jason Monteiro

Acquisition Editor
Manish Nainani Production Coordinator
Aparna Bhagat

Content Development Editor


Aparna Mitra Cover Work
Aparna Bhagat

Technical Editor
Mohita Vyas

Copy Editors
Vikrant Phadke
Alpha Singh
Ameesha Smith-Green
About the Author

Jonathan Hayward is a polymath with advanced degrees bridging mathematics,


computers (UIUC), theology, and philosophy. He obtained his theology and
philosophy degrees from Cambridge University. He has worked in many areas of
web development, with a site (http://cjsh.name/) for "after hours" titles, and he
is also interested in the human side of computing, including usability/UI/UX. His
most popular work is a piece of poetry at https://cjshayward.com/doxology/.
The faster route to get there is by typing cjsh.name/doxology, and it gets there.
Jonathan has studied many languages, including French, Spanish, Latin, and
Greek. He is currently learning Russian. He has worked on various other books
as well (refer to http://www.amazon.com/s/ref=nb_sb_noss_2?url=search-
alias%3Daps&field-keywords=%22CJS+Hayward%22 to find out more).

I would like to thank my parents, John and Linda; my brothers,


Matthew, Joe, and Kirk; my sisters-in-law, Kristin and Adrien; and
my nephews, Jack and James. I would also like to thank all of the
Packt Publishing editorial team, including a great many who I do not
know, but I would like to single out Usha, Akshay, Neetu, Mohita,
and Aparna. They are the editors who left me wishing we lived next
door. Finally, I'd like to thank all those at Facebook for releasing
ReactJS as a framework that is free for the rest of the world.
About the Reviewers

Antal Orcsik is a full-stack web developer from Hungary. He works at Prezi


(https://prezi.com/) as a payment engineer. In the last decade, he worked
for Hungary's biggest real estate catalog site and one of the biggest local weather
portals. Then he joined the fantastic team that created a revolutionary presentation
tool called Prezi to change the way the world shares ideas. During this time, he
gained experience in Scala, Python, and PHP backend environments as well as
JavaScript frontend technologies, while experimenting with various other fields
of the full-stack web development spectrum. Antal is a big fan of cats, games,
science fiction, and hamburgers.

I would like to thank my lovely girlfriend for her support and


patience while I played my part in creating this book.

Sven A Robbestad is a Norwegian open source developer and frequent


conference speaker with more than 20 years of experience of working on the Web.
He is passionate about mobile development and is always ready to talk about code.
Sven is currently employed at TeliaSonera (http://www.teliasonera.com/) as a
technologist.
Hibai Unzueta is a multifaceted builder who was programming and designing
complex systems much before he applied for his first job.

He believes that technology is nothing without technique and technique in turn needs
a solid vision-based foundation. He enjoys territories where different knowledge
areas overlap. Lately, he has been involved in projects of data visualization and user
experience design.

For the past 2 years, he has been researching travel search paradigms and technology
with the intention of launching a new project that is expected to rethink the way we
do travel planning. As a result, he has worn many hats, but never all of them at once.
www.PacktPub.com

Support files, eBooks, discount offers, and more


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

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

At www.PacktPub.com, you can also read a collection of free technical articles, sign
up for a range of free newsletters and receive exclusive discounts and offers on Packt
books and eBooks.
TM

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

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

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

Free access for Packt account holders


If you have an account with Packt at www.PacktPub.com, you can use this to access
PacktLib today and view 9 entirely free books. Simply use your login credentials for
immediate access.
To my nephews Jack and James: You are the light of my life
Visit https://textbookfull.com
now to explore a rich
collection of eBooks, textbook
and enjoy exciting offers!
Table of Contents
Preface v
Chapter 1: Introduction and Installation 1
A 10,000-foot overview 1
An easier way to handle user interface programming 2
Programming paradigms 3
Installing the tools required 6
Installing Google Chrome 6
Installing Node.js 10
Installing the Starter Kit for ReactJS 16
Summary 18
Chapter 2: Core JavaScript 19
The strict mode 20
Variables and assignment 20
Comments 21
Flow control 22
A note on values and NaN 22
Functions 22
Comments 24
Loops 28
Taking a look at ECMAScript 6 29
Summary 30
Chapter 3: Reactive Programming – The Basic Theory 31
Declarative programming 33
The war on Heisenbugs 33
The Flux Architecture 35
From the pit of despair to the pit of success 35
Complete UI teardown and rebuild 38
JavaScript as a Domain-specific Language 39

[i]
Table of Contents

The Big-Coffee Notation 40


Summary 43
Chapter 4: Demonstrating Nonfunctional Reactive
Programming – A Live Example 45
The history of a game with multiple ports 46
The HTML for the web page 47
Using a content distribution network wherever we can 48
Some simple styling 48
A fairly minimal page body 50
The JavaScript that animates that page 51
A brief syntax note – Immediately Invoked Function Expression 51
Variable declaration and initialization 52
The function used to start or restart the game 53
The function that creates game levels 54
Getting our hands dirty with ReactJS classes 55
Tick-tock, tick-tock – the game's clock ticks 59
GAME OVER 62
Summary 65
Chapter 5: Learning Functional Programming – The Basics 67
Custom sort functions – the first example of functional
JavaScript and first-class functions 69
This leads us to array.filter() 72
Illusionism, map, reduce, and filter 74
Fool's gold – extending Array.prototype 75
Avoiding global pollution 77
The map, reduce, and filter toolbox – map 78
The reduce function 78
The last core tool – filter 81
An overview of information hiding in JavaScript 82
Information hiding with JavaScript closures 85
Summary 87
Chapter 6: Functional Reactive Programming – The Basics 89
A trip down computer folklore's memory lane 90
Advanced prerequisites for Hello, World! 92
Distinguishing the features of functional reactive programming 95
If you learn just one thing... 96
Learn what you can! 99
JavaScript as the new bare metal 103
Summary 105

[ ii ]
Table of Contents

Chapter 7: Not Reinventing the Wheel – Tools for


Functional Reactive Programming 107
ClojureScript 108
Om 110
Bacon.js 110
Brython – a Python browser implementation 112
Immutable.js – permanent protection from change 115
Jest – BDD unit testing from Facebook 122
Implementing the Flux Architecture using Fluxxor 126
Summary 127
Chapter 8: Demonstrating Functional Reactive
Programming in JavaScript – A Live Example, Part I 129
What we will be attempting in this chapter 130
This project's first complete component 136
The render() method 139
Triggering the actual display for what we have created 142
Summary 143
Chapter 9: Demonstrating Functional Reactive Programming
in JavaScript with a Live Example Part II – A To-do List 145
Adding a to-do list to our application 146
Including ReactJS add-ons in our project 147
Setting the appropriate initial state 147
Making text editable 147
Heavy lifting with render() 148
Inner functions used to render 148
Building the result table 149
Rendering our result 151
Differentiating columns visually 151
Summary 152
Chapter 10: Demonstrating Functional Reactive Programming
in JavaScript: A Live Example Part III – A Calendar 153
Play it again Sam – an interesting challenge 154
Classical Hijaxing works well 157
Built with usability in mind, but there's still room to grow 160
Plain old JavaScript objects are all you need 164
Progressive disclosure that starts simply 166
A render() method can easily delegate 168
Boring code is better than interesting code! 169
A simple UI for simply non-recurring entries... 170

[ iii ]
Table of Contents

The user can still opt-in for more 172


Avoiding being clever 174
Anonymous helper functions may lack pixie dust 175
How far in the future should we show? 178
Different stripes for different entry types 178
Now we're ready to display! 179
Let's be nice and sort each day in order 180
Let them use Markdown! 181
One thing at a time! 182
The holidays that inspired this calendar 183
Summary 184
Chapter 11: Demonstrating Functional Reactive Programming
in JavaScript with a Live Example Part IV – Adding a
Scratchpad and Putting It All Together 187
Adding a WYSIWYG scratchpad, courtesy CKeditor 188
Bringing all things together into one web page 188
This book is about ReactJS, so why use CKeditor? 189
CKeditor – small free offerings, and small is beautiful 190
Including CKeditor in our page 190
Integrating all four subcomponents into one page 192
Persistence 194
One detail – persisting the CKeditor state 198
Summary 199
Chapter 12: How It All Fits Together 201
A review of the terrain covered 202
Could the Mythical Man-Month have been avoided? 202
ReactJS is just a view, but what a view! 204
Programming is fun again! 205
Summary 208
The next steps from here 209
Appendix: A Node.js Kick start 211
Node.js and INTERCAL 212
Warning – Node.js and its ecosystem are hot, and hot enough
to burn you badly! 218
A sample project – a server for our Pragmatometer 223
Client-side preparations 224
The server side 227
Summary 231
Index 235

[ iv ]
Preface

Preface
Charles Cézanne famously said about the impressionist painter Claude Monet,
"Monet is only an eye, but what an eye!" Today, we can similarly say, "ReactJS
[or if you prefer, "ReactJS is only a view, but what a view!"

ReactJS has neither the intention nor the ambition to be a complete, general-purpose
web framework. It doesn't even include tooling for Ajax calls! Rather, the intent
is that you will use technologies that make sense for different concerns in your
application, and use ReactJS's power tools for views and user interface development.

Functional reactive programming has been an extremely high-hanging fruit, with


a prohibitive barrier to entry in terms of sheer mathematical expectations assumed
in order to work with it. No longer with ReactJS! A veteran C++ programmer with
no particularly deep math background—I said this to pick a profile of programmers
who keep on saying on Stack Overflow that they don't get functional reactive
programming—is a veteran programmer who stands a fair chance of getting real
work done using ReactJS.

This book is about ReactJS, a simple and small technology that nonetheless lets huge
teams work together on different components of a web page without stepping on
each others' feet, but without a hint of bureaucratic measures. And add some liberal
help of pixie dust.

What this book covers


Chapter 1, Introduction and Installation, provides a 10,000-foot overview of different
programming paradigms, each of which has its strengths, and an introduction to
the trio of functional programming, reactive programming, and functional reactive
programming.

[v]
Preface

Chapter 2, Core JavaScript, covers some of JavaScript's better neighborhoods and omits
the minefields, with a debt to Douglas Crockford, if not a complete agreement. In
terms of the parts of JavaScript that you use, you should be doing most of your
work within this core.

Chapter 3, Reactive Programming – The Basic Theory, is a basic exploration of reactive


theory, or reactive programming, specifically in relation to Facebook's ReactJS user
interface framework.

Chapter 4, Demonstrating Nonfunctional Reactive Programming – A Live Example, proves


that not all development is from scratch. Most professional work is not greenfield.
This will offer a live example of retrofitting a simple video game, the most recent
implementation using jQuery, to take advantage of ReactJS (if you are using ReactJS,
you will probably be doing other conversions from jQuery to ReactJS).

Chapter 5, Learning Functional Programming – The Basics, helps you if you want to
understand functional programming but have no idea where to start. Here's one
place to start! Map, reduce, and filter are introduced as an inexhaustible bag of tricks.

Chapter 6, Functional Reactive Programming – The Basics, covers what has been said about
functional programming and reactive programming. It will be put together with some
sage advice, and the last bit of foundation will be laid for the remaining hands-on work
in this book.

Chapter 7, Not Reinventing the Wheel – Tools for Functional Reactive Programming,
contains a lot to cover in one book, let alone one chapter. But there is meant to be an
interesting sampling of a space where a lot of interesting options are made available,
including writing ReactJS code from a language other than JavaScript.

Chapter 8, Demonstrating Functional Reactive Programming in JavaScript – A Live


Example, Part I, is where we see an application housing a whimsical ReactJS
component written in ReactJS from scratch, and showcasing the sweet JSX syntactic
sugar that is not required but is still made available for ReactJS development.

Chapter 9, Demonstrating Functional Reactive Programming in JavaScript with a Live


Example Part II – A To-do List, leads us to our first real component, designed to be
used rather than just amuse. We implement a to-do list, and it has several markers
other than just "done" to indicate what state, priority, and other things a task has.

Chapter 10, Demonstrating Functional Reactive Programming in JavaScript: A Live


Example Part III – A Calendar, is where we build a calendar. It is intended to
gracefully support not only one-time events but also many kinds of repeating
events with all kinds of rules that people offer.

[ vi ]
Preface

Chapter 11, Demonstrating Functional Reactive Programming in JavaScript with a Live


Example Part IV – Adding a Scratchpad and Putting It All Together, provides a rich-text
scratchpad with CKeditor. This shows how we might interoperate with other user
interface tools. Then we wind up by bringing the four components together into
one combined page and adding persistence functionality so that our user interface
doesn't forget what it is told.

Chapter 12, How It All Fits Together, reviews what we covered in this book, and we
look at the next steps in a world to explore.

Appendix, A Node.js Kick start, looks at some of the good, the bad, and the ugly of
a "Wild, Wild West" technology that everybody seems to want in on.

What you need for this book


There is a bit of software to download, and you will need a web server that can at
least serve static content. Appendix, Node.js, covers building a web server for the
larger project in Node.js, but all the chapters can work with just a web server that
will serve static content in the most basic fashion. You'll need a desktop computer,
which can be almost anything that can run Node.js (if you choose to work through
the appendix). The text will work well enough with Unix, Linux, Mac, Windows,
Cygwin, and so on. If you want to run it from a mobile device, that may be a
praiseworthy approach, but please work from a device (desktop or otherwise)
using some standard server or desktop operating system.

However, all that you really need is a server or desktop, a browser such as Chrome,
a web server, and a willingness to dive into something new. Everything else is
provided in the text.

Who this book is for


This book is intended for programmers who want to dive into functional reactive
programming and Facebook's ReactJS. There is an expectation of some general
programming maturity, some knowledge of JavaScript, and some knowledge of
producing user interfaces. Familiarity with functional programming is also one of
the several things that would help, but the hope, whether realized or not, is to create
a book using which a veteran programmer in any general-purpose language with
some (perhaps light) knowledge of JavaScript and web development would be able
to get things to work.

People who do have a solid background in frontend web development and


JavaScript's functional core may be surprised how easy it is to work with ReactJS,
and may find it like slicing a hot knife through butter.

[ vii ]
Preface

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

Code words in text, database table names, folder names, filenames, file extensions,
pathnames, dummy URLs, user input, and Twitter handles are shown as follows:
"The typeof function returns a string containing a description of a type; thus,
typeof can offer an extended type."

A block of code is set as follows:


var counter = (function() {
var value = 0;
return {
get_value: function() {
return value;
},
increment_value: function() {
value += 1;
}
}
})();

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


python -c "import binascii; print binascii.hexlify(open('/dev/random').
read(1024))"

New terms and important words are shown in bold. Words that you see on the
screen, for example, in menus or dialog boxes, appear in the text like this: "When
the installer starts, click on Next, as follows:"

Warnings or important notes appear in a box like this.

Tips and tricks appear like this.

[ viii ]
Preface

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

To send us general feedback, simply e-mail [email protected], and mention


the book's title in the subject of your message.

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

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

Downloading the example code


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

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

To view the previously submitted errata, go to https://www.packtpub.com/books/


content/support and enter the name of the book in the search field. The required
information will appear under the Errata section.

[ ix ]
Visit https://textbookfull.com
now to explore a rich
collection of eBooks, textbook
and enjoy exciting offers!
Preface

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

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


pirated material.

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

Questions
If you have a problem with any aspect of this book, you can contact us at
[email protected], and we will do our best to address the problem.

[x]
Introduction and Installation
Welcome to the wonderful world of reactive (functional) programming in JavaScript!
In this book, we will cover the good parts of JavaScript, although we will not follow
it religiously. We will cover functional programming, reactive programming, and
the ReactJS library and integrate all of these into functional reactive programming
with JavaScript. If you are going to study reactive programming, it is our suggestion
that you seriously consider functional reactive programming, including learning
functional programming as much you can. In this context, the whole of functional
reactive programming is more than the sum of its parts. We will be applying reactive
programming to JavaScript user interface development. User interfaces are one
domain in which functional reactive programming (FRP), really shines.

The topics that will be covered in this chapter are as follows:

• A 10,000-foot overview of the subject-matter, including:


°° A discussion of an easier approach to user interface programming
°° A brief discussion of programming paradigms, such as functional
and reactive programming

• An overview of the chapters in this book


• A look at how to install some of the tools used over the course of this book

A 10,000-foot overview
There are a lot of things that can be stated, but (functional) reactive programming
may be easier than you think. Today, much that has been written about functional
reactive programming is intimidating, much like the instructions for closures a few
years ago.

[1]
Introduction and Installation

An easier way to handle user interface


programming
Years ago, when I first began to study JavaScript, I picked one site and literally
took everything from it that I needed to understand to perform objected-oriented
information hiding, that is, how to create a JavaScript object that had private fields.
I read perhaps two or three chapters that were dense with theoretical computer
science and 10-15 percent of the introduction before giving up. Then I saw how easy
it was to use a closure to create an object with private fields on a simple monkey see,
monkey do basis:
var counter = (function() {
var value = 0;
return {
get_value: function() {
return value;
},
increment_value: function() {
value += 1;
}
}
})();

Right now, functional reactive programming is in the state in which JavaScript


closures were some years back. The amount of theory you have to read before you
can start reactive programming is astounding, and large portions of the literature
are of a PhD reading level. That's bad news. But the good news is that you don't
have to wade through so much reading.

The purpose of this book is to provide something comparable to the monkey see,
monkey do way of conveying how to use a closure to make a JavaScript object with
private fields. Theory, as such, is not bad, nor is it a problem to introduce theory for
a discussion, but making a full-fledged dissertation's theoretical backing as the price
to do something simple is a problem.

It is our hope that this book will let you understand why building, for instance, a game
UI in JavaScript is easier with functional reactive programming than with jQuery.

[2]
Chapter 1

Programming paradigms
There are multiple programming paradigms around, and not all are mutually
exclusive. Many programming languages are multiparadigm languages, supporting
the use of more than one paradigm, including not only JavaScript, but also the likes
of OCaml, PHP, Python, and Perl.

Note that you can at least sometimes use a paradigm with a language that is not
explicitly designed to support it. Object-oriented programming was originally
formulated not for languages such as Java or Ruby that are specifically intended to
support object-oriented programming, but as matter of an engineering discipline
originally used in languages that predate object-oriented programming.

Among the programming paradigms, we now have the following:

• Aspect-oriented programming: Some have suggested that the professional


development of a programmer moves from procedural programming to
object-oriented programming, then to aspect-oriented programming, and
finally to functional programming. A canonical example of an aspect-
oriented concern, for an aspect that is spread through the program in naïve
usage, is logging. Aspect-oriented programming deals with cross-cutting
aspects of programming, such as security, the diagnostic exposure of a state,
and logging.
• Declarative programming: One of the key concepts of functional reactive
programming is that it is declarative rather than imperative. In other words,
c = a + b does not mean take the present value of a, add the present value
of b, and store their sum in c. Instead, we declare a lasting relationship that
works a bit like C1 = A1 + B1 in a spreadsheet. If A1 or B1 changes, C1 is
immediately affected by the change. What is stored in C1 is not the value of
A1 plus the value of B1 at the time of assignment, but something more lasting
from which individual values may be obtained in a print on demand fashion.
• Defensive programming: Analogous to defensive driving, defensive coding
means writing code that behaves correctly when it is given something
defective. Functional reactive programming is, among other things, an
approach to either functioning correctly or degrading gracefully in the
face of network issues and nonideal, real-world conditions.

[3]
Introduction and Installation

• Functional programming: Here, the term function has its mathematical


rather than programming meaning. In imperative programming, functions
can (and most often, they do) manipulate states. Hence, an init() function
might initialize all of the data that a program initially needs to run initially. A
function is something that takes zero or more inputs and returns a result. For
example, f(x) = 3x+1, g(x) = sin(x), and h(x, y) = x'(y) (the derivative of x at y)
are all mathematical functions; none of them command any manipulation of
stateful data. A pure function is a function under a mathematical definition
that excludes telling how to deal with states. Functional programming also
allows and often includes, with the last derivative-based example, higher
order functions, or functions that act on functions (in calculus, a derivative
or an integral represents a higher order function, and iterative integration
includes a higher order function that takes another higher order function
as the input). Problems whose solutions center on abstract functions that
operate on abstract functions tend to be more appealing to computer science
types than something really used in the business world. The higher order
functions explored here will be relatively concrete. You need not use higher
order functions all the time, and once you've grasped the core concepts, they
are not hard to use.
• Imperative programming: Imperative programming is a common way of
programming, and for the majority of programmers who are first taught
imperative programming, it may seem the most natural way to work.
Functional reactive programming's marketing proposal includes a live
alternative to this basic approach. An alternative to the natural-seeming
tendency towards imperative programming is found in functional reactive
programming's declarative programming, pure functions (including higher
order functions) in functional programming, and the time series of reactive
programming.
• Information hiding: Steve McConnel's Code Complete describes several
methodologies, and tells us which are optimal for different settings (the
sweet spot for procedural programming is on smaller projects than on
object-oriented programming, for instance). For information hiding alone,
his recommendation was use this as much as possible. In generic information
hiding developments, a large project is approached by walling off secrets
within the larger area, and larger secrets are divided by walling off subsecrets.
A large portion of procedural programming, object-oriented programming,
and functional programming alike is intended to facilitate information hiding.
Information hiding is the software engineering concern behind the Law
of Demeter, for example, you may have up to one dot in a method call
(foo.bar()), but not two (foo.baz.bar()).

[4]
Random documents with unrelated
content Scribd suggests to you:
"I shall stay whatever happens," said Clarissa. "Is it likely I shall go
whilst Eva's fate hangs in the balance?"

"But it doesn't hang," said a husky voice from behind. "It's because I
knew you'd be in such a funk about her that I've come," and there advanced
into the circle a boy with grimed face and torn clothes that only those who
knew him best could recognize as Jack.

"Jack! Jack!" cried Betty, throwing her arms about him, and her
enormous feeling of relief found vent in hysterical laughter.

Questions poured in on the boy from every side.

"Where had he come from, where was Eva?" etc., but Tom, watching
Jack's face paling under its grime, knew him fairly played out.

"Eva is with Jessie," was all he could gasp out, and he would have fallen
to the ground but that Tom's arms caught him and laid him down gently on
a bed of fern.

"Give him air and space and a drink of water. His story can wait till later.
It's enough to know they are safe."

Tom's intervention saved Jack from fainting, and in a few minutes he


was able to relate what had occurred.

"And when Eva was put to bed," he said, "I ran off to join the beaters,
but I found the fire had swept on, taking a different course, so there was no
need for further alarm. Then I sneaked off on my own to see if there was a
chance of getting back to you, and I got through somehow."

"Came through the bush?" said Tom. "It was a horrible risk."

"But someone had to come, and I found a place where the fire had not
caught on much, and I made a dash for it and dodged it, racing from tree to
tree. No, I've not a burn on me. The soles of my boots are scorched and my
clothes half off my back, because I could not stop to pick my way, and the
fire had only penetrated quite a narrow way into the bush. The puzzle was
when I came to the far side of it to find the track. I should have been here
quicker else."

"But you found it all right at last."

"Yes, I found it safe enough. That's why I wanted to get off whilst it was
daylight. Even with a moon I should have lost my way."

"But what of those left behind?"

Jack made a little grimace. "I never thought of them, only of you, but it's
different, isn't it? Eva's all right. She'll sleep as sound as a top till the
morning, and for the rest, I don't belong to them as I do to Aunt Betty."

"No, no," said Clarissa Kenyon, seizing one of Jack's hands, and laying
her soft cheek against it. "They will only wonder vaguely what has become
of you, but my heart was breaking, Jack, breaking with the fear that I had
lost my little Eva. God bless you for bringing me the news of her safety."

Jack drew away his hand uneasily as her tears fell on it, and tried to rub
it clean.

"Come along, Jack, come down to the river and have a wash and a comb
up before we start for home," said Aunt Betty, in her matter-of-fact way, but
Jack never guessed that her heart was thumping against her ribs with joy
and pride in the boy who was ready to go through fire or water if he thought
that duty demanded it of him, and her pride found its lawful expression later
when she found herself alone with Tom for a minute.

"Yes," he answered with quiet satisfaction. "He promises to turn into a


boy that his father will be proud of one day."
CHAPTER XII

GOING HOME

"Jack," called Betty, a few days afterwards, "come in a minute. I want to


speak to you."

Jack passed in rapid review his conduct of the last few days, and decided
that there was nothing Aunt Betty could want to lecture him about, and yet
the brevity of the summons sounded like the preface to a lecture. He came
up the paddock rather reluctantly.

"Well," he said, joining her in the verandah, but not sitting down. "Don't
keep me long, there's a dear. I'm making an aeroplane, and it's frightfully
exciting."

"But I think the news I have for you will be frightfully exciting too," she
said smiling at him.

Jack's eyes shone like stars. "Is it that father's coming?"

Betty's heart smote her that she had raised the boy's hope so high only to
dash it again.

"Not quite so exciting as that, but something that will get you more
ready to go to England. Father wants you to go to school in Melbourne, a
boys' school that Uncle Tom knows about, and thinks a good one. Father is
very anxious that you should be working hard now so that you will be able
to take your place with other boys of your age when you go home."

Jack seized his cap from his head and sent it spinning into the air with a
whoop of triumph.

"I should say it just was exciting! Why, Aunt Betty, it's glorious."

His delight was so natural, that Betty would not dim it by any expression
of personal regret. Besides, although she did not tell Jack this, his father's
decision was the result of her own advice. She did not consider that the
experiment of sending him to the State school had answered. He was too
well known to every boy in the place, and was contracting acquaintances
she did not care for him to make, and imitating follies that were by no
means harmless, and she believed a complete change of companionship
would be better for him and for his progress in learning. She knew that
Captain Stephens was making not only a name but some money by his
inventive skill and mastership of aircraft, and that it was his full intention to
give Jack a good education, so she had written some months back
suggesting the change of school and saying that she believed her influence
over Jack stood a better chance of making itself felt when he was away
from her and constantly in need of her than now, when more than half his
time was spent out of her sight, and when her presence at home was so
completely a matter of course that he scarcely realised its value. And from
Jack's father had come an entirely reassuring answer. No mother could have
his little son's interests more entirely at heart than Betty, and he was quite
willing to accept her judgment, and that of the man who had acted the part
of a kind and wise elder brother to Jack, and to send him to the school Tom
Chance recommended.

"And you need not worry about ways and means. Let Jack have a proper
school outfit. You will know what he needs better than I. It was certainly
my wish at first that he should remain with you at all hazards until I could
come and fetch him, but the time has been longer than I at first expected,
and I quite see the force of your argument that he shall be able to take his
proper standing with other boys of his age on his return, and possibly the
education of a State school would hardly prepare him for this. Is it asking
too much that Tom Chance will keep an eye to him as regards religious
matters? A boy's first plunge into school life is an important era in his life.
I'm not sure that Mr. Chance is still in the colony, but if you are in touch
with him tell him what I feel about it."

All this was running through Betty's mind as she listened to Jack's
outpouring of delight.

"And when am I going, Aunt Betty?"


"Next term if you can be taken in. I've already written to the head-master
about you, for this has been in our heads for some time, although I could
not mention it to you until I knew father's decision. Now I see no reason
why you should not travel back to Melbourne under Uncle Tom's care."

Jack fairly danced with joy.

"I'm off, Aunt Betty; I'm off to find Uncle Tom, and to tell Eva. She'll
mind rather much, I fancy, but I'll tell her she can write to me if she likes,
and I'll answer as I get time," and away he flew, leaving Betty half amused
and half heart-sore.

"A budding lord of creation," she said to Tom later in the day when he
came to talk matters over with her.

"Women and girls find their right place in looking after him."

The words were playful, but there was an under-lying sadness in them.

"It's partly the fault of the women and the girls who spoil boys and men,
isn't it? But there's scarcely one amongst us but owns in his secret heart that
all that is noble in him he owes to the influence of some good woman—a
mother, a sister, or an aunt—and Jack, come to man's estate, will look back
and call Aunt Betty's name blessed."

Tears stood in Betty's eyes, but her smile was sweet and tender.

"If that prophecy comes true, I shall consider that life has been worth
living," she said.

"Let us hope that there may be other causes by that time which will
make your life very much worth living; others who will need you even
more than little Jack, a husband, perhaps, and—children of your own."

The colour mounted to Betty's face flooding it from brow to chin, then
faded leaving her deadly pale. Tom was standing over her looking down on
her with a smile that told her more clearly than any words that he loved her,
that the husband his imagination pictured was himself.
"Betty," he said, using her Christian name for the first time, "I did not
mean to speak yet. I meant to wait until I am recalled to England and have a
likelihood of a home to offer you, but your regret at losing your Jack led me
on. Should I do, can you think of me as the husband? Betty, my dear, my
whole heart cries out to you, I love you so. I don't know when it began, but
I almost think it was the first day we ever met, and you caught me at
cricket. It will be the biggest blow of my life if you catch me out now.
Betty, my sweet one, what answer will you give me? My whole happiness
hangs on it. Is it yes, or no?"

Betty looked into his face with a tremulous smile, put out her hands to
him, and the next moment was clasped in his arms.

"My darling," he said, as he reverently kissed her, "you shall never have
cause to regret your decision."

In the first few moments of their tumultuous happiness neither wished to


speak; it was enough for Betty to feel Tom's arm round her, and to know
that she was his for evermore, his helpmeet, sharing his home and work, the
one man in the world she had ever loved, for a pretty helpful girl like Betty
had had other men who wished to marry her, but not one of them had even
set her pulses beating, much less suggested himself as her husband, but now
she had entered her kingdom! Was ever girl quite as happy as she was at
this moment?

Later on they talked of their future. Tom had mapped out work that
would take him about two years to carry through, and then he meant to go
home.

"And you will come with me, Betty darling, come with me as my wife,"
he said joyously. "I wonder if you realise what you are doing in marrying
me. It's rather like catching a lark and shutting it up in a close dark cage, for
my work will lie in some slum parish probably, where sorrow and sin will
close you in on every side, and after your free country-life out here, you
will feel choked by it often and often."

"I daresay I shall, but—I shall have you," said Betty, simply. "Shall we
go and tell mother?"
Mr. and Mrs. Treherne's consent was a foregone conclusion, and
separation from their only daughter being as yet a thing in the distance, left
them free now to rejoice in her happiness. Ted's congratulations when he
came in from the farm were rather less hearty.

"It's rather a mean trick to play," he said. "You had all England to choose
from, and you come out here and want to carry off our Betty, and there's not
a girl who can hold a candle to her in all the colony, is there, mother?"

"Not one," said Mrs. Treherne, giving the hand she held a squeeze.

"And that's the very reason why I want to take her home when the time
comes," said Tom with a happy laugh. "I want them to see the kind of girl
the colony can produce. I don't underrate her, Ted."

"I won't stay and be discussed as if I wasn't here," said Betty, blushing a
little. "Ought not we to go and see Clarissa, Tom?" so they walked off
together down the paddock, hand-in-hand.

"And that's how they'll walk off one day for good and all," said Ted,
watching them moodily from the verandah. "Hang it all, mother. I wonder
you can take it so quietly. Why can't she marry some man in the colony, and
stay in the land she belongs to? They will only look down upon her in
England," but that fired Mrs. Treherne into speech.

"Look down on her! Look down on my Betty! Isn't it because I know


that to Tom she is the one woman in all the world that I give my consent to
his carrying her away? But don't rub it in, Ted," and her tone was a little
weary. "She's not going yet for a year or two, and every mother has to face
the fact that the young ones she has reared and loved will fly off sometime
and make nests of their own. It's God's law, and there is no escaping it."

Ted bent and brushed his bronzed cheek against hers.

"No fear, mother. There's one who will stick by the old birds, and keep
their nest warm and dry for them," he said gruffly, and stirred by an unusual
emotion he strolled off to the farm and solaced himself with a pipe.
Meanwhile no explanations were necessary with Clarissa. She just
glanced at the smiling faces, saw the clasped hands, and burst into a laugh.

"So it's settled at last," she said, her own hands closing over their clasped
ones, "but the wonder to me is why you have been so long about it, for
you've known your own minds long enough. Betty, my dear, you're a lucky
woman."

"As if I didn't know it," protested Betty, as Clarissa kissed her.

"But I remember your telling me almost the first night I came that you
should like a sister just like Betty," Tom grumbled.

"So I did, so I do, but all the same I call her a lucky sister in marrying
you," and with that assertion Betty was well content.

"Shall you tell the children?" Clarissa asked later.

"Oh yes," Betty said. "I never see the use of making mysteries out of
things that are clear and true as daylight, and to Jack it will make no
difference. He claimed Tom as his uncle long ago. Where are they, Clarissa?
Jack rushed off here in great excitement to tell the news of his going to
school, and I have not seen him since."

"They are in the garden, I think. Eva is full of lamentation that she was
not born a boy, so that she might go to school with Jack, but he comforts
her by reminding her that she would be in a lower form, and would see little
of him!"

"He's a little beyond himself; he'll come back to his bearings directly,"
Tom said. "It's the first event of importance that has come to him. Come,
Betty; we will find them."

They sat side by side in the swing, their heads close together deep in
conversation, but at sight of Aunt Betty and Tom, Jack sprang to the ground
and came rushing towards them.
"Uncle Tom, has Aunt Betty told you? Do you know I'm going to
school?"

"Yes, I know that and something else which makes me very glad, happier
than I've ever been in all my life."

"What?" asked Jack and Eva in chorus.

"That some day, when I go home, Aunt Betty will marry me, and go
home with me as my wife. That's a big bit of news, isn't it, Jack?"

Eva laughed and clapped her hands, but Jack stood looking from Tom to
Aunt Betty, with a slight air of bewilderment.

"Then she'll stay with you for ever and ever?" he said.

"I hope so, Jack," said Tom, with a little laugh.

"And you'll be my real uncle, not a pretence one?"

"Yes," said Tom again.

"Then I'm jolly glad, and oh, Aunt Betty," fresh light dawning on him, "it
will mean that I'll have you always too the same as I do now. I think I'm
almost as glad as Uncle Tom," and forgetful of his boyish dignity his arms
closed round her neck in a rapturous hug, and Betty, as she held him fast,
felt no congratulation on her engagement was quite so dear and sweet as
his.

*****

The days would have dragged heavily after Jack's departure but for the
new great happiness which filled Betty's heart to overflowing. Tom had
taken Jack to school and installed him there, a very good school Tom told
her, with a wholesome religious basis, where "Jack will get such teaching as
you and his father would wish him to have," Tom wrote, and Betty was
content in this, as in all things, to rely upon Tom's judgment.
Months passed by, Jack came for his first holidays full of his school-
mates, and, what pleased Betty more, very full of his work.

He was developing rather an extraordinary turn for mathematics and


mechanics, and spent most of his recreation time in the workshop attached
to his school, intent upon models of various sorts, and Betty rejoiced and
sympathised with his hobby. It was all helping to get him ready for his
future work.

Meanwhile, as the months ran into years, Betty went on quite quietly and
contentedly with her own work—her preparations for her marriage which
she now knew not to be far distant. Had not Tom said he would come to
fetch her in about two years? The dainty garments she fashioned were
finished one by one and laid by in a box which she named her glory box.

"For it is a glory, mother, to be loved by a man like Tom," she said.

"Then my gift shall be the household linen," said Mrs. Treherne, and side
by side with the glory box there stood a large chest which received Mrs.
Treherne's contributions as they were folded and marked in readiness for
Betty's marriage.

And true to his promise when the two years were nearly completed Tom
wrote a letter, almost incoherent in its happiness, to tell her he was coming
to claim his own.

"I shall bring Jack along with me, for, as you know, his holidays will be
due, and the dear boy is looking forward with sober happiness to his
Confirmation day. I always promised to be present at it if I were still in the
Colony, and the Bishop, I hear, holds one at Wallaroo about the 21st of
December. Jack's preparation has been a careful one, and by his letters to
me I think his mind is fully made up to continue Christ's faithful soldier and
servant unto his life's end. He had his choice of being confirmed in the
cathedral at Melbourne, when some other lads from his school received the
laying on of hands, but he wrote that he would rather wait for the
Confirmation in his own little church at home, 'when you and Aunt Betty
will be there with me.' I thought it sweet of the boy, but, indeed, my Betty, I
think Jack will turn into a boy you will have every cause to be proud of."
And the post which brought that letter brought another which was almost
as important. Jack's father was coming to take his boy home; indeed, within
a week of the letter's departure he would be on his way. Pressure of business
would make his stay in the colony a short one, "but I always promised Jack
to come and fetch him, and I will keep my word."

He gave the name of the liner in which his passage was taken, and the
date when she was due at Melbourne.

"But mother—it's too delightful," said Betty, looking up from the letter.
"Jack's father is coming and is due in Melbourne on the 18th or 19th of
December. By good luck he should be here on Jack's Confirmation day.
Won't it be beautiful if he is?"

And through the coming weeks Betty lived on in happy expectation,


wondering what she had done to deserve such happiness. Jack was coming,
and Jack's father, and, what was greater still, her own Tom, from whom,
God willing, she would never again be separated.

Clarissa had clamoured to make her her wedding gown, but Betty
asserted she did not mean to have one.

"Tom and I are of one mind," she said. "We think the greatest and holiest
day of our lives shall not be desecrated by flutter and fuss. I'll be married in
a coat and skirt, a white one if you prefer it, and we mean to have no fuss of
any kind, and we want only those present who love us, and will say their
prayers for us. We have not yet settled the day, but it will be pretty soon
after he comes, for he has marching orders to return to England. He means
to take our passages for about the end of the year. Don't you wish you were
coming too?"

"No, I don't," said Clarissa, vehemently. "I love this place and its kind,
warm-hearted people, and I love your father and mother, and mean to make
up your loss to them as far as I can. I know it will be very imperfectly
accomplished, but just think of the desolation which will be theirs when
you've left them for good, gone out of their reach, Betty."
Tears stood in Betty's eyes. "Yes, I know, and often I wonder at myself
for doing it, and yet—it's not that I love them less than I ever did, that I
don't know what I'm leaving behind me, but if Tom were going to the
uttermost parts of the earth I feel my call to go with him. I love him better
than life itself, Clarissa. Don't you know what I mean?"

Clarissa was very white. "Yes, I loved George like that, but, unlike you, I
married without the sanction of my father, and I never felt that God's
blessing followed me as it will follow you, my Betty, going before and after
like the pillar of cloud that guided the Israelites. It's because I love George
so dearly that I don't want to go home. I want to live and die in the country
where we spent our short married life together."

On the 16th of December Betty stood in her simple white gown waiting
at the corner of the green lane for the evening coach that was to bring Tom
and Jack from the station, and as she heard the rattle of the wheels and the
sound of the galloping horses breasting the hill, her own heart beat in joyful
sympathy, for her happiness was close at hand. And almost before the coach
stood still, Tom and Jack had jumped from their seats on the top, and were
taking her eagerly between them up the green lane towards the farm.

"But, Jack, you grow by feet, not by inches," said Betty, putting him a
little away from her that she might see him more distinctly. "Father will feel
quite shy of you."

"More than I'll be of him, then. Do you see he's won a medal for his last
invention, Aunt Betty? Isn't he glorious? The boys at school chaff me
because they say I'm always boasting about father, and I tell them they
would boast too if they had a father like him to boast about. Why, there's
Eva, waiting at the gate. I'll just run on and have a word with her."

Then Tom and Betty were left alone, and took a long look into each
other's eyes.

"Well, darling! Are you ready for me?"

"Quite ready. Have I not said so often enough."


"And you will marry me any day I like?"

"Yes, mother knows we both wish it to be as quiet as possible, to have no


splash breakfast, not even a wedding cake."

"Then I've settled it," said Tom joyously. "I saw the Bishop at
Launceston and he's kind enough to express a wish to perform the Service.
The Confirmation is to be quite early in the morning of the twenty-first and
if you could fix the wedding to take place immediately after it, it would be
delightful. It's short notice, but will it suit you, my darling? The time has
dragged just lately Your face, your dear face, has come between me and my
work. We've been pretty patient, I think. Will your mother object?"

"The time will suit me, and I don't think mother will object," said Betty,
slipping her hand into his. "She is prepared for us to sail about the end of
the year. She knows the parting is quite close; sometimes I think the strain
tells on her. It will be better for her when it's over. We needn't tell anyone,
Tom. We'll be married and slip away somewhere."

"To Melbourne," said Tom, "or we'll keep our Christmas at Launceston
and your luggage can follow us there."

"And it's a good time in a way for us to be going, for Jack's father will be
here and take away the bitterness of the parting. He will be following us
soon to England."

"Betty, are you afraid, afraid to trust yourself to me all that long distance
from home? It's a tremendous trust you give me."

Betty turned her face, glorified by love, to his.

"Afraid! with you, Tom!" and Tom was satisfied.


CHAPTER XIII

TWO VENTURES OF HOPE

It was the evening before Jack's confirmation and Tom's and Betty's
wedding day. Up and down the paddock paced Tom and Jack, arm in arm,
and Tom's heart was almost as full of the boy who gripped his arm as of the
fair woman whom he would call wife on the morrow.

"It will be a great day for us both, Jack," he said, giving expression to his
thought.

"Yes, Uncle Tom."

"Your whole life may depend upon your decision."

"Yes, it's rather awful when you come to think of it."

"It would be if you did not feel sure that the hosts of God, that God
Himself is behind you."

"Uncle Tom, I want to grow into just such a man as you."

"Ah no," said Tom quickly. "There is but one model for us all to copy,
the man Christ Jesus."

Jack's heart was too full to answer.

"I do wish father could have got here in time," he said, wistfully.

"Aunt Betty thinks he will appear some time to-morrow, but she does not
think it possible that he can arrive in time for the service."

"I heartily wish he could for all our sakes. Aunt Betty is almost as keen
as you, for she longs to get a glimpse of him before I carry her off. We leave
for Launceston in the afternoon."
"It would be just beastly if I did not know that I shall see you both in
England in a few months' time; but now I shall have father, and going about
with him all the time, I shan't be able to miss anyone very much. I wish
girls didn't cry. Whenever I talk of going to England, Eva cries or blows her
nose to prevent it! Men aren't made like that, are they? It would be horrid if
they were! I always tell her to dry up, and perhaps some day, when I'm a
man, I'll come out and marry her."

Tom laughed out loud; it was rather refreshing to find that the boy at his
side, so manly in some ways, was still at heart as innocent as a child.

"But Eva might have found someone else to marry by that time," he
suggested.

"Oh, of course if she did it would be all right, and she would not want
me," said Jack, nonchalantly, in no way affected at the thought of the loss of
his ladylove. "She has cheered up a bit since Aunt Betty has consented to
her being bridesmaid, although she's not to be dressed up fine, just a new
white frock and a white muslin hat, she says."

Then Aunt Betty's voice, ringing down the paddock, called them both in
to supper.

The little church was full to overflowing on the morrow, for quick as had
been the final choice of the wedding day the rumour of it had spread like
fire through the township, and loving hands had been busy on the previous
afternoon, decorating the tiny sanctuary with Madonna lilies and other
white flowers for the double service. And all had been carried through so
quickly and quietly that no one at the farm knew anything of it.

It was only a handful of candidates that were presented for


Confirmation, not more than a score, but of those it may be said that the
present Vicar had spent much time and prayer on their preparation. The
candidates were ranged in the front seats, and quite at the back of the
church was seated the party from the farm, with Clarissa and Eva, and the
intervening benches were filled with neighbours from the township. The
only one who had come from a distance was Jessie Butler, who hearing that
her friend of earlier years was to be confirmed, and remembering his
presence at her own confirmation, had come to stay a night or two with
someone in Wallaroo on purpose to be present when Jack was confirmed.

The congregation rose simultaneously to its feet as the Bishop, preceded


by the Vicar, appeared from the tiny vestry, and the service began with a
hymn, during the singing of which the rather unusual sound of a motor
driving at full speed and brought to a sudden standstill outside the open
door of the little church, fell upon Betty's ear. Could it be the sudden arrival
of a belated candidate. But creeping quietly into the church, her glad eyes
recognised Jack's father, standing hesitatingly in the doorway. He had
motored all the way from Launceston to be present at his son's
Confirmation, and Mr. Treherne, with a quick movement, motioned him to
Betty's side. It was the one presence she and Jack needed to make the day
perfect in their eyes. And a great joy and thankfulness filled the elder Jack's
heart, as he recognised his tall boy standing at the head of the row of boy
candidates, and heard his emphatic promise to renew his baptismal
promises and serve God manfully for the rest of his life, and when it came
to Jack's turn to kneel before the Bishop and receive the laying on of hands,
Betty's hand sought for a moment that of her brother-in-law, and together
they sank upon their knees and prayed very fervently for God's blessing on
the head of the boy who was almost equally dear to both of them.

The Bishop's charge was a very simple one, but the earnest words could
scarcely fail to reach the hearts of all who listened to them, and a reverent
hush fell on the congregation as he pronounced the blessing. And then there
was a pause for those who wished to leave the church, but not one stirred
from his place. They waited for what was to follow. Then Tom, with a
glance at Betty, moved to the chancel steps to be followed immediately by
Betty, leaning on her father's arm, while little Eva with round wondering
eyes took her place behind, and forthwith the wedding service proceeded.
Jack's father, meanwhile, had walked up the church and taken his own place
by his son.

Then, in low clear voices, fully audible to all present, Tom and Betty
spoke out their promises to be true and loyal to each other as long as life
should last. There were those in the congregation who beforehand had
grumbled that such an unusual event as a wedding should be carried
through in what they were pleased to call such a hole-and-corner fashion,
but criticism vanished when the simply attired bride came down the church
upon her husband's arm. All felt the bright-faced bride was in her right
setting.

The Bishop, after shaking hands with the wedding couple, had to hurry
off for another function, and then the wedding party walked quietly back to
the farm, where a meal, laid in readiness beforehand, awaited them. Jack sat
by his father and Tom and Betty were placed in the centre of the table. Just
at the end of the meal, Mr. Treherne rose to his feet.

"God bless my girl, as good a daughter as ever stepped, and God bless
the man she has married," was all he said, and Betty turned and kissed him.

The last half hour before the buggy came round to carry them to the
station was spent by Betty in her mother's room. What passed between them
none knew, but when Betty came out in her neat travelling dress, there were
traces of tears in her eyes. Then came the hubbub of adieus, and more
farewells had to be spoken at the gate of the paddock, where half the
township had gathered to wish the bride and bridegroom farewell. Missiles
of all description had been tabooed, but the kindly cheers of her neighbours,
the eager outstretched hands which grasped hers, were a lovely ending to a
happy life, thought Betty, as she drove off with her husband at her side. For
she fully realised that one page of her life was folded down, but another
page, very fair and white, was spread out before her.

What shall be written upon it is not for us to say. Some blots will surely
blister it.

"Into each life some rain must fall,


Some days must be dark and dreary."

But now as Betty drives away with sunshine in her face and sunshine in
her heart, we breathe the prayer that such days will be few and far between.
EPILOGUE

Extract from an English daily paper five years later.

"Special mention should be made of the amazing exhibition of prowess


on the part of Lieutenant Stephens in yesterday's military aeronautic
manoeuvres on Salisbury Plain. His aeroplane, the combined creation of his
father and himself, is of such perfect construction that it is likely to make
their name famous, and the Lieutenant's command of it left nothing to be
desired. He executed feats of skill which have rarely been surpassed.
England has just cause for pride in her present race of young men, prepared
to face every danger in the service of their country, for it is an open secret
that upon the efficiency of our air fleet, the future safety of our island home
will very largely depend."

This paper, with others, was forwarded in due time to Mrs. Kenyon, who
read aloud the paragraph just quoted to Eva, now a blooming girl of
seventeen. She flew round the table and snatched it from her mother's
hands.

"Let me read it for myself, mother. We shall all feel proud of him. He's
playing our childish game of subduing giants to some purpose, isn't he?
He's fairly earned his rights to his title of 'Jack, the Englishman.' I'm ever so
glad. I'll run across to the farm and tell them about it."

Clarissa laughed at the girl's enthusiasm.

"They are perfectly certain to have these papers as well as ourselves.


Isn't he their grandson?"

"And a grandson to be proud of! I wish he were mine, or a brother or


something. Oh mother! I wonder—Shall we ever see him again?"
*** END OF THE PROJECT GUTENBERG EBOOK JACK THE
ENGLISHMAN ***

Updated editions will replace the previous one—the old editions will
be renamed.

Creating the works from print editions not protected by U.S.


copyright law means that no one owns a United States copyright in
these works, so the Foundation (and you!) can copy and distribute it
in the United States without permission and without paying
copyright royalties. Special rules, set forth in the General Terms of
Use part of this license, apply to copying and distributing Project
Gutenberg™ electronic works to protect the PROJECT GUTENBERG™
concept and trademark. Project Gutenberg is a registered trademark,
and may not be used if you charge for an eBook, except by following
the terms of the trademark license, including paying royalties for use
of the Project Gutenberg trademark. If you do not charge anything
for copies of this eBook, complying with the trademark license is
very easy. You may use this eBook for nearly any purpose such as
creation of derivative works, reports, performances and research.
Project Gutenberg eBooks may be modified and printed and given
away—you may do practically ANYTHING in the United States with
eBooks not protected by U.S. copyright law. Redistribution is subject
to the trademark license, especially commercial redistribution.

START: FULL LICENSE


THE FULL PROJECT GUTENBERG LICENSE
PLEASE READ THIS BEFORE YOU DISTRIBUTE OR USE THIS WORK

To protect the Project Gutenberg™ mission of promoting the free


distribution of electronic works, by using or distributing this work (or
any other work associated in any way with the phrase “Project
Gutenberg”), you agree to comply with all the terms of the Full
Project Gutenberg™ License available with this file or online at
www.gutenberg.org/license.

Section 1. General Terms of Use and


Redistributing Project Gutenberg™
electronic works
1.A. By reading or using any part of this Project Gutenberg™
electronic work, you indicate that you have read, understand, agree
to and accept all the terms of this license and intellectual property
(trademark/copyright) agreement. If you do not agree to abide by all
the terms of this agreement, you must cease using and return or
destroy all copies of Project Gutenberg™ electronic works in your
possession. If you paid a fee for obtaining a copy of or access to a
Project Gutenberg™ electronic work and you do not agree to be
bound by the terms of this agreement, you may obtain a refund
from the person or entity to whom you paid the fee as set forth in
paragraph 1.E.8.

1.B. “Project Gutenberg” is a registered trademark. It may only be


used on or associated in any way with an electronic work by people
who agree to be bound by the terms of this agreement. There are a
few things that you can do with most Project Gutenberg™ electronic
works even without complying with the full terms of this agreement.
See paragraph 1.C below. There are a lot of things you can do with
Project Gutenberg™ electronic works if you follow the terms of this
agreement and help preserve free future access to Project
Gutenberg™ electronic works. See paragraph 1.E below.
1.C. The Project Gutenberg Literary Archive Foundation (“the
Foundation” or PGLAF), owns a compilation copyright in the
collection of Project Gutenberg™ electronic works. Nearly all the
individual works in the collection are in the public domain in the
United States. If an individual work is unprotected by copyright law
in the United States and you are located in the United States, we do
not claim a right to prevent you from copying, distributing,
performing, displaying or creating derivative works based on the
work as long as all references to Project Gutenberg are removed. Of
course, we hope that you will support the Project Gutenberg™
mission of promoting free access to electronic works by freely
sharing Project Gutenberg™ works in compliance with the terms of
this agreement for keeping the Project Gutenberg™ name associated
with the work. You can easily comply with the terms of this
agreement by keeping this work in the same format with its attached
full Project Gutenberg™ License when you share it without charge
with others.

1.D. The copyright laws of the place where you are located also
govern what you can do with this work. Copyright laws in most
countries are in a constant state of change. If you are outside the
United States, check the laws of your country in addition to the
terms of this agreement before downloading, copying, displaying,
performing, distributing or creating derivative works based on this
work or any other Project Gutenberg™ work. The Foundation makes
no representations concerning the copyright status of any work in
any country other than the United States.

1.E. Unless you have removed all references to Project Gutenberg:

1.E.1. The following sentence, with active links to, or other


immediate access to, the full Project Gutenberg™ License must
appear prominently whenever any copy of a Project Gutenberg™
work (any work on which the phrase “Project Gutenberg” appears,
or with which the phrase “Project Gutenberg” is associated) is
accessed, displayed, performed, viewed, copied or distributed:
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.

1.E.2. If an individual Project Gutenberg™ electronic work is derived


from texts not protected by U.S. copyright law (does not contain a
notice indicating that it is posted with permission of the copyright
holder), the work can be copied and distributed to anyone in the
United States without paying any fees or charges. If you are
redistributing or providing access to a work with the phrase “Project
Gutenberg” associated with or appearing on the work, you must
comply either with the requirements of paragraphs 1.E.1 through
1.E.7 or obtain permission for the use of the work and the Project
Gutenberg™ trademark as set forth in paragraphs 1.E.8 or 1.E.9.

1.E.3. If an individual Project Gutenberg™ electronic work is posted


with the permission of the copyright holder, your use and distribution
must comply with both paragraphs 1.E.1 through 1.E.7 and any
additional terms imposed by the copyright holder. Additional terms
will be linked to the Project Gutenberg™ License for all works posted
with the permission of the copyright holder found at the beginning
of this work.

1.E.4. Do not unlink or detach or remove the full Project


Gutenberg™ License terms from this work, or any files containing a
part of this work or any other work associated with Project
Gutenberg™.

1.E.5. Do not copy, display, perform, distribute or redistribute this


electronic work, or any part of this electronic work, without
prominently displaying the sentence set forth in paragraph 1.E.1
with active links or immediate access to the full terms of the Project
Gutenberg™ License.

1.E.6. You may convert to and distribute this work in any binary,
compressed, marked up, nonproprietary or proprietary form,
including any word processing or hypertext form. However, if you
provide access to or distribute copies of a Project Gutenberg™ work
in a format other than “Plain Vanilla ASCII” or other format used in
the official version posted on the official Project Gutenberg™ website
(www.gutenberg.org), you must, at no additional cost, fee or
expense to the user, provide a copy, a means of exporting a copy, or
a means of obtaining a copy upon request, of the work in its original
“Plain Vanilla ASCII” or other form. Any alternate format must
include the full Project Gutenberg™ License as specified in
paragraph 1.E.1.

1.E.7. Do not charge a fee for access to, viewing, displaying,


performing, copying or distributing any Project Gutenberg™ works
unless you comply with paragraph 1.E.8 or 1.E.9.

1.E.8. You may charge a reasonable fee for copies of or providing


access to or distributing Project Gutenberg™ electronic works
provided that:

• You pay a royalty fee of 20% of the gross profits you derive
from the use of Project Gutenberg™ works calculated using the
method you already use to calculate your applicable taxes. The
fee is owed to the owner of the Project Gutenberg™ trademark,
but he has agreed to donate royalties under this paragraph to
the Project Gutenberg Literary Archive Foundation. Royalty
payments must be paid within 60 days following each date on
which you prepare (or are legally required to prepare) your
periodic tax returns. Royalty payments should be clearly marked
as such and sent to the Project Gutenberg Literary Archive
Foundation at the address specified in Section 4, “Information
about donations to the Project Gutenberg Literary Archive
Foundation.”

• You provide a full refund of any money paid by a user who


notifies you in writing (or by e-mail) within 30 days of receipt
that s/he does not agree to the terms of the full Project
Gutenberg™ License. You must require such a user to return or
destroy all copies of the works possessed in a physical medium
and discontinue all use of and all access to other copies of
Project Gutenberg™ works.

• You provide, in accordance with paragraph 1.F.3, a full refund of


any money paid for a work or a replacement copy, if a defect in
the electronic work is discovered and reported to you within 90
days of receipt of the work.

• You comply with all other terms of this agreement for free
distribution of Project Gutenberg™ works.

1.E.9. If you wish to charge a fee or distribute a Project Gutenberg™


electronic work or group of works on different terms than are set
forth in this agreement, you must obtain permission in writing from
the Project Gutenberg Literary Archive Foundation, the manager of
the Project Gutenberg™ trademark. Contact the Foundation as set
forth in Section 3 below.

1.F.

1.F.1. Project Gutenberg volunteers and employees expend


considerable effort to identify, do copyright research on, transcribe
and proofread works not protected by U.S. copyright law in creating
the Project Gutenberg™ collection. Despite these efforts, Project
Gutenberg™ electronic works, and the medium on which they may
be stored, may contain “Defects,” such as, but not limited to,
incomplete, inaccurate or corrupt data, transcription errors, a
copyright or other intellectual property infringement, a defective or
damaged disk or other medium, a computer virus, or computer
codes that damage or cannot be read by your equipment.

1.F.2. LIMITED WARRANTY, DISCLAIMER OF DAMAGES - Except for


the “Right of Replacement or Refund” described in paragraph 1.F.3,
the Project Gutenberg Literary Archive Foundation, the owner of the
Project Gutenberg™ trademark, and any other party distributing a
Project Gutenberg™ electronic work under this agreement, disclaim
all liability to you for damages, costs and expenses, including legal
fees. YOU AGREE THAT YOU HAVE NO REMEDIES FOR
NEGLIGENCE, STRICT LIABILITY, BREACH OF WARRANTY OR
BREACH OF CONTRACT EXCEPT THOSE PROVIDED IN PARAGRAPH
1.F.3. YOU AGREE THAT THE FOUNDATION, THE TRADEMARK
OWNER, AND ANY DISTRIBUTOR UNDER THIS AGREEMENT WILL
NOT BE LIABLE TO YOU FOR ACTUAL, DIRECT, INDIRECT,
CONSEQUENTIAL, PUNITIVE OR INCIDENTAL DAMAGES EVEN IF
YOU GIVE NOTICE OF THE POSSIBILITY OF SUCH DAMAGE.

1.F.3. LIMITED RIGHT OF REPLACEMENT OR REFUND - If you


discover a defect in this electronic work within 90 days of receiving
it, you can receive a refund of the money (if any) you paid for it by
sending a written explanation to the person you received the work
from. If you received the work on a physical medium, you must
return the medium with your written explanation. The person or
entity that provided you with the defective work may elect to provide
a replacement copy in lieu of a refund. If you received the work
electronically, the person or entity providing it to you may choose to
give you a second opportunity to receive the work electronically in
lieu of a refund. If the second copy is also defective, you may
demand a refund in writing without further opportunities to fix the
problem.

1.F.4. Except for the limited right of replacement or refund set forth
in paragraph 1.F.3, this work is provided to you ‘AS-IS’, WITH NO
OTHER WARRANTIES OF ANY KIND, EXPRESS OR IMPLIED,
INCLUDING BUT NOT LIMITED TO WARRANTIES OF
MERCHANTABILITY OR FITNESS FOR ANY PURPOSE.

1.F.5. Some states do not allow disclaimers of certain implied


warranties or the exclusion or limitation of certain types of damages.
If any disclaimer or limitation set forth in this agreement violates the
law of the state applicable to this agreement, the agreement shall be
interpreted to make the maximum disclaimer or limitation permitted
by the applicable state law. The invalidity or unenforceability of any
provision of this agreement shall not void the remaining provisions.

1.F.6. INDEMNITY - You agree to indemnify and hold the Foundation,


the trademark owner, any agent or employee of the Foundation,
anyone providing copies of Project Gutenberg™ electronic works in
accordance with this agreement, and any volunteers associated with
the production, promotion and distribution of Project Gutenberg™
electronic works, harmless from all liability, costs and expenses,
including legal fees, that arise directly or indirectly from any of the
following which you do or cause to occur: (a) distribution of this or
any Project Gutenberg™ work, (b) alteration, modification, or
additions or deletions to any Project Gutenberg™ work, and (c) any
Defect you cause.

Section 2. Information about the Mission


of Project Gutenberg™
Project Gutenberg™ is synonymous with the free distribution of
electronic works in formats readable by the widest variety of
computers including obsolete, old, middle-aged and new computers.
It exists because of the efforts of hundreds of volunteers and
donations from people in all walks of life.

Volunteers and financial support to provide volunteers with the


assistance they need are critical to reaching Project Gutenberg™’s
goals and ensuring that the Project Gutenberg™ collection will
remain freely available for generations to come. In 2001, the Project
Gutenberg Literary Archive Foundation was created to provide a
secure and permanent future for Project Gutenberg™ and future
generations. To learn more about the Project Gutenberg Literary
Archive Foundation and how your efforts and donations can help,
see Sections 3 and 4 and the Foundation information page at
www.gutenberg.org.

Section 3. Information about the Project


Gutenberg Literary Archive Foundation
The Project Gutenberg Literary Archive Foundation is a non-profit
501(c)(3) educational corporation organized under the laws of the
state of Mississippi and granted tax exempt status by the Internal
Revenue Service. The Foundation’s EIN or federal tax identification
number is 64-6221541. Contributions to the Project Gutenberg
Literary Archive Foundation are tax deductible to the full extent
permitted by U.S. federal laws and your state’s laws.

The Foundation’s business office is located at 809 North 1500 West,


Salt Lake City, UT 84116, (801) 596-1887. Email contact links and up
to date contact information can be found at the Foundation’s website
and official page at www.gutenberg.org/contact

Section 4. Information about Donations to


the Project Gutenberg Literary Archive
Foundation
Project Gutenberg™ depends upon and cannot survive without
widespread public support and donations to carry out its mission of
increasing the number of public domain and licensed works that can
be freely distributed in machine-readable form accessible by the
widest array of equipment including outdated equipment. Many
small donations ($1 to $5,000) are particularly important to
maintaining tax exempt status with the IRS.

The Foundation is committed to complying with the laws regulating


charities and charitable donations in all 50 states of the United
States. Compliance requirements are not uniform and it takes a
considerable effort, much paperwork and many fees to meet and
keep up with these requirements. We do not solicit donations in
locations where we have not received written confirmation of
compliance. To SEND DONATIONS or determine the status of
compliance for any particular state visit www.gutenberg.org/donate.

While we cannot and do not solicit contributions from states where


we have not met the solicitation requirements, we know of no
prohibition against accepting unsolicited donations from donors in
such states who approach us with offers to donate.

International donations are gratefully accepted, but we cannot make


any statements concerning tax treatment of donations received from
outside the United States. U.S. laws alone swamp our small staff.

Please check the Project Gutenberg web pages for current donation
methods and addresses. Donations are accepted in a number of
other ways including checks, online payments and credit card
donations. To donate, please visit: www.gutenberg.org/donate.

Section 5. General Information About


Project Gutenberg™ electronic works
Professor Michael S. Hart was the originator of the Project
Gutenberg™ concept of a library of electronic works that could be
freely shared with anyone. For forty years, he produced and
distributed Project Gutenberg™ eBooks with only a loose network of
volunteer support.

You might also like