0% found this document useful (0 votes)
28 views50 pages

Programming ERLANG Software for a Concurrent World 1st Edition Joe Armstrong - The full ebook with all chapters is available for download

The document promotes the ebook 'Programming Erlang: Software for a Concurrent World' by Joe Armstrong, available for download at ebookname.com. It highlights the importance of using Erlang for writing concurrent applications, reflecting real-world behavior in programming. Additionally, it lists various other ebooks available for instant download on the same platform.

Uploaded by

komakimirin
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
0% found this document useful (0 votes)
28 views50 pages

Programming ERLANG Software for a Concurrent World 1st Edition Joe Armstrong - The full ebook with all chapters is available for download

The document promotes the ebook 'Programming Erlang: Software for a Concurrent World' by Joe Armstrong, available for download at ebookname.com. It highlights the importance of using Erlang for writing concurrent applications, reflecting real-world behavior in programming. Additionally, it lists various other ebooks available for instant download on the same platform.

Uploaded by

komakimirin
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/ 50

Endless Ebook, One Click Away – Start Downloading at ebookname.

com

Programming ERLANG Software for a Concurrent World


1st Edition Joe Armstrong

https://ebookname.com/product/programming-erlang-software-
for-a-concurrent-world-1st-edition-joe-armstrong/

OR CLICK HERE

DOWLOAD EBOOK

Browse and Get More Ebook Downloads Instantly at https://ebookname.com


Click here to visit ebookname.com and download ebook now
Instant digital products (PDF, ePub, MOBI) available
Download now and explore formats that suit you...

Erlang programming 1st ed Edition Francesco Cesarini

https://ebookname.com/product/erlang-programming-1st-ed-edition-
francesco-cesarini/

Programming Elixir Functional Concurrent Pragmatic Fun


1st Edition Dave Thomas

https://ebookname.com/product/programming-elixir-functional-
concurrent-pragmatic-fun-1st-edition-dave-thomas/

Concurrent and Real Time Programming in Ada 3rd Edition


Alan Burns

https://ebookname.com/product/concurrent-and-real-time-
programming-in-ada-3rd-edition-alan-burns/

Research Methods in Sociolinguistics A Practical Guide


1st Edition Janet Holmes

https://ebookname.com/product/research-methods-in-
sociolinguistics-a-practical-guide-1st-edition-janet-holmes/
Gustav Klimt Best of 2nd ed Edition Jane Rogoyska

https://ebookname.com/product/gustav-klimt-best-of-2nd-ed-
edition-jane-rogoyska/

The Chemistry Of Radical Polymerization 2nd Edition


Graeme Moad

https://ebookname.com/product/the-chemistry-of-radical-
polymerization-2nd-edition-graeme-moad/

Infrared Spectra of Rubbers Plastics and Thermoplastic


Elastomers 4th Edition Yvonne Davies

https://ebookname.com/product/infrared-spectra-of-rubbers-
plastics-and-thermoplastic-elastomers-4th-edition-yvonne-davies/

Zora Neale Hurston and American Literary Culture 1st


Edition M. Genevieve West

https://ebookname.com/product/zora-neale-hurston-and-american-
literary-culture-1st-edition-m-genevieve-west/

Hitler s Crusade Bolshevism and the Myth of the


International Jewish Conspiracy Waddington

https://ebookname.com/product/hitler-s-crusade-bolshevism-and-
the-myth-of-the-international-jewish-conspiracy-waddington/
Consumer behavior buying having and being Ninth
Edition. Edition Michael R. Solomon

https://ebookname.com/product/consumer-behavior-buying-having-
and-being-ninth-edition-edition-michael-r-solomon/
The world is parallel.
If we want to write programs that behave as other objects behave in
the real world, then these programs will have a concurrent structure.
Use a language that was designed for writing concurrent applications,
and development becomes a lot easier.
Erlang programs model how we think and interact.
Joe Armstrong
Programming Erlang
Software for a Concurrent World

Joe Armstrong

The Pragmatic Bookshelf


Raleigh, North Carolina Dallas, Texas
Many of the designations used by manufacturers and sellers to distinguish their prod-
ucts are claimed as trademarks. Where those designations appear in this book, and The
Pragmatic Programmers, LLC was aware of a trademark claim, the designations have
been printed in initial capital letters or in all capitals. The Pragmatic Starter Kit, The
Pragmatic Programmer, Pragmatic Programming, Pragmatic Bookshelf and the linking g
device are trademarks of The Pragmatic Programmers, LLC.

Every precaution was taken in the preparation of this book. However, the publisher
assumes no responsibility for errors or omissions, or for damages that may result from
the use of information (including program listings) contained herein.

Our Pragmatic courses, workshops, and other products can help you and your team
create better software and have more fun. For more information, as well as the latest
Pragmatic titles, please visit us at

http://www.pragmaticprogrammer.com

Copyright © 2007 armstrongonsoftware.

All rights reserved.

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


ted, in any form, or by any means, electronic, mechanical, photocopying, recording, or
otherwise, without the prior consent of the publisher.

Printed in the United States of America.

ISBN-10: 1-9343560-0-X
ISBN-13: 978-1-934356-00-5
Printed on acid-free paper with 50% recycled, 15% post-consumer content.
P1.1 printing, July, 2007
Version: 2007-7-17
Contents
1 Begin 12
1.1 Road Map . . . . . . . . . . . . . . . . . . . . . . . . . . 13
1.2 Begin Again . . . . . . . . . . . . . . . . . . . . . . . . . 16
1.3 Acknowledgments . . . . . . . . . . . . . . . . . . . . . . 17

2 Getting Started 18
2.1 Overview . . . . . . . . . . . . . . . . . . . . . . . . . . . 18
2.2 Installing Erlang . . . . . . . . . . . . . . . . . . . . . . 21
2.3 The Code in This Book . . . . . . . . . . . . . . . . . . . 23
2.4 Starting the Shell . . . . . . . . . . . . . . . . . . . . . . 24
2.5 Simple Integer Arithmetic . . . . . . . . . . . . . . . . . 25
2.6 Variables . . . . . . . . . . . . . . . . . . . . . . . . . . . 27
2.7 Floating-Point Numbers . . . . . . . . . . . . . . . . . . 32
2.8 Atoms . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 33
2.9 Tuples . . . . . . . . . . . . . . . . . . . . . . . . . . . . 35
2.10 Lists . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 38
2.11 Strings . . . . . . . . . . . . . . . . . . . . . . . . . . . . 40
2.12 Pattern Matching Again . . . . . . . . . . . . . . . . . . 41

3 Sequential Programming 43
3.1 Modules . . . . . . . . . . . . . . . . . . . . . . . . . . . 43
3.2 Back to Shopping . . . . . . . . . . . . . . . . . . . . . . 49
3.3 Functions with the Same Name and Different Arity . . 52
3.4 Funs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 52
3.5 Simple List Processing . . . . . . . . . . . . . . . . . . . 58
3.6 List Comprehensions . . . . . . . . . . . . . . . . . . . . 61
3.7 Arithmetic Expressions . . . . . . . . . . . . . . . . . . 64
3.8 Guards . . . . . . . . . . . . . . . . . . . . . . . . . . . . 65
3.9 Records . . . . . . . . . . . . . . . . . . . . . . . . . . . . 69
3.10 case and if Expressions . . . . . . . . . . . . . . . . . . 72
3.11 Building Lists in Natural Order . . . . . . . . . . . . . . 73
3.12 Accumulators . . . . . . . . . . . . . . . . . . . . . . . . 74
CONTENTS 6

4 Exceptions 76
4.1 Exceptions . . . . . . . . . . . . . . . . . . . . . . . . . . 76
4.2 Raising an Exception . . . . . . . . . . . . . . . . . . . . 77
4.3 try...catch . . . . . . . . . . . . . . . . . . . . . . . . . . 78
4.4 catch . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 81
4.5 Improving Error Messages . . . . . . . . . . . . . . . . . 82
4.6 Programming Style with try...catch . . . . . . . . . . . . 82
4.7 Catching Every Possible Exception . . . . . . . . . . . . 83
4.8 Old- and New-Style Exception Handling . . . . . . . . . 84
4.9 Stack Traces . . . . . . . . . . . . . . . . . . . . . . . . . 84

5 Advanced Sequential Programming 86


5.1 BIFs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 87
5.2 Binaries . . . . . . . . . . . . . . . . . . . . . . . . . . . 87
5.3 The Bit Syntax . . . . . . . . . . . . . . . . . . . . . . . 89
5.4 Miscellaneous Short Topics . . . . . . . . . . . . . . . . 98

6 Compiling and Running Your Program 118


6.1 Starting and Stopping the Erlang Shell . . . . . . . . . 118
6.2 Modifying the Development Environment . . . . . . . . 119
6.3 Different Ways to Run Your Program . . . . . . . . . . . 122
6.4 Automating Compilation with Makefiles . . . . . . . . . 127
6.5 Command Editing in the Erlang Shell . . . . . . . . . . 130
6.6 Getting Out of Trouble . . . . . . . . . . . . . . . . . . . 131
6.7 When Things Go Wrong . . . . . . . . . . . . . . . . . . 131
6.8 Getting Help . . . . . . . . . . . . . . . . . . . . . . . . . 134
6.9 Tweaking the Environment . . . . . . . . . . . . . . . . 135
6.10 The Crash Dump . . . . . . . . . . . . . . . . . . . . . . 136

7 Concurrency 137

8 Concurrent Programming 141


8.1 The Concurrency Primitives . . . . . . . . . . . . . . . . 142
8.2 A Simple Example . . . . . . . . . . . . . . . . . . . . . 143
8.3 Client-Server—An Introduction . . . . . . . . . . . . . . 144
8.4 How Long Does It Take to Create a Process? . . . . . . 148
8.5 Receive with a Timeout . . . . . . . . . . . . . . . . . . 150
8.6 Selective Receive . . . . . . . . . . . . . . . . . . . . . . 153
8.7 Registered Processes . . . . . . . . . . . . . . . . . . . . 154
8.8 How Do We Write a Concurrent Program? . . . . . . . . 156
8.9 A Word About Tail Recursion . . . . . . . . . . . . . . . 156
8.10 Spawning with MFAs . . . . . . . . . . . . . . . . . . . . 157
8.11 Problems . . . . . . . . . . . . . . . . . . . . . . . . . . . 158
CONTENTS 7

9 Errors in Concurrent Programs 159


9.1 Linking Processes . . . . . . . . . . . . . . . . . . . . . . 159
9.2 An on_exit Handler . . . . . . . . . . . . . . . . . . . . . 160
9.3 Remote Handling of Errors . . . . . . . . . . . . . . . . 162
9.4 The Details of Error Handling . . . . . . . . . . . . . . . 162
9.5 Error Handling Primitives . . . . . . . . . . . . . . . . . 170
9.6 Sets of Linked Processes . . . . . . . . . . . . . . . . . . 172
9.7 Monitors . . . . . . . . . . . . . . . . . . . . . . . . . . . 172
9.8 A Keep-Alive Process . . . . . . . . . . . . . . . . . . . . 173

10 Distributed Programming 175


10.1 The Name Server . . . . . . . . . . . . . . . . . . . . . . 177
10.2 The Distribution Primitives . . . . . . . . . . . . . . . . 182
10.3 Libraries for Distributed Programming . . . . . . . . . 185
10.4 The Cookie Protection System . . . . . . . . . . . . . . . 186
10.5 Socket-Based Distribution . . . . . . . . . . . . . . . . . 187

11 IRC Lite 191


11.1 Message Sequence Diagrams . . . . . . . . . . . . . . . 193
11.2 The User Interface . . . . . . . . . . . . . . . . . . . . . 194
11.3 Client-Side Software . . . . . . . . . . . . . . . . . . . . 195
11.4 Server-Side Software . . . . . . . . . . . . . . . . . . . . 199
11.5 Running the Application . . . . . . . . . . . . . . . . . . 203
11.6 The Chat Program Source Code . . . . . . . . . . . . . . 204
11.7 Exercises . . . . . . . . . . . . . . . . . . . . . . . . . . . 211

12 Interfacing Techniques 212


12.1 Ports . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 213
12.2 Interfacing an External C Program . . . . . . . . . . . . 214
12.3 open_port . . . . . . . . . . . . . . . . . . . . . . . . . . 220
12.4 Linked-in Drivers . . . . . . . . . . . . . . . . . . . . . . 221
12.5 Notes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 225

13 Programming with Files 226


13.1 Organization of the Libraries . . . . . . . . . . . . . . . 226
13.2 The Different Ways of Reading a File . . . . . . . . . . . 227
13.3 The Different Ways of Writing to a File . . . . . . . . . . 235
13.4 Directory Operations . . . . . . . . . . . . . . . . . . . . 239
13.5 Finding Information About a File . . . . . . . . . . . . . 240
13.6 Copying and Deleting Files . . . . . . . . . . . . . . . . 241
13.7 Bits and Pieces . . . . . . . . . . . . . . . . . . . . . . . 241
13.8 A Find Utility . . . . . . . . . . . . . . . . . . . . . . . . 242
CONTENTS 8

14 Programming with Sockets 245


14.1 Using TCP . . . . . . . . . . . . . . . . . . . . . . . . . . 246
14.2 Control Issues . . . . . . . . . . . . . . . . . . . . . . . . 255
14.3 Where Did That Connection Come From? . . . . . . . . 258
14.4 Error Handling with Sockets . . . . . . . . . . . . . . . 259
14.5 UDP . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 260
14.6 Broadcasting to Multiple Machines . . . . . . . . . . . 263
14.7 A SHOUTcast Server . . . . . . . . . . . . . . . . . . . . 265
14.8 Digging Deeper . . . . . . . . . . . . . . . . . . . . . . . 272

15 ETS and DETS: Large Data Storage Mechanisms 273


15.1 Basic Operations on Tables . . . . . . . . . . . . . . . . 274
15.2 Types of Table . . . . . . . . . . . . . . . . . . . . . . . . 275
15.3 ETS Table Efficiency Considerations . . . . . . . . . . . 276
15.4 Creating an ETS Table . . . . . . . . . . . . . . . . . . . 277
15.5 Example Programs with ETS . . . . . . . . . . . . . . . 279
15.6 DETS . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 284
15.7 What Haven’t We Talked About? . . . . . . . . . . . . . 287
15.8 Code Listings . . . . . . . . . . . . . . . . . . . . . . . . 288

16 OTP Introduction 291


16.1 The Road to the Generic Server . . . . . . . . . . . . . . 292
16.2 Getting Started with gen_server . . . . . . . . . . . . . 301
16.3 The gen_server Callback Structure . . . . . . . . . . . . 305
16.4 Code and Templates . . . . . . . . . . . . . . . . . . . . 309
16.5 Digging Deeper . . . . . . . . . . . . . . . . . . . . . . . 312

17 Mnesia: The Erlang Database 313


17.1 Database Queries . . . . . . . . . . . . . . . . . . . . . . 313
17.2 Adding and Removing Data in the Database . . . . . . 317
17.3 Mnesia Transactions . . . . . . . . . . . . . . . . . . . . 319
17.4 Storing Complex Data in Tables . . . . . . . . . . . . . 323
17.5 Table Types and Location . . . . . . . . . . . . . . . . . 325
17.6 Creating the Initial Database . . . . . . . . . . . . . . . 328
17.7 The Table Viewer . . . . . . . . . . . . . . . . . . . . . . 329
17.8 Digging Deeper . . . . . . . . . . . . . . . . . . . . . . . 329
17.9 Listings . . . . . . . . . . . . . . . . . . . . . . . . . . . . 331
CONTENTS 9

18 Making a System with OTP 335


18.1 Generic Event Handling . . . . . . . . . . . . . . . . . . 336
18.2 The Error Logger . . . . . . . . . . . . . . . . . . . . . . 339
18.3 Alarm Management . . . . . . . . . . . . . . . . . . . . . 346
18.4 The Application Servers . . . . . . . . . . . . . . . . . . 348
18.5 The Supervision Tree . . . . . . . . . . . . . . . . . . . . 351
18.6 Starting the System . . . . . . . . . . . . . . . . . . . . 354
18.7 The Application . . . . . . . . . . . . . . . . . . . . . . . 358
18.8 File System Organization . . . . . . . . . . . . . . . . . 360
18.9 The Application Monitor . . . . . . . . . . . . . . . . . . 361
18.10 Digging Deeper . . . . . . . . . . . . . . . . . . . . . . . 361
18.11 How Did We Make That Prime? . . . . . . . . . . . . . . 363
19 Multicore Prelude 365
20 Programming Multicore CPUs 367
20.1 How to Make Programs Run Efficiently on a Multicore CPU 368
20.2 Parallelizing Sequential Code . . . . . . . . . . . . . . . 372
20.3 Small Messages, Big Computations . . . . . . . . . . . 375
20.4 mapreduce and Indexing Our Disk . . . . . . . . . . . . 379
20.5 Growing Into the Future . . . . . . . . . . . . . . . . . . 389
A Documenting Our Program 390
A.1 Erlang Type Notation . . . . . . . . . . . . . . . . . . . . 391
A.2 Tools That Use Types . . . . . . . . . . . . . . . . . . . . 394
B Erlang on Microsoft Windows 396
B.1 Erlang . . . . . . . . . . . . . . . . . . . . . . . . . . . . 396
B.2 Fetch and Install MinGW . . . . . . . . . . . . . . . . . 396
B.3 Fetch and Install MSYS . . . . . . . . . . . . . . . . . . 397
B.4 Install the MSYS Developer Toolkit (Optional) . . . . . 397
B.5 Emacs . . . . . . . . . . . . . . . . . . . . . . . . . . . . 397
C Resources 399
C.1 Online Documentation . . . . . . . . . . . . . . . . . . . 399
C.2 Books and Theses . . . . . . . . . . . . . . . . . . . . . 400
C.3 Link Collections . . . . . . . . . . . . . . . . . . . . . . . 400
C.4 Blogs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 400
C.5 Forums, Online Communities, and Social Sites . . . . 401
C.6 Conferences . . . . . . . . . . . . . . . . . . . . . . . . . 401
C.7 Projects . . . . . . . . . . . . . . . . . . . . . . . . . . . . 401
C.8 Bibliography . . . . . . . . . . . . . . . . . . . . . . . . . 402
CONTENTS 10

D A Socket Application 403


D.1 An Example . . . . . . . . . . . . . . . . . . . . . . . . . 403
D.2 How lib_chan Works . . . . . . . . . . . . . . . . . . . . 406
D.3 The lib_chan Code . . . . . . . . . . . . . . . . . . . . . 409

E Miscellaneous 419
E.1 Analysis and Profiling Tools . . . . . . . . . . . . . . . . 419
E.2 Debugging . . . . . . . . . . . . . . . . . . . . . . . . . . 422
E.3 Tracing . . . . . . . . . . . . . . . . . . . . . . . . . . . . 431
E.4 Dynamic Code Loading . . . . . . . . . . . . . . . . . . . 435

F Module and Function Reference 439


F.1 Module: application . . . . . . . . . . . . . . . . . . . . . 439
F.2 Module: base64 . . . . . . . . . . . . . . . . . . . . . . . 440
F.3 Module: beam_lib . . . . . . . . . . . . . . . . . . . . . . 441
F.4 Module: c . . . . . . . . . . . . . . . . . . . . . . . . . . 441
F.5 Module: calendar . . . . . . . . . . . . . . . . . . . . . . 443
F.6 Module: code . . . . . . . . . . . . . . . . . . . . . . . . 444
F.7 Module: dets . . . . . . . . . . . . . . . . . . . . . . . . . 445
F.8 Module: dict . . . . . . . . . . . . . . . . . . . . . . . . . 448
F.9 Module: digraph . . . . . . . . . . . . . . . . . . . . . . . 449
F.10 Module: digraph_utils . . . . . . . . . . . . . . . . . . . 450
F.11 Module: disk_log . . . . . . . . . . . . . . . . . . . . . . 451
F.12 Module: epp . . . . . . . . . . . . . . . . . . . . . . . . . 452
F.13 Module: erl_eval . . . . . . . . . . . . . . . . . . . . . . . 453
F.14 Module: erl_parse . . . . . . . . . . . . . . . . . . . . . . 453
F.15 Module: erl_pp . . . . . . . . . . . . . . . . . . . . . . . 454
F.16 Module: erl_scan . . . . . . . . . . . . . . . . . . . . . . 454
F.17 Module: erl_tar . . . . . . . . . . . . . . . . . . . . . . . 454
F.18 Module: erlang . . . . . . . . . . . . . . . . . . . . . . . 455
F.19 Module: error_handler . . . . . . . . . . . . . . . . . . . 464
F.20 Module: error_logger . . . . . . . . . . . . . . . . . . . . 464
F.21 Module: ets . . . . . . . . . . . . . . . . . . . . . . . . . 465
F.22 Module: file . . . . . . . . . . . . . . . . . . . . . . . . . 468
F.23 Module: file_sorter . . . . . . . . . . . . . . . . . . . . . 470
F.24 Module: filelib . . . . . . . . . . . . . . . . . . . . . . . . 471
F.25 Module: filename . . . . . . . . . . . . . . . . . . . . . . 471
F.26 Module: gb_sets . . . . . . . . . . . . . . . . . . . . . . . 472
F.27 Module: gb_trees . . . . . . . . . . . . . . . . . . . . . . 474
F.28 Module: gen_event . . . . . . . . . . . . . . . . . . . . . 475
F.29 Module: gen_fsm . . . . . . . . . . . . . . . . . . . . . . 476
CONTENTS 11

F.30 Module: gen_sctp . . . . . . . . . . . . . . . . . . . . . . 477


F.31 Module: gen_server . . . . . . . . . . . . . . . . . . . . . 478
F.32 Module: gen_tcp . . . . . . . . . . . . . . . . . . . . . . . 478
F.33 Module: gen_udp . . . . . . . . . . . . . . . . . . . . . . 479
F.34 Module: global . . . . . . . . . . . . . . . . . . . . . . . . 479
F.35 Module: inet . . . . . . . . . . . . . . . . . . . . . . . . . 480
F.36 Module: init . . . . . . . . . . . . . . . . . . . . . . . . . 481
F.37 Module: io . . . . . . . . . . . . . . . . . . . . . . . . . . 481
F.38 Module: io_lib . . . . . . . . . . . . . . . . . . . . . . . . 482
F.39 Module: lib . . . . . . . . . . . . . . . . . . . . . . . . . . 483
F.40 Module: lists . . . . . . . . . . . . . . . . . . . . . . . . . 483
F.41 Module: math . . . . . . . . . . . . . . . . . . . . . . . . 487
F.42 Module: ms_transform . . . . . . . . . . . . . . . . . . . 487
F.43 Module: net_adm . . . . . . . . . . . . . . . . . . . . . . 487
F.44 Module: net_kernel . . . . . . . . . . . . . . . . . . . . . 488
F.45 Module: os . . . . . . . . . . . . . . . . . . . . . . . . . . 488
F.46 Module: proc_lib . . . . . . . . . . . . . . . . . . . . . . 489
F.47 Module: qlc . . . . . . . . . . . . . . . . . . . . . . . . . 489
F.48 Module: queue . . . . . . . . . . . . . . . . . . . . . . . 490
F.49 Module: random . . . . . . . . . . . . . . . . . . . . . . 491
F.50 Module: regexp . . . . . . . . . . . . . . . . . . . . . . . 492
F.51 Module: rpc . . . . . . . . . . . . . . . . . . . . . . . . . 492
F.52 Module: seq_trace . . . . . . . . . . . . . . . . . . . . . . 494
F.53 Module: sets . . . . . . . . . . . . . . . . . . . . . . . . . 494
F.54 Module: shell . . . . . . . . . . . . . . . . . . . . . . . . 495
F.55 Module: slave . . . . . . . . . . . . . . . . . . . . . . . . 495
F.56 Module: sofs . . . . . . . . . . . . . . . . . . . . . . . . . 496
F.57 Module: string . . . . . . . . . . . . . . . . . . . . . . . . 500
F.58 Module: supervisor . . . . . . . . . . . . . . . . . . . . . 501
F.59 Module: sys . . . . . . . . . . . . . . . . . . . . . . . . . 501
F.60 Module: timer . . . . . . . . . . . . . . . . . . . . . . . . 502
F.61 Module: win32reg . . . . . . . . . . . . . . . . . . . . . . 503
F.62 Module: zip . . . . . . . . . . . . . . . . . . . . . . . . . 504
F.63 Module: zlib . . . . . . . . . . . . . . . . . . . . . . . . . 504

Index 507
Chapter 1

Begin
Oh no! Not another programming language! Do I have to learn yet another
one? Aren’t there enough already?
I can understand your reaction. There are loads of programming lan-
guages, so why should you learn another?
Here are five reasons why you should learn Erlang:
• You want to write programs that run faster when you run them on
a multicore computer.
• You want to write fault-tolerant applications that can be modified
without taking them out of service.
• You’ve heard about “functional programming” and you’re wonder-
ing whether the techniques really work.
• You want to use a language that has been battle tested in real
large-scale industrial products that has great libraries and an
active user community.
• You don’t want to wear your fingers out by typing lots of lines of
code.
Can we do these things? In Section 20.3, Running SMP Erlang, on
page 376, we’ll look at some programs that have linear speed-ups when
we run them on a thirty-two-core computer. In Chapter 18, Making a
System with OTP, we’ll look at how to make highly reliable systems that
have been in round-the-clock operation for years. In Section 16.1, The
Road to the Generic Server, on page 292, we’ll talk about techniques for
writing servers where the software can be upgraded without taking the
server out of service.
R OAD M AP 13

In many places we’ll be extolling the virtues of functional programming.


Functional programming forbids code with side effects. Side effects and
concurrency don’t mix. You can have sequential code with side effects,
or you can have code and concurrency that is free from side effects.
You have to choose. There is no middle way.
Erlang is a language where concurrency belongs to the programming
language and not the operating system. Erlang makes parallel program-
ming easy by modeling the world as sets of parallel processes that can
interact only by exchanging messages. In the Erlang world, there are
parallel processes but no locks, no synchronized methods, and no pos-
sibility of shared memory corruption, since there is no shared memory.
Erlang programs can be made from thousands to millions of extremely
lightweight processes that can run on a single processor, can run on a
multicore processor, or can run on a network of processors.

1.1 Road Map


• Chapter 2, Getting Started, on page 18 is a quick “jump in and
swim around” chapter.
• Chapter 3, Sequential Programming, on page 43 is the first of two
chapters on sequential programming. It introduces the ideas of
pattern matching and of nondestructive assignments.
• Chapter 4, Exceptions, on page 76 is about exception handling. No
program is error free. This chapter is about detecting and handling
errors in sequential Erlang programs.
• Chapter 5, Advanced Sequential Programming, on page 86 is the
second chapter on sequential Erlang programming. It takes up
some advanced topics and fills in the remaining details of sequen-
tial programming.
• Chapter 6, Compiling and Running Your Program, on page 118
talks about the different ways of compiling and running your pro-
gram.
• In Chapter 7, Concurrency, on page 137, we change gears. This
is a nontechnical chapter. What are the ideas behind our way of
programming? How do we view the world?
• Chapter 8, Concurrent Programming, on page 141 is about concur-
rency. How do we create parallel processes in Erlang? How do pro-
cesses communicate? How fast can we create parallel processes?
R OAD M AP 14

• Chapter 9, Errors in Concurrent Programs, on page 159 talks about


errors in parallel programs. What happens when a process fails?
How can we detect process failure, and what can we do about it?
• Chapter 10, Distributed Programming, on page 175 takes up dis-
tributed programming. Here we’ll write several small distributed
programs and show how to run them on a cluster of Erlang nodes
or on free-standing hosts using a form of socket-based distribu-
tion.
• Chapter 11, IRC Lite, on page 191 is a pure application chapter.
We tie together the themes of concurrency and socket-based distri-
bution with our first nontrivial application: a mini IRC-like client
and server program.
• Chapter 12, Interfacing Techniques, on page 212 is all about inter-
facing Erlang to foreign-language code.
• Chapter 13, Programming with Files, on page 226 has numerous
examples of programming with files.
• Chapter 14, Programming with Sockets, on page 245 shows you
how to program with sockets. We’ll look at how to build sequential
and parallel servers in Erlang. We finish this chapter with the sec-
ond sizable application: a SHOUTcast server. This is a streaming
media server, which can be used to stream MP3 data using the
SHOUTcast protocol.
• Chapter 15, ETS and DETS: Large Data Storage Mechanisms, on
page 273 describes the low-level modules ets and dets. ets is a
module for very fast, destructive, in-memory hash table opera-
tions, and dets is designed for low-level disk storage.
• Chapter 16, OTP Introduction, on page 291 is an introduction to
OTP. OTP is a set of Erlang libraries and operating procedures
for building industrial-scale applications in Erlang. This chap-
ter introduces the idea of a behavior (a central concept in OTP).
Using behaviors, we can concentrate on the functional behavior
of a component, while allowing the behavior framework to solve
the nonfunctional aspects of the problem. The framework might,
for example, take care of making the application fault tolerant or
scalable, whereas the behavioral callback concentrates on the spe-
cific aspects of the problem. The chapter starts with a general dis-
cussion on how to build your own behaviors and then moves to
describing the gen_server behavior that is part of the Erlang stan-
dard libraries.
R OAD M AP 15

• Chapter 17, Mnesia: The Erlang Database, on page 313 talks about
the Erlang database management system (DBMS) Mnesia. Mnesia
is an integrated DBMS with extremely fast, soft, real-time
response times. It can be configured to replicate its data over sev-
eral physically separated nodes to provide fault-tolerant operation.
• Chapter 18, Making a System with OTP, on page 335 is the second
of the OTP chapters. It deals with the practical aspects of sewing
together an OTP application. Real applications have a lot of small
messy details. They must be started and stopped in a consistent
manner. If they crash or if subcomponents crash, they must be
restarted. We need error logs so that if they do crash, we can figure
out what happened after the event. This chapter has all the nitty-
gritty details of making a fully blown OTP application.
• Chapter 19, Multicore Prelude, on page 365 is a short introduction
to why Erlang is suited for programming multicore computers. We
talk in general terms about shared memory and message passing
concurrency and why we strongly believe that languages with no
mutable state and concurrency are ideally suited to programming
multicore computers.
• Chapter 20, Programming Multicore CPUs, on page 367 is about
programming multicore computers. We talk about the techniques
for ensuring that an Erlang program will run efficiently on multi-
core computers. We introduce a number of abstractions for speed-
ing up sequential programs on multicore computers. Finally we
perform some measurements and develop our third major pro-
gram, a full-text search engine. To write this, we first implement
a function called mapreduce—this is a higher-order function for
parallelizing a computation over a set of processing elements.
• Appendix A, on page 390, describes the type system used to doc-
ument Erlang functions.
• Appendix B, on page 396, describes how to set up Erlang on the
Windows operating system (and how to configure emacs on all
operating systems).
• Appendix C, on page 399, has a catalog of Erlang resources.
• Appendix D, on page 403, describes lib_chan, which is a library for
programming socket-based distribution.
Other documents randomly have
different content
The Project Gutenberg eBook of Scottish
Reminiscences
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: Scottish Reminiscences

Author: Archibald Geikie

Release date: August 29, 2020 [eBook #63074]


Most recently updated: October 18, 2024

Language: English

Credits: E-text prepared by Susan Skinner, Charlie Howard, and


the Online Distributed Proofreading Team
(http://www.pgdp.net) from page images generously
made available by Internet Archive
(https://archive.org)

*** START OF THE PROJECT GUTENBERG EBOOK SCOTTISH


REMINISCENCES ***
The Project Gutenberg eBook, Scottish Reminiscences, by
Archibald Geikie

Note: Images of the original pages are available through


Internet Archive. See
https://archive.org/details/scottishreminisc00geikuoft

SCOTTISH REMINISCENCES

PUBLISHED BY
JAMES MACLEHOSE AND SONS, GLASGOW
Publishers to the University.

MACMILLAN AND CO., LTD., LONDON.


New York, The Macmillan Co.
London, Simpkin, Hamilton and Co.
Cambridge, Bowes and Bowes.
Edinburgh, Douglas and Foulis.

MCMVIII.

SCOTTISH · REMINIS-
CENCES ❧ ❧ BY SIR
ARCHIBALD · GEIKIE · K.C.B.

GLASGOW · JAMES · MACLEHOSE


AND · SONS · PUBLISHERS · TO
THE · UNIVERSITY · 1908

First Edition, April, 1904.


Reprinted April 1904, 1905, 1908.

GLASGOW: PRINTED AT THE UNIVERSITY PRESS


BY ROBERT MACLEHOSE AND CO. LTD.
FROM THE PREFACE.
One who has sojourned in every part of a country and for sixty years
has mingled with all classes of its inhabitants; who has watched the
decay and disappearance of old, and the uprise of new usages; who
has been ever on the outlook for illustrations of native humour, and
who has been in the habit all along of freely recounting his
experiences to his friends, may perhaps be forgiven if he ventures to
put forth some record of what he has seen and heard, as a slight
contribution to the history of social changes.
Literature is rich in Scottish reminiscences of this kind, so rich
indeed that a writer who adds another volume to the long list runs
great risk of repeating what has already been told. I have done my
best to avoid this danger by turning over the pages of as many
books of this class as I have been able to lay hands upon. In the
course of this reading I have discovered that not a few of the
‘stories’ which I picked up long ago have found their way into print.
These I have generally excluded from the present volume, save in
cases where my version seemed to me better than that which had
been published. But with all my care I cannot hope to have wholly
escaped from pitfalls of this nature.
No one can have read much in this subject without discovering
the perennial vitality of some anecdotes. With slight and generally
local modification, they are told by generation after generation, and
always as if they related to events that had recently occurred and to
persons that were still familiarly known. Yet the essential basis of
their humour may occasionally be traced back a long way. As an
example of this longevity I may cite the incident of snoring in
church, related at p. 86 of the following chapters, where an
anecdote which has been told to me as an event that had recently
happened among people now living was in full vigour a hundred
years ago, and long before that time had formed the foundation of a
clever epigram in the reign of Charles II. Another illustration of this
persistence and transformation may be found in the anecdote of the
wolf’s den (p. 292). The same recurring circumstances may
sometimes conceivably evoke, at long intervals, a similar sally of
humour; but probably in most cases the original story survives,
undergoing a process of gradual evolution and local adaptation as it
passes down from one generation to another.
CONTENTS.
Pages
CHAPTER I.
Social changes in Scotland consequent
on the Union of the Crowns. Impetus
given to these changes after Culloden
in the eighteenth century, and after
the introduction of steam as a motive
power in the nineteenth. Posting from
Scotland to London. Stage coach
travelling to England. Canal travelling
between Edinburgh and Glasgow.
Loch Katrine in 1843. Influence of
Walter Scott. Steamboats to London.
Railroads in Scotland. Effects of
steamboat development in the West
Highlands, 1–37

CHAPTER II.

Traces of Paganism in Scotland. Relics of 38–76


the Celtic Church; ‘Deserts.’ Survival of
Roman Catholicism in West Highlands
and Islands. Influence of the
Protestant clergy. Highland ministers.
Lowland ministers. Diets of
catechising. Street preachers,

CHAPTER III.
The sermon in Scottish Kirks. Intruding
animals in country churches. The
‘collection.’ Church psalmody.
Precentors and organs. Small
congregations in the Highlands. Parish
visitation. Survival of the influence of
clerical teaching. Religious mania, 77–106

CHAPTER IV.

Superstition in Scotland. Holy wells.


Belief in the Devil. Growth of the rigid
observance of the Sabbath. Efforts of
kirk-sessions and presbyteries to
enforce Jewish strictness in regard to
the Sabbath. Illustrations of the
effects of these efforts, 107–141

CHAPTER V.
Litigiousness of the Scots. Sir Daniel
Macnee and jury-trial. Scottish judges,
Patrick Robertson, Cullen, Neaves,
Rutherford Clark. 142–155
CHAPTER VI.
Medical Men. Sandy Wood. Knox. Nairn
and Sir William Gull. A broken leg in
Canna. Changes in the professoriate
and students in the Scottish
Universities. A St. Andrews Professor.
A Glasgow Professor. Some Edinburgh
Professors—Pillans, Blackie, Christison,
Maclagan, Playfair, Chalmers, Tait.
Scottish Schoolmasters. 156–184

CHAPTER VII.

Old and new type of landed proprietors


in Scotland. Highland Chiefs—Second
Marquess of Breadalbane; late Duke
of Argyll. Ayrshire Lairds—T. F.
Kennedy of Dunure; ‘Sliddery Braes’;
Smith of Auchengree. Fingask and
Charles Martin. New lairds of wealth, 185–204

CHAPTER VIII.
Lowland farmers; Darlings of Priestlaw. 205–238
Sheep-farmers. Hall Pringle of Hatton.
Farm-servants. Ayrshire milk-maids.
The consequences of salting.
Poachers. ‘Cauld sowens out o’ a
pewter plate.’ Farm life in the
Highlands. A Skye eviction. Clearances
in Raasay. Summer Shielings of former
times. Fat Boy of Soay. A West
Highlander’s first visit to Glasgow.
Crofters in Skye. Highland ideas of
women’s work. Highland repugnance
to handicrafts,

CHAPTER IX.
Highland ferries and coaches. The
charms of Iona. How to see Staffa.
The Outer Hebrides. Stones of
Callernish. St. Kilda. Sound of Harris.
The Cave-massacre in Eigg. Skeleton
from a clan fight still unburied in Jura.
The hermit of Jura. Peculiar charms of
the Western Isles. Influence of the
clergy on the cheerfulness of the
Highlanders. Disappearance of
Highland customs. Dispersing of clans
from their original districts. Dying out
of Gaelic; advantages of knowing
some Gaelic; difficulties of the
language, 239–273

CHAPTER X.

The Orkney Islands. The Shetland 274–293


Islands. Faroe Islands contrasted with
Western Isles. ‘Burning the water.’ A
fisher of men. Salmon according to
London taste. Trout and fishing-poles.
A wolf’s den,

CHAPTER XI.
Scottish shepherds and their dogs. A
snow-storm among the Southern
Uplands. Scottish inns of an old type.
Reminiscences of some Highland inns.
Revival of roadside inns by cyclists.
Scottish drink. Drinking customs now
obsolete, 294–320

CHAPTER XII.

Scottish humour in relation to death and


the grave. Resurrectionists.
Tombstone inscriptions. ‘Naturals’ in
Scotland. Confused thoughts of
second childhood. Belief in witchcraft.
Miners and their superstitions. Colliers
and Salters in Scotland were slaves
until the end of the eighteenth
century. Metal-mining in Scotland, 321–346

CHAPTER XIII.
Town-life in old times. Dirtiness of the 347–369
streets. Clubs. Hutton and Black in
Edinburgh. A feast of snails. Royal
Society Club. Bailies ‘gang lowse.’
Rothesay fifty years ago. James Smith
of Jordanhill. Fisher-folk of the Forth.
Decay of the Scots language. Receipt
for pronouncing English,

CHAPTER XIV.
The Scottish School of Geology.
Neptunist and Vulcanist Controversy.
J. D. Forbes. Charles Maclaren. Hugh
Miller. Robert Chambers. W. Haidinger.
H. von Dechen. Ami Boué. The life of
a field-geologist. Experiences of a
geologist in the West Highlands. A
crofter home in Skye. The Spar Cave
and Coruisk. Night in Loch Scavaig, 370–409

CHAPTER XV.

Influence of Topography on the people 410–439


of Scotland. Distribution and ancient
antagonism of Celt and Saxon.
Caithness and its grin. Legends and
place-names. Popular explanation of
boulders. Cliff-portraits. Fairy-stones
and supposed human footprints.
Imitative forms of flint. Scottish
climate and its influence on the
people. Indifference of the Highlander
to rain. ‘Dry rain.’ Wind in Scotland.
Salutations on the weather.
Shakespeare on the climate of
Morayland. Influence of environment
on the Highlander,

Index, 440–447
CHAPTER I.
Social changes in Scotland consequent on the Union of the
Crowns. Impetus given to these changes after Culloden in the
eighteenth century, and after the introduction of steam as a
motive power in the nineteenth. Posting from Scotland to
London. Stage coach travelling to England. Canal travelling
between Edinburgh and Glasgow. Loch Katrine in 1843.
Influence of Walter Scott. Steamboats to London. Railroads in
Scotland. Effects of steamboat development in the West
Highlands.

When on the 5th of April, 1603, James VI. left Edinburgh with a great
cavalcade of attendants, to ascend the throne of England, a series of
social changes was set in motion in Scotland which has been
uninterruptedly advancing ever since. Its progress has not been
uniform, seeing that it has fluctuated with the access or diminution of
national animosities on the two sides of the Tweed, until, as these
sources of irritation died away, the two nations were welded into one
by the arts of peace. Looking back across the three centuries, we can
recognise two epochs when the progress of change received a marked
impetus.
ATIONAL ANIMOSITIES
The first of these dates from the failure of the Jacobite cause in
1746. At Culloden, not only were the hopes of the Stuarts finally
extinguished, but a new period was ushered in for the development of
Scotland. The abolition of the heritable jurisdictions, the extension of
the same organised legal system over every part of the kingdom, the
suppression of cattle-raids and other offences by the Highlanders
against their lowland neighbours, the building of good roads, and the
improvement of the old tracks, whereby easy communication was
provided across the country, and especially through the Highlands
between the northern and southern districts—these and other
connected reforms led to the gradual breaking down of the barrier of
animosity that had long kept Highlander and Lowlander apart, and by
thus producing a freer intercourse of the two races, greatly
strengthened the community as a whole, whether for peace or for war.
On the other hand, the landing of Prince Charles Edward, the uprise of
the clans, the victory of Prestonpans, and the invasion of England could
not fail to revive and intensify the ancient enmity of the English against
their northern neighbours. This animosity blazed out anew under the
Bute administration, when fresh fuel was added to it from the literary
side by Wilkes and Churchill. Nevertheless the leaven of union was
quietly at work all the time. Not only did Scot commingle more freely
with Scot, but increasing facilities of communication allowed the
southward tide of migration to flow more freely across the Border.
English travellers also found their way in growing numbers into that
land north of the Tweed which for centuries had been at once scorned
and feared, but which could now be everywhere safely visited. What
had been satirised as

The wretched lot


Of the poor, mean, despised, insulted Scot,

came to be the subject of banter, more or less good humoured. The


Englishman, while retaining a due sense of his own superiority, learnt
to acknowledge that his northern neighbour did really possess some
good qualities which made him not unworthy of a place in the
commonwealth, while the Scot, on his side, discovered that his ‘auld
enemies’ of England were far from being all mere ‘pock-puddings.’ As
the result of this greater intimacy of association, the smaller nation was
necessarily drawn more and more to assimilate itself to the speech and
ways of its larger, wealthier, and more advanced partner.
But the decline in Scottish national peculiarities during the hundred
years that followed Culloden was slow compared with that of the
second epoch, which dates from the first half of last century, when
steam as a motive power came into use, rapidly transforming our
manufacturing industries, and revolutionising the means of locomotion,
alike on land and sea. Scott in his youth saw the relics of the older time
while they were still fairly fresh and numerous, and he has left an
imperishable memorial of them in his vivid descriptions. Cockburn
beheld the last of these relics disappear, and as he lived well on into
the second of the two periods, he could mark and has graphically
chronicled the accelerated rate of change.
OCIAL TRANSFORMATIONS
Those of us who, like myself, can look back across a vista of more
than three score years, and will compare what they see and hear
around them now with what they saw and heard in their childhood, will
not only realise that the social revolution has been marching along, but
will be constrained to admit that its advance has been growing
perceptibly more rapid. They must feel that the old order has indeed
changed, and though they may wish that the modern could establish
itself with less effacement of the antique, and may be disposed with
Byron to cry,

Out upon Time! who for ever will leave


But enough of the past for the future to grieve,

they have, at least, the consolation of reflecting that the changes have
been, on the whole, for the better. Happily much of the transformation
is, after all, external. The fundamental groundwork of national
character and temperament continues to be but little affected. The
surface features and climate of the country, with all their profound, if
unperceived, influences on the people, remain with no appreciable
change. Even the inevitable wave of evolution does not everywhere roll
on with the same speed, but leaves outlying corners and remote
parishes unsubmerged, where we may still light upon survivals of an
older day, in men and women whose ways and language seem to carry
us back a century or more, and in customs that link us with an even
remoter past.
ODES OF TRAVEL
It would be far beyond my purpose to enter into any discussion of
the connection between the causes that have given rise to these social
changes and the effects that have flowed from them. The far-reaching
results of the introduction of steam-machinery in aggregating
communities around a few centres, in depopulating the country
districts, and in altering the habits and physique of the artizans, open
up a wide subject on which I do not propose to touch. My life has been
largely passed in the rural and mountainous parts of the country, where
increased facilities for locomotion have certainly been the most obvious
direct source of change to the inhabitants, though other causes have
undoubtedly contributed less directly to bring about the general result.
It has been my good fortune to become acquainted with every district
of Scotland. There is not a county, hardly a parish, which I have not
wandered over again and again. In many of them I have spent months
at a time, finding quarters in county towns, in quiet villages, in wayside
inns, in country houses, in remote manses, in shepherds’ shielings, and
in crofters’ huts. Thrown thus among all classes of society, I have been
brought in contact with each varying phase of life of the people. During
the last twenty years, though no longer permanently resident in
Scotland, I have been led by my official duties to revisit the country
every year, even to its remotest bounds. I have also been enabled,
through the kindness of a yachting friend, to cruise all through the
Inner and Outer Hebrides. These favourable opportunities have allowed
me to mark the gradual decline of national peculiarities perhaps more
distinctly than would have been possible to one continuously resident.
As a slight contribution to the history of the social evolution in
Scotland, I propose in the following chapters to gather together such
reminiscences as may serve to indicate the nature and extent of the
changes of which I have been a witness, and to record a few
illustrations of the manners and customs, the habits and humour of the
people with whom I have mingled.
My memory goes back to a time before railways had been
established in Scotland, when Edinburgh and Glasgow were connected
only by a coach-road and a canal, and when stage-coaches still ran
from the two cities into England. I may therefore begin these
reminiscences with some reference to modes of travel.
Probably few readers are aware how recently roads practicable for
wheeled carriages have become general over the whole country. In the
seventeenth century various attempts were made to run stage-coaches
between Edinburgh and Leith, between Edinburgh and Haddington, and
between Edinburgh and Glasgow. But these efforts to open up
communication, even with the chief towns, appear to have met with
such scant support as to be soon abandoned. The usual mode of
conveyance, for ladies as well as gentlemen, was on horseback. A
traveller writing in 1688 states that there were then no stage-coaches,
for the roads would hardly allow of them, and that although some of
the magnates of the land made use of a coach and six horses, they did
so ‘with so much caution that, besides their other attendance, they
have a lusty running footman on each side of the coach, to manage
and keep it up in rough places.’ It was probably not until after the
suppression of the Jacobite rising in 1715 that road-making and road-
repair were begun in earnest. For strategic purposes, military roads
were driven through the Highlands, and this important work, which
continued until far on in the century, not only opened up the Highlands
to wheeled traffic, but reacted on the general lines of communication
1
throughout the country. By the time that railways came into operation
the main roads had been well engineered and constructed, and were
fitted for all kinds of vehicles.
OCOMOTION TO ENGLAND
Before the beginning of the railroad period, the inhabitants of
Scotland had three means of locomotion into England. Those who were
wealthy took their own carriages and horses, or hired post-horses from
stage to stage. For the ordinary traveller, there were stage-coaches on
land and steamboats on the sea.
With a comfortable carriage, and the personal effects of the
occupants strapped on behind it, posting to London was one of the
pleasant incidents of the year to those who had leisure and money at
command. Repeated season after season, the journey brought the
travellers into close acquaintance with every district through which the
public road passed. They had a far greater familiarity with the details of
these districts than can now be formed in railway journeys. They knew
every village, church, and country-house to be seen along the route,
and could mark the changes made in them from year to year. At the
inns, where they halted for the night, they were welcomed as old
friends, and made to feel themselves at home. This pleasant mode of
travelling, so graphically described in Humphry Clinker, continued in
use among some county families long after the stage-coaches had
reached the culmination of their speed and comfort. My old friend, T. F.
Kennedy of Dunure, used to describe to me the delights of these yearly
journeys in his youth. Posting into England did not die out until after
the completion of the continuous railway routes, when the failure of
travellers on the road led to the giving up of post-horses at the inns.
AGE-COACHES TO LONDON
One of my early recollections is to have seen the London coaches
start from Princes Street, Edinburgh. Though railways were beginning
to extend rapidly over England, no line had yet entered Scotland, so
that the first part of the journey to London was made by stage-coach.
There was at that time no line of railway, with steam locomotives,
leading out of Edinburgh. Stage-coaches appear to have been tried
between London and Edinburgh as far back as 1658, for an
advertisement published in May of that year announces that they would
‘go from the George Inn without Aldersgate to Edinburgh in Scotland,
once in three weeks for £4 10s., with good coaches and fresh horses
on the roads.’ In May, 1734, a coach was advertised to perform the
journey between Edinburgh and London ‘in nine days, or three days
sooner than any other coach that travels the road.’ An improvement in
the service, made twenty years later, was thus described in an
advertisement which appeared in the Edinburgh Evening Courant for
July 1st, 1754:

‘The Edinburgh Stage-Coach, for the better accommodation


of Passengers, will be altered to a new genteel two-end Glass
Machine, hung on Steel Springs, exceeding light and easy, to go
in ten days in summer and twelve in winter; to set out the first
Tuesday in March, and continue it from Hosea Eastgate’s, the
Coach and Horses in Dean Street, Soho, London, and from John
Somerville’s in the Canongate, Edinburgh, every other Tuesday,
and meet at Burrow-bridge on Saturday night, and set out from
thence on Monday morning, and get to London and Edinburgh
on Friday. In the winter to set out from London and Edinburgh
every other Monday morning and to go to Burrow-bridge on
Saturday night; and to set out thence on Monday morning and
get to London and Edinburgh on Saturday night. Passengers to
pay as usual. Performed, if God permits, by your dutiful servant,
‘Hosea Eastgate.
‘Care is taken of small parcels according to their value.’

Before the end of the century the frequency, comfort, and speed of
the coaches had been considerably increased. Palmer, of the Bath
Theatre, led the way in this reform, and in the year 1788 organised a
service from London to Glasgow, which accomplished the distance of
rather more than 400 miles in sixty-five hours. Ten years later, Lord
Chancellor Campbell travelled by the same system of coaches between
Edinburgh and London, and he states that in 1798 he ‘performed the
journey in three nights and two days, Mr. Palmer’s mail-coaches being
then established; but this swift travelling was considered dangerous as
well as wonderful,—and I was gravely advised to stop a day at York,
“as several passengers who had gone through without stopping had
died of apoplexy from the rapidity of the motion.” The whole distance
may now (1847) be accomplished with ease and safety in fourteen
2
hours.’
DINBURGH AND GLASGOW COACHES
Passengers between Edinburgh and Glasgow before the days of
railways had a choice of two routes, either by road or by canal. As far
back as the summer of 1678, an Edinburgh merchant set up a stage-
coach between the two cities to carry six passengers, but it appears to
have had no success. In 1743, another Edinburgh merchant offered to
start a stage-coach on the same route with six horses, to hold six
passengers, to go twice a week in summer and once in winter. But his
proposal does not appear to have met with adequate support. At last,
in 1749, a kind of covered spring-cart, known as the ‘Edinburgh and
Glasgow Caravan,’ was put upon the road and performed the journey of
forty-four miles in two days. Nine years later, in 1758, the ‘Fly,’ so called
on account of its remarkable speed, actually accomplished the distance
in twelve hours. The establishment of Palmer’s improved stage-coaches
led to a further advance in the communications between Edinburgh and
Glasgow, but it was not until 1799 that the time taken in the journey
was reduced to six hours. In my boyhood, before the stage-coaches
were driven off by the railway, various improvements on the roads, the
carriages, and the arrangements connected with the horses, had
3
brought down the time to no more than four hours and a half.
Much more leisurely was the transit on the Union Canal. The boats
were comfortably fitted up and were drawn by a cavalcade of horses,
urged forward by postboys. It was a novel and delightful sensation,
which I can still recall, to see fields, trees, cottages, and hamlets flit
past, as if they formed a vast moving panorama, while one seemed to
be sitting absolutely still. For mere luxury of transportation, such canal-
travel stands quite unrivalled. Among its drawbacks, however, are the
long detentions at the locks. But as everything was new to me in my
first expedition to the west, I remember enjoying these locks with the
keenest pleasure, sometimes remaining in the boat, and feeling it
slowly floated up or let down, sometimes walking along the margin and
watching the rush of the water through the gradually opening sluices.
OCH KATRINE IN 1843
Both the stage-coaches and the passenger boats on the canal were
disused after the opening of the Edinburgh and Glasgow Railway in the
spring of 1842. A few weeks subsequent to the running of the first
trains, the Glasgow Courier announced that ‘the whole of the stage-
coaches from Glasgow and Edinburgh are now off the road, with the
exception of the six o’clock morning coach, which is kept running in
consequence of its carrying the mail bags.’
Steamboats had not yet been introduced upon the large freshwater
lakes of Scotland, except upon Loch Lomond, when I visited the
Trossachs region for the first time in 1843. I was rowed the whole
length of Loch Katrine in a boat by four stout Highlanders, who sang
Gaelic songs, to the cadence of which they kept time with their oars. It
was my first entry into the Highlands, and could not have been more
impressive. The sun was almost setting as the boat pushed off from
Stronachlachar and all the glories of the western sky were cast upon
the surrounding girdle of mountains, the reflections of which fell
unbroken on the mirror-like surface of the water. As we advanced and
the sunset tints died away, the full autumn moon rose above the crest
of Ben Venue, and touched off the higher crags with light, while the
shadows gathered in deepening black along the lower slopes and the
margin of the water. Before we reached the lower end of the lake the
silvery sheen filled all the pass of the Trossachs above the sombre
forest. The forms of the hills, the changing lights in the sky, and the
weird tunes of the boatmen combined to leave on my memory a
picture as vivid now as when it was impressed sixty years ago.
No more remarkable contrast between the present tourist traffic in
this lake region and that of the early part of last century could be
supplied than that which is revealed by an incident recorded as having
occurred about the year 1814, four years after the publication of Scott’s
Lady of the Lake. An old Highlander, who was met on the top of Ben
Lomond, said he had been a guide from the north side of the mountain
for upwards of forty years; ‘but that d——d Walter Scott, that
everybody makes such a work about!’ exclaimed he with vehemence—‘I
wish I had him to ferry over Loch Lomond: I should be after sinking the
boat, if I drowned myself into the bargain; for ever since he wrote his
Lady of the Lake, as they call it, everybody goes to see that filthy hole
Loch Katrine, then comes round by Luss, and I have had only two
gentlemen to guide all this blessed season, which is now at an end. I
shall never see the top of Ben Lomond again!—The devil confound his
4
ladies and his lakes, say I!’
OTT AND THE HIGHLANDS
If this indignant mountaineer could revisit his early haunts, his
grandchildren would have a very different story to tell him of the poet’s
influence. For one visitor to his beloved mountain in his day there must
now be at least a hundred, almost all of whom have had their first
longing to see that region kindled by the poems and tales of Scott. No
man ever did so much to make his country known and attractive as the
Author of Waverley has done for Scotland. His fictitious characters have
become historical personages in the eyes of the thousands of pilgrims
who every year visit the scenes he has described. In threading the pass
of the Trossachs, they try to see where Fitz James must have lost his
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!

ebookname.com

You might also like