Writing High Performance NET Code Ben Watson Et Al. All Chapters Instant Download
Writing High Performance NET Code Ben Watson Et Al. All Chapters Instant Download
com
https://textbookfull.com/product/writing-high-performance-
net-code-ben-watson-et-al/
OR CLICK BUTTON
DOWNLOAD NOW
https://textbookfull.com/product/principles-of-macroeconomics-5e-ben-
bernanke-et-al/
textboxfull.com
https://textbookfull.com/product/anesthesiology-david-longnecker-et-
al/
textboxfull.com
https://textbookfull.com/product/management-john-r-schermerhorn-et-al/
textboxfull.com
https://textbookfull.com/product/financial-accounting-john-hoggett-et-
al/
textboxfull.com
Stylish F#: Crafting Elegant Functional Code for .NET and
.NET Core 1st Edition Kit Eason
https://textbookfull.com/product/stylish-f-crafting-elegant-
functional-code-for-net-and-net-core-1st-edition-kit-eason/
textboxfull.com
https://textbookfull.com/product/stylish-f-crafting-elegant-
functional-code-for-net-and-net-core-1st-edition-kit-eason-2/
textboxfull.com
https://textbookfull.com/product/heinemann-biology-2-philip-batterham-
et-al/
textboxfull.com
https://textbookfull.com/product/paediatric-dentistry-richard-welbury-
et-al-eds/
textboxfull.com
https://textbookfull.com/product/we-the-people-benjamin-ginsberg-et-
al/
textboxfull.com
Writing High-Performance
.NET Code
Ben Watson
Writing High-Performance
.NET Code
Writing High-Performance .NET Code
About the Author
Acknowledgements
Foreword
Introduction to the Second Edition
Introduction
Purpose of this Book
Why Should You Choose Managed Code?
Is Managed Code Slower Than Native Code?
Are The Costs Worth the Benefits?
Am I Giving Up Control?
Work With the CLR, Not Against It
Layers of Optimization
The Seductiveness of Simplicity
.NET Performance Improvements Over Time
.NET Core
Sample Source Code
Why Gears?
Performance Measurement and Tools
Choosing What to Measure
Premature Optimization
Average vs. Percentiles
Benchmarking
Useful Tools
Measurement Overhead
Summary
Memory Management
Memory Allocation
Garbage Collection Operation
Configuration Options
Performance Tips
Investigating Memory and GC
Summary
JIT Compilation
Benefits of JIT Compilation
JIT in Action
JIT Optimizations
Reducing JIT and Startup Time
Optimizing JITting with Profiling (Multicore JIT)
When to Use NGEN
.NET Native
Custom Warmup
When JIT Cannot Compete
Investigating JIT Behavior
Summary
Asynchronous Programming
The Thread Pool
The Task Parallel Library
TPL Dataflow
Parallel Loops
Performance Tips
Thread Synchronization and Locks
Investigating Threads and Contention
Summary
General Coding and Class Design
Classes and Structs
Tuples
Interface Dispatch
Avoid Boxing
ref returns and locals
for vs. foreach
Casting
P/Invoke
Delegates
Exceptions
dynamic
Reflection
Code Generation
Preprocessing
Investigating Performance Issues
Summary
Using the .NET Framework
Understand Every API You Call
Multiple APIs for the Same Thing
Collections
Strings
Avoid APIs that Throw Exceptions Under Normal Circumstances
Avoid APIs That Allocate From the Large Object Heap
Use Lazy Initialization
The Surprisingly High Cost of Enums
Tracking Time
Regular Expressions
LINQ
Reading and Writing Files
Optimizing HTTP Settings and Network Communication
SIMD
Investigating Performance Issues
Summary
Performance Counters
Consuming Existing Counters
Creating a Custom Counter
Summary
ETW Events
Defining Events
Consume Custom Events in PerfView
Create a Custom ETW Event Listener
Get Detailed EventSource Data
Consuming CLR and System Events
Custom PerfView Analysis Extension
Summary
Code Safety and Analysis
Understanding the OS, APIs, and Hardware
Restrict API Usage in Certain Areas of Your Code
Centralize and Abstract Performance-Sensitive and Difficult Code
Isolate Unmanaged and Unsafe Code
Prefer Code Clarity to Performance Until Proven Otherwise
Summary
Building a Performance-Minded Team
Understand the Areas of Critical Performance
Effective Testing
Performance Infrastructure and Automation
Believe Only Numbers
Effective Code Reviews
Education
Summary
Kick-Start Your Application’s Performance
Define Metrics
Analyze CPU Usage
Analyze Memory Usage
Analyze JIT
Analyze Asynchronous Performance
Higher-Level Performance
ASP.NET
ADO.NET
WPF
Big O
Common Algorithms and Their Complexity
Bibliography
Useful Resources
People and Blogs
Contact Information
Writing High-Performance
.NET Code
Writing High-Performance .NET Code
Version 2.0
Smashwords Edition
ISBN-13: 978-0-990-58349-3
ISBN-10: 0-990-58349-X
This eBook is licensed for your personal and professional use only.
You may not resell or give this book away to other people. If you
wish to give this book to another person, please buy an additional
copy for each recipient. If you are reading this book and did not
purchase it, or it was not purchased for your use only, then please
purchase your own copy. If you wish to purchase this book for your
organization, please contact me for licensing information. Thank you
for respecting the hard work of this author.
Trademarks
Disclaimer
Contact
Cover Design
Thank you to Claire Watson for doing the beautiful cover art for both
book editions.
Thank you to my mentor Mike Magruder who has read this book
perhaps more than anyone. He was the technical editor of the first
edition and, for the second edition, took time out of his retirement to
wade back into the details of .NET.
Thank you to Vance Morrison who read an early version of this and
wrote the wonderful Foreword to this edition.
Finally, thank you to all the readers of the first edition, who with
their invaluable feedback, have also helped contribute to making the
second edition a better book in every way.
Foreword
by Vance Morrison
Kids these days have no idea how good they have it! At the risk of
being branded as an old curmudgeon, I must admit there is more
than a kernel of truth in that statement, at least with respect to
performance analysis. The most obvious example is that “back in my
day” there weren’t books like this that capture both the important
“guiding principles” of performance analysis as well as the practical
complexities you encounter in real world examples. This book is a
gold mine and is worth not just reading, but re-reading as you do
performance work.
For over 10 years now, I have been the performance architect for
the .NET Runtime. Simply put, my job is to make sure people who
use C# and the .NET runtime are happy with the performance of
their code. Part of this job is to find places inside the .NET Runtime
or its libraries that are inefficient and get them fixed, but that is not
the hard part. The hard part is that 90% of the time the
performance of applications is not limited by things under the
runtime’s control (e.g., quality of the code generation, just in time
compilation, garbage collection, or class library functionality), but by
things under the control of the application developer (e.g.,
application architecture, data structure selection, algorithm selection,
and just plain old bugs). Thus my job is much more about teaching
than programming.
The “Have a Performance Plan” step really boils down to “care about
perf.” This means identifying what metric you care about (typically it
is some elapsed time that human beings will notice, but occasionally
it is something else), and identifying the major operations that might
consume too much of that metric (typically the “high volume” data
operation that will become the “hot path”). Very early in the project
(before you have committed to any large design decision) you
should have thought about your performance goals, and measured
something (e.g., similar apps in the past, or prototypes of your
design) that either gives you confidence that you can reach your
goals or makes you realize that hitting your perf goals may not be
easy and that more detailed prototypes and experimentation will be
necessary to find a better design. There is no rocket science here.
Indeed some performance plans take literally minutes to complete.
The key is that you do this early in the design so performance has a
chance to influence early decisions like data representation.
With that, I will leave the rest in Ben’s capable hands. The goal of
my words here are not to enlighten but simply motivate you.
Performance investigation is a complex area of the already complex
area of computer science. It will take some time and determination
to become proficient in it. I am not here to sugar-coat it, but I am
here to tell you that it is worth it. Performance does matter. I can
almost guarantee you that if your application is widely used, then its
performance will matter. Given this importance, it is almost a crime
that so few people have the skills to systematically create high-
performance applications. You are reading this now to become a
member of this elite group. This book will make it so much easier.
Kids these days—they have no idea how good they have it!
Vance Morrison
Microsoft Corporation
Introduction to the Second
Edition
The fundamentals of .NET performance have not changed much in
the years since the first edition of Writing High-Performance .NET
Code. The rules of optimizing garbage collection still remain largely
the same. JIT, while improving in performance, still has the same
fundamental behavior. However, there have been at least five new
point releases of .NET since the previous edition, and they deserve
some coverage where applicable.
I am confident that, even if you read the first edition, this second
edition is more than worth your time and attention.
Introduction
Purpose of this Book
.NET is an amazing system for building software. It allows us to
build functional, connected apps in a fraction of the time it would
have taken us years ago. So much of it just works, and that is a
great thing. It offers applications memory and type safety, a robust
framework library, services like automatic memory management, and
so much more.
This book is largely about giving you an idea of the costs and
benefits of your building materials, from which you can apply lessons
to whatever kind of project you are building.
This book will teach you how to get maximum performance out of
managed code, while sacrificing none or as few of the benefits of
.NET as possible. You will learn good coding techniques, specific
things to avoid, and perhaps most importantly, how to use freely
available tools to easily measure your performance. This book will
teach you those things with minimum fluff. This book is what you
need to know, relevant and concise, with no padding of the content.
Most chapters begin with general knowledge and background,
followed by specific tips in a cook-book approach, and finally end
with a section on step-by-step measurement and debugging for
many different scenarios.
Along the way you will deep-dive into specific portions of .NET,
particularly the underlying Common Language Runtime (CLR) and
how it manages your memory, generates your code, handles
concurrency, and more. You will see how .NET’s architecture both
constrains and enables your software, and how your programming
choices can drastically affect the overall performance of your
application. As a bonus, I will share relevant anecdotes from the last
nine years of building very large, complex, high-performance .NET
systems at Microsoft. You will likely notice that my bias throughout
this book is for server applications, but nearly everything discussed
in this book is applicable to desktop, web, and mobile applications as
well. Where appropriate, I will share advice for those specific
platforms.
All of the code samples in this book are in C#, the underlying IL, or
occasionally x86 or x64 assembly code, but all of the principles here
apply to any .NET language. Throughout this book, I assume that
you are using .NET 4.5 or higher, and some examples require newer
features only available in more recent versions. I strongly encourage
you to consider moving to the latest version so that you can take
advantage of the latest technologies, features, bug fixes, and
performance improvements.
All of this is to say that you can write more code quickly, with fewer
bugs. You can diagnose what bugs you do have far more easily. With
all of these benefits, managed code should be your default pick.
However, even if some of the above points apply to you, it does not
mean than all of your application must be unmanaged code. You can
quite easily mix the two in the same application for the best of both
worlds.
What is closer to the truth is that the .NET platform makes it very
easy to write slow code if you are sloppy and uncritical.
When you build your C#, VB.NET, or other managed language code,
the compiler translates the high-level language to Intermediate
Language (IL) and metadata about your types. When you run the
code, it is just-in-time compiled (“JITted”). That is, the first time a
method is executed, the CLR will invoke the JIT compiler on your IL
to convert it to assembly code (e.g., x86, x64, ARM). Most code
optimization happens at this stage. There is a definite performance
hit on this first run, but after that you will always get the compiled
version. As we will see later, there are ways around this first-time hit
when it is necessary.
In fact, there are some cases where you may see a significant
benefit from managed code:
The answer to the question “Is managed code slower than native
code?” is an emphatic “No” in most cases. Of course, there are
bound to be some areas where managed code just cannot overcome
some of the safety constraints under which it operates. They are far
fewer than you imagine and most applications will not benefit
significantly. In most cases, the difference in performance is
exaggerated. In reality, hardware and architecture will often make a
bigger impact than language and platform choices.
It is much more common to run across code, managed or native,
that is in reality just poorly written code; e.g., it does not manage its
memory well, it uses bad patterns, it defies CPU caching strategies
or is otherwise unsuitable for good performance.
The cost of the services .NET provides is not free, but it is also lower
than you may expect. You do not have to reduce this cost to zero
(which is impossible); just reduce it to a low enough threshold that
other factors in your application’s performance profile are more
significant.
Feature Benefits
JITted Better
Code memory
locality,
reduced
memory
usage
Bounds Safe
Checking memory
access
(fewer
unfindable
bugs)
Feature Benefits
Type Easier
metadata debugging,
overhead rich
metadata,
reflection,
better
exception
handling,
easy static
analysis
Garbage Fast
Collection memory
allocation,
no bugs
with calling
delete, safe
pointer
access
(access
violations
are not
possible)
Am I Giving Up Control?
One common objection to using managed code is that it can feel like
you are giving up too much control over how your program
executes. This is a particular fear of garbage collection, which occurs
at what feels like random and inconvenient times. For all practical
purposes, however, this is not actually true. Garbage collection is
largely deterministic, and you can significantly affect how often it
runs by controlling your memory allocation patterns, object scope,
and GC configuration settings. What you control is different from
native code, but the ability is certainly there.
I
GEORGE BERNARD SHAW was born in Dublin, July 26, 1856. His
paternal grandfather, Bernard Shaw, was high sheriff of County
Kilkenny, and his maternal grandfather, Walter Bagnall Gurley, a
county ’squire and fox hunter, with an extensive, but entailed estate.
Shaw’s father was a younger son and, in consequence, no
millionaire. But that he was a pauper or that the dramatist, in his
youth, was attracted to vegetarianism because, as James Huneker
hints, cabbages are cheaper than venison, there is no reason to
believe. When the family came to London, in 1876, it took up
quarters in “a well furnished house in a pleasant part” of the city. This
upon the authority of Mr. Stanley Shaw, a relative, in a letter to the
New York Sun, dated Berlin, April 25, 1905.
The Shaws then, were country gentlemen, and in all probability
little different from the other Irish gentry about them. The son of the
younger son was educated and reared in the orthodox fashion. He
learned the speech of the Irish aristocracy and the foreign tongues in
favor—English, French, and maybe a bit of German; he mastered
the three R’s, he studied the history of his country, and went to
church. “When I was a little boy,” he says in his essay “On Going to
Church,” “I was compelled to go on Sunday; and though I escaped
from that intolerable bondage before I was ten, it prejudiced me so
violently against church-going that twenty years elapsed before, in
foreign lands and in pursuit of works of art, I became once more a
church-goer. To this day, my flesh creeps when I recall that genteel
suburban Irish Protestant church, built by Roman Catholic workmen
who would have considered themselves damned had they crossed
its threshold afterward....” A virtuous, commonplace family. Its
present head, says the Mr. Stanley Shaw aforesaid, “is Major Sir
Frederick Shaw, Bart., D. S. O. of Bushey Park, Dublin.” A
respectable, well-sounding name and address.
II
Shaw was twenty when he reached London—the meditative,
impressionable, speculative, iconoclastic age. Apparently he fell an
easy prey to the philosophical anarchists who then held the centre of
the stage—Proudhon, Lassalle, Marx, Louis Blanc, Engels,
Liebknecht, and the lesser Germans. Certainly it was a day of
stimulating stirring about. Huxley and Spencer were up to their necks
in gore; Ibsen, with “The League of Youth” behind him, was giving
form to “The Pillars of Society” and “A Doll’s House”; Nietzsche was
tramping up and down his garden path; Wagner was hard at work;
“The Principles of Sociology” had just come from the press. Sham-
smashing was in the air. Everything respectable was under
suspicion.
It didn’t take Shaw long to spring out of the audience upon the
stage. His first novel, in truth, must have been begun long before he
learned to find his way about the streets of London. Whether it was
good or bad the human race will never know; publishers declined it
without thanks, and the author, when his manuscripts began to have
a value, decided that it should remain unpublished. “It was a very
remarkable work,” he says, “but hardly one which I should be well
advised in letting loose whilst my livelihood depends on my credit as
a literary workman. I can recall a certain difficulty, experienced even
while I was writing the book, in remembering what it was about....”
Thus heavily did his theme bear down upon him.
What the young Irishman did to relieve his imagination during the
next three years is not recorded. That he learned a great deal,
particularly of music and literature, is very probable. His sister was a
professional singer, and the persons he met were chiefly of the
literary-artistic sort. He was “but an infant of twenty-four, when, being
at that time one of the unemployed” he essayed to mend his
“straitened fortunes” by writing his second novel, “The Irrational
Knot.” It was no masterpiece, but if the few persons who glanced
through it possessed prophetic eyes they must have seen in it marks
of a genius rather startling. A year later came “Love Among the
Artists”—a volume of nearly 500 pages. Then, in order, came
“Cashel Byron’s Profession” and “An Unsocial Socialist.” Not one of
these extraordinary tales struck the fancy of the publishers. “An
encouraging compliment or two,” says Shaw, was his sole reward for
the fatiguing labor of writing them. Not until a good while afterward
did any of the five see the light, and then it was only “to fill up the
gaps in socialist magazines financed by generous friends.” “An
Unsocial Socialist” was the first to reach the dignity of covers. After it
came “Cashel Byron’s Profession” and “The Irrational Knot.” “Love
Among the Artists” was the last to appear upon the book stalls.
III
Meanwhile Shaw had become engaged in half a dozen reform
crusades. Vegetarianism found in him an early advocate and
socialism won him easily. In 1883, the year Karl Marx died, Thomas
Davidson, an American, laid the foundation of the Fabian Society at
a series of parlor conferences in London. In 1884 Shaw joined the
society, and four years later, when it began holding public meetings,
he found himself one of its leading lights. He has told us himself how
he delighted to indulge in eloquent socialistic orations from cart-tails
and how he came to acquire a bodyguard of faithful auditors whose
presence was assured whenever it was announced that he would
speak. With the pen, too, he labored for the manifesto of 1845, and
even to-day he is still hard at it—despite prosperity, the approach of
middle age and a fair imitation of the thing called fame. He wrote
tracts in great number and after 1889 edited the Fabian Essays.
Incidentally he wrote “Fabianism and the Empire” (1900), “Fabianism
and the Fiscal Question” (1904), and other socialistic broadsides. At
odd moments he had his say, too, upon the subjects of
vegetarianism, the use of quotation marks, capitalization, evening
clothes, capital punishment, and the eternal snobbishness of the
patriotic Britisher.
During all this time he was drawn nearer and nearer to the
theater. As far back as 1885 he began a play in collaboration with
William Archer, the translator of Ibsen. This drama, rewritten and
amplified seven years later, was the first of his works to be
performed in public. But the need of getting on in the world pressed
gloomily. “The question was,” Shaw has told us, “how to get a pound
a week.” Novel writing was plainly hopeless and play making
seemed equally impossible. There remained a chance to set up shop
as a critic. Shaw made the plunge and almost immediately his humor
and originality won him an audience. “Soon,” he says, “my privileges
were enormous and my wealth immense.... The classes patiently
read my essays; the masses patiently listened to my harangues. I
enjoyed the immunities of impecuniosity with the opportunities of a
millionaire....”
At the start Shaw’s regular topic was the art pictorial, but before
long he began to dabble in music. According to Max Beerbohm, his
first essay was printed in the first number of the Star in 1888. This
was a highly purposeful periodical, founded by T. P. O’Connor (“If we
enable the charwoman to put two lumps of sugar in her tea instead
of one,” said “Tay Pay,” in his salutatory, “we shall not have worked in
vain”), and Shaw wrote over the nom de plume of “Corno di
Bassetto.” In 1890, after two years’ service, he transferred his flag to
the World. Then, like his friend Huneker, he abandoned music for the
drama, and from January, 1895, to May, 1898, he was the critic of
the Saturday Review—the London weekly in whose columns the
ingenious Mr. Beerbohm now holds forth.
IV
As has been noted, “Widowers’ Houses,” Shaw’s first play, was
completed in 1892. It was given its initial performance during that
year at the Royalty Theater, London, by the Independent Theater
Company, and made a rather strenuous success. “The socialists and
independents,” says Shaw, “applauded me furiously on principle; the
ordinary play-going first-nighters hooted me frantically on the same
ground; I, being at that time in some practice as what might be
unpolitely called a mob-orator, made a speech before the curtain; the
newspapers discussed the play for a whole fortnight, not only in the
ordinary theatrical notices and criticisms, but in leading articles and
letters; and finally the text of the play was published, with an
introduction by Mr. Grein (the manager of the Independent
Company), an amusing account by Mr. Archer of the original
collaboration, and a long preface and several elaborate controversial
appendices in the author’s most energetically egotistical fighting
style.”
“The Philanderer” was written in 1893, also for the Independent
Theater, and “Mrs. Warren’s Profession” was completed the same
year. The former was withdrawn because it was found well-nigh
impossible to unearth actors capable of understanding it sufficiently
to play it, and the latter remained in the manager’s desk because the
virtuous English play-censor forbade its performance. Nine years
later—January 12, 1902—it was presented privately by the Stage
Society.
In 1894 a group of philanthropic play-goers, convinced that the
dramas of the day were intolerable, financed a series of special
performances at the Avenue Theater, London. The second play
presented was Shaw’s “Arms and the Man.” It was given its premiere
April 21, and ran until July 7. Shaw, in his preface to the second
volume of “Plays Pleasant and Unpleasant” enters upon an
elaborate account of its receipts and the philosophy thereof. During
its brief season the Londoners paid $8,500 to see it and the cost of
presenting it, counting salaries, rents, lights, advertising, and
royalties, was nearly $25,000. Soon afterwards Richard Mansfield
presented the play in the United States and it made a very fair
success. It is in the Mansfield repertoire even to-day, and now and
then there is a matinée performance of it. But apparently the public
does not very vigorously demand it. In translation it has been done in
Germany.
“The Man of Destiny” was written in 1895. Two years later it was
given one performance at Croydon, England. Then it slumbered until
the last months of 1904, when Arnold Daly played it in New York as
an after-piece to “Candida.” Since then his company has appeared in
it in most of the large cities of the United States. “Candida” and “You
Never Can Tell” were written in 1896. The former was first played by
the Independent Theater Company, during a tour of the English
provinces, in 1897. Arnold Daly, scraping together $300, presented
it, in association with Winchell Smith, at the Berkeley Lyceum, a
diminutive theater in West 45th street, New York, in 1904. The
success of the drama was so great that before long Daly found
himself a Broadway star under the management of Liebler & Co.,
and at present it seems likely that Shaw’s plays will serve to keep
him in the public eye for a good while to come.
Shaw wrote a one-act piece, “How He Lied to Her Husband,” for
his young American interpreter, and when it was presented in New
York, in the fall of 1904, it made a great stir. “You Never Can Tell,”
which had been withdrawn by Shaw after being placed in rehearsal
in London, was given at the Garrick Theater by Daly at the
conclusion of the run of “Candida.” The two volumes of “Plays
Pleasant and Unpleasant” were published in 1898. They included
“Widowers’ Houses,” “The Philanderer,” “Mrs. Warren’s Profession,”
“Arms and the Man,” “You Never Can Tell,” “Candida,” and “The Man
of Destiny”—not to speak of a 37-page preface dealing with a vast
multitude of subjects.
V
“The Devil’s Disciple,” the first of the “Three Plays for Puritans,”
was written early in 1897. Richard Mansfield presented it in New
York in the fall of that year and it made an excellent success. Like
“Arms and the Man” it is still in his repertoire—pretty far down in the
trunk, it may be mentioned in passing, with many other plays atop of
it. In October, 1899, Murray Carson’s company played it for a few
weeks at Kensington, near London. “Cæsar and Cleopatra” was
written in 1898, and “Capt. Brassbound’s Conversion” the next year.
The “Three Plays for Puritans” were published in 1900. “The
Admirable Bashville, or Constancy Rewarded” was given by the
Stage Society at the Imperial Theatre in 1903. Shaw evolved it from
the fragments of “Cashel Byron’s Profession” to protect his rights in
the latter, an unauthorized dramatization having been made for an
American pugilist-actor. The play was printed as an appendix to the
second English edition of “Cashel Byron’s Profession.”
“Man and Superman” was written in 1902, and published the
next year, with a gigantic preface, and “The Revolutionist’s
Handbook and Pocket Companion” as an appendix. Preface, play,
and appendix make a volume of 244 closely-printed pages. The
drama saw the light on the evening of May 23, 1905, at the Court
Theater, London. Granville Barker, made up to resemble Shaw,
played the role of John Tanner, and Miss Lillian McCarthy was the
Ann Whitefield. May 21 and 22 there were special performances of
the play by the Stage Society, and in September, 1905, Robert
Loraine and his company presented it in New York. The third act with
the scene of Don Juan in Hell was omitted. “John Bull’s Other Island”
was completed in 1904, and presented at six special matinees at the
Court Theater by the Stage Society in the fall of that year. “Major
Barbara” was written in 1905.
Shaw’s two critical tracts, “The Perfect Wagnerite” and “The
Quintessence of Ibsenism” were published in 1888 and 1891,
respectively. His last scholastic manifesto, “The Common Sense of
Municipal Training” was issued in 1904. A remarkable essay, “On
Going to Church,” which appeared originally in the Savoy Quarterly
—Arthur Symons’ journal—in 1896, was reprinted early in 1905, and
attained a large sale. In the late ’80’s, in an English periodical, there
appeared his celebrated answer to Max Nordau’s book,
“Degeneration.” In the opinion of some of his admirers this is, by far,
the best of his controversial works, but, unfortunately, it has not been
reprinted in permanent form.
“When Arnold Daly visited Shaw,” says Gustav Kobbé, “he found
several indications that cynicism and Fabian socialism are not
unprofitable. Shaw lives in large apartments in the New Reform
Club, overlooking the Thames embankment, and he has a country
place at Welwin, too.... There is no sham in the interior of his places
of abode. There is a complete absence of the cheap æsthetic or of
superfluous ornamentation. Simplicity of outline distinguishes such
ornaments as there are. Handles, incrustations and the like are
eschewed. Shaw explained to Daly that he wished nothing in his
abode that would collect dust. Even rugs are tabooed.... Daly did not
find the author a poseur, but simply a man who was not an ordinary
man....”
That Shaw has a keen eye to business a great many aspiring
managers have discovered. He demands a royalty of 15 per cent. of
the gross receipts of his plays—considerably more than all but the
most famous dramatists receive—and is careful and unsentimental
in his negotiations. That he is now basking in the sun of prosperity is
very probable. Saving only Shakespeare, no English author was
better represented in the productions of the winter of 1904–5. In
addition Shaw is much in demand as a lecturer and has no difficulty
in finding a publisher for whatever he chooses to write. In 1898 he
inherited the entailed estate of his maternal grandfather, Walter
Bagnall Gurley. He was married the same year to Miss Charlotte
Frances Payne-Townshend.
“Who’s Who” says that Shaw’s favorite exercises are swimming
and cycling and that his recreation is “anything except sport.” He is
tall, lanky, and wears a shaggy, red beard. He affects loose fitting
flannel shirts and heaps his curses upon the dress suit. He is a
vegetarian, a socialist, and many other things of a heterodox,
fearsome sort. He uses the typewriter in preference to a pen, even
for correspondence. He has travelled in Europe and the Levant, and
may soon come to America. He refuses to use apostrophes in such
words as don’t and can’t, and affects thin spacing, after the German
style, instead of italics, to emphasize words. “Last season,” says the
sapient Mr. Daly, “he was a social freak; now he is a legitimate
amuser (sic!) of the people.”
And so much for George Bernard Shaw.
SHAKESPEARE AND SHAW
SHAW’S notion that Shakespeare’s plays—or, at least, some of
them—have been left behind by the evolution of popular philosophy
and ideals is scarcely original with him. As he himself points out, the
Bard of Avon has been burned in hot critical fire for many years,
despite the “Shakespeare fanciers” who hold him as a god. Some of
his plays, says Shaw, were so far ahead of their time when they
were first presented that it has taken 300 years of theater-goers to
tire of the “long line of disgraceful farces, melodramas, and stage-
pageants which actor-managers, from Garrick and Cibber to our own
contemporaries, have hacked out of them,” and to understand
performances of the texts as the poet wrote them. By the same
token, those plays which Shakespeare himself “wrote down” to the
level of his audience have grown archaic in sentiment and character.
Dramas like “Anthony and Cleopatra,” says Shaw, will nevermore be
written, “nor relished by men in whose philosophy guilt and
innocence, and, consequently, revenge and idolatry, have no
meaning. Such men must rewrite all the old plays in terms of their
own philosophy....”
When this was published, as a preface to “Cæsar and
Cleopatra,” in “Three Plays for Puritans,” there was a volcanic critical
eruption, and ever since then the flames have roared about the
ingenious Irishman. He has delivered lectures explaining his
position, he has set forth his views, elaborately and carefully, in print,
and his admirers have gone to his rescue—but a large party of
Shakespeare worshipers insist on clinging to the belief that he has
attempted to drag the bard from his pedestal and himself climb upon
it. Recently, in London, he delivered a lecture designed to make
clear his idea. Next morning the London morning papers printed
amazingly confused reports of it, and to set himself right Shaw wrote
a letter to the Daily News containing 12 assertions, which, like the 95
theses Luther nailed upon the church door at Wittenberg, he desired
should make known the substance of his argument. Here they are:
“1. That the idolatry of Shakespeare which prevails now existed
in his own time, and got on the nerve of Ben Jonson.
“2. That Shakespeare was not an illiterate poaching laborer who
came up to London to be a horseboy, but a gentleman with all the
social pretensions of our higher bourgeoisie.
“3. That Shakespeare, when he became an actor, was not a
rogue and a vagabond, but a member and part proprietor of a
regular company, using, by permission, a nobleman’s name as its
patron, and holding itself as exclusively above the casual
barnstormer as a Harley Street consultant holds himself above a
man with a sarsaparilla stall.
“4. That Shakespeare’s aim in business was to make money
enough to acquire land in Stratford, and to retire as a country
gentleman with a coat of arms and a good standing in the county;
and that this was not the ambition of a parvenu, but the natural
course for a member of the highly respectable, though temporarily
impecunious, family of the Shakespeares.
“5. That Shakespeare found that the only thing that paid in the
theater was romantic nonsense, and that when he was forced by this
to produce one of the most effective samples of romantic nonsense
in existence—a feat which he performed easily and well—he publicly
disclaimed any responsibility for its pleasant and cheap falsehood by
borrowing the story and throwing it in the face of the public with the
phrase ‘As You Like It.’
“6. That when Shakespeare used that phrase he meant exactly
what he said, and that the phrase ‘What You Will,’ which he applied
to ‘Twelfth Night,’ meaning ‘Call it what you please,’ is not, in
Shakespearean or any other English, the equivalent of the perfectly
unambiguous and penetratingly simple phrase ‘As You Like It.’
“7. That Shakespeare tried to make the public accept real
studies of life and character in—for instance—‘Measure for Measure’
and ‘All’s Well That Ends Well’; and that the public would not have
them, and remains of the same mind still, preferring a fantastic sugar
doll, like Rosalind, to such serious and dignified studies of women as
Isabella and Helena.
“8. That the people who spoil paper and waste ink by describing
Rosalind as a perfect type of womanhood are the descendants of the
same blockheads whom Shakespeare, with the coat of arms and the
lands in Warwickshire in view, had to please when he wrote plays as
they liked them.
“9. Not, as has been erroneously stated, that I could write a
better play than ‘As You Like It,’ but that I actually have written much
better ones, and in fact, never wrote anything, and never intend to
write anything, half so bad in matter. (In manner and art nobody can
write better than Shakespeare, because, carelessness apart, he did
the thing as well as it can be done within the limits of human faculty.)
“10. That to anyone with the requisite ear and command of
words, blank verse, written under the amazingly loose conditions
which Shakespeare claimed, with full liberty to use all sorts of words,
colloquial, technical, rhetorical, and even obscurely technical, to
indulge in the most far-fetched ellipses, and to impress ignorant
people with every possible extremity of fantasy and affectation, is the
easiest of all known modes of literary expression, and that this is
why whole oceans of dull bombast and drivel have been emptied on
the head of England since Shakespeare’s time in this form by people
who could not have written ‘Box and Cox’ to save their lives. Also
(this on being challenged) that I can write blank verse myself more
swiftly than prose, and that, too, of full Elizabethan quality plus the
Shakespearian sense of the absurdity of it as expressed in the lines
of Ancient Pistol. What is more, that I have done it, published it, and
had it performed on the stage with huge applause.
“11. That Shakespeare’s power lies in his enormous command of
word music, which gives fascination to his most blackguardly
repartees and sublimity to his hollowest platitudes.
“12. That Shakespeare’s weakness lies in his complete
deficiency in that highest sphere of thought, in which poetry
embraces religion, philosophy, morality, and the bearing of these on
communities, which is sociology. That his characters have no
religion, no politics, no conscience, no hope, no convictions of any
sort. That there are, as Ruskin pointed out, no heroes in
Shakespeare. That his test of the worth of life is the vulgar hedonic
test and that since life cannot be justified by this or any other
external test, Shakespeare comes out of his reflective period a
vulgar pessimist, oppressed with a logical demonstration that life is
not worth living, and only surpassing Thackeray in respect to being
fertile enough, instead of repeating ‘Vanitas vanitatum’ at second
hand to work the futile doctrine differently and better in such
passages as ‘Out, out, brief candle.’”
These twelve articles merely serve to arouse a new storm of
discussion and Shaw profited much thereby in the advertising it gave
him. In May, 1905, the controversy had reached such a height that
J. B. Fagan, a young English dramatist, wrote a burlesque about it.
The piece was called “Shakespeare vs. Shaw” and was presented at
the Haymarket Theater, London. The scene of the one act was a
courtroom, in which the case between the two playwrights was being
tried. James Welsh, Miss Winifred Emery, Cyril Maude, and other
prominent players were in the cast and the little revue evidently
made a fair success. At all events, its presentation was a rather
significant thing. Few dramatists, in their lifetimes, see plays written
about them.
THE END
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.
textbookfull.com