A “Literary” Computer Programming Language

The epigraphs of the book “The Java Language Specification”
informatics, computing, programming language, Java, computer programming, Java programming language


1. Introduction
2. Grammar
3. Lexical Structure
3.12. Operators
4. Types, Values and Variables
4.5.5. Variables Have Types, Object Have Classes
5. Conversions and Promotions
5.5. Casting Conversion
5.6.2. Binary Numeric Promotion
6. Names
6.8.6. Local Variables and Parameter Names
7. Packages
7.3.12. Unique Package Names
8. Classes
8.3. Field Declarations
8.4. Method Declarations
8.6. Constructor Declarations
8.6.8. Preventing Instantiation of a Class
9. Interfaces
9.3. Field (Constant) Declarations
9.4.3. Examples of Abstract Method Declarations
10. Arrays
10.10. Array Store Exception
11. Exceptions
11.1. The Causes of Exceptions
11.5.2. The Class Error
12. Execution
12.9. Virtual Machine Exit
13. Binary Compatibility
13.5.5. Abstract Method Declarations
14. Blocks and Statements
14.1. Normal and Abrupt Completion of Statements
14.8.1. The if-then Statement
14.18. The try statement
14.18.1. Execution of try-catch
14.18.2. Execution of try-catch-finally
14.19. Unreachable Statements
15. Expressions
15.5. Normal and Abrupt Completion of Evaluation
15.6. Evaluation Order
15.6.3. Parentheses and Precedence Respected
15.11.2. Compile-Time Step 2: Determine Method Signature
15.14.2. Prefix Decrement Operator —
15.15. Cast Expressions
15.16.1. Multiplication Operator ·
15.16.2. Division Operator /
15.16.3. Remainder Operator %
15.18. Shift Operators
15.20.3. Reference Equality Operators == and !=
15.27. Constant Expression
16. Definite Assignment
16.2.13. try Statements
17. Threads and Locks
17.5. Rules about Locks
17.12. Threads
17.14. Wait Sets and Notification
18. Documentation Comments
20. The Package java.lang
20.2. The Interface java.lang.Cloneable
20.4. The Class java.lang.Boolean
20.5. The Class java.lang.Character
20.11. The Class java.lang.Math
20.15. The Class java.lang.Process
21. The Package java.util
21.2. TheClass java.util.BitSet
21.5. The Class java.util.Hashtable
21.9. The Class java.util.Random
21.12. The Class java.util.Stack

Title page

‘When I use a word,’ Humpty Dumpty said, in rather a scornful tone, ‘it means just what I choose it to mean—neither more nor less.’

‘The question is,’ said Alice, ‘whether you can make words mean so many different things.’

‘The question is,’ said Humpty Dumpty, ‘which is to be master—that’s all.’

Lewis Carroll: Through the Looking Glass

Chapter 1 Introduction

If I have seen further it is by standing upon the shoulders of Giants.

Sir Isaac Newton

Chapter 2 Grammar

Grammar, which knows how to control even kings…

Molière: Les Femmes Savantes, 1672, Act II, Scene VI

Chapter 3 Lexical Structure

Lexicographer: A writer of dictionaries, a harmless drudge.

Samuel Johnson: Dictionary, 1755

3.12. Operators

Give her no token but stones; for she’s as hard as steel.

William Shakespeare: Two Gentlemen of Verona, Act I, Scene 1

These lords are visited; you are not free;
For the Lord’s tokens on you do I see.

William Shakespeare: Love’s Labour’s Lost, Act V, scene 2

Thou, thou, Lysander, thou hast given her rhymes,
And interchanged love-tokens with my child.

William Shakespeare: A Midsummer Night’s Dream, Act I, Scene 1

Here is a letter from Queen Hecuba,
A token from her daughter …

William Shakespeare: Troilus and Cressida, Act V, Scene 1

Are there no other tokens…?

William Shakespeare: Measure for Measure, Act IV, Scene 1

Chapter 4 Types, Values and Variables

I send no agent or medium,
offer no representative of value,
but offer the value itself.

Walt Whitman: Carol of Occupations, in Leaves of Grass, 1855

4.5.5. Variables Have Types, Object Have Classes

Oft on the dappled turf at ease
I sit, and play with similes,
Loose types of things through all degrees.

William Wordsworth: To the Same Flower

Chapter 5 Conversions and Promotions

Thou art not for the fashion of these times,
Where none will sweat but for promotion.

William Shakespeare: As You Like It, Act II, Scene 3

5.5. Casting Conversion

Sing away sorrow, cast away care.

Miguel de Cervantes (1547—1616): Don Quixote, Lockhart’s translation, Chapter VIII

5.6.2. Binary Numeric Promotion

O suns! O grass of graves! O perpetual transfers and promotions!

Walt Whitman (1855): in Leaves of Grass

Chapter 6 Names

The Tao that can be told is not the eternal Tao;
The name that can be named is not the eternal name.
The Nameless is the origin of Heaven and Earth;
The Named is the mother of all things.

Lao-Tsu (c. 6th century B.C.)

6.8.6. Local Variables and Parameter Names

What’s in a name? That which we call a rose
By any other name would smell as sweet.

William Shakespeare: Romeo and Juliet, c. 1594, Act II, Scene 2

Rose is a rose is a rose is a rose.

Gertrude Stein: Sacred Emily in Geographies and Plays, 1913

“…stat rosa pristina nomine, nomina nuda tenemus.

Bernard of Morlay: De contemptu mundi, 12th century (quoted in Umberto Eco, The Name of the Rose, 1980)

Chapter 7 Packages

Good things come in small packages.

Traditional proverb

7.3.12. Unique Package Names

Did I ever tell you that Mrs. McCave
Had twenty-three sons and she named them all ‘Dave’?
Well, she did. And that wasn’t a smart thing to do. …

Dr. Seuss (Theodore Geisel): Too Many Daves, 1961

Chapter 8 Classes

class 1. The noun class derives from Medieval French and French classe from Latin classis, probably originally a summons, hence a summoned collection of persons, a group liable to be summoned: perhaps for callassis from calare, to call, hence to summon.

Eric Partridge: Origins: A Short Etymological Dictionary of Modern English

8.3. Field Declarations

Poetic fields encompass me around,
And still I seem to tread on classic ground.

Joseph Addison (1672—1719): A Letter from Italy

8.4. Method Declarations

The diversity of physical arguments and opinions embraces all sorts of methods.

Michael de Montaigne (1533—1592): Of Experience

8.6. Constructor Declarations

The constructor of wharves, bridges, piers, bulk-heads, floats, stays against the sea …

Walt Whitman: Song of the Broad-Axe, 1856

8.6.8. Preventing Instantiation of a Class

Bow, bow, ye lower middle classes!
Bow, bow, ye tradesmen, bow, ye masses!
Blow the trumpets, bang the brasses!
Tantantara! Tzing! Boom!

W. S. Gilbert: Iolanthe

Chapter 9 Interfaces

My apple trees will never get across
And eat the cones under his pines, I tell him.
He only says ‘Good Fences Make Good Neighbors.’

Robert Frost: Mending Wall, 1914

9.3. Field (Constant) Declarations

The materials of action are variable, but the use we make of them should be constant.

Epictetus (c. 60 A.D.), translated by Thomas Wentworth Higginson

9.4.3. Examples of Abstract Method Declarations

Death, life, and sleep, reality and thought,
Assist me, God, their boundaries to know …

William Wordsworth: Maternal Grief

Chapter 10 Arrays

Even Solomon in all his glory was not arrayed like one of these.

Matthew 6:29

10.10. Array Store Exception

At length burst in the argent revelry,
With plume, tiara, and all rich array …

John Keats: The Eve of St. Agnes, 1819

Chapter 11 Exceptions

If anything can go wrong, it will.

Finagle’s Law (often incorrectly attributed to Murphy, whose law is rather different—which only goes to show that Finagle was right)

11.1. The Causes of Exceptions

If we do not succeed, then we run the risk of failure.

J. Danforth Quayle, 1990

11.5.2. The Class Error

No rule is so general, which admits not some exception.

Robert Burton, 1576—1640

Chapter 12 Execution

We must all hang together, or assuredly we shall all hang separately.

Benjamin Franklin, July 4, 1776

12.9. Virtual Machine Exit

… Farewell!
The day frowns more and more. Thou’rt like to have
A lullaby too rough: I never saw
The heavens so dim by day: A savage clamour!
Well may I get aboard! This is the chase.
I am gone for ever! [Exit, pursued by a bear]

William Shakespeare: The Winter’s Tale Act III, Scene 3

Chapter 13 Binary Compatibility

13.5.5. Abstract Method Declarations

Lo! keen-eyed, towering Science! …
Yet again, lo! the Soul—above all science …
For it, the partial to the permanent flowing,
For it, the Real to the Ideal tends.
For it, the mystic evolution …

Walt Whitman: Song of the Universal, 1874

Chapter 14 Blocks and Statements

He was not merely a chip of the old block, but the old block itself.

Edmund Burke: On Pitt’s First Speech

14.1. Normal and Abrupt Completion of Statements

Poirot’s abrupt departure had intrigued us all greatly.

Agatha Christie: The Mysterious Affair at Styles, 1920, Chapter 12

14.8.1. The if-then Statement

I took an early opportunity of testing that statement …

Agatha Christie: The Mysterious Affair at Styles, 1920, Chapter 12

14.18. The try statement

These are the times that try men’s souls.

Thomas Paine: The American Crisis, 1780

… and they all fell to playing the game of catch as catch can, till the gunpowder ran out at the heels of their boots.

Samuel Foote

14.18.1. Execution of try-catch

Our supreme task is the resumption of our onward, normal way.

Warren G. Harding: Inaugural Address, 1921

14.18.2. Execution of try-catch-finally

After the great captains and engineers have accomplish’d their work,

After the noble inventors—after the scientists, the chemist, the geologist, ethnologist,
Finally shall come the Poet …

Walt Whitman: Passage to India, 1870

14.19. Unreachable Statements

That looks like a path.
Is that the way to reach the top from here?

Robert Frost: The Mountain, 1915

One ought not to be thrown into confusion
By a plain statement of relationship …

Robert Frost: The Generations of Men, 1914

Chapter 15 Expressions

When you can measure what you are speaking about, and express it in numbers, you know something about it; but when you cannot measure it, when you cannot express it in numbers, your knowledge of it is of a meager and unsatisfactory kind: it may be the beginning of knowledge, but you have scarcely, in your thoughts, advanced to the stage of science.

William Thompson, Lord Kelvin

15.5. Normal and Abrupt Completion of Evaluation

No more: the end is sudden and abrupt.

William Wordsworth: Apology for the Foregoing Poems, 1831

15.6. Evaluation Order

Let all things be done decently and in order.

I. Corinthians 14:40

15.6.3. Parentheses and Precedence Respected

That is too weighty a subject to be discussed parenthetically …

John Stuart Mill: On Liberty, 1869, Chapter IV

15.11.2. Compile-Time Step 2: Determine Method Signature

The hand-writing experts were called upon for their opinion of the signature…

Agatha Christie: The Mysterious Affair at Styles, 1920, Chapter 11

15.14.2. Prefix Decrement Operator —

He must increase, but I must decrease.

John 3:30

15.15. Cast Expressions

My days among the dead are passed;
Around me I behold,
Where’er these casual eyes are cast,
The mighty minds of old …

Robert Southey (1774—1843): Occasional Pieces, xviii

15.16.1. Multiplication Operator ·

Entia non sunt multiplicanda praeter necessitatem.

William of Occam, c. 1320

15.16.2. Division Operator /

Gallia est omnis divisa in partes tres.

Julius Caesar: Commentaries on the Gallic Wars, 58 B.C.

15.16.3. Remainder Operator %

And on the pedestal these words appear:
‘My name is Ozymandias, king of kings:
Look on my works, ye Mighty, and despair!’
Nothing beside remains.

Percy Bysshe Shelley: Ozymandias, 1817

15.18. Shift Operators

What, I say, is to become of those wretches?
… What more can you say to them than ’shift for yourselves?’

Thomas Paine: The American Crisis, 1780

15.20.3. Reference Equality Operators == and !=

Things are more like they are now than they ever were before.

Dwight D. Eisenhower

15.27. Constant Expression

… when faces of the throng turned toward him and ambiguous eyes stared into his, he assumed the most romantic of expressions …

F. Scott Fitzgerald: This Side of Paradise, 1920

Chapter 16 Definite Assignment

All the evolution we know of proceeds from the vague to the definite.

Charles Pierce

16.2.13. try Statements

I resolved to assign Bartleby a corner by the folding doors …
It does not strike me that there is anything definite about that.

Herman Melville: Bartleby, the Scrivener (1853)

Chapter 17 Threads and Locks

And oft-times in the most forbidding den
Of solitude, with love of science strong,
How patiently the yoke of thought they bear;
How subtly glide its finest threads along!

William Wordsworth: Monks and Schoolmen (1822), in Ecclesiastical Sonnets

17.5. Rules about Locks

By the pricking of my thumbs,
Something wicked this way comes.
Open, locks,
Whoever knocks!

William Shakespeare: Macbeth, Act IV, Scene 1

17.12. Threads

They plant dead trees for living, and the dead
They string together with a living thread …
But in no hush they string it … With a laugh, …
They bring the telephone and telegraph.

Robert Frost: The Line-gang (1920)

17.14. Wait Sets and Notification

These pearls of thought in Persian gulfs were bred,
Each softly lucent as a rounded moon;
The diver Omar plucked them from their bed,
Fitzgerald strung them on an English thread.

James Russell Lowell: in a copy of Omar Khayyam

Chapter 18 Documentation Comments

The view that documentation is something that is added to a program after it has been commissioned seems to be wrong in principle, and counterproductive in practice. Instead, documentation must be regarded as an integral part of the process of design and coding.

C. A. R. Hoare: Hints on Programming Language Design (1973)

Very few facts are able to tell their own story, without comments to bring out their meaning.

John Stuart Mill: On Liberty (1869)

Chapter 20 The Package java.lang

20.2. The Interface java.lang.Cloneable

I am disappointed in Japp. He has no method!

Agatha Christie: The Mysterious Affair at Styles, 1920, Chapter 8

20.4. The Class java.lang.Boolean

This above all: to thine own self be true,
And it must follow, as the night the day,
Thou canst not then be false to any man.

William Shakespeare: Hamlet, Act I, Scene 3

20.5. The Class java.lang.Character

Here is the whole set ! a character dead at every word.

Richard Brinsley Sheridan: The School for Scandal, Act 2, Scene 2

20.11. The Class java.lang.Math

Oh, back to the days that were free from care in the ’Ology ’varsity shop,
With nothing to do but analyse air in an anemometrical top,
Or the differentiation of the trigonometrical pow’rs
Of the constant pi that made me sigh in those happy days of ours!

I. W. Litchfield: Take Me Back to Tech, 1885

In mathematics he was greater
Than Tycho Brahe or Erra Pater
For he, by geometric scale,
Could take the size of pots of ale;
Resolve, by sines and tangents straight
Whether bread or butter wanted weight;
And wisely tell what hour o’ the day
The clock does strike, by algebra.

Samuel Butler: Hudibras, Part I, canto 1

20.15. The Class java.lang.Process

It was my hint to speak—such was the process.

William Shakespeare: Othello, Act I, Scene 3

Chapter 21 The Package java.util

21.2. The Class java.util.BitSet

T is an old maxim in the schools,
That flattery’s the food of fools;
Yet now and then your men of wit
Will condescend to take a bit.

Jonathan Swift: Cadenus and Vanessa

At Mooneen he had leaped a place
So perilous that half the astonished meet
Had shut their eyes, and where was it
He rode a race without a bit?

William Butler Yeats: In Memory of Major Robert Gregory, 1919

21.5. The Class java.util.Hashtable

… never did they seem to have new experiences in common … and the things they had for dissection—college, contemporary personality, and the like—they had hashed and rehashed for many a frugal conversational meal.

F. Scott Fitzgerald: This Side of Paradise, 1920

Twelve sphered tables, by silk seats insphered,
High as the level of a man’s breast rear’d
On libbard’s paws, upheld the heavy gold
Of cups and goblets, and the store thrice told
Of Ceres’ horn, and, in huge vessels, wine
Came from the gloomy tun with merry shine.
Thus loaded with a feast the tables stood …

John Keats: Lamia, Part II

21.9. The Class java.util.Random

Oh, many a shaft at random sent
Finds mark the archer little meant
And many a word at random spoken
May soothe, or wound, a heart that’s broken!

Sir Walter Scott: The Lady of the Lake, Canto V, stanza 18

… who can tell what may be the event? …
The mind of the multitude is left at random …

Thomas Paine: Common Sense, 1776, Appendix AA

21.12. The Class java.util.Stack

… and from the stack a thin blue wreath of smoke
Curled through the air across the ripening oats…

Oscar Wilde: Charmides, 1881

… And overhead in circling listlessness
The cawing rooks whirl round the frosted stacks…

Oscar Wilde: Humanitad, 1881

Appendix A Quoted works by authors

Addison, Joseph: A Letter from Italy
Bernardus Morlanensis: De contemptu mundi
Burke, Edmund: On Pitt’s First Speech
Burton, Robert: aphorism
Butler, Samuel: Hudibras
Caesar, Iulius: Commentarii de bello Gallico
Carroll, Lewis: Through the Looking Glass
Cervantes, Miguel de: Don Quixote
Christie, Agatha: The Mysterious Affair at Styles
Eisenhower, Dwight D.
Finagle: Finagle’s Law
Fitzgerald, F. Scott: This Side of Paradise
Foote, Samuel
Franklin, Benjamin
Frost, Robert Lee: Mending Wall · The Generations of Men · The Line-gang · The Mountain
Geisel, Theodore [Dr. Seuss]: Too Many Daves
Gilbert, William Schwenck, Sir: Iolanthe
Harding, Warren G.: Inaugural Address
Hoare, C. A. R.: Hints on Programming Language Design
Johnson, Samuel: Dictionary
Keats, John: Lamia · The Eve of St. Agnes
Lao-tzu: Tao te Ching
Litchfield, I. W.: Take Me Back to Tech
Melville, Herman: Bartleby, the Scrivener
Mill, John Stuart: On Liberty
Molière: Les Femmes Savantes
Montaigne, Michael de: Essais
Newton, Isaac, Sir
Paine, Thomas: Common Sense · The American Crisis
Partridge, Eric: Origins: A Short Etimology Dictionary of Modern English
Pierce, Charles
Quayle, J. Danforth
Russell, James: Lowell
Scott, Walter, Sir: The Lady of the Lake
Seuss, Dr. lásd: Geisel, Theodore
Shakespeare, William: Love’s Labour’s Lost · Two Gentlemen of Verona · As You Like It · Hamlet · Macbeth · Measure for Measure · A Midsummer Night’s Dream · Othello · Romeo and Juliet · The Winter’s Tale · Troilus and Cressida
Shelley, Percy Bysshe: Ozymandias
Sheridan, Richard Brinsley: The School for Scandal
Southey, Robert: Occasional Pieces
Stein, Gertrude: Sacred Emily
Swift, Jonathan: Cadenus and Vanessa
Thompson, William, Lord Kelvin
Whitman, Walt: Carol of Occupations · Passage to India · Song of the Broad-Axe · Song of the Universal
Wilde, Oscar: Charmides, Humanitad
William of Occam: Occam’s Razor
Wordsworth, William: Apology for the Foregoing Poems · Maternal Grief · Monks and Schoolmen · To the Same Flower
Yeats, William Butler: In Memory of Major Robert Gregory

Appendix B Quoted works by titles

Love’s Labour’s Lost—William Shakespeare
Commentarii de bello Gallico—Julius Caesar
The Mountain—Robert Lee Frost
Two Gentlemen of Verona—William Shakespeare
The School for Scandal—Richard Brinsley Sheridan
On Liberty—John Stuart Mill
The Lady of the Lake—Sir Walter Scott
De contemptu mundi—Bernardus Morlanensis
aphorisms—Robert Burton · Dwight D. Eisenhower · Samuel Foote · Benjamin Franklin · Sir Isaac Newton · Charles Pierce · J. Danforth Quayle · William Thompson (Lord Kelvin)
As You Like It—William Shakespeare
Through the Looking Glass—Lewis Carroll
Apology for the Foregoing Poems—William Wordsworth
The American Crisis—Thomas Paine
Origins: A Short Etimology Dictionary of Modern English—Eric Partridge
Bartleby, the Scrivener—Herman Melville
Bible—János evangéliuma, Korintusiaknak írt I. levél, Matthew evangéliuma
Cadenus and Vanessa—Jonathan Swift
Carol of Occupations—Walt Whitman
Charmides—Oscar Wilde
Don Quixote—Miguel de Cervantes
Finagle’s Law—Finagle
Hamlet—William Shakespeare
Hudibras—Samuel Butler
Humanitad—Oscar Wilde
Sacred Emily—Gertrude Stein
Inaugural Address—Warren G. Harding
This Side of Paradise—F. Scott Fitzgerald
A Letter from Italy—Joseph Addison
Iolanthe—Sir William Schwenck Gilbert
Common Sense—Thomas Paine
Essais—Michael de Montaigne
Lamia—John Keats
Tao te Ching—Lao-tzu
Les Femmes Savantes—Moliere
Lowell—James Russell
Macbeth—William Shakespeare
Maternal Grief—William Wordsworth
Mending Wall—Robert Lee Frost
Monks and Schoolmen—William Wordsworth
Occasional Pieces—Robert Southey
Occam’s Razor—William of Occam
Othello—William Shakespeare
Ozymandias—Percy Bysshe Shelley
Passage to India—Walt Whitman
On Pitt’s First Speech—Edmund Burke
In Memory of Major Robert Gregory—William Butler Yeats
Romeo and Juliet—William Shakespeare
Song of the Broad-Axe—Walt Whitman
Song of the Universal—Walt Whitman
Measure for Measure—William Shakespeare
The Eve of St. Agnes—John Keats
A Midsummer Night’s Dream—William Shakespeare
Dictionary—Samuel Johnson
Take Me Back to Tech—I. W. Litchfield
Hints on Programming Language Design—C. A. R. Hoare
The Winter’s Tale—William Shakespeare
The Generations of Men—Robert Lee Frost
The Line-gang—Robert Lee Frost
The Mysterious Affair at Styles—Agatha Christie
To the Same Flower—William Wordsworth
Too Many Daves—Theodore Geisel [Dr. Seuss]
Troilus and Cressida—William Shakespeare

The JAVA Language Specification

The number of quoted authors (writers, poets, scientists, politics, etc.) is fifty one; the number of quoted works (poems, plays, novels, detective stories, aphorisms, proverbs, etc.) is sixty two.

works by authors · works by titles

James Gosling, Bill Joy, Guy Steele: The JAVA Language Specification. Version 1.0. Redwood: Addison-Wesley, 1996. (The Java Series.)