Programming Language Concepts Peter Sestoft 2024 Scribd Download
Programming Language Concepts Peter Sestoft 2024 Scribd Download
com
https://textbookfull.com/product/programming-
language-concepts-peter-sestoft/
https://textbookfull.com/product/java-precisely-third-edition-the-mit-
press-peter-sestoft/
textbookfull.com
https://textbookfull.com/product/the-language-of-surrealism-peter-
stockwell/
textbookfull.com
https://textbookfull.com/product/programming-php-4th-edition-peter-
macintyre/
textbookfull.com
https://textbookfull.com/product/emerging-research-in-computing-
information-communication-and-applications-ercica-2018-volume-1-n-r-
shetty/
textbookfull.com
Internet Science 4th International Conference INSCI 2017
Thessaloniki Greece November 22 24 2017 Proceedings 1st
Edition Ioannis Kompatsiaris Et Al. (Eds.)
https://textbookfull.com/product/internet-science-4th-international-
conference-insci-2017-thessaloniki-greece-
november-22-24-2017-proceedings-1st-edition-ioannis-kompatsiaris-et-
al-eds/
textbookfull.com
https://textbookfull.com/product/3d-cell-culture-methods-and-
protocols-methods-in-molecular-biology-2764-2nd-edition-zuzana-
sumbalova-koledova/
textbookfull.com
https://textbookfull.com/product/brain-computer-
interfaces-2-technology-and-applications-1st-edition-maureen-clerc/
textbookfull.com
https://textbookfull.com/product/diagnostic-molecular-biology-chang-
hui-shen/
textbookfull.com
https://textbookfull.com/product/alessandro-torlonia-the-popes-
banker-1st-edition-daniela-felisini-auth/
textbookfull.com
Environmental Public Policy Making Exposed: A Guide for
Decision Makers and Interested Citizens Cynthia H. Stahl
https://textbookfull.com/product/environmental-public-policy-making-
exposed-a-guide-for-decision-makers-and-interested-citizens-cynthia-h-
stahl/
textbookfull.com
Undergraduate Topics in Computer Science
Peter Sestoft
Programming
Language
Concepts
Second Edition
Undergraduate Topics in Computer Science
Series editor
Ian Mackie
Advisory Board
Samson Abramsky, University of Oxford, Oxford, UK
Karin Breitman, Pontifical Catholic University of Rio de Janeiro, Rio de Janeiro, Brazil
Chris Hankin, Imperial College London, London, UK
Dexter C. Kozen, Cornell University, Ithaca, USA
Andrew Pitts, University of Cambridge, Cambridge, UK
Hanne Riis Nielson, Technical University of Denmark, Kongens Lyngby, Denmark
Steven S. Skiena, Stony Brook University, Stony Brook, USA
Iain Stewart, University of Durham, Durham, UK
Undergraduate Topics in Computer Science (UTiCS) delivers high-quality instruc-
tional content for undergraduates studying in all areas of computing and information
science. From core foundational and theoretical material to final-year topics and
applications, UTiCS books take a fresh, concise, and modern approach and are ideal
for self-study or for a one- or two-semester course. The texts are all authored by
established experts in their fields, reviewed by an international advisory board, and
contain numerous examples and problems. Many include fully worked solutions.
Programming Language
Concepts
Second Edition
123
Peter Sestoft
IT University of Copenhagen, Computer
Science Department
Copenhagen
Denmark
What is Covered
Topics covered include abstract and concrete syntax; functional and imperative
programming languages; interpretation, type checking, and compilation; peep-hole
optimizations; abstract machines, automatic memory management and garbage
collection; the Java Virtual Machine and Microsoft’s .NET Common Language
Runtime; and real machine code for the x86 architecture.
Some effort is made throughout to put programming language concepts into their
historical context, and to show how the concepts surface in languages that the
students are assumed to know already; primarily Java or C#.
We do not cover regular expressions and parser construction in much detail. For
this purpose, we refer to Torben Mogensen’s textbook; see Chap. 3 and its references.
Apart from various updates, this second edition adds a synthesis chapter, con-
tributed by Niels Hallenberg, that presents a compiler from a small functional
language called micro-SML to an abstract machine; and a chapter that presents a
compiler from a C subset called micro-C to real x86 machine code.
The book’s emphasis is on virtual stack machines and their intermediate languages,
often known as bytecode. Virtual machines are machine-like enough to make the
central purpose and concepts of compilation and code generation clear, yet they are
much simpler than present-day microprocessors such as Intel i7 and similar.
v
vi Preface
Why F#?
Supporting Material
There are practical exercises at the end of each chapter. Moreover, the book is
accompanied by complete implementations in F# of lexer and parser specifications,
abstract syntaxes, interpreters, compilers, and runtime systems (abstract machines,
in Java and C) for a range of toy languages. This material, and lecture slides in PDF,
are available separately from the book’s homepage: http://www.itu.dk/people/
sestoft/plc/.
Acknowledgements
This book originated as lecture notes for courses held at the IT University of
Copenhagen, Denmark. I would like to thank Andrzej Wasowski, Ken Friis Larsen,
Hannes Mehnert, David Raymond Christiansen and past students, in particular
Niels Kokholm, Mikkel Bundgaard, and Ahmad Salim Al-Sibahi, who pointed out
mistakes and made suggestions on examples and presentation in earlier drafts. Niels
Kokholm wrote an early version of the machine code generating micro-C compiler
presented in Chap. 14. Thanks to Luca Boasso, Mikkel Riise Lund, and Paul
Jurczak for pointing out misprints and unclarities in the first edition. I owe a lasting
debt to Neil D. Jones and Mads Tofte who influenced my own view of program-
ming languages and the presentation of programming language concepts.
Niels Hallenberg deserves a special thanks for contributing all of Chap. 13 to this
second edition.
1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1
1.1 Files for This Chapter . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1
1.2 Meta Language and Object Language . . . . . . . . . . . . . . . . . . . 1
1.3 A Simple Language of Expressions . . . . . . . . . . . . . . . . . . . . 2
1.3.1 Expressions Without Variables . . . . . . . . . . . . . . . . . 2
1.3.2 Expressions with Variables . . . . . . . . . . . . . . . . . . . . 3
1.4 Syntax and Semantics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5
1.5 Representing Expressions by Objects . . . . . . . . . . . . . . . . . . . 6
1.6 The History of Programming Languages . . . . . . . . . . . . . . . . . 8
1.7 Exercises . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9
References . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12
2 Interpreters and Compilers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13
2.1 Files for This Chapter . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13
2.2 Interpreters and Compilers . . . . . . . . . . . . . . . . . . . . . . . . . . . 13
2.3 Scope and Bound and Free Variables . . . . . . . . . . . . . . . . . . . 14
2.3.1 Expressions with Let-Bindings and Static Scope . . . . . 15
2.3.2 Closed Expressions . . . . . . . . . . . . . . . . . . . . . . . . . . 16
2.3.3 The Set of Free Variables . . . . . . . . . . . . . . . . . . . . . 17
2.3.4 Substitution: Replacing Variables by Expressions . . . . 17
2.4 Integer Addresses Instead of Names . . . . . . . . . . . . . . . . . . . . 20
2.5 Stack Machines for Expression Evaluation . . . . . . . . . . . . . . . 22
2.6 Postscript, a Stack-Based Language . . . . . . . . . . . . . . . . . . . . 23
2.7 Compiling Expressions to Stack Machine Code . . . . . . . . . . . 25
2.8 Implementing an Abstract Machine in Java . . . . . . . . . . . . . . . 26
2.9 History and Literature . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 26
2.10 Exercises . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 26
References . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 29
3 From Concrete Syntax to Abstract Syntax . . . . . . . . . . . . . . . . . . . 31
3.1 Preparatory Reading . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31
3.2 Lexers, Parsers, and Generators . . . . . . . . . . . . . . . . . . . . . . . 32
ix
x Contents
This chapter introduces the approach taken and the plan followed in this book. We
show how to represent arithmetic expressions and other program fragments as data
structures in F# as well as Java, and how to compute with such program fragments.
We also introduce various basic concepts of programming languages.
File Contents
Intro/Intro1.fs simple expressions without variables, in F#
Intro/Intro2.fs simple expressions with variables, in F#
Intro/SimpleExpr.java simple expressions with variables, in Java
function, recursion, list, pattern matching, and datatype. Several books give a more
detailed introduction, including Hansen and Rischel [1] and Syme et al. [6].
It is convenient to run F# interactive sessions inside Microsoft Visual Studio (under
MS Windows), or executing fsharpi interactive sessions using Mono (under Linux
and MacOS X); see Appendix A.
First, let us consider expressions consisting only of integer constants and two-
argument (dyadic) operators such as (+) and (*). We represent an expression as a
term of an F# datatype expr, where integer constants are represented by constructor
CstI, and operator applications are represented by constructor Prim:
type expr =
| CstI of int
| Prim of string * expr * expr
A value of type expr is an abstract syntax tree that represents an expression. Here
are some example expressions and their representations as expr values:
Now, let us extend our expression language with variables such as x and y. First, we
add a new constructor Var to the syntax:
type expr =
| CstI of int
| Var of string
| Prim of string * expr * expr
Next we need to extend the eval interpreter to give a meaning to such variables.
To do this, we give eval an extra argument env, a so-called environment. The role
of the environment is to associate a value (here, an integer) with a variable; that is,
the environment is a map or dictionary, mapping a variable name to the variable’s
current value. A simple classical representation of such a map is an association list:
a list of pairs of a variable name and the associated value:
let env = [("a", 3); ("c", 78); ("baf", 666); ("b", 111)];;
This environment maps "a" to 3, "c" to 78, and so on. The environment has
type (string * int) list. An empty environment, which does not map any
variable to anything, is represented by the empty association list
let emptyenv = [];;
As promised, our new eval function takes both an expression and an environment,
and uses the environment and the lookup function to determine the value of a
variable Var x. Otherwise the function is as before, except that env must be passed
on in recursive calls:
let rec eval e (env : (string * int) list) : int =
match e with
| CstI i -> i
| Var x -> lookup env x
| Prim("+", e1, e2) -> eval e1 env + eval e2 env
| Prim("*", e1, e2) -> eval e1 env * eval e2 env
| Prim("-", e1, e2) -> eval e1 env - eval e2 env
| Prim _ -> failwith "unknown primitive";;
Note that our lookup function returns the first value associated with a variable, so
if env is [("x", 11); ("x", 22)], then lookup env "x" is 11, not 22.
This is useful when we consider nested scopes in Chap. 2.
1.4 Syntax and Semantics 5
We have already mentioned syntax and semantics. Syntax deals with form: is this
program text well-formed? Semantics deals with meaning: what does this (well-
formed) program mean, how does it behave – what happens when we execute it?
The distinction between syntax and static semantics is not clear-cut. Syntax can tell
us that x12 is a legal variable name (in Java), but it is impractical to use syntax
to check that we do not declare x12 twice in the same scope (in Java). Hence this
restriction is usually enforced by static semantics checks.
In the rest of the book we shall study a small expression language, two small
functional languages (a first-order and a higher-order one), a subset of the imperative
language C, and a subset of the backtracking language Icon. In each case we take
the following approach:
In addition we study some abstract stack machines, both homegrown ones and
two widely used so-called managed execution platforms: The Java Virtual Machine
(JVM) and Microsoft’s Common Language Infrastructure (CLI, also known as .Net).
Note that each Expr subclass has fields of exactly the same types as the arguments
of the corresponding constructor in the expr datatype from Sect. 1.3.2. For instance,
class CstI has a field of type int just as constructor CstI has an argument of
type int. In object-oriented terms Prim is a composite because it has fields whose
type is its base type Expr; in functional programming terms one would say that type
expr is a recursively defined datatype.
How can we define an evaluation method for expressions similar to the F# eval
function in Sect. 1.3.2? That eval function uses pattern matching, which is not
available in Java or C#. A poor solution would be to use an if-else sequence that
tests on the class of the expression, as in if (e instanceof CstI) and so on.
1.5 Representing Expressions by Objects 7
Since 1956, thousands of programming languages have been proposed and imple-
mented, several hundred of which have been widely used. Most new programming
languages arise as a reaction to some language that the designer knows (and likes
or dislikes) already, so one can propose a family tree or genealogy for programming
languages, just as for living organisms. Figure 1.1 presents one such attempt. Of
course there are many many more languages than those shown, in particular if one
counts also more domain-specific languages such as Matlab, SAS and R, and strange
“languages” such as spreadsheets [5].
In general, languages lower in the diagram (near the time axis) are closer to
the real hardware than those higher in the diagram, which are more “high-level”
in some sense. In Fortran77 or C, it is fairly easy to predict what instructions and
how many instructions will be executed at run-time for a given line of program. The
mental machine model that the C or Fortran77 programmer must use to write efficient
programs is close to the real machine.
Conversely, the top-most languages (SASL, Haskell, Standard ML, F#, Scala)
are functional languages, possibly with lazy evaluation, with dynamic or advanced
static type systems and with automatic memory management, and it is in general
difficult to predict how many machine instructions are required to evaluate any given
expression. The mental machine model that the Haskell or Standard ML or F# or
Scala programmer must use to write efficient programs is far from the details of a
real machine, so he can think on a rather higher level. On the other hand, he loses
control over detailed efficiency.
It is remarkable that the recent mainstream languages Java and C#, especially their
post-2004 incarnations, have much more in common with the academic languages
of the 1980’s than with those languages that were used in the “real world” during
those years (C, Pascal, C++).
SASL HASKELL
F#
LISP ML STANDARD ML
Scala
CAML LIGHT OCAML
SCHEME C# 2 C# 4
PROLOG GJ Java 5
BETA
SMALLTALK JAVA C# VB.NET 10
Go
SIMULA VISUAL BASIC
ALGOL 68 C++
ALGOL
CPL BCPL B C
FORTRAN FORTRAN77
1.7 Exercises
Exercise 1.1 (i) File Intro2.fs contains a definition of the expr expression
language and an evaluation function eval. Extend the eval function to handle
three additional operators: "max", "min", and "==". Like the existing operators,
they take two argument expressions. The equals operator should return 1 when true
and 0 when false.
(ii) Write some example expressions in this extended expression language, using
abstract syntax, and evaluate them using your new eval function.
(iii) Rewrite one of the eval functions to evaluate the arguments of a primitive
before branching out on the operator, in this style:
let rec eval e (env : (string * int) list) : int =
match e with
| ...
| Prim(ope, e1, e2) ->
let i1 = ...
let i2 = ...
match ope with
| "+" -> i1 + i2
| ...
(iv) Extend the expression language with conditional expressions If(e1, e2,
e3) corresponding to Java’s expression e1 ? e2 : e3 or F#’s conditional
expression if e1 then e2 else e3.
10 1 Introduction
You need to extend the expr datatype with a new constructor If that takes three
expr arguments.
(v) Extend the interpreter function eval correspondingly. It should evaluate e1, and
if e1 is non-zero, then evaluate e2, else evaluate e3. You should be able to evaluate
the expression If(Var "a", CstI 11, CstI 22) in an environment that
binds variable a.
Note that various strange and non-standard interpretations of the conditional
expression are possible. For instance, the interpreter might start by testing whether
expressions e2 and e3 are syntactically identical, in which case there is no need to
evaluate e1, only e2 (or e3). Although possible, this shortcut is rarely useful.
Exercise 1.2 (i) Declare an alternative datatype aexpr for a representation of arith-
metic expressions without let-bindings. The datatype should have constructors CstI,
Var, Add, Mul, Sub, for constants, variables, addition, multiplication, and subtrac-
tion.
Then x ∗ (y + 3) is represented as Mul(Var "x", Add(Var "y", CstI
3)), not as Prim("*", Var "x", Prim("+", Var "y", CstI 3)).
(ii) Write the representation of the expressions v − (w + z) and 2 ∗ (v − (w + z))
and x + y + z + v.
(iii) Write an F# function fmt : aexpr -> string to format expressions
as strings. For instance, it may format Sub(Var "x", CstI 34) as the string
"(x - 34)". It has very much the same structure as an eval function, but takes no
environment argument (because the name of a variable is independent of its value).
(iv) Write an F# function simplify : aexpr -> aexpr to perform expres-
sion simplification. For instance, it should simplify (x + 0) to x, and simplify (1 + 0)
to 1. The more ambitious student may want to simplify (1 + 0) ∗ (x + 0) to x. Hint:
Pattern matching is your friend. Hint: Don’t forget the case where you cannot simplify
anything.
You might consider the following simplifications, plus any others you find useful
and correct:
0+e −→ e
e+0 −→ e
e−0 −→ e
1∗e −→ e
e∗1 −→ e
0∗e −→ 0
e∗0 −→ 0
e−e −→ 0
I remain, sir,
Your faithful and obliged friend,
BJARNI JOHNSON.
A man who can write thus, who can so express himself, in the purest
and most forcible English, does not belong to a community of people
who are entirely ignorant of the world at large, or indifferent to the
national, political, and educational movements of the powerful
nations of the earth. If the Danish government should open the
ports of Iceland to all nations, it would be in accordance with the
advanced and progressive spirit of the age, and while conferring a
great benefit on a quiet, peaceful, and isolated colony, knit more
closely the ties of affection and union between the colonists and the
parent country. Then we might chronicle the arrival and departure of
vessels, a little oftener, between the northern isle of the ocean and
our own seaports.
Last year, a ship bearing the classic name of the “SAGA,”[43] sailed into
the harbor of New-York, direct from Iceland, being the first arrival
from that country to this, in a period of more than eight hundred
years! I think the maritime records of the world would be searched
in vain for a parallel case. The crew of this ship were the “followers”
of Eric the Red, and his compeers, who discovered the American
continent, and gave it the name of Vinland; but they were certainly a
long time in following him.[44]
FOOTNOTES:
40. “Tiðindi frá Alþingi. Annað þing, 1 Juli til 7 Agust, 1847.”
44. Since the above was in type, intelligence has arrived from
Denmark, that a law has just been passed, throwing open the
ports of Iceland to the trade of the world. For this, none will
rejoice more than the Icelanders themselves; for a more
relentless, grinding, and hated monopoly never oppressed a
poor people. The resident Danish merchants will now not be
able to have every thing their own way. As the law takes effect
in April, 1855, a trade between Iceland and England, and
Iceland and America, will soon spring up. The articles that the
Icelanders most require from foreign countries, and the
productions of the island which they have to export, will be
found enumerated in preceding chapters.
CHAPTER XXVIII
THOUGH this little book was not written for the Iceland market, I
cannot help making one or two remarks respecting their own
internal affairs. Most undoubtedly they have learned more from
experience than a foreigner from a hasty visit could teach them, but
I believe they do not appreciate the productiveness and value of
their soil. As scanty as are the agricultural resources of Iceland, and
as short as their seasons are, I am confident that this “art of arts”
might be greatly advanced here. Plowing would, certainly, in many
places, greatly improve their land, smooth the surface, and enable
them to lay it down with a better quality of grass. Their seed would,
the most of it, however, have to be brought from foreign countries.
On seeing their fine meadows of “red top”—the kind of grass most
prevalent,—I at once told them that the white, if not the red clover,
would be much more productive than their native grasses.
Afterwards, I saw many farms in the valleys of the Laxá and the
Thiorsá rivers, that were well seeded with white clover; and as it
was the haying season, I could see that these farms yielded about
double the hay that other farms did, where there was no clover. The
clover had once been sown, and then it had propagated itself. I
believe many of the more favorably located farms could be made to
produce barley and oats, if the land were properly prepared. These
grains are raised in Orkney, Shetland, and the Faroe Isles; and the
latter group is but little south of Iceland. Nothing would do, however,
without plowing; and in Iceland never a horse wore harness yet, so
it would take a little time to get such a business started. If the
governor of Iceland were a thoroughly practical man, he could do
much towards introducing these and other improvements. A good
opening place for the plow would be the “public square” in
Reykjavik, about two acres of irregular grass; that, once broken up,
and leveled, and seeded down to white clover, would make a
beautiful village green. If they had plows, they would make larger
gardens than they now do with the spade, and more table
vegetables would be raised. This would be conducive to the health
and comfort of the people, and would, probably, in time, if not
entirely eradicate at least greatly reduce the diseases of the skin,
and that terrible plague, the leprosy; both of which are somewhat
common, and undoubtedly produced, or greatly aggravated, by
living to a great extent on animal food.
The Icelanders, like all other ancient people, are extremely attached
to their own customs, and averse to innovation. I noticed one thing
here, that—though, as Captain Cuttle would say, there was not much
wisdom in it—is characteristic of every people under the sun. While
fond of every foreign article, particularly of ornament, they about
entirely neglected the native productions. With great pains and
trouble, they would rear in their houses, geraniums, roses, fuchsias,
violets, and other exotics, and yet neglect to plant one single native
flower. The beautiful and fragrant heath, common over much of
Iceland, does not grow within several miles of Reykjavik; and yet not
one single resident had planted by his dwelling a stalk of this elegant
little shrub, to bloom and give out perpetual fragrance. I saw, also,
beautiful annual flowers growing wild in the fields, and on the river
banks, but which were never cultivated. Sir George Mackenzie has
given a list of the Iceland Flora, and a pretty long catalogue it is.
I believe a carriage road could be made in some places, particularly
between Reykjavik and Hafnarfiorth; but then it might not pay to
attempt to make many carriage roads, and introduce wheeled
vehicles in Iceland. If the land was leveled and seeded down, and
bogs and wet places drained, and converted into dry, productive
meadows, I believe it would be an object for the larger farmers to
have carts to draw their hay on, rather than carry it in bundles on
the backs of men or horses. Then, too, if their meadows were
smooth the product would be much greater, and they would be able
to introduce a much larger scythe than the little two-foot knife-blade
affair used there at present. With the improvement of their land,
their tools could be greatly improved. The population of Iceland has
been stated at 60,000 souls, and probably the increase is not one-
and-a-half per cent. annually. Women, as well as men, work in the
fields, during the hay season; but, in fishing, the men only are
engaged. The exposure attendant on this latter business gives many
complaints of the lungs; and probably more die of consumption than
of any other disease. The plague, about five hundred years ago,
visited Iceland; but cholera and yellow fever have never been here.
There are but few physicians in the country, and the distances they
have to travel often make their services of no avail, Death calling on
the patient before the doctor does. In countries of more luxury and
refinement, Death often calls soon after the doctor! From what I
learn, I should judge longevity was not as great here as in most
countries in the temperate zones.
The last Sunday I was in Iceland I attended church at the Reykjavik
cathedral. This is a beautiful little edifice, of brick, with a fine altar—
altogether of an ornamental appearance. The sermon was in
Icelandic, the service Lutheran, but much after the style of the
Church of England. Three Sundays out of four, I think it is, that the
service in this place is in Icelandic, and every fourth Sunday in
Danish. What the use may be of having any service in Danish is
more than I can tell, for a more worldly, ungodly set than the Danish
merchants of Iceland I never saw in a Christian country. At this
place, their example has driven nearly all religious observances away
from the Icelanders. Though the day was beautiful, and but one
church in the village, and all professing the same religion, and all the
people, too, understanding both languages, there were not, from
among the twelve hundred people of the place, fifty worshipers. This
certainly does not accord with what I have said of the moral and
religious habits of the Icelanders in general. I do not think I do the
Danes injustice, when I lay the immorality in and around Reykjavik
to their influence and example. In several villages and country
places I had a good opportunity of observing, and I know that ten
times greater proportion of the people attended church than here in
Reykjavik. A class like these merchants, who notoriously do nothing
but traffic, make money, gamble, and drink, cannot improve the
morals of a simple, pious, and intellectual people.
The people assembled at the church very quietly, and took their
seats without tarrying at the door, or entering into conversation.
They were all dressed neatly, and two or three females wore the
ancient costume of the country. It is very picturesque, but
“Description will not suit itself in words.”
FOOTNOTES:
46. “Efterretninger.”
And we sailed, and we flew, and went near the Maelstrom bay,
And we danced, and we frolicked, and we fiddled all the way.
OLD SONG.
A FINE morning in August found our little schooner dancing over the
waves of the Greenland strait. Towering up on our right, was the
lofty Snæfell Jokull, one of the highest mountains in Iceland. It has
the regular conical shape of most volcanoes. It is six thousand feet
high, being one-third higher than Vesuvius. At this season about
two-thirds of its height is black, and the rest is covered with
perpetual snow. When more than fifty miles to the south, I took a
drawing of it. It is near the end of a long peninsula, south of
Breithifiorth, and very nearly the westernmost point of Iceland. The
sharp outline of the mountain is distinctly visible in the clear
atmosphere here for more than a hundred miles. This volcano has
not had an eruption for several centuries. Two or three parties of
modern travelers have been to the summit. They have described the
ascent, after reaching the snow-line, as extremely dangerous. Wide
and deep cracks in the everlasting ice, and treacherous bridges of
snow, made the danger so great that they tied themselves in a
string, to a long rope, and walked about six feet apart. Then, if one
man fell through into a chasm, the rest pulled him out. No lives were
lost, however, in these excursions; the toil sweetened the pleasure,
the danger spiced it, and they were much gratified with their lofty
journey. To the east of Snæfell Jokull, we sailed by Stapi, a small
town near some famous basaltic cliffs, on the coast. Immense
perpendicular columns, and many thrown down, give the coast much
the appearance of the vicinity of the Giant’s Causeway, and the
island of Staffa. The coast here is more varied, and the scenery
more magnificent, than the north of Ireland; but there is no cave yet
discovered that will vie with the famed one of Fingal’s. Some of the
pillars here at Stapi are near eight feet in diameter, and all of them
of the regular geometrical shape so often seen in basaltic rocks.
They are like the cells in honeycombs, but solid, and generally
hexagonal, but sometimes heptagons and pentagons. Though the
time when these basalts were in a state of fusion is very remote, yet
there is no doubt of their volcanic character. If geologists and
mineralogists wish to see volcanic matter in every variety of form, let
them come to Iceland.
We passed by the Meal Sack and the Grenadier Islands, the first day,
and rounded the long nose of Cape Reykjanes, and the second
found us driving before a southwest wind; due east, along the south
coast of Iceland. We sailed near the Westmann Islands, and plainly
in sight of the lofty summits of Hekla, Torfa, Eyjafjalla, and Tindfjalla
Jokulls. The most singular curiosity on the south coast of Iceland,
that can be seen from the sea, is a group of rocks that I should call
The Needles, from their great resemblance to the “Needles” of the
Isle of Wight. They are near a little fishing village called Dyarholar, or
“Portland.” The rocks are shaped a little more like bodkins than
needles, and some of them rear their pointed heads near a hundred
feet high. They all stand in the ocean, some of them over a mile
from land. As we sailed east, the craggy summit of the Oræfa Jokull
showed his lofty and chilly head. The sides, too, were visible as well
as the summit, and perpendicular rocks and dark-looking caverns
showed the foot-prints of mighty convulsions of nature. The Oræfa
Jokull, forming part of that immense mountain known as Skaptar
Jokull, is, as I have mentioned before, the highest in Iceland. By
trigonometrical measurement, it is 6,760 feet high. Snæfell Jokull is
6,000 feet; Eyjafjalla Jokull, 5,900; and Hekla, 5,700. The Thiorsá
river, a stream larger than the Hudson or the Rhine, rises high up on
the side of Skaptar Jokull, 3,000 feet above the level of the sea, and
in a deep cañon in the lava, pours its resistless torrent down into the
ocean. Its rapid and turbulent current may be imagined. These
mountains in the interior of the country, the volcanic islands out at
sea, the rapid and powerful rivers, the Geysers, and innumerable hot
springs, along with the magnificent coast scenery, form the most
prominent physical features of Iceland.
For two days we were skirting the island on the south coast. This,
and the eastern part of Iceland, has few harbors. The coast is, much
of it, low and sandy, and difficult of approach. Some years since, a
French vessel was wrecked here in the winter season, and the crew
cast ashore, perfectly destitute. A few poor Icelanders that lived in
the vicinity, carried them to their huts, fed and took care of them,
and gave them shelter till spring. The next summer, on the annual
return of the French war-vessel that visits Iceland, the sailors were
taken home; and king Louis Philippe ordered a handsome
compensation and reward in money, to the Icelanders who had so
hospitably protected his shipwrecked sailors. They, however, did not
wish it; said they had only done their duty, and neither wanted nor
deserved compensation; and steadily refused to accept a single
penny. Determined to do something in return for their kindness,
Louis Philippe ordered his representative in Iceland to state that he
would educate at the University of France, four young Icelanders;
and the Governor, the Bishop, and the President of the College,
made choice of the young men who were to be recipients of the
favor. At the end of their term—four years—as many more were
selected; and thus the French government undertook the constant
care and expense of the education of four Iceland boys, who were
appointed for their ability, diligence, and good conduct, to receive
the bounty of the French government; and all for an act of humanity
towards a crew of shipwrecked sailors. The whole transaction
reflects the highest honor on all concerned. One of the young
gentlemen who was a recipient of this privilege, was a son of my
friend Mr. Sivertsen. After the French war-vessel, the unfortunate
LILLOISE, was lost, or failed to return from the Arctic sea, in connection
with one of the expeditions that went in search of her, there was a
scientific corps—a “Scandinavian Commission”—organized, of
learned men from France, Denmark, and Iceland, to gather
information, make drawings of landscapes, and collect specimens of
mineralogy, botany, and the various branches of natural history. The
commission was headed by M. Paul Geimar, and our young Icelander
was one of the party. The results of the expedition, in a scientific
point of view, were of the highest value. A work was published,
containing several folio volumes of plates, many of them colored,
and the Journal of the Expedition, in six octavos; and altogether it
forms the most valuable work of the kind extant. It comprises
Iceland, Greenland, Lapland, and Spitzbergen; and nothing, either of
a geographical, scientific, or historical nature has been omitted.
Along with portraits of Geimar and others of the Commission, is a
“counterfeit presentment” of young Sivertsen; and his is one of the
finest faces ever delineated. It has the lively, intelligent
countenance, lofty brow, and beaming eye of the Anglo-Saxons, and
equal to the finest specimens of the Caucasian race in any part of
the world. This promising young man died in France, a few years
after his return from the North, universally esteemed by all, and by
none more than by Louis Philippe himself.
But the winds are drifting us lazily to the eastward. We sailed north
of Faroe, and saw the cliffs of the lofty Stromoe towering upwards
like the ruins of some gigantic temple. The return voyage was all
beautiful September weather. Our passengers—except the bachelor
of the present writing—consisted of twelve young Iceland ladies, and
a small lad; and we had a regular “jolly” time. Several of the young
ladies were singers, and two of them had guitars. Nearly every
afternoon we had a dance. The young ladies made fast progress in
English—and Yankee—manners, customs, language, and dancing. I
also got well posted up in Icelandic, particularly in the sentimental,—
or, as Sam Weller would say, in the more “tenderer vords.” Guitar
music, Iceland hymns, the violin, and “threading the dance” on a
rocking deck, were all matters of every-day occurrence. Did I say
every day? Not with me. But the master of the Sölöven, Captain
Heinrich Stilhoff, was certainly the most reckless, irreligious man for
a sea-captain, that ever I saw in my life. Had a sober traveler come
alongside of us on Sunday, he would have been bothered to have
found out what kind of worship we had aboard. His reflections would
probably have been like old Lambro’s, when he returned, from his
piratical cruise, to his island and his daughter. Suppose such a one in
his yacht had come up with us:
A Christian he, and as our ship he nears,
He looks aboard, and finds no signs of idling,
He hears—alas! no music of the spheres,
But an unhallowed, earthly sound of fiddling!
A melody which makes him doubt his ears,
The cause being past his guessing or unriddling:
But, lo! it is the sailors all a prancing,
The women, too, and Captain Stilhoff, dancing!
It does not speak well for the Danish people and nation, that their
mail-ship, the only government vessel running between Denmark
and Iceland, is commanded by a man of the character of Captain
Stilhoff; and I cannot think it will long continue so. Commanding a
vessel carrying the Government dispatches, and having the most
popular and direct passenger traffic between the two countries, a
profligate who openly boasts of debauching his female passengers,
defenseless women, the sisters and daughters of the citizens of both
countries; a state of things that certainly does not reflect any honor
on the proprietors of the vessel, or show much sagacity in their
choice of a commander.
On, on, goes our little bark; the northern shore
“Fades o’er the waters blue;
The night winds sigh, the breakers roar,
And shrieks the wild sea-mew.”
Old Norway’s coast appears, and we are several days in sight of the
brown and snowy mountains, and little villages of wooden houses.
The thirteenth day, we passed Cape Lindesness, and Christiansand.
We were then within two hundred and fifty miles of Copenhagen—
only a few hours’ voyage for a steamship; but we had no steam a-
board, except what might be found in certain kettles and casks, and
these did not aid our progress much. I thought two days, at farthest
would suffice for the rest of our voyage; but Boreas was not in the
ascendant, nor any of his brethren either, much, for we had very
little wind from any quarter. The current in the Skager Rack took us
outwardly about two miles an hour, and the wind was southeasterly,
and we were bound in. One tack would throw us near the coast of
Norway, and the next brought us along the low, flat sands of
Jutland. We progressed from twenty-five to fifty miles a day. Several
huge steamers boomed past us, with their black sides, and volumes
of smoke, and swift progress. Some of them were bound into the
Baltic, and some out, and some to Norwegian ports. At last we
rounded the Skagen Horn, and entered the Cattegat. Finally, the
towers of Elsinore Castle appeared; and, a breeze springing up from
the north, we dropped anchor before Copenhagen, the twentieth
day after leaving Iceland; and, in a most terrible rain—so anxious
were we to tread the land again—all the passengers were set on the
quay, and found lodgings amid the turmoil of a great city.
GENERAL INDEX.