100% found this document useful (2 votes)
9 views

(Ebook) Practical Rust Projects: Build Serverless, AI, Machine Learning, Embedded, Game, and Web Applications by Shing Lyu & Andrew Rzeznik ISBN 9781484293317, 1484293312 pdf download

Ebook download

Uploaded by

zakenbcurthwn
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
100% found this document useful (2 votes)
9 views

(Ebook) Practical Rust Projects: Build Serverless, AI, Machine Learning, Embedded, Game, and Web Applications by Shing Lyu & Andrew Rzeznik ISBN 9781484293317, 1484293312 pdf download

Ebook download

Uploaded by

zakenbcurthwn
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 46

(Ebook) Practical Rust Projects: Build

Serverless, AI, Machine Learning, Embedded,


Game, and Web Applications by Shing Lyu & Andrew
Rzeznik ISBN 9781484293317, 1484293312 download
https://ebooknice.com/product/practical-rust-projects-build-
serverless-ai-machine-learning-embedded-game-and-web-
applications-58938126

Explore and download more ebooks at ebooknice.com


Here are some recommended products that we believe you will be
interested in. You can click the link to download.

(Ebook) Practical Rust Web Projects: Build Serverless, AI, Machine


Learning, Embedded, Game, and Web Applications by Shing Lyu, Andrew
Rzeznik ISBN 9781484293300, 1484293304

https://ebooknice.com/product/practical-rust-web-projects-build-
serverless-ai-machine-learning-embedded-game-and-web-
applications-51003808

(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

(Ebook) Matematik 5000+ Kurs 2c Lärobok by Lena Alfredsson, Hans


Heikne, Sanna Bodemyr ISBN 9789127456600, 9127456609

https://ebooknice.com/product/matematik-5000-kurs-2c-larobok-23848312

(Ebook) SAT II Success MATH 1C and 2C 2002 (Peterson's SAT II Success)


by Peterson's ISBN 9780768906677, 0768906679

https://ebooknice.com/product/sat-ii-success-
math-1c-and-2c-2002-peterson-s-sat-ii-success-1722018
(Ebook) Practical Rust Projects by Shing Lyu and Andrew Rzeznik

https://ebooknice.com/product/practical-rust-projects-53050582

(Ebook) Master SAT II Math 1c and 2c 4th ed (Arco Master the SAT
Subject Test: Math Levels 1 & 2) by Arco ISBN 9780768923049,
0768923042

https://ebooknice.com/product/master-sat-ii-math-1c-and-2c-4th-ed-
arco-master-the-sat-subject-test-math-levels-1-2-2326094

(Ebook) Cambridge IGCSE and O Level History Workbook 2C - Depth Study:


the United States, 1919-41 2nd Edition by Benjamin Harrison ISBN
9781398375147, 9781398375048, 1398375144, 1398375047

https://ebooknice.com/product/cambridge-igcse-and-o-level-history-
workbook-2c-depth-study-the-united-states-1919-41-2nd-edition-53538044

(Ebook) Practical Rust Web Projects: Building Cloud and Web-Based


Applications by Shing Lyu ISBN 9781484265895, 1484265890

https://ebooknice.com/product/practical-rust-web-projects-building-
cloud-and-web-based-applications-23174690

(Ebook) Serverless Web Applications with AWS Amplify: Build Full-Stack


Serverless Applications Using Amazon Web Services by Akshat Paul,
Mahesh Haldar ISBN 9781484287064, 1484287061

https://ebooknice.com/product/serverless-web-applications-with-aws-
amplify-build-full-stack-serverless-applications-using-amazon-web-
services-51197104
Shing Lyu and Andrew Rzeznik

Practical Rust Projects


Build Serverless, AI, Machine Learning, Embedded,
Game, and Web Applications
2nd ed.
Shing Lyu
Amsterdam, The Netherlands

Andrew Rzeznik
Arlington, MA, USA

ISBN 978-1-4842-9330-0 e-ISBN 978-1-4842-9331-7


https://doi.org/10.1007/978-1-4842-9331-7

© Shing Lyu and Andrew Rzeznik 2020, 2023

This work is subject to copyright. All rights are solely and exclusively
licensed by the Publisher, whether the whole or part of the material is
concerned, specifically the rights of translation, reprinting, reuse of
illustrations, recitation, broadcasting, reproduction on microfilms or in any
other physical way, and transmission or information storage and retrieval,
electronic adaptation, computer software, or by similar or dissimilar
methodology now known or hereafter developed.

The use of general descriptive names, registered names, trademarks, service


marks, etc. in this publication does not imply, even in the absence of a
specific statement, that such names are exempt from the relevant protective
laws and regulations and therefore free for general use.

The publisher, the authors, and the editors are safe to assume that the advice
and information in this book are believed to be true and accurate at the date
of publication. Neither the publisher nor the authors or the editors give a
warranty, expressed or implied, with respect to the material contained
herein or for any errors or omissions that may have been made. The
publisher remains neutral with regard to jurisdictional claims in published
maps and institutional affiliations.

This Apress imprint is published by the registered company APress Media,


LLC, part of Springer Nature.
The registered company address is: 1 New York Plaza, New York, NY
10004, U.S.A.
Introduction
Almost every programming language has one or more books about it that
provide a deep dive into fundamental syntax, semantics, and functionality.
These books are amazing as both an introduction and a reference. It’s
important to be able to dive deep and fully immerse yourself in a topic to
gain a thorough understanding of it. Whenever I am starting to learn a new
language, I look for this kind of foundational text to start my journey.
After completing this first stage, however, there is a question of where
to move next. Sometimes you’ve learned a language for a very specific
purpose, so you focus all your energies toward using the language for that
task. But breadth of learning is also very important, and can sometimes be
harder to find. The best programmers don’t just know their own specialty,
but also have a broad foundation of knowledge along with background on
adjacent subjects. Learning different applications of a language can open
your mind to new ideas both within that language and outside of it. It’s also
really fun to throw together a new project that does something you’ve never
done before.
This book was created to provide some of these projects, which will let
you take your core Rust knowledge and apply it to several different areas.
Its goal is to expose you to new ideas and different ways of thinking, and
show, not tell, you how Rust can be used.
One of the big reasons I was drawn to Rust as a programming language
was how it embodies the “general purpose” paradigm. If you ask ten
different people why they like the language, you’ll frequently get ten
different answers. Some people like it because it’s low level; it compiles
directly to machine code in the same way as C, with all of the fine control
afforded there. However, some people like it because it’s high level, with a
strong type system and advanced macros for working with abstract
constructs. Some people like Rust because it feels like a safer C++, while
others learn it as a more performant alternative to Python. Some people like
Rust for its large selection of available packages, while others like how
powerful the core language feels even when the standard library has been
disabled.
A lot of these different views are because Rust exists in a big ecosystem
with wildly different applications, especially for being such a comparatively
young language. On one end, it’s possible to write tiny bare-metal programs
whose compiled size can be measured in hundreds of bytes (not megabytes,
not kilobytes, but bytes). On the other end, people are currently building
operating systems, language compilers, and large distributed systems in
Rust. This book was written to share with you a small set of these
interesting applications, and hopefully show you the benefits (and joy) of
writing them in Rust.
A drawback to the approach taken here is that we can’t go into great
depth on any of the topics. A whole book could be written for each single-
chapter project we present here, diving deep into advanced theory, design,
and tradeoffs. We chose to instead focus only on the core essence of each
project, providing you with a scaffold that does something useful and that
you can later extend with your own ideas. As any programmer knows,
frequently the hardest parts of a new project are the initial setup,
architecture, and library choices. We’ve tried to provide these components
to you as a solid foundation for your projects, while also trying to include
some interesting examples that touch on important issues in each of the
topics.
We hope that this book lets you see the many faces of the Rust
programming language, where it shines, and in some cases the places where
a person like you can make things better. Many programmers feel that the
gap between a novice and an expert is insurmountable, and that the people
who build “real” production applications must have some unique gifts.
Hopefully the examples here will help build your confidence and show you
that anyone can build real, practical projects in Rust with a little guidance
and determination.

Source Code
All code used in this book can be found at
github.com/apress/practical-rust-projects-2e.
Any source code or other supplementary material referenced by the author
in this book is available to readers on GitHub (github.com/apress). For
more detailed information, please visit http://www.apress.com/source-code.
Table of Contents
Chapter 1: Welcome to the World of Rust
1.1 Who Is This Book For?
1.2 Who Is This Book Not For?
1.3 Criteria for Selecting Libraries
Pure Rust
Maturity
Popularity
1.4 How to Use This Book
Chapters Overview
1.5 Source Code
1.6 Topics Not Covered
Chapter 2: Building a Command-line Program
2.1 What Are You Building?
2.2 Creating a Binary Project
2.3 Reading Command-line Arguments with std::env::args
2.4 Handling Complex Arguments with Clap
2.5 Adding Binary Flags
2.6 Printing to STDERR
2.7 Printing with Color
2.8 Reading the Cat Picture from a File
2.9 Handling Errors
2.10 Piping to Other Commands
Piping to STDOUT Without Color
Accepting STDIN
2.11 Integration Testing
2.12 Publishing and Distributing the Program
Install from Source
Publish to crates.io
Building Binaries for Distribution
2.13 Conclusion
Chapter 3: Creating Graphical User Interfaces (GUIs)
3.1 What Are You Building?
3.2 Building a Text-based User Interface
3.3 Showing a Dialog Box
3.4 Handling Simple Keyboard Inputs
3.5 Adding a Dialog
3.6 Multi-step Dialogs
3.7 Reading User Input
3.8 Moving to Graphical User Interfaces (GUIs)
3.9 Creating a Window
3.10 Displaying an Image
3.11 Using Glade to Design the UI
3.12 Accepting Inputs and Button Clicks
3.13 Reading a gtk::Switch
3.14 Alternatives
3.15 Conclusion
Chapter 4: High-Performance Web Frontend Using WebAssembly
4.1 What Is WebAssembly?
4.2 What Are You Building?
4.3 Hello WebAssembly!
Setting Up the Development Environment
Creating the Project
Creating the Frontend
4.4 Resizing an Image with WebAssembly
Loading an Image File onto the <canvas>
Passing the Image to Wasm
4.5 Writing the Whole Frontend in Rust
4.6 A Hello World Example
4.7 A Cat Management Application
CSS Styling
Deleting Files
4.8 Wasm Alternatives
4.9 Conclusion
Chapter 5: REST APIs
5.1 What Are You Building?
5.2 Hello Backend World!
5.3 Serving Static Files
5.4 Converting the Cats List to a REST API
5.5 Using a Database
5.6 Adding Cats with a POST Command
5.7 API Testing
5.8 Building the Cat Detail API
5.9 Input Validation
5.10 Error Handling
Using the actix_web::error Helpers
Using a Generic Error That Has Implemented the
ResponseError Trait
Using a Custom-Built Error Type
5.11 Customizing the web::Path Extractor Error
5.12 Logging
5.13 Enabling HTTPS
5.14 Framework Alternatives
5.15 Conclusion
Chapter 6: Going Serverless with the Amazon AWS Rust SDK
6.1 What Are You Building?
6.2 What Is AWS Lambda?
6.3 Registering an AWS Account
6.4 Hello World in Lambda
6.5 The Full Architecture
6.6 Using the AWS Serverless Application Model (AWS SAM)
6.7 Setting Up AWS SAM CLI Credentials
6.8 Creating the Catdex Serverless Project
6.9 Building the Upload API
6.10 Building the /cats API
6.11 Uploading the Image Using S3 Pre-signed URL
6.12 Adding the Frontend
6.13 A Note on Security
6.14 Next Steps
6.15 Conclusion
Chapter 7: Building a Game
7.1 What Are We Building?
7.2 Bevy and the Entity Component System Pattern
7.3 Creating a Bevy Project
7.4 See the World Through a Camera
7.5 Adding the Cats
7.6 Loading a Spritesheet
7.7 Moving the Cats
7.8 Creating the Ball
7.9 Can’t Defy Gravity
7.10 Making the Ball Bounce
7.11 Keeping Score
7.12 Let There Be Music
7.13 Alternatives
7.14 Conclusion
Chapter 8: Physical Computing in Rust
8.1 What Are You Building?
8.2 Physical Computing on Raspberry Pi
Getting to Know Your Raspberry Pi
Installing Raspberry Pi OS Using Raspberry Pi Imager
Installing the Rust Toolchain
Understanding the GPIO Pins
Building an LED Circuit
Controlling the GPIO Output with Rust
Reading Button Clicks
8.3 Cross-Compiling to Raspberry Pi
8.4 How Does the GPIO Code Work?
8.5 Where to Go from Here?
Chapter 9: Artificial Intelligence and Machine Learning
9.1 Types of Machine Learning Models
9.2 What Are You Building?
9.3 Introducing linfa and rusty-machine
9.4 Clustering Cat Breeds with K-means
Introduction to the K-means Algorithm
The Training Data
Exporting as a CSV
Moving the Configuration into a File
Setting the Configuration File at Runtime
Visualizing the Data
Details on Adding More Entries
Setting Up K-means
9.5 Detecting Cats Versus Dogs with a Neural Network
Introduction to Neural Networks
Preparing the Training Data and Testing Data
Setting Up the Neural Network Model
Reading the Training and Testing Data
Normalizing the Training Data
Training and Predicting
Making the Prediction
9.6 Alternatives
9.7 Conclusion
Chapter 10: What Else Can You Do with Rust?
10.1 The End Is Just the Beginning
10.2 Server-side Rendered Website
10.3 Web Browser and Crawler
10.4 Mobile
10.5 Operating Systems and Embedded Devices
10.6 The Cloud
10.7 Blockchains and Cryptocurrencies
10.8 Unlimited Possibilities of Rust
Index
About the Authors
Shing Lyu
is a software engineer who is passionate
about open source software. He’s worked
on Rust professionally at Mozilla on the
Firefox (Gecko) and Servo browser engine
project. Currently, he works at Amazon
Web Services (AWS) as a solutions
architect. Previously, Shing worked at
DAZN, a sports streaming platform, as a
backend developer, with a focus on AWS
and serverless technology. Shing has
worked for other world-famous brands
such as Intel. He is also active in the open
source community. Being one of the
founders of the Taiwan Rust community, he loves to share his enthusiasm
for Rust with people.

Andrew Rzeznik
is a software development engineer at AWS
Cryptography with interests in distributed
systems, languages, tooling, Internet of
Things (IoT), and low-level programming.
His primary working language is Rust, but
he considers himself a polyglot, having
worked in C, C++, Python, Java, C#, and
many others. Before AWS Andrew worked
in various software positions, with a
primary focus in factory automation. He
developed robust yet accessible distributed
machine control frameworks to bring
advanced software patterns and techniques
to manufacturing. He also served as a
consultant, where he debugged manufacturing issues at various firms.
Andrew received his PhD in mathematics from the Massachusetts Institute
of Technology (MIT), where he wrote simulations for ocean mining plumes
and tested them aboard a research vessel at sea.
About the Technical Reviewer
Satej Kumar Sahu
works in the role of senior software data
architect at Boeing. He is passionate about
technology, people, and nature. He believes
that through technology focused on
sustainability and conscientious decision
making each of us has the power to make
this world a better place. In his free time,
he can be seen reading books, playing
basketball, and having fun with friends and
family.
© The Author(s), under exclusive license to APress Media, LLC, part of Springer
Nature 2023
S. Lyu, A. Rzeznik, Practical Rust Projects
https://doi.org/10.1007/978-1-4842-9331-7_1

1. Welcome to the World of Rust


Shing Lyu1 and Andrew Rzeznik2
(1) Amsterdam, The Netherlands
(2) Arlington, MA, USA

If you’re reading this book, you’re probably as excited about Rust as we


are. Since its first stable release in 2015, Rust has come a long way in terms
of features and stability. Developers around the world are fascinated by how
Rust can combine features that were once thought of as unavoidable trade-
offs: performance with memory safety, and low-level control with
productivity. Despite its infamous steep learning curve, Rust has gained
popularity over the years. It was named the “most loved programming
language” in a StackOverflow survey eight years in a row, from 2016 to
2023. In 2022, it was also named the “most wanted programming
language,” just beating out Python. Many big companies and organizations
like Amazon, Facebook, Google, Microsoft, Dropbox, and npm use Rust in
production. The Android platform supports writing native components in
Rust, and, perhaps most interesting of all, Rust is the first language after C
to be added to the Linux Kernel.
How large is the Rust ecosystem currently? If we take a look at
crates.io, the official Rust crates (libraries) registry, there are over 100,000
crates and over fifty million downloads a day. There are 55 categories on
crates.io,1 ranging from command-line interfaces and cryptography to
databases, games, operating systems, web programming, and more. What
does it feel like to use these libraries? How does Rust’s syntax and design
philosophy affect the design of these crates? How can you get started
writing some cool code with real use cases? This book will try to answer
these questions.
1.1 Who Is This Book For?
This book will be useful for
people who already know basic Rust syntax, but want to learn how to
build applications in Rust;
people who are considering using Rust to build production-ready systems
and want a tour of some of the options; and
people who wish to have a quick overview of high-level architecture and
programming interface design in other fields.
You might have learned Rust out of curiosity. After finishing all the
tutorials and beginner books, you might have been left wondering, “What
should I do next? What can I build with Rust?” This book will walk you
through a few different applications of Rust, which will help you move
beyond basic language theory and into building real applications. Rust has a
fascinating design and many interesting language features, but simply
knowing how to write basic algorithms and data structures won’t
necessarily prepare you for building useful applications. We’ve tried to find
the most production-ready but also modern Rust libraries to do the job, so
you’ll be able to judge if Rust is ready for the application you’ve
envisioned. If it’s not, you might find opportunities to contribute back to
Rust’s community by improving the existing libraries and frameworks, or
by designing and building new ones.
You might have learned Rust for a specific project, like a CLI tool for
work or an open-source browser engine that happens to use Rust. Once you
master Rust for that domain, it’s beneficial to learn Rust for other domains
—say, building a game or a website. This will open you to new ideas that
you can apply to the original domain. For example, by building a game,
you’ll know how game engine designers organize their code to make it
decoupled and easy to maintain, while also being very performant. You may
never build a game for work, but that knowledge might influence the
architecture of your next project. As another example, learning how to
cross-compile code to a Raspberry Pi might help you understand how
compiling to WebAssembly works. This book aims to take you through a
tour of various applications of Rust like this. You’ll learn what their
application programming interfaces (APIs)2 look like and how they
organize their code and architecture.
Exploring the Variety of Random
Documents with Different Content
The Project Gutenberg eBook of Famous Men
of Ancient Times
This ebook is for the use of anyone anywhere in the United States
and most other parts of the world at no cost and with almost no
restrictions whatsoever. You may copy it, give it away or re-use it
under the terms of the Project Gutenberg License included with this
ebook or online at www.gutenberg.org. If you are not located in the
United States, you will have to check the laws of the country where
you are located before using this eBook.

Title: Famous Men of Ancient Times

Author: Samuel G. Goodrich

Release date: June 23, 2016 [eBook #52400]


Most recently updated: October 23, 2024

Language: English

Credits: Haragos Pál and the Online Distributed


Proofreading Team at http://www.pgdp.net (This file was
produced from images generously made available by The
Internet Archive)

*** START OF THE PROJECT GUTENBERG EBOOK FAMOUS MEN OF


ANCIENT TIMES ***
FAMOUS MEN

OF

ANCIENT TIMES.

BY

S. G. GOODRICH.

BOSTON:
THOMPSON, BROWN & COMPANY.
23 Hawley Street.
PREFACE
The reader of these pages will perhaps remark, that the length of
the following sketches is hardly proportioned to the relative
importance of the several subjects, regarded in a merely historical
point of view. In explanation of this fact, the author begs leave to
say, that, while he intended to present a series of the great beacon
lights that shine along the shores of the past, and thus throw a
continuous gleam over the dusky sea of ancient history,—he had still
other views. His chief aim is moral culture; and the several articles
have been abridged or extended, as this controlling purpose might
be subserved.
It may be proper to make one observation more. If the author has
been somewhat more chary of his eulogies upon the great men that
figure in the pages of Grecian and Roman story, than is the
established custom, he has only to plead in his vindication, that he
has viewed them in the same light—weighed them in the same
balance—measured them by the same standard, as he should have
done the more familiar characters of our own day, making due
allowance for the times and circumstances in which they acted. He
has stated the results of such a mode of appreciation; yet if the
master spirits of antiquity are thus shorn of some portion of their
glory, the writer still believes that the interest they excite is not
lessened, and that the instruction they afford is not diminished. On
the contrary, it seems to him that the study of ancient biography, if it
be impartial and discriminating, is one of the most entertaining and
useful to which the mind can be applied.
CONTENTS.

PAGE
Mohammed 7
Belisarius 25
Attila 60
Nero 68
Seneca 74
Virgil 83
Cicero 95
Julius Cæsar 130
Hannibal 145
Alexander 157
Aristotle 183
Demosthenes 197
Apelles 209
Diogenes 231
Plato 218
Socrates 229
Alcibiades 244
Democritus 252
Pericles 256
Aristides 261
Æsop 264
Solon 271
Lycurgus 277
Homer 282
Confucius 291

FAMOUS MEN OF ANCIENT TIMES


MOHAMMED.
This individual, who has exercised a greater influence upon the
opinions of mankind than any other human being, save, perhaps,
the Chinese philosopher Confucius, was born at Mecca, in Arabia, A.
D. 570. He was the only son of Abdallah, of the noble line of
Hashem and tribe of Koreish—descendants of Ishmael the reputed
progenitor of the Arabian race.
The Koreishites were not only a commercial people, and rich by
virtue of their operations in trade, but they were the hereditary
guardians of the Caaba, or Kaaba, a heathen temple at Mecca. The
custody of this sacred place, together with all the priestly offices,
belonged to the ancestors of Mohammed.
The Mohammedan authors have embellished the birth of the prophet
with a great variety of wonderful events, which are said to have
attended his introduction into the world. One of these is, that the
Persian sacred fire, kept in their temples, was at once extinguished
over all Arabia, accompanied by the diffusion of an unwonted and
beautiful light. But this and other marvels, we leave to the credulity
of the prophet’s followers.
Mohammed’s father died early, and his son came under the
guardianship of his uncle, Abu Taleb. He was a rich merchant, who
was accustomed to visit the fairs of Damascus, Bagdad, and Bassora
—three great and splendid cities, and Mohammed often
accompanied him to these places. In his twelfth year, Mohammed
took part in an expedition against the wandering tribes that
molested the trading caravans. Thus, by travelling from place to
place, he acquired extensive knowledge, and, by being engaged in
warlike enterprise, his imagination became inflamed with a love of
adventure and military achievements. If we add to this, that he had
naturally a love of solitude, with a constitutional tendency to
religious abstraction; and if, moreover, we consider that in his
childhood he had been accustomed to behold the wild exercises, the
dark ceremonies, and hideous rites of the temple of Caaba—we shall
at once see the elements of character, and the educational
circumstances, which shaped out the extraordinary career of the
founder of Islamism.
It appears that Mohammed was remarkable for mental endowments,
even in his youth, for, in a religious conversation with a Nestorian
monk, at Basra, he showed such knowledge and talent, that the
monk remarked to his uncle, that great things might be expected of
him. He was, however, attentive to business, and so completely
obtained the confidence of his uncle, as a merchant, that he was
recommended as a prudent and faithful young man, to Khadijah, a
rich widow, who stood in need of an agent to transact her business
and manage her affairs. In this capacity he was received, and so
well did he discharge his duties, that he not only won the confidence
of the widow, but finally obtained her hand in marriage. This event
took place when he was about twenty-five years old, Khadijah being
almost forty.
Mohammed was now rich, and, though he continued to carry on
mercantile business, he often retired to a cave, called Heva, near
Mecca, where he resided. He also performed several journeys to
different parts of Arabia and Syria, taking particular pains to gather
religious information, especially of learned Jews and Christians.
For some time, Mohammed, who lived happily with his wife, confided
to her his visits to the cave Heva, professing to enjoy interviews with
Heaven there, by means of dreams and trances, in which he met
and conversed with the angel Gabriel. There is little doubt that his
habits of religious retirement and gloomy reflection had unsettled his
judgment, and that he now gave himself up to the guidance of an
overwrought fancy. It is probable, therefore, that he believed these
visions to be of divine inspiration; else, why should he first
communicate them, as realities, to his wife?
Soon after this, he informed other members of his family of his
visions, and, being now about forty years old, assumed with them,
the character and profession of a prophet. Several of his friends,
particularly his wife, and his cousin Ali, a young man of great energy
of character, yielded to the evidence he gave of his divine mission.
Having been silently occupied about three years in converting his
nearest friends, he invited some of the most illustrious men of the
family of Hashem to his house, and, after conjuring them to
abandon their idolatry, for the worship of One God, he openly
proclaimed his calling, and set forth, that, by the commands of
Heaven, revealed through the angel Gabriel, he was prepared to
impart to his countrymen the most precious gift—the only means of
future salvation.
Far from being convinced, the assembly was struck silent with
mingled surprise and contempt. The young and enthusiastic Ali,
alone, yielded to his pretences, and, falling at his feet, offered to
attend him, in good or evil, for life or for death. Several of the more
sober part of the assembly sought to dissuade Mohammed from his
enterprise; but he replied with a lofty fervor, that if the sun were
placed in his right hand, and the moon in his left, with power over
the kingdoms they enlighten, he would not, should not, could not
hesitate or waver in his course.
Inflamed by the opposition he met with among this assembly,
Mohammed now went forth, and, wherever he could find crowds of
people, there he announced his mission. In the temples, in the
public squares, streets, and market-places, he addressed the people,
laying claim to the prophetic character, and setting forth the duty of
rejecting idolatry, for the worship of one God. The people were
struck with his eloquence, his majesty of person, the beautiful
imagery he presented to their minds, and the sublime sentiments he
promulgated. Even the poet Lebid is said to have been converted by
the wonderful beauty and elevation of the thoughts poured forth by
the professed prophet. The people listened, and, though they felt
the fire of his eloquence, still they were so wedded to their
idolatries, that few were yet disposed to join him.
To aid in understanding the revolution wrought by Mohammed, it
may be well to sketch the condition of the Arabians at that period.
The original inhabitants of Arabia, though all of one stock, and
occupying a peninsula 1200 miles in length by 700 in width, had
been, from time immemorial, divided into a variety of distinct tribes.
These constituted petty communities or states, which, often
changing, still left the people essentially the same. In the more
elevated table lands, intersected by mountain ridges, with dreary
wastes consisting of sandy plains, the people continued to pursue a
roving life, living partly upon their flocks of camels, horses, and
horned cattle, and partly upon the robbery of trading caravans of
other tribes. The people of the plains, being near the water, settled
in towns, cultivated the soil, and pursued commerce.
The various tribes were each governed by the oldest or most worthy
sheik or nobleman. Their bards met once a year, at Okhad, holding a
fair of thirty days, for the recitation of their productions. That which
was declared to be the finest, was written in gold and suspended in
the great temple of Mecca. This was almost the only common tie
between the several states or tribes, for, although they nominally
acknowledged an emir, or national chief, they had never been
brought to act in one body.
The adoration of the Arabians consisted chiefly in the worship of the
heavenly luminaries; but they had a great variety of deities, these
being personifications of certain powers in nature, or passions in
mankind. They were represented by idols of every variety of shape,
which were gathered around the ancient temple of Caaba, at Mecca,
a large square edifice, considered as the central point of religion,
and the favorite seat of divinity. Their worship was attended with the
most horrid rites and shocking ceremonies: even children were
sacrificed to the idols, and one of the tribes was accustomed to bury
their daughters alive. Except that they fancied the souls of the
departed to be transformed into owls, hovering in gloom around the
grave, it does not appear that they had the least idea of a future
state of existence.
Such was the state of religion among the native Arabians. Among
the foreign settlers in the towns there were a few followers of the
Greek and Roman philosophy; the Christians were never numerous.
These latter were divided into a variety of sects, and those belonging
to the Greek church, advocated monasteries, and were addicted to
the worship of images, martyrs and relics. Some of these, even
elevated the Virgin Mary into a deity, and addressed her as the third
person in the Trinity.
Mohammed, while he no doubt looked with horror upon this state of
things, having studied the Bible, and clearly comprehended its
sublime revelation of one God, conceived the idea of uniting the
people of his native land under a religion of which this fundamental
principle should constitute the basis. His purpose was to crush
idolatry, and restore the lost worship of the true God. How far he
was sincere, and how far he was an impostor, we cannot venture to
affirm. It is probable that he was a religious enthusiast, deceived by
his own fancies, and, perhaps, really believing his own visions. At
the outset of his career, it is likely that he acted in good faith, while
he was himself deluded. When he had advanced so far as to see
power and dominion offered to his grasp, it is probable that his
integrity gave way, and that thenceforward we are to consider him
as under the alternate guidance of craft and fanaticism.
Several of the nobles citizens of Mecca were finally converted by
Mohammed. Khadijah was now dead, and the prophet had married
Ayesha, the daughter of Abubeker, a man of great influence, and
who exercised it in favor of his son-in-law. Yet the new faith made
little progress, and a persecution of its votaries arose, which drove
them to Abyssinia, and caused Mohammed himself to fly for safety
to Medina. This flight is called the Hegira, and, taking place in the
year 622, is the epoch from which Mohammedan chronology is
computed, as is ours from the birth of Christ.
At Medina, whither his tenets had been carried by pilgrims,
Mohammed was received with open arms. He was met by an
imposing procession, and invested at once with the regal and
sacerdotal office. The people also offered him assistance in
propagating his faith, even by force, if it should be required. From
this moment, a vast field seems to have been opened to the mind of
Mohammed. Hitherto, he may have been but a self-deceived
enthusiast; but now, ambition appears to have taken at least partial
possession of his bosom. His revelations at once assumed a higher
tone. Hitherto he had chiefly inculcated the doctrine of one God,
eternal, omnipotent, most powerful and most merciful, together with
the practical duties of piety, prayer, charity, and pilgrimages. He now
revealed, as a part of his new faith, the duty of making war, even
with the sword, to propagate Islamism, and promised a sensual
paradise to those who should fall in doing battle in its behalf. At the
same time he announced that a settled fate or destiny hung over
every individual, which he could not by possibility alter, evade, or
avert.
He now raised men, and proceeded, sword in hand, to force the
acknowledgment of his pretensions. With alternate victory and
defeat, he continued to prosecute his schemes, and at last fell upon
the towns and castles of the peaceful and unwarlike Jews. These
were soon taken and plundered. But the prophet paid dearly for his
triumph. A Jewish female, at the town of Chaibar, gave him poison in
some drink, and, though he survived, he never fully recovered from
the effects of the dose.
Thus advancing with the tribes settled in his own country, the power
of the ambitious apostle increased like the avalanche in its
overwhelming descent. Mecca was conquered, and yielded as well to
his faith as to his arms. He now made expeditions to Palestine and
Syria, while his officers were making conquests in all directions. His
power was soon so great, that he sent messages to the kings of
Egypt, Persia, and Ethiopia, and the emperor of Constantinople,
commanding them to acknowledge the divine law revealed through
him.
At last, in the tenth year of the Hegira, he proceeded on a farewell
pilgrimage to Mecca. The scene was imposing beyond description.
He was attended by more than a hundred thousand of his followers,
who paid him the greatest reverence. Everything in dress, equipage
and imposing ceremony that could enhance the splendor of the
pageant, and give it sanctity in the eyes of the people, was adopted.
This was the last great event of his life.
Mohammed had now become too powerful to be resisted by force,
but not too exalted to be troubled by competition. His own example
in assuming the sacred character of an apostle and prophet, and the
brilliant success which had attended him, gave a hint to others of
the probable means of advancing themselves to a similar pitch of
dignity and dominion. The spirit of emulation, therefore, raised up a
fellow-prophet in the person of Moseilama, called to this day by the
followers of Islam “the lying Moseilama,” a descendant of the tribe of
Honeifa, and a principal person in the province of Yemen.
This man headed an embassy sent by his tribe to Mohammed, in the
ninth year of the Hegira, and then professed himself a Moslem; but
on his return home, pondering on the nature of the new religion and
the character and fortunes of its founder, the sacrilegious suggestion
occurred to him, that by skilful management he might share with his
countryman in the glory of a divine mission; and, accordingly, in the
ensuing year he began to put his project in execution. He gave out
that he, also, was a prophet sent of Heaven, having a joint
commission with Mohammed to recall mankind from idolatry to the
worship of the true God. He, moreover, aped his model so closely as
to publish written revelations resembling the Koran, pretended to
have been derived from the same source.
Having succeeded in gaining a considerable party, from the tribe of
Honeifa, he at length began to put himself still more nearly upon a
level with the prophet of Medina, and even went so far as to
propose to Mohammed a partnership in his spiritual supremacy. His
letter commenced thus: “From Moseilama, the apostle of God, to
Mohammed, the apostle of God. Now let the earth be half mine and
half thine.” But the latter, feeling himself too firmly established to
stand in need of an associate, deigned to return him only the
following reply: “From Mohammed, the apostle of God, to
Moseilama, the liar. The earth is God’s: he giveth the same for
inheritance unto such of his servants as he pleaseth; and the happy
issue shall attend those who fear him.”
During the few months that Mohammed lived after this, Moseilama
continued, on the whole, to gain ground, and became at length so
formidable, as to occasion extreme anxiety to the prophet, now
rapidly sinking under the effects of disease. An expedition, under the
command of Caled, the “Sword of God,” was ordered out to suppress
the rival sect headed by the spurious apostle, and the bewildered
imagination of Mohammed, in the moments of delirium, which now
afflicted him, was frequently picturing to itself the results of the
engagement between his faithful Moslems and these daring
apostates.
The army of Caled returned victorious. Moseilama himself, and ten
thousand of his followers, were left dead on the field; while the rest,
convinced by the shining evidence of truth that gleamed from the
swords of the conquerors, renounced their errors, and fell quietly
back into the bosom of the Mohammedan church. Several other
insurgents of similar pretences, but of minor consequence, were
crushed in like manner in the early stages of their defection.
We have now reached the period at which the religion of Mohammed
may be considered as having become permanently established. The
conquest of Mecca and of the Koreishites had been, in fact, the
signal for the submission of the rest of Arabia; and though several of
the petty tribes offered, for a time, the show of resistance to the
prophet’s arms, they were all eventually subdued. Between the
taking of Mecca and the period of Mohammed’s death, somewhat
more than three years elapsed. In that short period he had
destroyed the idols of Arabia; had extended his conquests to the
borders of the Greek and Persian empires; had rendered his name
formidable to those once mighty kingdoms; had tried his arms
against the disciplined troops of the former, and defeated them in a
desperate encounter at Muta.
His throne was now firmly established; and an impulse given to the
Arabian nation, which induced them to invade, and enabled them to
conquer, a large portion of the globe. India, Persia, the Greek
empire, the whole of Asia Minor, Egypt, Barbary, and Spain, were
eventually reduced by their victorious arms. Mohammed himself did
not indeed live to see such mighty conquests achieved, but he
commenced the train which resulted in this wide-spread dominion,
and, before his death, had established over the whole of Arabia, and
some parts of Asia, the religion which he had devised.
And now, having arrived at the sixty-third year of his age, and the
tenth of the Hegira, A. D. 632, the fatal effects of the poison, which
had been so long rankling in his veins, began to discover themselves
more and more sensibly, and to operate with alarming virulence. Day
by day, he visibly declined, and it was evident that his life was
hastening to a close. For some time previous to the event, he was
conscious of its approach, and is said to have viewed and awaited it
with characteristic firmness. The third day before his dissolution, he
ordered himself to be carried to the mosque, that he might, for the
last time, address his followers, and bestow upon them his parting
prayers and benedictions. Being assisted to mount the pulpit, he
edified his brethren by the pious tenor of his dying counsels, and in
his own example taught a lesson of humility and penitence, such as
we shall scarcely find inculcated in the precepts of the Koran.
“If there be any man,” said the prophet, “whom I have unjustly
scourged, I submit my own back to the lash of retaliation. Have I
aspersed the reputation of any Mussulman? let him proclaim my
fault in the face of the congregation. Has any one been despoiled of
his goods? the little that I possess shall compensate the principal
and the interest of the debt.” “Yes,” replied a voice from the crowd,
“thou owest me three drachms of silver!” Mohammed heard the
complaint, satisfied the demand, and thanked his creditor that he
had accused him in this world, rather than at the day of judgment.
He then set his slaves at liberty, seventeen men and eleven women;
directed the order of his funeral; strove to allay the lamentations of
his weeping friends, and waited the approach of death. He did not
Welcome to our website – the ideal destination for book lovers and
knowledge seekers. With a mission to inspire endlessly, we offer a
vast collection of books, ranging from classic literary works to
specialized publications, self-development books, and children's
literature. Each book is a new journey of discovery, expanding
knowledge and enriching the soul of the reade

Our website is not just a platform for buying books, but a bridge
connecting readers to the timeless values of culture and wisdom. With
an elegant, user-friendly interface and an intelligent search system,
we are committed to providing a quick and convenient shopping
experience. Additionally, our special promotions and home delivery
services ensure that you save time and fully enjoy the joy of reading.

Let us accompany you on the journey of exploring knowledge and


personal growth!

ebooknice.com

You might also like