100% found this document useful (1 vote)
6 views

Functional Programming in JavaScript How to improve your JavaScript programs using functional techniques First Edition Luis Atencio download

The document is an overview of the book 'Functional Programming in JavaScript' by Luis Atencio, which aims to improve JavaScript programming using functional techniques. It includes links to download the book and other related resources, as well as a detailed table of contents outlining various topics covered in the book. The author emphasizes the importance of functional programming principles for creating modular and maintainable code.

Uploaded by

monekjejigua7
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
100% found this document useful (1 vote)
6 views

Functional Programming in JavaScript How to improve your JavaScript programs using functional techniques First Edition Luis Atencio download

The document is an overview of the book 'Functional Programming in JavaScript' by Luis Atencio, which aims to improve JavaScript programming using functional techniques. It includes links to download the book and other related resources, as well as a detailed table of contents outlining various topics covered in the book. The author emphasizes the importance of functional programming principles for creating modular and maintainable code.

Uploaded by

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

Functional Programming in JavaScript How to

improve your JavaScript programs using


functional techniques First Edition Luis Atencio
download
https://textbookfull.com/product/functional-programming-in-
javascript-how-to-improve-your-javascript-programs-using-
functional-techniques-first-edition-luis-atencio/

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!

Functional Programming in JavaScript How to improve


your JavaScript programs using functional techniques 1
edition Edition Luis Atencio

https://textbookfull.com/product/functional-programming-in-
javascript-how-to-improve-your-javascript-programs-using-
functional-techniques-1-edition-edition-luis-atencio/

Beginning Functional JavaScript. Functional Programming


with JavaScript using EcmaScript 6 1st Edition Anto
Aravinth

https://textbookfull.com/product/beginning-functional-javascript-
functional-programming-with-javascript-using-ecmascript-6-1st-
edition-anto-aravinth/

Beginning Functional JavaScript: Functional Programming


with JavaScript Using EcmaScript 6 1st Edition Anto
Aravinth

https://textbookfull.com/product/beginning-functional-javascript-
functional-programming-with-javascript-using-ecmascript-6-1st-
edition-anto-aravinth-2/

The Joy of JavaScript 1st Edition Luis Atencio

https://textbookfull.com/product/the-joy-of-javascript-1st-
edition-luis-atencio/
Beginning Functional JavaScript: Uncover the Concepts
of Functional Programming with EcmaScript 8 2nd Edition
Srikanth Machiraju

https://textbookfull.com/product/beginning-functional-javascript-
uncover-the-concepts-of-functional-programming-with-
ecmascript-8-2nd-edition-srikanth-machiraju/

JavaScript Learn JavaScript in 24 Hours or Less A


Beginner s Guide To Learning JavaScript Programming Now
JavaScript JavaScript Programming 1st Edition Robert
Dwight.
https://textbookfull.com/product/javascript-learn-javascript-
in-24-hours-or-less-a-beginner-s-guide-to-learning-javascript-
programming-now-javascript-javascript-programming-1st-edition-
robert-dwight/

The Joy of JavaScript 1st Edition Atencio

https://textbookfull.com/product/the-joy-of-javascript-1st-
edition-atencio/

Head First JavaScript Programming, 2nd Edition: A


Learner’s Guide to Modern JavaScript Eric Freeman

https://textbookfull.com/product/head-first-javascript-
programming-2nd-edition-a-learners-guide-to-modern-javascript-
eric-freeman/

Head First JavaScript Programming, 2nd Edition: A


Learner’s Guide to Modern JavaScript Eric Freeman

https://textbookfull.com/product/head-first-javascript-
programming-2nd-edition-a-learners-guide-to-modern-javascript-
eric-freeman-2/
Functional Programming in JavaScript
Functional
Programming
in JavaScript
LUIS ATENCIO

MANNING
SHELTER ISLAND
For online information and ordering of this and other Manning books, please visit
www.manning.com. The publisher offers discounts on this book when ordered in quantity.
For more information, please contact
Special Sales Department
Manning Publications Co.
20 Baldwin Road
PO Box 761
Shelter Island, NY 11964
Email: [email protected]

©2016 by Manning Publications Co. All rights reserved.

No part of this publication may be reproduced, stored in a retrieval system, or transmitted, in


any form or by means electronic, mechanical, photocopying, or otherwise, without prior written
permission of the publisher.

Many of the designations used by manufacturers and sellers to distinguish their products are
claimed as trademarks. Where those designations appear in the book, and Manning
Publications was aware of a trademark claim, the designations have been printed in initial caps
or all caps.

Recognizing the importance of preserving what has been written, it is Manning’s policy to have
the books we publish printed on acid-free paper, and we exert our best efforts to that end.
Recognizing also our responsibility to conserve the resources of our planet, Manning books
are printed on paper that is at least 15 percent recycled and processed without the use of
elemental chlorine.

Manning Publications Co. Development editor: Marina Michaels


20 Baldwin Road Technical development editor: Dean Iverson
PO Box 761 Review editor: Aleksandar Dragosavljevic
Shelter Island, NY 11964 Project editor: Tiffany Taylor
Copy editor: Tiffany Taylor
Proofreader: Katie Tennant
Technical proofreader: Daniel Lamb
Typesetter: Dennis Dalinnik
Cover designer: Leslie Haimes

ISBN: 9781617292828
Printed in the United States of America
1 2 3 4 5 6 7 8 9 10 – EBM – 21 20 19 18 17 16
To my wonderful wife, Ana.
Thank you for your unconditional support
and for being the source of passion and inspiration in my life.
brief contents
PART 1 THINK FUNCTIONALLY ..................................................1
1 ■ Becoming functional 3
2 ■ Higher-order JavaScript 23

PART 2 GET FUNCTIONAL........................................................55


3 ■ Few data structures, many operations 57
4 ■ Toward modular, reusable code 84
5 ■ Design patterns against complexity 117

PART 3 ENHANCING YOUR FUNCTIONAL SKILLS ......................151


6 ■ Bulletproofing your code 153
7 ■ Functional optimizations 180
8 ■ Managing asynchronous events and data 205

vii
contents
preface xv
acknowledgments xvii
about this book xix

PART 1 THINK FUNCTIONALLY .......................................1

1 Becoming functional
1.1
3
Can functional programming help? 5
1.2 What is functional programming? 5
Functional programming is declarative 7 Pure functions and

the problem with side effects 9 Referential transparency and


substitutability 13 Preserving immutable data 15


1.3 Benefits of functional programming 16


Encouraging the decomposition of complex tasks 16
Processing data using fluent chains 18 Reacting to the

complexity of asynchronous applications 19


1.4 Summary 22

ix
x CONTENTS

2 Higher-order JavaScript 23
2.1 Why JavaScript? 24
2.2 Functional vs. object-oriented programming 24
Managing the state of JavaScript objects 31 Treating objects ■

as values 32 Deep-freezing moving parts 34 Navigating


■ ■

and modifying object graphs with lenses 37


2.3 Functions 38
Functions as first-class citizens 39 Higher-order functions
■ 40
Types of function invocation 43 Function methods 44

2.4 Closures and scopes 45


Problems with the global scope 47 JavaScript’s function

scope 48 A pseudo-block scope 49 Practical applications


■ ■

of closures 50
2.5 Summary 53

PART 2 GET FUNCTIONAL ............................................55

3 Few data structures, many operations 57


3.1 Understanding your application’s control flow 58
3.2 Method chaining 59
3.3 Function chaining 60
Understanding lambda expressions 61 Transforming data ■

with _.map 62 Gathering results with _.reduce 65


Removing unwanted elements with _.filter 68


3.4 Reasoning about your code 70
Declarative and lazy function chains 71 ■
SQL-like data:
functions as data 75
3.5 Learning to think recursively 77
What is recursion? 77 Learning to think recursively

77
Recursively defined data structures 79
3.6 Summary 83

4 Toward modular, reusable code 84


4.1 Method chains vs. function pipelines 85
Chaining methods together 86 ■
Arranging functions
in a pipeline 87
CONTENTS xi

4.2 Requirements for compatible functions 88


Type-compatible functions 88 ■ Functions and arity:
the case for tuples 89
4.3 Curried function evaluation 92
Emulating function factories 95 ■
Implementing reusable
function templates 97
4.4 Partial application and parameter binding 98
Extending the core language 100 ■
Binding into
delayed functions 101
4.5 Composing function pipelines 102
Understanding composition with HTML widgets 102
Functional composition: separating description from
evaluation 104 Composition with functional libraries 107

Coping with pure and impure code 109 Introducing point-free


programming 111
4.6 Managing control flow with functional combinators 112
Identity (I-combinator) 112 Tap (K-combinator) 113

Alternation (OR-combinator) 113 Sequence (S-combinator) 114


Fork (join) combinator 115


4.7 Summary 116

5 Design patterns against complexity 117


5.1 Shortfalls of imperative error handling 118
Error handling with try-catch 118 Reasons not to throw

exceptions in functional programs 119 Problems with ■

null-checking 121
5.2 Building a better solution: functors 121
Wrapping unsafe values 122 ■ Functors explained 124
5.3 Functional error handling using monads 127
Monads: from control flow to data flow 128 Error handling with

Maybe and Either monads 132 Interacting with external


resources using the IO monad 141


5.4 Monadic chains and compositions 144
5.5 Summary 150
xii CONTENTS

PART 3 ENHANCING YOUR FUNCTIONAL SKILLS ..........151

6 Bulletproofing your code 153


6.1 Functional programming’s influence on unit tests 154
6.2 Challenges of testing imperative programs 155
Difficulty identifying and decomposing tasks 155
Dependency on shared resources leads to inconsistent results 157
Predefined order of execution 158
6.3 Testing functional code 159
Treating a function as a black box 159 Focusing on business

logic instead of control flow 160 Separating the pure from


the impure with monadic isolation 161 Mocking external


dependencies 164
6.4 Capturing specifications with property-based testing 166
6.5 Measuring effectiveness through code coverage 172
Measuring the effectiveness of testing functional code 173
Measuring the complexity of functional code 177
6.6 Summary 179

7 Functional optimizations 180


7.1 Under the hood of function execution 181
Currying and the function context stack 183 ■
Challenges of
recursive code 186
7.2 Deferring execution using lazy evaluation 188
Avoiding computations with the alternation functional
combinator 189 Taking advantage of shortcut fusion
■ 190
7.3 Implementing a call-when-needed strategy 191
Understanding memoization 192 Memoizing computationally

intensive functions 192 Taking advantage of currying and


memoization 196 Decomposing to maximize memoization 196


Applying memoization to recursive calls 197


7.4 Recursion and tail-call optimization (TCO) 199
Converting non-tail calls to tail calls 201
7.5 Summary 203
CONTENTS xiii

8 Managing asynchronous events and data 205


8.1 Challenges of asynchronous code 206
Creating temporal dependencies among functions 207
Falling into a callback pyramid 208 Using continuation-

passing style 210


8.2 First-class asynchronous behavior with promises 214
Future method chains 216 Composing synchronous and

asynchronous behavior 221


8.3 Lazy data generation 224
Generators and recursion 226 ■ The Iterator protocol 228
8.4 Functional and reactive programming with RxJS 229
Data as observable sequences 229 Functional and reactive

programming 230 RxJS and promises 233


8.5 Summary 234

appendix JavaScript libraries used in this book 235


index 239
preface
When I was in college and graduate school, my class schedule was focused on object-
oriented design as the sole methodology for planning and architecting software sys-
tems. And, like many developers, I began my career writing object-oriented code and
building entire systems based on this paradigm.
Throughout my development career, I’ve learned and followed programming lan-
guages closely, not only because I want to learn something cool, but also because I’m
intrigued by the design decisions and philosophy that each language fosters. Just as a
new language provides a different perspective on how to approach software problems,
a new paradigm can achieve the same effect. Although the object-oriented approach
continues to be the modus operandi of software design, learning about functional
programming will open your eyes to new techniques that you can use on their own or
in parallel with any other design paradigm that fits your application.
Functional programming has been around for years, but to me it was only a minor
distraction. I had heard and read about the benefits of Haskell, Lisp, Scheme, and,
more recently, Scala, Clojure, and F# in terms of expressiveness and being highly pro-
ductive platforms; even Java, which has traditionally been known as a verbose language,
has functional artifacts that make code more succinct. Eventually, the minor distrac-
tion became impossible to avoid. And guess what? JavaScript, that object-oriented
language everyone uses, can be turned around 180 degrees and used functionally. It
turns out that this is the most powerful and effective way to use JavaScript. It took me
a long time to discover this, and in this book I want to make you aware of it so you
don’t have go on wondering why your JavaScript code is becoming so complex.

xv
xvi PREFACE

Throughout my journey as a developer, I’ve learned how to use functional pro-


gramming principles to create code that is modular, expressive, robust, easy to reason
about, and simple to test. Without a doubt, this has changed me as a software engi-
neer, so I wanted to capture and jot down my experiences somehow—perhaps in a
book. Naturally, I approached Manning, with the idea of writing a functional pro-
gramming book using the Dart programming language. I was playing around with
Dart at the time and thought that combining it with my functional background would
be a fun, unexplored, uncharted territory. I wrote a proposal, and a week later I had
an interview. During the interview, I learned that Manning was seeking a person to
write a book about functional programming in JavaScript. Because JavaScript is a lan-
guage I’m very much obsessed with, to say the least, I was thrilled to jump into this
opportunity. By writing this book, I hope to help you develop the same skills and take
your development in a new direction.
acknowledgments
Writing a book is not a trivial undertaking, and the tireless collaboration of many peo-
ple with a variety of talents brought to life the manuscript you’re holding (or reading
onscreen).
The staff at Manning were incredible and instrumental in obtaining the level of
quality we all hoped for, and I thank all of them from the bottom of my heart. Without
them, this book would not have been possible. Special thanks to Marjan Bace and
Mike Stephens for believing in the idea of this book and in me as an author; to Marina
Michaels, for giving me a map and a flashlight to navigate this maze of book-writing
challenges; to Susan Conant, for bringing me up to speed and teaching me my first
lessons about what it means to write a technical book; to Bert Bates, for giving me my
initial sparks of creativity and for his amazing insights on how to teach programming;
and to everyone on the editorial and production teams, including Mary Piergies, Janet
Vail, Kevin Sullivan, Tiffany Taylor, Katie Tennant, Dennis Dalinnik, and many others
who worked behind the scenes.
I can’t thank enough the amazing group of technical peer reviewers led by
Aleksandar Dragosavljevic—Amy Teng, Andrew Meredith, Becky Huett, Daniel Lamb,
David Barkol, Ed Griebel, Efran Cobisi, Ezra Simeloff, John Shea, Ken Fukuyama,
Peter Edwards, Subhasis Ghosh, Tanner Slayton, Thorsten Szutzkus, Wilfredo Manrique,
William E. Wheeler, and Yiling Lu—and the talented forum contributors. Their con-
tributions included catching technical mistakes, errors in terminology, and typos, and
making topic suggestions. Each pass through the review process and each piece of
feedback implemented through the forum topics shaped and molded the manuscript.

xvii
xviii ACKNOWLEDGMENTS

On the technical side, special thanks to Dean Iverson, who served as the book’s
technical editor; Daniel Lamb, who served as the book’s technical proofreader; and
Brian Hanafee, for his thorough and in-depth evaluation of the entire book. They are
the best technical editors I could have hoped for.
Last but not least, I thank my wife for always supporting me, and my family for
pushing me to become better every day and not asking why I didn’t call as often to
check in while I was writing this book. Also, thanks go to my colleagues at work for
purchasing early releases of the chapters. I am grateful to have the pleasure of work-
ing alongside such wonderful people.
about this book
Complexity is a huge beast to tame, and we’ll never get rid of it entirely; it will always
be an aspect of software development. I’ve spent countless hours and immeasurable
brainpower trying to understand what a particular piece of code does. The secret is to
control the complexity so it doesn’t grow in proportion to the size of your code base—
and functional programming can help. We’re writing more JavaScript than ever before.
We’ve gone from building small client-side event-handling routines, to heavy client-
side architectures, to complete isomorphic (server + client) JavaScript applications.
Functional programming isn’t a tool—it’s a way of thinking that can apply equally to
any of these environments.
This book is designed to teach you how to apply functional programming tech-
niques to your code using ECMAScript 6 JavaScript. The material is presented at a
gradual, steady pace and covers both theoretical and practical aspects of functional
programming. I provide additional information for advanced readers, to help you get
deeper into some of the harder concepts.

Roadmap
This book has eight chapters and is divided into three parts that guide you from fun-
damental building blocks to more-advanced and practical applications of functional
programming.

xix
xx ABOUT THIS BOOK

Part 1, “Think functionally,” paints a high-level landscape of functional JavaScript.


It also discusses core aspects of using JavaScript functionally and thinking like a func-
tional programmer:
■ Chapter 1 introduces some of the core functional concepts that are explained
in later chapters and prepares you to make the functional leap. It introduces
the main pillars of functional programming, including pure functions, side
effects, and declarative programming.
■ Chapter 2 establishes a level playing field for beginning and intermediate
JavaScript developers and acts as a refresher for more-advanced readers. In
addition, it’s sprinkled with basic functional programming concepts to prepare
you for the techniques discussed in part 2.
Part 2, “Get functional,” focuses on core functional programming techniques, includ-
ing function chains, currying, composition, monads, and more:
■ Chapter 3 introduces function chains and explores writing programs as combi-
nations of recursion and high-order functions like map, filter, and reduce. It
teaches these concepts using the Lodash.js framework.
■ Chapter 4 covers the popular techniques of currying and composition, which
increase the modularity of your code. Using a functional framework such as
Ramda.js, composition is the glue that orchestrates your entire JavaScript solution.
■ Chapter 5 provides a deep dive into more-theoretical areas of functional pro-
gramming, with a comprehensive and gradual discussion of functors and monads
in the context of error handling.

Part 3, “Enhancing your functional skills,” discusses the practical benefits of using
functional programming to tackle real-world challenges:
■ Chapter 6 reveals the inherent ease with which functional programs can be unit
tested. In addition, it introduces a rigorous, automated testing mode called
property-based testing.
■ Chapter 7 takes a look at JavaScript’s memory model, which is used to support
the evaluation of functions. This chapter also discusses techniques that help
optimize the execution time of functional JavaScript applications.
■ Chapter 8 introduces some of the main challenges JavaScript developers face
on a day-to-day basis when dealing with event-driven and asynchronous behav-
ior. It discusses how functional programming can provide elegant solutions to
reduce the complexity of existing imperative solutions with a related paradigm
known as reactive programming, implemented using RxJS.

Who should read this book


Functional Programming in JavaScript is written for JavaScript developers with at least a
basic understanding of object-oriented software and a general awareness of the chal-
lenges of modern web applications. Because JavaScript is such a ubiquitous language,
ABOUT THIS BOOK xxi

if you want an introduction to functional programming and prefer a familiar syntax,


you can take full advantage of this book instead of learning Haskell. (If you want to
ease your way into Haskell, this book isn’t the best resource, because each language
has its own idiosyncrasies that are best understood by learning it directly.)
The book will help beginning and intermediate programmers heighten their
JavaScript skills with higher-order functions, closures, function currying, composition,
as well as new JavaScript ES6 features like lambda expressions, iterators, generators,
and promises. Advanced developers will enjoy the comprehensive coverage of monads
and reactive programming as well, which can help you implement innovative ways of
tackling the arduous task of dealing with event-driven and asynchronous code, taking
full advantage of the JavaScript platform.

How to use this book


If you’re a beginner or intermediate JavaScript developer and functional program-
ming is new to you, begin with chapter 1. If you’re a strong JavaScript programmer,
you can skim through chapter 2 and move quickly into chapter 3, which begins with
function chains and overall functional design.
More-advanced users of functional JavaScript typically understand pure functions,
currying, and composition, so you may skim chapter 4 and move into functors and
monads in chapter 5.

Examples and source code


The code examples in this book use ECMAScript 6 JavaScript, which can run equally
well on either the server (Node.js) or the client. Some examples show I/O and
browser DOM APIs, but without regard for browser incompatibilities. I assume you
have experience interacting at a basic level with HTML pages and the console. No spe-
cific browser-based JavaScript is used.
The book makes heavy use of functional JavaScript libraries like Lodash.js, Ramda.js,
and others. You can find documentation and installation information in the appendix.
This book contains extensive code listings that showcase functional techniques
and, where appropriate, compare imperative versus functional designs. You can find
all the code samples at the publisher’s website, https://www.manning.com/books/
functional-programming-in-javascript, and on GitHub at https://github.com/luijar/
functional-programming-js.

Typographical conventions
The following conventions are used throughout the book:
■ Italic typeface is used to reference important terms.
■ Courier typeface is used to denote code listings, as well as elements and attri-
butes, methods names, classes, functions, and other programming artifacts.
■ Code annotations accompany some of the source code listings, highlighting
important concepts.
xxii ABOUT THIS BOOK

About the author


Luis Atencio (@luijar) is a staff software engineer for Citrix Systems in Ft. Lauderdale,
Florida. He has a B.S. and an M.S. in Computer Science and now works full-time
developing and architecting applications using JavaScript, Java, and PHP platforms.
Luis is very involved in the community and has presented frequently at local meetups
and conferences. He blogs about software engineering at luisatencio.net, writes arti-
cles for magazines and DZone, and is also the coauthor of RxJS in Action (forthcoming
from Manning in 2017).

Author Online
Purchase of Functional Programming in JavaScript includes free access to a private web
forum run by Manning Publications where you can make comments about the book,
ask technical questions, and receive help from the author and from other users. To
access the forum and subscribe to it, point your web browser to https://www.manning
.com/books/functional-programming-in-javascript. This page provides information
on how to get on the forum once you are registered, what kind of help is available,
and the rules of conduct on the forum.
Manning’s commitment to our readers is to provide a venue where a meaningful
dialog between individual readers and between readers and the author can take place.
It is not a commitment to any specific amount of participation on the part of the
author, whose contribution to Author Online remains voluntary (and unpaid). We
suggest you try asking the author some challenging questions lest his interest stray!
The Author Online forum and the archives of previous discussions will be accessible
from the publisher’s website as long as the book is in print.
Part 1

Think functionally

I t’s highly probable that most of your experience building professional appli-
cations has been with an object-oriented language. You may have heard or read
about functional programming in other books, blogs, forums, and magazine
articles, but you’ve probably never written any functional code. Don’t worry; this
is to be expected. I’ve done most of my development in an object-oriented envi-
ronment as well. Writing functional code isn’t difficult, but learning to think
functionally and letting go of old habits is. The primary goal of part 1 of this
book is to lay the foundation for and prepare your mind to embrace the func-
tional techniques discussed in parts 2 and 3.
Chapter 1 discusses what functional programming is and the mindset you
need to embrace it; it also introduces some of the most important techniques
based on pure functions, immutability, side effects, and referential transparency.
These form the backbone of all functional code and will help you transition into
functional more easily. Also, these will be the guiding principles that set the stage
for many of the design decisions we make in the following chapters.
Chapter 2 provides a first view of JavaScript as a functional language. Because
it’s so ubiquitous and mainstream, it’s an ideal language with which to teach func-
tional programming. If you aren’t a strong JavaScript developer, this chapter will
bring you up to speed with everything you need to know to understand functional
JavaScript, such as higher-order functions, closures, and scoping rules.
Becoming functional

This chapter covers


■ Thinking in functional terms
■ Learning the what and why of functional
programming
■ Understanding the principles of immutability
and pure functions
■ Functional programming techniques and their
impact on overall design

OO makes code understandable by encapsulating moving parts.


FP makes code understandable by minimizing moving parts.

—Michael Feathers (Twitter)

If you’re reading this book, chances are you’re a JavaScript developer with a work-
ing knowledge of object-oriented or structured design, and you’re curious about
functional programming. Perhaps you’ve tried to learn it before and haven’t been
able to apply it successfully at work or on your personal projects. In either case,
your main goal is to advance your development skills and improve the quality of
your code. This book can help you accomplish that.

3
4 CHAPTER 1 Becoming functional

The rapid pace of web platforms, the evolution of browsers, and—most impor-
tant—the demands of end users have all had a profound effect on the way we design
web applications today. Users demand that web applications feel more like a native
desktop or a mobile app with rich and responsive widgets. Naturally, these demands
force JavaScript developers to think more broadly about the solution space and to
adopt adequate programming paradigms and best practices that provide the best pos-
sible solutions.
As developers, we gravitate toward frameworks that help us create extensible and
clean application architectures. Yet the complexity of our codebase still gets out of
control, and we’re challenged to reexamine the basic design principles of our code.
Also, the web of today is radically different than it was years ago for JavaScript develop-
ers, because we can do many things now that weren’t technically feasible before. We
can choose to write large server-side applications with Node.js or push the bulk of the
business logic onto the client, leaving a thin server behind. In either case, we need to
interact with storage technology, spawn asynchronous processes, handle events, and
much more.
Object-oriented design helps solve part of the problem; but because JavaScript is
such a dynamic language with lots of shared state, it isn’t long before we accumulate
enough complexity to make our code unwieldy and hard to maintain. Object-oriented
design certainly moves the needle in the right direction, but we need more. Perhaps
you’ve heard the term reactive programming in recent years. This programming para-
digm facilitates working with data flows and propagation of change. In JavaScript, this
is extremely important when dealing with asynchronous or event-based code. Overall,
what we need is a programming paradigm that encourages us to think carefully about
our data and the functions that interact with it. When thinking about an application’s
design, ask yourself the following questions in terms of these design principles:
■ Extensibility—Do I constantly refactor my code to support additional functionality?
■ Easy to modularize—If I change one file, is another file affected?
■ Reusability—Is there a lot of duplication?
■ Testability—Do I struggle to unit test my functions?
■ Easy to reason about—Is my code unstructured and hard to follow?
If you answer “Yes” or “I don’t know” to any of these questions, then you’ve picked up
the right book as a guide on the path to productivity. Functional programming (FP) is
the programming paradigm you need. Although it’s based on simple concepts, FP
requires a shift in the way you think about problems. FP isn’t a new tool or an API, but
a different approach to problem solving that will become intuitive once you under-
stand the basic principles.
In this chapter, I define what functional programming is and tell you how and why
it’s useful and important. I introduce the core principles of immutability and pure func-
tions and talk about FP techniques and how those techniques affect your approach to
designing programs. These techniques allow you to easily pick up reactive programming
What is functional programming? 5

and use it to solve complex JavaScript tasks. But before we can get into all this, you
need to learn why thinking functionally is important and how it can help you tackle
the complexities of JavaScript programs.

1.1 Can functional programming help?


Learning functional programming has never been as important as it is today. The
development community and major software companies are starting to realize the
benefits of using FP techniques to power their business applications. Nowadays, most
major programming languages (Scala, Java 8, F#, Python, JavaScript, and many more)
provide either native or API-based functional support. Hence, FP skills are in high
demand now and will continue to be in the years to come.
In the context of JavaScript, an FP mindset can be used to shape the incredibly
expressive nature of the language and help you write code that is clean, modular, test-
able, and succinct so that you can be more productive at work. For many years, we’ve
neglected the fact that JavaScript can be written more effectively in a functional style.
This neglect is partly due to an overall misunderstanding of the JavaScript language,
and also due to JavaScript’s lack of native constructs to properly manage state; it’s a
dynamic platform that places the burden of managing this state on us (the ones
responsible for introducing bugs into our applications). This may work well for small
scripts, but it becomes harder to control as your code base grows. In a way, I think FP
protects you from JavaScript itself. I discuss this further in chapter 2.
Writing functional JavaScript code addresses most of these concerns. Using a set of
proven techniques and practices based on pure functions, you can write code that is
easy to reason about in the face of increasing complexity. Writing JavaScript function-
ally is a two-for-one deal, because you not only improve the quality of your entire
application, but also gain more proficiency in and a better understanding of the
JavaScript language.
Because functional programming isn’t a framework or a tool, but a way of writing
code, thinking functionally is radically different from thinking in object-oriented
terms. But how do you become functional? How do you begin to think functionally?
Functional programming is intuitive once you’ve grasped its essence. Unlearning old
habits is the hardest part and can be a huge paradigm shift for most people who come
from an object-oriented background. Before you can learn to think functionally, first
you must learn what FP is.

1.2 What is functional programming?


In simple terms, functional programming is a software development style that places a
major emphasis on the use of functions. You might say, “Well, I already use functions
on a day-to-day basis at work; what’s the difference?” As I mentioned earlier, FP
requires you to think a bit differently about how to approach the tasks you’re facing.
It’s not a matter of just applying functions to come up with a result; the goal, rather, is
to abstract control flows and operations on data with functions in order to avoid side effects
6 CHAPTER 1 Becoming functional

and reduce mutation of state in your application. I know this sounds like a mouthful, but
I’ll visit each of these terms further and build on them throughout the book.
Normally, FP books start with computing Fibonacci numbers, but I’d rather start
with a simple JavaScript program that displays text on an HTML page. What better text
to print than the good ol’ “Hello World”:

document.querySelector('#msg').innerHTML = '<h1>Hello World</h1>';

NOTE I mentioned earlier that because functional programming isn’t a spe-


cific tool, but a way of writing code, you can apply it to write client-side
(browser-based) as well as server-side applications (Node.js). Opening the
browser and typing in some code is probably the easiest way to get JavaScript
up and running, and that’s all you’ll need for this book.

This program is simple, but because everything is hardcoded, you can’t use it to dis-
play messages dynamically. Say you wanted to change the formatting, the content, or
perhaps the target element; you’d need to rewrite this entire expression. Maybe you
decide to wrap this code with a function and make the change points parameters, so
you can write it once and use it with any configuration:
function printMessage(elementId, format, message) {
document.querySelector(`#${elementId}`).innerHTML =
`<${format}>${message}</${format}>`;
}

printMessage('msg', 'h1','Hello World');

An improvement, indeed, but still not a completely reusable piece of code. Suppose
you want to write to a file instead of an HTML page. You need to take the simple
thought process of creating parameterized functions to a different level, where param-
eters aren’t just scalar values but can also be functions themselves that provide addi-
tional functionality. Functional programming is a bit like using functions on steroids,
because your sole objective is to evaluate and combine lots of functions with others to
achieve greater behavior. I’ll fast-forward a bit and show you a sneak peek at this same
program using a functional approach.

Listing 1.1 Functional printMessage

var printMessage = run(addToDom('msg'), h1, echo);

printMessage('Hello World');

Without a doubt, this looks radically different than the original. For starters, h1 isn’t a
scalar anymore; it’s a function just like addToDom and echo. Visually, it feels as though
you’re creating a function from smaller functions.
There’s a reason for this madness. Listing 1.1 captures the process of decomposing
a program into smaller pieces that are more reusable, more reliable, and easier to
Random documents with unrelated
content Scribd suggests to you:
The Project Gutenberg eBook of The Diary of a
Hunter from the Punjab to the Karakorum
Mountains
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 Diary of a Hunter from the Punjab to the Karakorum


Mountains

Author: Augustus Henry Irby

Release date: May 9, 2013 [eBook #42674]


Most recently updated: October 23, 2024

Language: English

Credits: Produced by sp1nd, Paul Clark and the Online Distributed


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

*** START OF THE PROJECT GUTENBERG EBOOK THE DIARY OF A


HUNTER FROM THE PUNJAB TO THE KARAKORUM MOUNTAINS ***
Transcriber's Note:
Every effort has been made to replicate this text as faithfully as possible, including some
inconsistencies of hyphenation. Some changes have been made. They are listed at the
end of the text.

DIARY OF A HUNTER.

THE

DIARY OF A HUNTER
FROM

THE PUNJAB

TO THE

KARAKORUM MOUNTAINS.

LONDON:
LONGMAN, GREEN, LONGMAN, AND ROBERTS;
NORWICH:
HENRY W. STACY, HAYMARKET.

M.DCCC.LXIII.
NORWICH:
PRINTED BY HENRY W. STACY,
HAYMARKET.
PREFACE.
It is hoped that the circumstances under which this volume appears
may be considered such as to excuse its imperfections. It is—with
some omissions and completions of sentences but with hardly a
verbal alteration—the copy of a journal, not written with a view to
publication but simply as a private record, kept up from time to time
as opportunity offered in the midst of the scenes which it describes.
The hand that wrote it is now in the grave. And it is solely in
compliance with the wishes of many relatives and friends who were
anxious to obtain such a memorial of one whom they loved, that it is
now committed to the press by a brother.
CONTENTS.
PAGE.
CHAPTER I. Preparations and Equipments 1
II. To Sirinuggur 7
III. Sirinuggur—to the Wurdwan 28
IV. Shikar in the Wurdwan 48
V. Ditto 67
VI. Ditto 89
VII. Sooroo Pass to Ladâk 109
VIII. Ladâk 135
IX. Leh 157
X. To the Shayak 176
XI. To the Karakorum 196
XII. Sugheit 225
XIII. The Yâk 249
XIV. The Return 264
XV. Leh and Ladâk 285
XVI. The Bara Sing 302
XVII. Cashmere 324
Browne. Lith. Norwich.
CHAPTER I.
PREPARATIONS AND EQUIPMENTS.

Possianah, Pir Panjal,


29th April, 1860.
An attempt at a Diary, with the intention of recording my adventures
and experiences in an excursion contemplated in Cashmere and
adjacent countries—that of Ladâk being a principal object—during
six months' leave from my duties at Amritsir.
Several times in former days have I resolved to keep a journal, or jot
down briefly the incidents and experiences of each passing day. But
as often, after the lapse of a few days, have I failed to persist in the
undertaking: whether from infirmity of purpose, or idleness, or from
an utter contempt of the 'small beer' I had to chronicle, I do not
myself know; and whether I shall be more successful in this present
effort remains to be seen. Primary indications are not promising, as I
have now been 'en route' from Amritsir, from the 16th to the 29th,
thirteen days, and have excused myself, on one ground or other,
from making a commencement until now.
To be in order, I must note my preparatory arrangements, detail my
supplies—their quality and quantity—the number and office of my
attendants—the extent of my stud, and the amount and nature of
my sporting equipments; especially this latter, as the chase, or, as it
is called in India, 'shikar,' is with me a sort of mania, and all that
appertains thereto is to me of very great importance. Therefore, as a
guide for myself, or to advise others on some subsequent and similar
occasion, I must minutely specify my shooting apparatus and fishing
appointments, and, in the course of my diary, especially take note of
efficiences and deficiences in this respect, as occasion may demand.
To commence with the most important part of my travelling
establishment,—the servants,—there was, First in consideration, the
khansamah, who unites the duties of caterer, cook, and director
general of the ways and means. Secondly, the sirdar or bearer,—the
individual who, in this land of the minutest division of labour, looks
after the clothes, bedding, &c., and assists in dressing and washing.
He was a new hand, hired for the occasion, as my regular sirdar had
to remain behind in charge of my property. Thirdly, the bheestie,
who, in addition to his ordinary duties of fetching water, undertook
to assist in cooking, washing up dishes, &c., for the consideration of
three rupees additional wages, which I thought preferable to hiring a
mussulchee, as the fewer attendants one has on the road to Ladâk
the better, considering that for some marches all provisions and food
have to be carried for the whole party. Fourthly, the classee, in
whose charge were the tents and their belongings, &c.—his duty to
accompany and pitch them. Fifthly and sixthly, two syces, grooms, in
whose charge were my two ponies: one of which was a stout animal
from Yarkand, a famous animal for mountain travelling: the other a
good-looking, good sort of pony from Cabul, which I bought at
hazard, taking him according to description in an advertisement, and
he seems likely to justify fully the account given of him.
In addition to these attendants, I agreed, after consultation with my
excellent friends, the missionaries of Amritsir, to attach to my party a
native Catechist, who by birth claims to be a Cashmiri. He has been,
however, brought up and educated in the Punjab; where, when
serving as a khitmudgur or sirdar, he became a convert to
Christianity, and has for some years been in the employment of the
Amritsir Mission. He has been in Cashmere and Ladâk, and
understands the language of the former country. The object of his
accompanying me is to circulate the Gospel in Bibles, Testaments,
and tracts, which I received for that purpose from the missionaries,
having myself first suggested the possibility of my being able to
promote the spread and knowledge of the Christian Faith and Hope,
by means of these books, in the heathen lands to which I was going,
—intending to distribute them personally should opportunities offer.
But the co-operation of the Catechist was a sudden after-thought of
one of my good friends, the missionaries; which, as it only had birth
two days before I started, was rather embarrassing to mature and
act upon. But after the project had almost lapsed, owing to some
misunderstanding resulting from the excited and unsettled state of
mind of Suleiman, the Catechist, consequent on so sudden a
summons to start, with little or no preparation, on such an arduous
journey, leaving, too, a wife and family—she in a delicate state—it
was finally arranged that Suleiman should accompany me at my
charges.
My retinue was again unexpectedly increased by engaging a
Cashmiri who presented himself to me as I was returning home from
breakfast at mess. He shewed me a certificate of character, stating
him to be an useful servant, capable of any personal attendance
required by a traveller and hunter. He had the strong
recommendation, too, of an intimate acquaintance with the country
of Ladâk, and the routes north and east of Cashmere, together with
the sporting localities, the haunts of the yâk (wild cattle), and the
kyang (wild horse); so thinking him an acquisition I closed with him
at twelve rupees per month, and directed him to proceed to the
rendezvous at Bhimber.
Having thus enumerated my personal attendants, I must now
mention my coolies, Cashmiries, twenty of whom I engaged at five
rupees a month to convey my baggage to Sirinuggur, the capital of
Cashmere.
My stores, and all articles that could be so disposed, were packed in
long baskets, called kheltas, which the Cashmiries hoist on their
backs, strapping them to their shoulders: and with them they carry a
stout crutch about two feet high, on the cross-piece of which they
rest their load when pausing on the road, and taking breath in
ascending mountains—an excellent mode of relief as it does not
cause them to shift or put down their load. They only straighten
their backs, so that the khelta rests on the crutch; and when
refreshed again bend to their burden and trudge on, often—too
often for the early arrival of one's baggage—repeating this process.
This mode of hiring coolies answers admirably. They are returning to
their homes in Cashmere from Amritsir, to which grand emporium for
Cashmere goods they had brought loads of merchandise in the
commencement of the cold season, and it is to them, of course, a
piece of good luck getting return loads. They all appeared strong,
sturdy, well-limbed men, and got away with my traps, my servants
and horses in company, the whole under charge of my khansamah,
Abdoolah, on the evening of the 8th April.
I must not forget, in my catalogue of live stock, two little dogs, of no
particular merit, but dear to me as affectionate companions after
their kind.
I had made ample provision for my creature comforts, having been
told by an experienced traveller, and having gleaned from books of
travel, that the Ladâk country is sterile in the extreme, and
consequently possesses little of what constitutes by habit the
necessaries of an European.
I took 4 tins of bacon, 1 case of maccaroni, 1 ditto vermicelli, 2 ditto
biscuits, 1 tin of cheese, 3 pots of jam, 7 bottles of pickles, 24 lbs. of
tea in 3 tins, and 3 lbs. for immediate use, two 8-lb. boxes of China
sugar, and some 5 or 6 lbs. I had by me, 3 bottles essence of coffee,
7 lbs. raw ditto, 2 bottles fish sauce, 4 various ditto, 3 bottles lime
juice, 2 vinegar, 2 oil, 6 lbs. candles, besides which Clarke's patent
lamp, and lots of candles, 6 bottles brandy, 12 sherry, 12 beer, to
which I added, carrying with me, 6 bottles of hock and 6 claret—
some of a batch arriving the day I left, which, having ordered
expressly for the mess myself, I was anxious to taste. I took, by way
of medicines, 12 drams of quinine, a box of Peake's pills, one phial
chloridyne, some Holloway's ointment and sticking-plaister, with
some odds and ends I do not remember. This was my stock.
Of fire arms, I took a double rifle by Blissett, 10 bore—one heavy
double Enfield, ditto—one rifle, military pattern, by Whitworth—one
double-barrelled Westley Richards for shot; 8 lbs. powder, good
supply of bullets, shot No 3 and 6, caps, wads, &c.
These guns were taken from their cases and placed in a woollen
case, then in a leathern case respectively, this being, I think, the
most convenient way of carrying them, four of my servants having
charge, each of one. Two Colt's revolvers and ammunition, shikar
knife and belts, knives for skinning, four boxes arsenical paste, from
Peake and Allen, cleaning rods, bullet moulds, and all the
paraphernalia of a sportsman.
Of fishing-tackle, a large salmon-rod, a common trout-rod, a gaff,
two large winches, one small; stout plaited silk line, and hair for the
small rod, a variety of flies, and a good supply of spinning tackle and
hooks, on which, from past success, I principally depended. Being
without good spinning gear, I had some hooks, or rather the
spinning contrivance to which they were fitted, made by a 'maistry'
in Amritsir, after a model I had given him; and very well he
succeeded. The system of hooks was devised and fitted by a young
brother officer, an ardent devotee of the gentle craft, and clever at
all kinds of fishing gear.
Having the year previous killed some good fish in a fine stream 'en
route' to Cashmere, I anticipated some sport this time.
My tents were, the one a small two-poled shikar tent made very
light, about 12 ft. long by 7, which for the present trip I had covered
so as to resemble, in some degree, what is called a Swiss cottage
tent; the other was a small thing, just big enough to put a bed in,
and carried altogether by one coolie: the bigger one takes four. I
had also a folding wooden bed, and lots of bed clothes, &c.
I have now enumerated all I recollect of my equipment, a good
stock of suitable clothes being understood.
CHAPTER II.
TO SIRINUGGUR.

I had hoped to have received intelligence of the Commander-in-


Chief's sanction of my application for leave ere the 15th. I only
heard from the Assistant Adjutant General at Lahore that it had been
forwarded: so, being in command at Amritsir, I gave myself leave in
anticipation, and, having some days previously arranged my 'palki
dâk,' I entered it about 4.30 P.M. on Monday the 16th, and making
up my mind for a grilling, it being extremely hot, off I started amid
the farewell salaams of my deserted retainers. The heat was very
great, but the prospect before me of, ere many days, plunging into
the eternal snows rendered endurance easy.
I reached the Sealkote bungalow about twelve next day: bathed,
breakfasted, made another meal at 4 P.M., after which I again jogged
on along the dusty road, keeping down my disgust and refreshing
my weary spirits, by conjuring up visions of snowy regions, and
glorious sport as before. And thus I arrived at Goojerat, after
crossing the Chenab at 5 A.M. on the morning of the 18th.
Here I halted, breakfasted, and dined. Pursuing my hot and dusty
route at 4.30 P.M., I arrived at Bhimber about twelve midnight,
received good accounts of my belongings from Abdoolah, was
almost devoured by my two little pets, found Suleiman had arrived,
but no tidings of the Cashmiri, Jamhal Khan. I turned into bed in my
tent, feeling a delightful sensation at being really out of the
scorching plains of the Punjab; though I could hardly be said to be
so, for the following day,—
Thursday, 19th April, the heat was excessive, thermometer in the
day 96°, and at 9 P.M. in my tent, 90°. This day was employed in
arranging loads, and selecting such articles as I needed on the road.
Jamhal Khan joined, and made salaam. Suleiman went into Bhimber,
a large straggling town, and endeavoured to create a desire for the
knowledge of the Gospel. He encountered opposition, and found
none willing to receive books.
20th April. I made a good start before day had well dawned. It was
a miserable day's march, having a river to be crossed about ten
times, the bed of which, and indeed the road itself, is composed of
boulders and stones innumerable. There is also a steep ascent to
climb, which is no easy job, the path up it being merely indented in
the naked rock by continual footsteps. I may as well remark here,
that this road is the whole way abominable, nothing being ever done
to improve it, although there is a large amount of traffic along it with
the Punjab; and the Maharajah, with his usual avarice, takes good
care to have heavy dues levied on all imports and exports—bad luck
to him, for a horrid screw! The track is nothing more than a
watercourse, and up and down the steep hills is really dangerous.
The path this day leads over the said hill, on which is a station of the
rajah's in a narrow pass, where are officials to examine passengers
and take toll. The path thence descends roughly and irregularly to a
small valley, in which is the halting place, the 'baraduri' being a
repaired portion of one of the old 'serais,' built, I believe, by the
Emperor Akbar. Many of them still exist, as also remnants of bridges,
also the work of that mighty potentate.
This place is called Saidabad, and though, perhaps, as hot as the
Punjab, being very confined, the pines and firs, the variety of
foliage, green crops, and verdant grassy slopes, with hills around
you, and mountains in the distance, tend much to lessen the sense
of heat. There are officials and sepoys here, and supplies in
moderation—tattoos, perhaps, coolies, fowls, &c. to be had.
21st April. I made a good start for Nowshera, sending on a coolie
with a basket containing breakfast.
The first part of the road is rough and difficult, lying by the stream,
interrupted by rocks; but it now opens into a pretty narrow valley,
from which you ascend a stiff steep hill of rock, but well wooded,
and, at this season, clothed with varieties of flowering shrubs and
plants, dog-roses abounding, by which the air was pleasantly
perfumed. On the summit of the hill is an old piece of solid masonry,
now inhabited by an old couple who supply excellent milk and eggs
to wayfarers.
There is a beautiful and very extensive view from this eminence of a
fertile valley in which, on a small hill, is situate Nowshera, its white
buildings conspicuous. But the object of interest is the snowy ridge
of the Panjal range, and interposing itself midway, so as to exclude
from sight all but the upper ridges of the Pir Panjal, lies the Rattan
Panjal, its upper crests partially and thinly covered with snow. The
whole scene is charming as viewed at early morning, ere the dews,
ascending in misty vapours—in themselves beautifying the landscape
by their varied and many-tinted effects—are dissipated by the sun.
At the foot of the hill the path proceeds through ups and downs of a
more or less stony character, until you descend into the valley of the
Tooey, a fine rapid brawling stream, in some places one hundred
yards wide, but averaging perhaps fifty: possessing some deep still
pools, at the turbulent entrances to which an angler would wager
good fish would be found, were there any in these waters. Nor
would he be far wrong. There are fish, and huge ones, too, in those
promising pools. Nor are they quite insensible to the wiles of the
crafty angler, who may with moderate skill enjoy good sport along
this river. But here, as elsewhere, fish have their moods and whims,
their times and seasons, so that some practice and observation are
requisite.
You cross this river, and some two hundred yards on the 'baraduri' is
situated in the middle of a densely-planted garden. Not liking its
appearance—thinking it would, at least, be prolific of insects and of
fever—I went on through the town of Nowshera, and, descending
again to the river, encamped under a 'tope' of mulberry trees, in a
long grassy plain, lying between a range of hills of moderate height
and the river. There is little to notice in Nowshera, a long street with
the ordinary bazaar shops, and, on the right-hand, a castellated
gateway, leading into an old serai, one of the series of Akbar, I
suppose.
I tried fishing in the evening at a splendid looking pool, very deep, in
which the rushing waters bury themselves, as it were, for a time,
pausing ere they again pursue their onward troubled course. This
pool lies under a precipitous cliff, just beneath the town; it is of
considerable extent, and of unknown depth, and in its dark recesses
lurk mahseer of monstrous bulk, I am told. My fortunes were at their
worst this evening, as far as catching a dish of fish went. I tried
spinning, having been provided with most tempting minnow-like bait
by some small boys, eager for 'backsheesh': and I tried 'atta' in a
sticky lump on a large-sized salmon-hook—a bait of reputed
irresistibility—but without effect. Numbers of fish, small and some
evidently of goodly size, to set one longing, rose and actually
floundered on the surface; but not a run could I get. A heavy
thunderstorm, bursting in the distance, was rapidly approaching,
which was, perhaps, the unlucky evil influence: so, tired of trying to
get anything out of the water, I took a header in, and enjoyed a
most refreshing and cooling swim.
22nd April. Sunday. Halted and passed the Sabbath in repose.
23rd April. To Chungir-ke-Serai—a long and tedious march, the path
leading over rocks which hedge in the river, on turning an angle of
which I overtook Abdoolah, who had preceded me with the breakfast
things, standing gazing back in my direction. I told him it was not
yet time for breakfast, supposing that to be his meaning, when he
pointed upwards, and, suspended from the projecting limb of a tree,
some little way up the hill shutting in the river, hung the still-
mouldering body of a man, his lower limbs still in his clothes, the
ghastly face denuded of flesh, yet with a matted felt of hair
straggling here and there over the glistening bones, grinning horribly
down upon us.
This wretch, it appeared, had in the most treacherous, barbarous,
and cowardly manner murdered an old man and child, close to the
spot where he expiated his crime. Being a sort of rural policeman in
the employ of the Maharajah, he was armed with a sword, which, of
course, excited no suspicion in his victims, whom he joined on the
road as they journeyed from Nowshera, and ascertaining that they
possessed a few rupees' worth of property, the miserable caitiff,
yielding to the suggestions of the Tempter, cut them down, and
threw their bodies into the river. Suspicions followed their
disappearance: other circumstances pointed to this man, who was
arrested, and confessing his guilt was executed where the bloody
deed was committed.
I left this gloomy spot full of reflections of the most depressing
nature: but with that rapidly revolving mental process, which so
soon exchanges our train of thought, I was soon almost as though
the repulsive object had not been met with.
I soon afterwards arrived at a pool, where I proposed stopping to
breakfast, and also to fish, having in this pool, when passing last
year, whilst occupying a seat on a rock overhanging it, observed
some monstrous great fish basking; for it was a scorching hot day,
and the sun at high meridian at the time.
I tried the 'atta' bait—merely paste made very adhesive—but without
more than one or two nibbles which came to nothing: so knocked off
and comforted the inner man. While so employed, came by a 'gent'
riding, whom I saluted. I knew him to be in my rear, proceeding to
join the Trig. survey party which was before me some days: asked
him to dinner, and he accepted.
Arrived at Chungir-ke-Serai, an old Akbar serai, on the top of a hill
overhanging the river—a fine view of the snowy range—the features
of the country rough, but picturesque. I tried fishing again without
success: enjoyed a cool swim: returned and had to wait about three-
quarters of an hour for my guest, although he was close at hand,
and I sent to him two or three times. But, lo! he at length appeared,
got up rather considerably, quite abashing me, who was sitting in a
flannel shirt and corresponding nethers. We had a pleasant chat
together. He informed me that he had never been out of India, was
born in the country, and educated at Landour, whence he was
appointed direct to the Survey department. I do not know his name.
24th April. Rijaori. I made an early start as usual, and had a rough
scrambling march of it. The road following the trend of the river,
here and there crosses steep stony hills, where the track is only a
watercourse. We crossed the river just below Rijaori. This passage is
at times very difficult and dangerous, and never very pleasant, as
there is a great body of water, and strong current at all times, but
after the rains a roaring flood.
The camp-ground of Rijaori is very pretty, in a garden, one of much
note, there being remains of aqueducts and fountains, a summer-
house on an eminence overlooking the river, and the town on the
other side. In the garden are some magnificent plane trees, called
'chunar' in Cashmere, affording good and pleasant protection from
the sun.
I found a young officer of the 24th encamped here, and asked him
and my former guest to dinner.
I prepared my tackle, and was provided with small fish by
youngsters who remembered me the year before, and started to
fish, full of expectation, at 4.30 P.M.—the sun broiling. I tried the
nearest pool under the temple, where last year a mighty fish had got
off, breaking my line and robbing me of my best spinning tackle—no
run, nothing stirring. I went down to another fine pool, where two
streams blend their waters, situated under a lofty hill, steep and
well-wooded down to the precipitous rocky bank of the river—a
lovely piece of water; had an offer or two, and hooked and landed
an impudent little brat of 2-lb. weight; then had some little sport
with a nice little chap of 5-lb. or so, when, having disturbed the pool,
I went lower and fished two or three likely spots, without moving
anything.
So I struggled back over the bothering boulders to my pet pool,
where I strove long and ineffectually, and was actually on the point
of leaving off, when—Whirr, whirr, whirr, whirr went the reel, the rod
bent double, the line smoked again, and the still waters of the pool
rose in swells, as the sogdollager I had hold of darted violently down
the stream. Fifty yards were out in no time, when I butted him
strongly, and turned him, only then getting an idea of his weight,
and joyfully exclaimed he was a twenty-pounder. The young officer
of the 24th was with me; he and the native attendants were greatly
excited.
I was conscious of having work cut out for me, and intensely eager
to secure the prize I knew to be at stake. The struggle was long and
stout. At one time the fish turning up stream, made direct for the
bank where 24th stood, about forty yards from me. A brawling
cascade separated us, and I was over knees in water in another
noisy rapid, so did not hear his remarks, but noticed his
gesticulations, and judged from them, he was astonished at the
monster I had hold of.
Well, after a rare game of pully-hauly, my scaly enemy took the
bottom, and I could not move him. 'Oh! what a weight he must be,'
thought I; 'hold on good tackle!' I shook the bait, so as to make his
jaws rattle and his teeth ache, when at last he moved with a
vengeance, making a violent effort, up and down and all sides, to
break away. Then he shewed his massive golden side—glorious
sight! I hauled him towards a round hand-net a handy lad held
ready in the water—no gaff with me—but too soon yet. Away he
sped, bending the rod alarmingly, and making the winch talk loudly.
I turned him again, and repeated the attempt to net him—away he
rushed again. I then humoured him, and tired him with the rod and
short line, until he was bagged, the lad going up to his middle, and
when in the net he could not lift him out himself.
He was a regular monster in size, but beautiful to behold—a truly
handsome fish, of lustrous golden hues. He was carried off in
triumph, suspended from my mountain staff across the shoulders of
two well-sized youths, who could but just keep his tail off the
ground.
Great was the admiration in camp, and many and various the
guesses at his weight. 24th and I each had a 24-lb. weighing hook:
putting both together, a weight of 48 lb. was required to bring both
indicators flush, which my captive did; so we rated him as a fifty-
pounder.
I must not dismiss this sporting incident without recording the
excellent qualities of this fish when brought to table. He had hung all
night, disembowelled: in the morning was not scaled, but skinned,
and being cut in lateral scallops was simply fried, and without any
exaggeration was delicious, only inferior to a good salmon. It was
firm and rich, of a brown colour, flaked with curd, and though I was
prepared with anchovy sauce, that was scouted. I never myself eat
any mahseer, or other Indian river fish, anything like it.
My two guests chatted away at dinner, a glass or two of ale being
highly appropriate on the occasion of this huge success. We parted
at nine, early hours being essential, they intending to proceed
onwards at dawn, I to stop and try my luck again.
25th April. Rijaori. I tried the upper pool above the town, a beautiful
and most promising-looking pool: but, after trying every persuasive
and seducing attitude, failed to move an admirer, and being chilled
returned to camp and breakfast, when I regaled upon the morsel I
have above described.
I passed the day reading, and anxious for the shades of evening to
permit my further attempts on the fishes, but to cut short this
evening's proceeding need only say that I fastened to another
leviathan in the same pool, after many indecisive offers had been
made; but, woe is me! he at once, after feeling himself fast and
trying rod and line, bored straight down, and cutting my bottom-line
over a stone got clear off with my set of spinning tackle. Let me
draw a veil over my misery, nor again awake memory to the
bitterness of my disappointment.
26th April. To Thanna. The road still running in company with the
river, the courses only being reversed. This day's march was much
pleasanter than any previous one, there being but little up and down
comparatively, and the pathway in many places lying under shady
wooded slopes, its sides fringed with numbers of sweet-smelling
shrubs.
The approach to Thanna presents a lovely view of the Rattan Panjal
range in front; and on the left-hand is a well-wooded range of hills,
beneath which are undulating slopes, whereon is a good deal of
cultivation which is in some parts carried in terraces to the tops of
the hills. There is an old fort-like building, formerly the habitation of
some ruffian of a rajah, I presume. The camp was pitched close to a
small village on the road to the Rattan Pir. At this place Suleiman
had an attentive audience of some ten or twelve respectable natives,
who listened to his account of our religion with pleasure, and were
glad to accept some Gospels and tracts, never having, they said,
obtained any accurate idea before of what the Christian Faith
consisted.
I have omitted to note the effect produced by Suleiman at the
different stations, so will retrace my steps for that purpose.
At Rijaori, the first day, he was not only repulsed, but threatened.
On the second day, however, he had listeners, and distributed some
books.
At Nowshera, favourable results—being listened to calmly and
attentively, some enquiries and discussions entered into, and some
Gospels and tracts received. There was here a teacher in a school,
who had been educated in the mission school of Lahore, and he it
was whose influence operated favourably. He took some books for
his school.
I forgot to mention an occurrence at Bhimber. I had noticed in the
day a man lying near the 'baraduri,' who was apparently suffering,
and continually uttered cries and moans from the same spot. I called
Suleiman, and with a light proceeded to make enquiries; when it
appeared that this unfortunate man had fallen from a mulberry tree
close by, and had disabled himself so much that he could not
proceed on his way home to Cashmere. So there he was left to shift
for himself, dependent on the charity of passers by, wholly unable to
raise himself from the ground. I sent for the havildar of the guard,
and giving the disabled man five rupees, which I understood to be
ample for the purpose, ordered him to be removed to a house, to be
cared for, and sent to his home when recovered.
Thinking this a good opportunity, I called the attention of some thirty
people, who were looking on, to the fact that the Christian religion
thus enjoined its professors to obey their Lord's commands, and that
the religion of Jesus Christ was love. Not being sufficiently fluent
myself, I requested Suleiman to use this living text, and he
addressed the assemblage, who seemed much impressed, and
expressed their entire concurrence in the sentiments and principles
uttered. But this is often the case without any further consequences.
27th April. From Thanna across the Rattin Pir pass to Byramgullah.
This is a stiff pull, but not precipitous. The path winds about, taking
advantage of the slopes of the mountain to gain the summit
gradually. There is a faquir's establishment on the top, and the view
on either side is very fine. That looking down over the plain past
Rijaori and Nowshera—over the several wave-like lines of inferior
hills into the plains of the Punjab of limitless extent, lost only in
vapour and distance—is grand from its great extent, and beautiful in
its varied features as in its colouring.
The other side presents the masses of the Pir Panjal, covered with
snow. This range is of bold massive proportions, and affords the
traveller a truly sublime picture of mountain scenery.
The descent to Byramgullah is steep and rugged, and altogether
wearisome. But, when accomplished, one is amply compensated for
one's toils. The road from the foot of the mountain crosses a bridge
over a picturesque torrent, clear and rapid, rushing in roaring
cascades below. There is here every component part of a beautiful
landscape, but space. The valley is confined, there being but just
room for the river and a small bit of level on an elevated bank. This
is shut in by lofty hills, some entirely clothed with a rich mantle of
foliage, others having intervals of grassy slopes. But the whole is
singularly beautiful.
There is a fort on an isolated hill, of curious structure, only capable
of defence against bows and arrows, I should think; but it is a
picturesque object, of a Swiss character as to architectural
appearance.
28th April. Along the bed of the torrent to Possianah, crossing some
thirty-five bridges (so called), very awkward for riding, but, on the
whole, an easy march, the scenery of a romantic character.
Possianah is a singularly built village, on the precipitous side of a
mountain which is the vis-a-vis of the redoubtable Pir Panjal; which
here, lifting his snowy summit to the clouds, frowns down upon you
in all his majesty and grandeur, looking by no means affable to
approach, and promising an arduous struggle to get the better of.
The village is at this time more miserable than ever, its ordinary
inhabitants having deserted it to escape the rigours of the winter;
there remained or had returned only two or three. Many houses,
being most inappropriately built with flat roofs, had fallen in, and
altogether the place had anything but a cheerful aspect.
Here, however, I must pass two days, the 29th being Sunday. So I
had the hovel, used as a baraduri, cleaned out, and there ensconced
myself and traps, and had nothing whatever to complain of,—the
most magnificent scenery around me, a delightful climate (the wind,
perhaps, a little too chill here), and no scarcity of creature comforts.
29th April. Sunday. I halted at Possianah. When at Byramgullah, I
heard the Pir was not passable for tattoos, so left mine there to
await orders, intending to leave them to come on in a few days,
when the road would probably be open. But from a near reconnoitre
of the mountain as to snow, and from information acquired, I
determined to run the risk, and sent for my ponies.
As I was at breakfast a saheb was announced, and a stout party
made his appearance, a M. Olive, a French merchant in the shawl
trade, who passes the winter season at Amritsir, returning to
Cashmere, when the passes open, for business.
The Maharajah does not permit Europeans to reside in the valley
during the winter; perhaps, from jealousy of their becoming
permanent residents, and finally annexing the country; perhaps,
because the winter is the time for collecting his revenue, when, it is
said, the most infamous oppression is practised, and complaints are
rife and loud.
I had seen the new comer, but was not acquainted with him, and
could do no less than invite him to share my homely fare, and after
some polite demur he fell to. He spoke no English, and my French
had been lying 'perdue' a couple of years or so; but I assayed to
converse, and eking out my French with Hindostani managed to
keep up the conversation without difficulty. The stout gent had been
carried all the way from Amritsir in a jan-pan—a sort of covered
chair on poles—which four or six men at a time carry on their
shoulders. How he could ever get up the Pir Panjal, I could not
imagine.
Another traveller had also arrived—one, by the bye, I should have
previously noted as having arrived at Rijaori the day I halted there—
an artillery Vet, who had been suffering from some affection of the
head, and irritability of nerves. He dined with me at Rijaori, and
highly approved the mahseer, which he pronounced equal to salmon,
but far inferior in my opinion.
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