(Ebook) High-Performance Programming in C# and .NET: Understand the nuts and bolts of developing robust, faster, and resilient applications in C# 10.0 and .NET 6 by Jason Alls - Download the ebook with all fully detailed chapters
(Ebook) High-Performance Programming in C# and .NET: Understand the nuts and bolts of developing robust, faster, and resilient applications in C# 10.0 and .NET 6 by Jason Alls - Download the ebook with all fully detailed chapters
com
https://ebooknice.com/product/high-performance-programming-
in-c-and-net-understand-the-nuts-and-bolts-of-developing-
robust-faster-and-resilient-applications-in-c-10-0-and-
net-6-54553130
OR CLICK BUTTON
DOWLOAD EBOOK
https://ebooknice.com/product/pro-c-10-with-net-6-foundational-principles-and-
practices-in-programming-44480694
ebooknice.com
https://ebooknice.com/product/pro-c-10-with-net-6-foundational-principles-and-
practices-in-programming-47148782
ebooknice.com
(Ebook) Biota Grow 2C gather 2C cook by Loucas, Jason; Viles, James ISBN
9781459699816, 9781743365571, 9781925268492, 1459699815, 1743365578, 1925268497
https://ebooknice.com/product/biota-grow-2c-gather-2c-cook-6661374
ebooknice.com
https://ebooknice.com/product/concurrency-in-net-modern-patterns-of-concurrent-
and-parallel-programming-with-examples-in-c-and-f-27186094
ebooknice.com
(Ebook) The Nuts and bolts of Paced ECG Interpretation (Nuts and Bolts Series) by
Tom Kenny ISBN 9781405184045, 1405184043
https://ebooknice.com/product/the-nuts-and-bolts-of-paced-ecg-interpretation-
nuts-and-bolts-series-1836302
ebooknice.com
https://ebooknice.com/product/options-and-derivatives-programming-
in-c-23-algorithms-and-programming-techniques-for-the-financial-industry-3rd-
edition-53487340
ebooknice.com
(Ebook) Simple and Efficient Programming with C# : Skills to Build Applications with
Visual Studio and .NET by Vaskaran Sarcar ISBN 9781484287378, 1484287371
https://ebooknice.com/product/simple-and-efficient-programming-with-c-skills-to-
build-applications-with-visual-studio-and-net-49420130
ebooknice.com
(Ebook) Simple and Efficient Programming with C#: Skills to Build Applications with
Visual Studio and .NET by Vaskaran Sarcar ISBN 9781484273210, 1484273214
https://ebooknice.com/product/simple-and-efficient-programming-with-c-skills-to-
build-applications-with-visual-studio-and-net-34493440
ebooknice.com
(Ebook) Implementing Design Patterns in C# 11 and .NET 7: Learn how to design and
develop robust and scalable applications using design patterns - 2nd Edition by
Malavasi Cardoso, Alexandre F. ISBN 9789355517333, 9355517335
https://ebooknice.com/product/implementing-design-patterns-in-c-11-and-
net-7-learn-how-to-design-and-develop-robust-and-scalable-applications-using-
design-patterns-2nd-edition-53883082
ebooknice.com
High-Performance
Programming in C#
and .NET
Jason Alls
BIRMINGHAM—MUMBAI
High-Performance Programming in C# and .NET
Copyright © 2022 Packt Publishing
All rights reserved. No part of this book may be reproduced, stored in a retrieval system, or transmitted
in any form or by any means, without the prior written permission of the publisher, except in the case of
brief quotations embedded in critical articles or reviews.
Every effort has been made in the preparation of this book to ensure the accuracy of the information
presented. However, the information contained in this book is sold without warranty, either express or
implied. Neither the author nor Packt Publishing or its dealers and distributors, will be held liable for
any damages caused or alleged to have been caused directly or indirectly by this book.
Packt Publishing has endeavored to provide trademark information about all of the companies and
products mentioned in this book by the appropriate use of capitals. However, Packt Publishing cannot
guarantee the accuracy of this information.
ISBN 978-1-80056-471-8
www.packt.com
I would like to dedicate this book to the team at Packt, who helped
me through each step of the way and were very accommodating and
understanding of the difficulties I was going through in my personal life
while working on this book. They have been a truly great team that has
encouraged me each step of the way. I could not have written this book
without their expertise and guidance.
I would also like to dedicate this book to my wonderful parents, who had
to suffer long periods without me as I spent many a long night and many
weekends on this book, but who encouraged me to keep going through
difficult times.
– Jason Alls
Contributors
About the author
Jason Alls is the author of Clean Code in C# and has been programming for over 21
years. Working with an Australasian company, he started his career developing call center
management reporting software used by global clients, including telecom providers,
banks, airlines, and the police. He then moved on to develop GIS marketing applications
and worked in the banking sector, performing data migrations between Oracle and SQL
Server. Certified as an MCAD in C# since 2005, he has been involved in the development
of various desktop, web, and mobile applications.
Currently employed by a leading software house, he develops and supports order
processing and warehouse management software written in C#.
I would like to send a warm thank you to Joy and Gianni, who reviewed
the chapters for me. Their attention to detail was excellent, and they
would often let me know when things needed improving or when I had
left something out. Because of them, the content of this book, I feel, will
be of great benefit to programmers and developers at all levels. I happily
recommend them as reviewers to any budding authors.
About the reviewers
Gianni Rosa Gallina is an Italian senior software engineer and architect who has
been focused on emerging technologies, AI, and virtual/augmented reality since 2013.
Currently, he works at Deltatre’s Innovation Lab, prototyping solutions for next-generation
sports experiences and business services. Besides that, he has more than 10 years of
certified experience as a consultant on Microsoft and .NET technologies (including
technologies such as the Internet of Things, the cloud, and desktop/mobile apps). Since
2011, he has been awarded Microsoft MVP in the Windows Development category. He
has been a Pluralsight Author since 2013 and is a speaker at national and international
conferences.
Joy Rathnayake is a solutions architect with over 19 years of industry experience and is
part of the Digital & Emerging Technology (DET) team at EY GDS, based in Colombo,
Sri Lanka. He is primarily responsible for understanding customer requirements,
identifying required products/ technologies, and defining the overall solution design/
architecture.
Before he joined EY GDS Sri Lanka, Joy worked as a solutions architect at WSO2 Inc.,
Totalamber Ltd, Virtusa Ltd, Solid Quality Mentors, IronOne Technologies, and Sri
Lankan Airlines. He was responsible for architecting, designing, and developing software
solutions primarily using Microsoft and related technologies.
Joy has been recognized as both a Microsoft Most Valuable Professional (MVP) and
a Microsoft Certified Trainer (MCT). He has contributed to developing content for
Microsoft Certifications and has worked as a Subject Matter Expert (SME) for many
Microsoft exam development projects.
He has contributed a lot to the community by presenting at various events, such as
Microsoft Tech-Ed, Southeast Asia SharePoint Conference, and SharePoint Saturday.
Joy enjoys traveling, speaking at public events/conferences, and reading.
Table of Contents
Preface
2
Implementing C# Interoperability
Technical requirements 42 Performing Component Object
Using Platform Invocation Model (COM) interoperability 58
(P/Invoke)43 Reading data from an
Using unsafe and fixed code 44 Excel spreadsheet 59
Exposing static entry points using Creating an Excel add-in 61
P/Invoke 48
Safely disposing of unmanaged
Interacting with Python code 56 code64
Summary 68
Questions 68
Further reading 69
3
Predefined Data Types and Memory Allocations
Technical requirements 72 Building a stack versus building a heap
(example project) 87
Understanding the predefined
.NET data types 73 Choosing between a struct and a class 93
4
Memory Management
Technical requirements 106 Preventing memory leaks 127
Object generations and Understanding the dangers of
avoiding memory issues 106 using Marshal.ReleaseComObject 128
Understanding long and How using events can be a
source of memory leaks 138
short weak references 111
Finalization117 Summary151
Using finalization 118 Questions152
Implementing the Further reading 152
IDisposable pattern 122
5
Application Profiling and Tracing
Technical requirements 157 Installing and using
Understanding code metrics 158 dotnet-counters 183
Application metrics 158 Collecting data and saving it to a file
Assembly metrics 159 for post-analysis 185
Namespace metrics 160 Listing .NET processes that can be
monitored 187
Type metrics 161
Listing the available list of well-known
Method metrics 162
.NET counters 187
Field metrics 162
Monitoring a .NET process 188
Performing static
Tracking down and
code analysis 163
fixing a memory leak
Generating and viewing with dotMemory 189
memory dumps 167
Finding the cause of a UI
Viewing loaded modules 169 freeze with dotTrace 198
Debugging your applications 171 Optimizing application
Using tracing and performance and memory
diagnostics tools 172 traffic with dotTrace 206
Using the Visual Studio 2022 Summary209
Performance Profiler 172
Questions210
Using JetBrains dotMemory 179
Further reading 210
Using JetBrains dotTrace 181
x Table of Contents
7
LINQ Performance
Technical requirements 268 LINQ queries 285
Setting up a sample database 268 Increasing Group By
Setting up our in-memory performance in LINQ queries 287
sample data 271 Filtering lists 290
Database query performance 273 Understanding closures 295
Getting the last value of Summary299
a collection 283 Questions299
Avoid using the let keyword in Further reading 299
Table of Contents xi
8
File and Stream I/O
Technical requirements 302 Accessing files asynchronously 315
Understanding the various Writing text to a file asynchronously 316
Windows file path formats 302 Handling I/O
Removing the maximum path length operation exceptions 319
limitation using the registry 303
Performing memory
Removing the maximum path length
limitation using the group policy 304
tasks efficiently 323
Understanding local
Considering improved storage tasks 326
I/O performance 305 Summary327
Moving files 308
Questions 328
Calculating directory sizes 313
Further reading 329
9
Enhancing the Performance of Networked Applications
Technical requirements 333 Programming a simple gRPC
Blazor application 358
Understanding the network
layers and protocols 334 The blank solution 359
10
Setting Up Our Database Project
Technical requirements 382 SqlCommandParameterModel
Setting up our database 382 class393
Setting up our database Writing the AdoDotNet class 393
access project 386 Writing the
Writing the Properties class 387 EntityFrameworkCoreData
Writing the DatabaseSettings class 388 class400
Writing the DapperDotNet
Writing the SecretsManager 389 class403
Writing the Product class 391 Summary409
Writing the Further reading 410
SqlCommandModel class 392
Writing the
11
Benchmarking Relational Data Access Frameworks
Technical requirements 413 Benchmarking data
Benchmarking data insertion deletion methods 432
methods413 The benchmarking results
Benchmarking data and their analysis 437
selection methods 420 Summary442
Benchmarking data Questions443
editing methods 427 Further reading 444
12
Responsive User Interfaces
Technical requirements 446 Adding a splash screen that updates
with loading progress 448
Building a responsive UI
with WinForms 446 Adding the increment count button
and label 451
Enabling DPI awareness and long file
Adding a table with paged data 451
path awareness 447
Table of Contents xiii
13
Distributed Systems
Technical requirements 514 Containers and serverless 532
Implementing the CQRS Managing your cloud
design pattern 514 infrastructure with Pulumi 534
Implementing event sourcing 516 Performance considerations
Event sourcing example project 519 for distributed computing 538
Using Microsoft Azure for Summary541
distributed systems 528 Questions542
Azure Functions 529 Further reading 543
Durable Azure Functions 530
15
Parallel Programming
Technical requirements 564 Parallel debugging and
Using the Task Parallel Library profiling tools 578
(TPL)564 The Parallel Stacks window 578
Using Parallel LINQ (PLINQ) 568 The Tasks window 579
The Concurrency Visualizer 580
Programming parallel data structures 570
16
Asynchronous Programming
Technical requirements 586 Benchmarking GetAwaiter.
Understanding the TAP model 586 GetResult(), .Result, and .Wait
Naming, parameters, and
for both Task and ValueTask 593
return types 587 Using async, await,
Initiating asynchronous operations 587 and WhenAll 596
Exceptions 588 Canceling asynchronous
Optional cancellation 588 operations 598
Optional Progress Reporting 589 Writing files asynchronously 600
async, await, and Task 590 Reading files asynchronously 602
Summary604
Questions604
Further reading 605
Table of Contents xv
Assessments
Chapter 1, Introducing C# 10.0 Chapter 9, Enhancing the
and .NET 6 607 Performance of Networked
Chapter 2, Implementing C# Applications612
Interoperability 608 Chapter 10, Setting Up Our
Chapter 3, Predefined Data Database Project 612
Types and Memory Chapter 11, Benchmarking
Allocations 608 Relational Data Access
Chapter 4, Memory Frameworks612
Management609 Chapter 12, Responsive User
Chapter 5, Application Interfaces613
Profiling and Tracing 609 Chapter 13, Distributed
Chapter 6, The .NET Systems 613
Collections610 Chapter 14, Multi-Threaded
Chapter 7, LINQ Performance 611 Programming614
Chapter 8, File and Stream I/O 611 Chapter 15, Parallel
Programming614
Chapter 16, Asynchronous
Programming614
Index
Other Books You May Enjoy
Preface
Writing high-performance code while building an application is crucial, and over the
years, Microsoft has focused on delivering various performance-related improvements
within the .NET ecosystem. This book will help you understand the aspects involved in
designing responsive, resilient, and high-performance applications with the new versions
of C# and .NET.
You will start by understanding the foundation of high-performance code and the latest
performance-related improvements in C# 10.0 and .NET 6. Next, you’ll learn how to
use tracing and diagnostics to track down performance issues and the cause of memory
leaks. The chapters that follow then show you how to enhance the performance of your
networked applications and various ways to improve directory tasks, file tasks, and
more. You’ll go on to improve data querying performance and write responsive user
interfaces. You’ll also discover how you can use cloud providers such as Microsoft Azure
to build scalable distributed solutions. Finally, you’ll explore various ways to process code
synchronously, asynchronously, and in parallel to reduce the time it takes to process a
series of tasks.
By the end of this C# programming book, you’ll have the confidence you need to build
highly resilient, high-performance applications that meet your customer’s demands.
Chapter 7, LINQ Performance, explains how to perform LINQ queries with performance
in mind. Depending on how you use LINQ, different methods that return the same result
can behave and perform differently. And so, in this chapter, you will learn how best to
perform queries on LINQ to improve the performance of your applications.
Chapter 8, File and Stream I/O, explains how to improve file and directory performance.
You will learn ways to improve directory tasks, file tasks, memory tasks, and isolated
storage tasks. In this book, you will learn how to write to files asynchronously and read
from files asynchronously.
Chapter 9, Enhancing the Performance of Networked Applications, breaks down how to
speed up the performance of network applications. You will learn how to communicate
over a network using the TCP and UDP network protocols. Then you will learn how to
perform network tracing processes with the OSI Network Layer Reference Model and a
selection of TCP and UDP networking protocols. Cache management will also be covered
so that you can improve the efficiency of resource retrieval.
Chapter 10, Setting Up Our Database Project, sets up the Northwind database project on
SQL Server as we will be using this database in the next section to benchmark data access
methods.
Chapter 11, Benchmarking Relational Data Access Frameworks, benchmarks three
different ways to manipulate SQL Server database data. We will be performing a side-by-
side comparison of Entity Framework, ADO.NET, and Dapper.NET. After running the
benchmarks for each of these data access and object mappers, you will be able to make
an educated judgment call on the best form of data access and object mapping for your
projects.
Chapter 12, Responsive User Interfaces, explains how to write responsive user interfaces.
You will write responsive Windows Forms (WinForms), Windows Presentation
Foundation (WPF), ASP.NET, .NET MAUI, and WinUI applications. Using background
worker threads, you will see how you can update and work with the user interface in real
time by running long-running tasks in the background.
Chapter 13, Distributed Systems, describes distributed applications and explains how
to improve their performance. You will learn how to build performant distributed
applications using the Command Query Responsibility Separation (CQRS) software
design pattern, event sourcing, and microservices. You will see how to use cloud providers
such as Microsoft Azure to build scalable distributed solutions using Cosmos DB, Azure
Functions, and the open source Pulumi infrastructure tool.
xx Preface
Chapter 14, Multi-Threaded Programming, explores what threads and threading are and
discusses background and foreground threads. Then you will learn how to pass data
into threads before you run them. You will also learn how to pause, interrupt, destroy,
schedule, and cancel threads.
Chapter 15, Parallel Programming, explains how to take advantage of the multiple CPU
cores that are available in today’s modern computers. You will learn how to process your
code by distributing the work between processes concurrently.
Chapter 16, Asynchronous Programming, demystifies the Task Asynchronous
Programming (TAP) model. You will learn how to program tasks asynchronously
and access web resources using async, await, and WhenAll. You will also look at
different return types, how to extract the required results, and how to correctly cancel
asynchronous operations and perform asynchronous file reading and writing.
If you are using the digital version of this book, we advise you to type the code yourself
or access the code from the book’s GitHub repository (a link is available in the next
section). Doing so will help you avoid any potential errors related to the copying and
pasting of code.
Please try and answer the questions, read the external resources provided at the end
of each chapter, and put what you have learned into action in your own programming
and performance training exercises. This will help to reinforce what you have learned
throughout this book.
Preface xxi
Conventions used
There are a number of text conventions used throughout this book.
Code in text: Indicates code words in text, database table names, folder names,
filenames, file extensions, pathnames, dummy URLs, user input, and Twitter handles.
Here is an example: “The enum data type is 4 bytes (32 bits) in size, nullable, and has
a minimum value of 0. You can measure the size of a value type using sizeof(Type
type).”
A block of code is set as follows:
When we wish to draw your attention to a particular part of a code block, the relevant
lines or items are set in bold:
csc /help
csc -langversion:10.0 /out:HelloWorld.exe Program.cs
csc HelloWorld
cd css
Bold: Indicates a new term, an important word, or words that you see onscreen. For
instance, words in menus or dialog boxes appear in bold. Here is an example: “Make sure
the project is set to Debug mode, and then step through the code.”
Get in touch
Feedback from our readers is always welcome.
General feedback: If you have questions about any aspect of this book, email us at
[email protected] and mention the book title in the subject of your
message.
Errata: Although we have taken every care to ensure the accuracy of our content, mistakes
do happen. If you have found a mistake in this book, we would be grateful if you would
report this to us. Please visit www.packtpub.com/support/errata and fill in the
form.
Piracy: If you come across any illegal copies of our works in any form on the internet,
we would be grateful if you would provide us with the location address or website name.
Please contact us at [email protected] with a link to the material.
If you are interested in becoming an author: If there is a topic that you have expertise in
and you are interested in either writing or contributing to a book, please visit authors.
packtpub.com.
Preface xxiii
Part 1 covers the foundation of high-performance code. We cover what’s new in C# 10.0
and .NET 6, including performance improvements. Next, we look at the interoperability
that is available that allows the gradual porting of Python systems to C#, followed by the
garbage collector. You will learn how types can negatively impact performance, as can
manually calling the garbage collector. And finally, we look at how we can use profiling
tools to identify and address performance issues.
This part contains the following chapters:
• Overview of .NET 6: In this section, we will cover, at a high level, what's new in
.NET 6. You will learn about the various performance improvements that will be
part of .NET 6.
• Overview of C# 10.0: Having learned how to obtain the latest Roslyn code in the
Technical requirements section, in this section, you will learn about the various
features that will be part of C# 10.0. This will include code examples.
• Native compilation: In this section, you will learn how to compile a .NET
Core application into a single native executable. You will write a simple console
application that recursively converts audio files from one format into another.
• Improving Windows Store performance: This is a brief section that provides
standard guidelines for improving the performance of applications that target the
Windows Store.
• Improving ASP.NET performance: This is a brief section that provides some
standard guidelines for improving ASP.NET applications.
By the end of this chapter, you will have the following skills:
Technical requirements
You will need the following prerequisites to complete this chapter:
Note
You can find the latest complete and up-to-date C# 10.0 feature set at
https://github.com/dotnet/roslyn/blob/master/docs/
Language%20Feature%20Status.md. At the time of writing, C# 10.0
is still undergoing much development and change. So, the contents of this book
may not work as expected. If this turns out to be the case, then please refer to
the preceding URL for the most relevant information to help you start working.
The following instructions are for downloading and building the latest version of the
Roslyn compiler source on Windows 10:
1. In the root of the C:\ drive, clone the Roslyn source code by using the following
command in the Windows Command Prompt:
git clone https://github.com/dotnet/roslyn.git
6. Once all the tests have finished running, check the versions of C# that are accessible
to the new computer. Do this by opening a Command Prompt window and
navigating to C:\roslyn\artifacts\bin\csc\Debug\net472.
7. Then, run the following command:
csc /langversion:?
Note
I always run my Command Prompt as an administrator. Hence, the screenshots
will show Command Prompt in administrative mode. But running Command
Prompt as an administrator is not necessary for this exercise. Where Command
Prompt must be executed as an administrator, this will be made clear as
needed.
Figure 1.1 – The versions of the C# programming language supported by the compiler
Overview of Microsoft .NET 6 7
As you can see, at the time of writing, version 10.0 of the C# language is available via the
C# compiler. C# 10.0 is set as the default. The preview is still under development. The
default version may be different on your computer.
Note
The latest version of Visual Studio 2022 should allow you to use the latest
available C# 10.0 code features. If it doesn't, then compile the latest source and
overwrite the files located at C:\Program Files (x86)\Microsoft
Visual Studio\2022\Preview\MSBuild\Current\Bin\
Roslyn.
The following three sets of instructions provide compiler help for compiling a program
that targets a specific C# version and then runs the program. These commands are for
demonstrative purposes only, and you do not have to run them now:
csc /help
csc -langversion:10.0 /out:HelloWorld.exe Program.cs
csc HelloWorld
Now that you can build C# 10.0 from the command line and from within Visual Studio
2022, let's learn what kind of new development is taking place with Microsoft .NET 6.
Note
To get the most out of .NET 6 and C# 10.0, it is best that you have Visual Studio
2022 or later installed.
Microsoft .NET 5 and later will no longer carry the Core or Framework suffix, as per the
following article: https://redmondmag.com/articles/2019/12/31/coming-
in-2020-net-5.aspx. Microsoft's goal with version 5 and later of the .NET platform
is to create a single platform for the .NET development of WinForms, WPF, Xamarin.
Forms, ASP.NET Core, and all other forms of .NET development. Xamarin.Forms
becomes Microsoft MAUI, with the main difference between versions being that the new
Microsoft MAUI will only use a single project to target all operating systems and devices.
Now, let's look at some of the new features of .NET 6 from a high-level viewpoint.
Garbage collection
The garbage collector's performance regarding marking and stealing has been improved.
When a thread has finished its marking allotment, it can steal outstanding marking
work from other threads. This speeds up the process of collecting items to be garbage
collected. Reduced lock contentions on computers with higher core counts, improved
de-committing, avoidance of costly memory resets, and vectorized sorting are just some of
the new garbage collection performance improvements in .NET 6.
Just-In-Time compiler
In .NET 6, the Just-In-Time (JIT) compiler has also been improved. You can apply
various optimizations to the JIT, and it has an unlimited amount of time to implement
those optimizations. Ahead-Of-Time (AOT) is just one of the various techniques
provided to the JIT so that it can compile as much code as it can before executing the
application. The JIT now sees the length of an array as unsigned, which improves the
performance of mathematical operations carried out on an array's length. There are still
many changes being made.
Suffice to say that between the JIT and the GC, the performance improvements that have
been made to JIT and GC concerning memory and compilation optimizations are just two
reasons alone to migrate to .NET 6.
The JIT also recognizes more than a thousand new hardware intrinsic methods. These
methods allow you to target various hardware instruction sets from C#. You are no longer
tied to just x86_x64 hardware instruction sets.
Several runtime helper functions are available in the JIT. These helper functions enable
the JIT compiler to manipulate the source code so that the code runs must faster. Generic
lookups are much faster now, as they no longer need to employ slower lookup tables.
10 Introducing C# 10.0 and .NET 6
Text-based processing
Performance enhancements have also been made within the text-based processing
elements of .NET 6. These include (but are not limited to) processing whitespace in the
System.Char class, which requires less branching and fewer arguments. Because this
class is used in various text-processing objects and methods within .NET 6, the speed of
processing text in .NET 6 will be generally improved. DateTime processing is also at
least 30% faster due to optimizations in extracting the date and time components from
the raw tick count. Performance improvements have also been made to string operations
due to culture-aware modifications of StartsWith and EndsWith. By utilizing stack
allocation and JIT devirtualization, the performance of data encoding, such as UTF8 and
Latin1 encoding, has also been enhanced.
Regular expression (RegEx) performance has also been improved in .NET 6. The RegEx
engine has had performance improvements that increase textual processing by up to
three to six times and even more. The CharInClass method is more intelligent in
determining if characters appear within the specified character class. Character and digit
comparisons use lookup tables and various method calls are inlined, providing improved
RegEx processing. Generated code for various expressions has been improved. Searching
for RegExes is carried out using span-based searching with vectorized methods. The
need for backtracking has been eliminated as it analyzes RegExes during the node tree
optimization phase and adds atomic groups that do not change the semantics but do
prevent backtracking. These are only some of the improvements to RegEx performance.
But there are many more.
Note
For more in-depth knowledge on .NET 5 performance improvements to
RegExes, please read the following very detailed post by Stephen Toub:
https://devblogs.microsoft.com/dotnet/regex-
performance-improvements-in-net-5/.
Overview of C# 10.0
You can find the features that will become part of C# 10.0 on the Roslyn GitHub page at
https://github.com/dotnet/roslyn/blob/master/docs/Language%20
Feature%20Status.md.
Not all these features are available at the time of writing. However, we will look at some of
the available features. With that, let's start with top-level programs.
Overview of C# 10.0 13
using System;
namespace HelloWorld
{
class Program
{
static void Main(string[] args)
{
Console.WriteLine("Hello, World!");
}
}
}
As you can see, first, we import our System library. Then, we have a namespace
definition followed by our class definition. Then, in the class definition, we have our Main
method, in which we output the phrase "Hello, World!" to the console window.
In version 10.0 of the C# programming language, this can be simplified down to
a single line:
System.Console.WriteLine("Hello, World");
Here, we have eradicated 10 lines of code. Running the program will output the following:
Figure 1.2 – The console window showing the output "Hello World!"
14 Introducing C# 10.0 and .NET 6
Figure 1.3 – ILDASM showing the internals of the hello world program
You will see from the decompilation that the compiler adds the Main method at compile
time. The next addition to C# 10.0 that we will look at is init-only properties.
namespace CH01_Books
{
internal class Book
{
public string Title { get; init; }
public string Author { get; init; }
}
}
The properties can be initialized when the book is created. But once created, they can
only be read, not updated, making the Book type immutable. Now, let's look at init-only
properties. In the Program class, replace its contents with the following:
using System;
using CH01_Books;
var bookName = new Book { Title = "Made up book name",
Author = "Made Up Author" };
Console.WriteLine($"{bookName.Title} is written by
{bookName.Author}. Well worth reading!");
Overview of C# 10.0 15
Here, we imported the System and CH01_Books namespaces. Then, we declared a new
immutable variable of the Book type. After that, we output the contents of that Book type
using an interpolated string. Run the program; you should see the following output:
Using records
When updating data, you do not want that data to be changed by another thread. So,
in multi-threaded applications, you will want to use thread-safe objects when making
updates. Records allow complete objects to be immutable and behave as values. The
advantage of using records over structs is that they require less memory to be allocated
to them. This reduction in memory allocation is accomplished by compiling records to
reference types. They are then accessed via references and not as copies. Due to this, other
than the original record allocation, no further memory allocation is required.
Let's learn how to use records. Start a new console application.
To demonstrate the use of records, we will use the following Book example:
The only change to the Book class is that class has been replaced with record.
Everything else remains the same. Now, let's put the record to work:
1. Replace the contents of the Program class with the following code:
using System;
using CH01_Records;
Console.WriteLine($"Some of {bookThree.Author}'s
books include:\n");
Console.WriteLine($"- {bookOne.Title}");
Console.WriteLine($"- {bookTwo.Title}");
Overview of C# 10.0 17
Console.WriteLine($"- {bookThree.Title}");
Console.WriteLine($"- {bookFour.Title}");
Console.WriteLine($"- {bookFive.Title}");
Console.WriteLine($"- {bookSix.Title}");
Console.WriteLine($"\nMy favourite book by {bookOne.
Author} is {bookOne.Title}.");
2. As you can see, we are creating immutable record types. We can create new
immutable types from them and change any fields we like using the with
expression. The original record is not mutated in any way. Run the code; you will
see the following output:
5. Book will now include PublisherName. When we initialize a new book, we can
now set its PublisherName:
var bookOne = new Book {
Title = "Made Up Book",
Author = "Made Up Author",
PublisherName = "Made Up Publisher Ltd."
};
8. As you can see, we never set the publisher's name for bookTwo to bookSix.
However, the inheritance has followed through from when we set it for bookOne.
9. Now, let's perform object equality checking. Add the following code to the end of
the Program class:
var book = bookThree with { Title = "Made Up Book" };
var booksEqual = Object.Equals(book, bookOne) ?
"Yes" : "No";
Console.WriteLine($"Are {book.Title} and
{bookOne.Title} equal? {booksEqual}");
10. Here, we created a new Book from bookThree and set the title to Made Up
Book. Then, we performed an equality check and output the result to the console
window. Run the code; you will see the following output:
11. Our final look at records considers positional records. Positional records set data
via the constructor and extract data via the deconstructor. The best way to
understand this is with code. Add a class called Product and replace the class with
the following:
public record Product
{
readonly string Name;
readonly string Description;
12. Here, we have an immutable record. The record has two private and readonly
fields. They are set in the constructor. The Deconstruct method is used to return
the data. Add the following code to the Program class:
var ide = new Product("Awesome-X", "Advanced Multi-
Language IDE");
var (product, description) = ide;
The prætor and his family, including Cleorita and Oviata Arcos, with
the Four, awaited, on the morning succeeding the eventful day of
Manito’s animalculan introduction, the coming of the Dosch of
Manatitla in the audience chamber of the house, dedicated by
Correliana in aptitude to the developing powers of the tympano-
microscope, “the auriculum.” After a short delay of expectation, the
courier falcon appeared at poise, from which in swift descent it came
in downward incline direct to its perch on Correliana’s wrist. But a
second elapsed before the tympanum reëchoed in cheery tones of
salutation the voice of our expected visitor. Our attention attracted
to the field of magnifying reflection, discovered a coterie of
animalculans, of nearly the same size, grouped about the speaker.
With the salutation, “Afferens scientiam errantes gigantes,” he
addressed us as follows:—
For ages untold, our race have waited in patient expectation for the
morning’s dawn when they could salute yours face to face, and
impart to you a source of happiness that in life realizes communion
with immortality. To us has been vouchsafed this coveted privilege,
and it shall be our study to improve it to your advantage.
Notwithstanding the malapropos accident—casting upon Correliana
an arch glance that wrought for her face a scarlet veil—of yesterday,
which detracted from the dignity of an introduction so important to
the regenerative welfare of your race, we were glad that auspicious
mirth was the trophy of the occasion, rather than tears of grief, of
which we shall be mindful in adjudging our censure to the cause.
Joyous mirth we have esteemed an evidence of goodness, for it
declares itself beyond the reach of selfish impediment that breeds
evil intention; even when the foibles of our kind become the subjects
of humorous provocation. Mirth is ill timed, when preconcerted with
a knowledge that a portion of those present will be unable to
appreciate the humorous incentive; as it opens wide the door of
suspicion with your peoples, who have been educated under the
partial sway of national habits and customs. Dissimilarity in habits
and customs, under national patronage, begets from seeming
incongruity a disposition to gibe with missile retorts, fledged and
tipped with ironical sarcasms, as rankling in effect as the pointed
weapons in the mouth of Mr. Welson’s knighted chief. To be frank, if
the ludicrous scene of yesterday had occurred with matured
acquaintance, I should not have spared the demure, but conscious
blushes of the fair medium. Our first acquaintance with you,
although not mutual in personal recognition, is of older date than
yesterday, and upon it has been founded our predilections, which in
train have led to the many concurrent circumstances favoring the
happy issue of our more direct scheme, devised for the liberation of
your race from the pampering trammels of instinct. It would have
been quite easy for our first giantescoes to have obtained an
introduction to your race, if they had emulated the desire of being
exhibited as an iotian monstrosity for the gratification of giga greed
and curiosity. But fortunately for our present hoped-for issue, our
system of education, devised for the development of affectionate
confidence, encouraged the past generations of our race to wait for
an opening free from the entailment of experimental disadvantage. A
knowledge of our race for the gratification of your scientific savants
curiosity, would have been as profitless for good, as their sight-
seeing acquaintance with the moon and stars. Our Manatitlan sages
have from the earliest period recommended extreme caution to
prevent the premature introduction of our race to yours. The
favorable indications to be watched for in premonition of a
successful issue were those of extreme folly, heralding a closing
cycle; for the contrast afforded by the result of our happy example
would attract kindly imitation of those inclined to affectionate
goodness.
Desideratus, one of our most approved prognosticators, deposed
that the affections of woman afford the best test of a closing giga
cycle. When frivolity and the gossiping comparisons of vanity gain
the ascendency over natural affection, inherent as the birthright of
woman, then you may know that the symbolic serpent’s tail has
received its final circle inclination for union with the mouth. This
inclination was foreshadowed in the eighteenth century, with
invention of power looms; which with the largely increased
acceleration of steam, fabricated in excess of the world’s actual
requirements for healthy protection and comely adornment. With
steam as an inductive aid to civilized progression, the Eugenic era
was ushered in, when the frail mortal tenements of women became
subject to empirical vanity, and in rivalry, the standard-bearers for
cumbersome mechanical products, to the utter perversion of healthy
elasticity, comfort, and their special vocation of fostering for
immortality affectionate goodness. This dereliction of giga women
from their manifest duty, has brought in train domestic and dynastic
miseries, while from dreary self conviction their hopeless prospect
closes with the grave. As we have now adventured the only
opportunity that has ever occurred, with a prospect of success, for
extending the influence of our happy experience to your race, we
will with our introduction premise a description of Our Country.
Manatitla is situated in the Andean district of La Plata, with a
southern aspect. It occupies a space between the parallels of 20°
40˝ and 30° south latitude and 40° 50° west longitude, embracing
an area of forty square furlongs, of Manatitlan measurement. Its
surface is diversified, combining in well-defined variety mountains,
hills, and vales, with their concomitant streams, lakes, and brooks;
affording with arable advantages, prospects unrivaled in beauty,
which have been enhanced by the grateful labor of its inhabitants in
acknowledgment for the benefits bestowed. The climate is salubrious
and free from the extremes of heat and cold, having a valley altitude
varying but little from six thousand feet above the estuary of the La
Plata. The adjacent country is occupied by the giga and animalculan
wild hordes. The Minim is the largest river. Its source is derived from
Lake Areta, located in the Andean spur of Ultisimma; flowing in a
northeasterly direction it finally becomes tributary to the Vermejo.
On the northwestern bank is situated our chief city, Maniculæ. Forty
of our miles below, on the same bank, is situated the City of Iota,
containing twenty thousand inhabitants. Nearly opposite the last
named city, is the town of Speck, its inhabitants, in transition, being
chiefly occupied in the manufacture of auro-silicate for edificial
construction and textile fabrics, rendering them indestructible and
repulsive to cumulative adhesion. The entire population of Manatitla
is estimated at eighteen millions, with a healthy tendency to a
continued rapid decrease in number, from causes which will be
described hereafter.
The Traditional History of Manatitla, is coeval with the imaginary
date of Mauna Che’s advent as a deity from the La Plata into Alta
Peru, reaching in your time measurement to eleven thousand years,
which probably embraces relics of truth, among others a like origin
with the Heracleans; as we are without doubt descended from
castaway parasites of gigas from the eastern continent. But as it is a
constant repetition of acts of oppression, in kind with your classical
written history, we will not shock you with their rehearsal.
The Actual, or Written History of Manatitla, was commenced in the
latter portion of the reign of King Primus, from which dates our
transition period, or emancipation of our people from the instinctive
rule of the stomach and its engendered lusts. But from its
resemblance in factional disruptions to your own, culminating in a
parallel to their cycle condition, we will only allude to the causes that
immediately preceded, and in tendency wrought the changes that
finally effected partition from old habits, and the reverenced usages
of instinct. Arbitrary, religious, and civil exactions, seconded by
compulsory persuasion against all nonconformists, signalized the
tendencies of the period, and gave birth to an ultra instinctive race,
styled liberal democrats, who claimed the inalienable right of
suffragian equality bestowed upon the lower orders of the animal
creation, in the exercise of their untrammeled state of field and
forest freedom. The regular national church, and king, persecuted
the nonconformists and schismatics with dire vengeance, under the
patronage of godhead personification, translating the living heretics
with tortures, burnings, and repetitions of drowning suffocations by
resuscitations from a moribund state, and like admonitory
chastenings in transition for the final judgment of their long
enduring and merciful godhead. The persecuted schismatics
emigrated to distant lands, in order that they might worship their
God of reformation in freedom from invidious restriction of rites.
When located, they in turn used the same strenuous arguments to
subvert the tribal forms of worship. Gaining the ascendency, with
destructive agents, they deprived the aboriginals of local option,
forcing them to conform, with death and displacement, until they
had obliged the remnant descendants of their benefactors to accept
a conditional exile on the outskirts of progressive civilization, in
transit for a grave ultimatum. The notable invention of letters
signalized the latter portion of the reign of Primus, and to it he laid
claim as king rief discoverer; which in the law of entail declares the
subject a utensil to be used for the exaltation of kingly prerogative;
being identified with everything that pertains to the glory of the
throne and its legitimate scionry, his assumptive appropriation was
sustained with ministerial affidavits and legal opinions, in attestation
of King Primus’s great literary and inventive capacity, allied to
clemency, justice, and generosity. But after his death, there was
found concealed in the hut of a bard, who had disappeared just
anterior to the announcement of the king’s invention, parchments
inscribed with the newly introduced characters, which set forth the
bard’s adverse claims in these terms:—
With symbolic signs, I have found,
The art of representing sound.
On distant business one can send,
Or with them greet a distant friend.
The third century of your Christian era was well advanced before
they were aware that there was a race of white gigas occupying a
city not far remote from Maniculæ. At that period distance was
measured by the time occupied in conveyance by the insects then in
use for transportation; but as the vitality of their bodies was subject
to deciduous tenure, travelers were obliged to confine their
researches within the limits of populated districts, between which
adventitious paths were well defined. The defective means of
communication with remote Manatitlan provinces had ever been a
source of sincere regret. Still the lack of advancement in the art of
locomotion had never interfered with the actual realization of
happiness. The wood roach and beetle were used as insects of
draught in the preparation of the soil for cultivation, and the flea for
equisaltation, it being the favorite mount for distant journeys and
pleasure excursions. The first innovation upon these time honored
extra locomotive adjuncts, was effected by the persevering ingenuity
and daring courage of a medium named Bussee. He had from an
early age devoted his thoughts to natural history with the practical
intention of improving the native stock which was too diminutive to
be made available for transportation. As a boy he had been noted
for a quick practical judgment, displayed in his ability to eke out
from scant means the fulfillment of a desired end. Many of his
improved domestic utensils are still in use, in evidence of an
inventive genius in advance of his age. His habits were erratic,
showing an impatience that disdained restraint within the bounds of
precedental usage. Still his affectionate desire to confer public
benefits attracted a grateful solicitude whenever his absence was
unusually prolonged. But as he rarely returned without some
valuable acquisition, confidence in his ability for self-protection
waived anxiety. At length an absence of two months without
communicating with his family, aroused public sympathy to such a
pitch that a search was decided upon. In preparation the citizens of
Maniculæ had collected in the anthemique to consult upon the most
feasible means of conducting the search.
When the direction was decided upon, and they were issuing forth
for its prosecution, they were startled by the gyrations of an apis
isolata (solitary bee) in close proximity to their heads. After a few
eccentric evolutions which excited a commensurate degree of alarm,
their fears were relieved by a shout of laughter in the jovial tones of
the absentee, who, by a skillful direction, caused the bee to alight in
their midst. When sufficiently assured of freedom from danger, his
parents and the Dosch approached near enough to obtain a view of
his mechanical appliances for guiding his prize. Between the wings
of the bee, upon his back, a net with latticed films, supported in
dome shape by stiff fibres, was attached. This turret was retained in
place by filaments, which passed beneath his body, in the
articulation between the body and thorax, so that his movements
and winged action were not impeded. To the antennæ, on either
side, were attached filamental guides, or reins, for directing his
course, the proximal extremities being coupled within the pilot cone.
When assured of the strength and security of the attachments, the
Dosch and parents of Buzzee ventured on a short experimental
flight. As the insect circled, in company with his mate, to gain a bee
line, the daring volantaph caused him to execute a variety of
intricate evolutions, which at first alarmed his passengers, who
expostulated with him in reproof for his temerity. But when he
explained his wish to show them how completely the movements of
the bee were under his control, they no longer offered objections,
their fears being turned to admiration. When satisfied that air flights
could be conducted with more ease, safety, and swiftness, beyond
the most sanguine expectations of ancient or modern Manatitlan
prognosticators, his enterprise was highly commended. When landed
the Dosch and advisors expressed a desire, in behalf of the people,
to listen to a relation of his adventures in the anthemique, as it
would be the means of avoiding rehearsals from hearsay, with the
defects that of necessity were attendant upon individual versions. An
hour before evening song the anthemique was thronged with the
citizens of Maniculæ anxious to hear Buzzee’s relation of the
expedients used for a capture so important in its prospective
bearings to the people of Manatitla. To enhance the clearness of his
demonstration, and at the same time show the dazed docility of the
bee, Buzzee directed his flight to the cantilor’s rostrum, and after he
had settled addressed the assemblage from the pilot cone, in
substance, as follows:—
“Although no stranger to your manifestations of affection, I am well
aware that in appearance I have been remiss in rendering you
suitable returns; but am certain that your confidence in the integrity
of my intentions will exculpate me from meditated indifference. I am
now happy in being able to bring you tangible proof that my
wanderings were not prompted from motives of selfishness or
disdain. From my childhood I have listened in silence to the oft
repeated regrets that our extraneous means of locomotion were
limited to insects so lacking in the instincts of intelligence necessary
for successful direction. Those available for locomotion were too
ephemeral in their term of existence to be trusted for conveyance far
beyond the habitable limits of our country, which from the illimitable
firmament seemed to be but a mere speck upon the earth’s surface.
With a curious desire to learn the wonders of creation overshadowed
by the starry canopy, my earliest thoughts were directed to the
acquirement of the means necessary for safe transportation above
the earth’s surface. My thoughts were at first naturally directed to
artificial wings as the indicated means of progressive transposition
from earth to atmospheric space, without giving thought to the
consideration of ponderable adaptability. Human mortality, which
requires omnivorous support, declares itself ponderable in the vis
inertia of earth, in contrast with the airy attenuations that bespeak
adaptative intention in creating the tenants of space. In addition,
with the successful achievement of working wings, there would be
inevitable friction with the uncertainties of wear and derangement in
flight, with awkward position of ponderable suspension in space for
repairs. So my inventive genius was fain to hold itself convinced of
the futility of subverting the order of elementary adaptation,
designed by the Creator for the perfection of His intentions. Self
convicted with the foolish audacity of my labors to safely suspend
with motion, and locomote with facility ponderable humanity in
space, I bethought myself of man’s privilege of making subordinate
organic vitality, with legitimate kindly motive, subservient to his
desired facilitations. For the elucidation of my thought suggestions I
directed my investigations to insects of flight, to select from their
varied species one suited to our requirements. The primary
qualifications necessary were sagacity, supporting wing expanse,
strength, longevity, and equal motion in flight, with instinctive
perception of individuality sufficient for submission to our kindly
direction. The efficient qualities indicated for the selection of a
winged conveyance, were first, size, with an adaptation for control,
in combination with a supporting buoyancy in excess of its individual
requirements. In the second degree intelligence, with a longevity
sufficient for compensative training, and memory capable of
retaining the imposed impressions, subject to the recognition of
personal direction foreign to their own volition. Added to these
essential qualifications, it was desirable that the insect should be
naturally inclined to sustain a long and swift flight. Bees had early
attracted my attention, but there were many objections to their
adoption that seemed insurmountable. Multitudinous in association,
and individually aggressive, were primary defects in disposition;
while in industrious habits and vocation they were subject to routine
enactments, which together with the tenacious nature and method
of collecting and disposing of their food threatened to end my
ambitious projects, in trial with them, in death from suffocation, or
waxed adhesion to their bodies or cells. The fear of being stalled and
borne to their cells for living incorporation, raised an insuperable
dread, that prevented me from coveting an experimental
acquaintance with the working orders of their kind. Often in my
wanderings I have passed beyond the boundaries of Manatitla in
search of a locomotive desideratum, which I had supposed
necessary for the welfare of our race, as well as a gratuitous vehicle
for the gratification of my covetous desire to rise into the realms of
space, to survey beneath our terrestrial place of abode. A month
since I was returning homeward sad and dispirited with continued
disappointments, when at the close of day, while the glowing tints of
the setting sun still lingered in the glory of their parting adornment
to foliage and flowers, I was attracted by the swift whirr of strange
insect wings. In a moment my attention was drawn with intent
desire toward a pair of insects bearing a hybrid resemblance to the
bee family. After a careful reconnoitering inspection, seemingly
directed, first, to the quality of the flowers of a tropical honeysuckle,
and secondly, to see if they contained insect occupants, they
alighted upon the petals of the fairest. Unlike the hoarding selfish
instincts of their congeners of the bee kind, they premised their
labors with playful dalliance, partly upon wing and with sprightly
pedal evolutions, while darting in chase and counter chase in and
out from the petaled cups of the flowers. In a few minutes their
playful antics and fondlings ceased, then the male with an autocratic
appearance of gallantry assisted his spouse to load herself with the
sweets and waxy exudations of the flowers, this accomplished he
sent her unescorted away, evidently to unload in their store house.
During her absence he devoted his time to a general inspection of
the flowers, with the evident intention of selecting the best. In one
he found a belated droniva (a tropical representative of the bumble-
bee family) who was ejected without ceremony, although double the
size of the audacious usurper. His activity, independence, and cleanly
regard for his own person, disposed me to excuse his cavalier
exaction of service drudgery from his mate, as the duty seemed to
afford her pleasure. In fact the pair impressed me so favorably, that
I determined to avail myself of the opportunity to secure a
permanent attachment.
“Years anterior, as you are aware, I perfected a harness in
anticipation of the fulfillment of my hopes of being able to make a
capture suited for our locomotive requirements. This I had carried
with me in all my excursions, and while my coveted prize was
engaged in his erratic flights, I placed myself in ambush in the
fairest flower of his selection, and had the gratification of securing
him in leash before the return of his mate. He soon became aware
of unusual restraint, and curious to learn its cause made
experimental flights which gave me an opportunity to test the
success of my invention, and I was delighted to find that I could
direct his course with ease. Seemingly puzzled at the loss of his
voluntary power of direction, he made every available effort to learn
the cause of his sudden bereavement, and was pursuing his
investigations when his spouse returned. With mandibulations he
quickly communicated to her the restraint that had been placed
upon his movements during her absence. With evident anxiety she
commenced a search for the impedimental cause. In a few moments
she discovered the filamental guides that I had attached to his
antennæ beneath the carapace, but failing in her attempts to
remove them, after a short consultation, they rose in flight from the
flower to the bee line of their home with a marked show of anxiety,
which made me feel a glow of regret that my selfishness had been
the cause of their disquietude. Once only, in homeward flight, did I
attempt to subject him to a variation in course, but it caused such a
trepidation in his mate that it was with difficulty that she recovered
the balance movement of her wings. Reaching their cell, which was
in a fissured ledge of basaltic formation, they held another
consultation and investigation, during which my turret cone was
subjected to a close examination, but the tough silicothed filaments
were too strong for removal by her feeble efforts. Finding his strange
investment inevitable, and attended with but slight inconvenience,
he, at last, with cheerful philosophy, soothed the anxiety of his
spouse with endearments, abated of their autocratic patronizing air
of superiority. This show of appreciation for his mate’s solicitude, at
once bespoke a high degree of sympathetic intelligence attained by
a union of instinctive equality. In contrasted proof of the evident
assumption, I will adduce the ants, and our neighbors of the human
species, who live in a state of concubinage, to show that sexual
gregation begets a condition of brutal selfishness in the males,
causing them to use physical strength for the reduction of their
females to serve as bond slaves of passion and labor for
multitudinous production in kind. From their continued dalliance
after nightfall, I was pleased to learn that their habits were semi-
nocturnal in perceptive activity. When they finally retired for the
night to the shelter within their cell, I suffered retributive spasms
from the powerful mellific odors that pervaded the cell, which
caused protracted coughing and general relaxation, so that in my
extremity I was prompted to make my escape into the open air, but
the intense darkness and my weakness prevented me. As my air
passages became accustomed to the acrid irritation, I in sequence
suffered from mellific narcotism, and fell into a stuporic medium
between waking impressions and fantastic visions of instinct that
precede the waking dawn from sleep. These variations continued
until the bees’ emergence into the open air, in the morning, revived
me. After their matutinal salutations they rose in flight circles to their
bee line, but winged their course in an opposite direction from the
honeysuckle plot so memorable in their previous day’s experience,
probably attributing the cause of restraint to some inherent property
of the flowers.
“My elevation and swift passage through the air, reminded me, with
its bracing effect, that I had not taken food for a donsenack, so
feeling at ease I unstrapped my script and made a hearty meal, with
a zest that the words of our language will fail to express. Shortly
after I had closed my morning meal, the bees commenced their
circlings in downward descent, and ere long I discovered below, on
the rocky declivity of a hillside a growth of honeysuckles, the goal of
their attraction. In the circling support of their buzzing wings they
remained suspended over the flowers for some time, until their
safety had been tested by dronivas and humming-birds, then with
caution they ventured to settle upon the petals, and after some
hesitation, the female was loaded and dispatched with her first cargo
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.
ebooknice.com