100% found this document useful (1 vote)
9 views

Julia Quick Syntax Reference: A Pocket Guide for Data Science Programming 1st Edition Antonello Lobianco - Download the ebook now for instant access to all chapters

The document promotes the 'Julia Quick Syntax Reference: A Pocket Guide for Data Science Programming' by Antonello Lobianco, available for download at textbookfull.com. It outlines the contents of the book, which covers the Julia programming language, its syntax, data types, control flow, custom types, input/output operations, and interfacing with other languages. The book also discusses the Julia package ecosystem and provides guidance on writing efficient code.

Uploaded by

hallsevickit
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
100% found this document useful (1 vote)
9 views

Julia Quick Syntax Reference: A Pocket Guide for Data Science Programming 1st Edition Antonello Lobianco - Download the ebook now for instant access to all chapters

The document promotes the 'Julia Quick Syntax Reference: A Pocket Guide for Data Science Programming' by Antonello Lobianco, available for download at textbookfull.com. It outlines the contents of the book, which covers the Julia programming language, its syntax, data types, control flow, custom types, input/output operations, and interfacing with other languages. The book also discusses the Julia package ecosystem and provides guidance on writing efficient code.

Uploaded by

hallsevickit
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 64

Explore the full ebook collection and download it now at textbookfull.

com

Julia Quick Syntax Reference: A Pocket Guide for


Data Science Programming 1st Edition Antonello
Lobianco

https://textbookfull.com/product/julia-quick-syntax-
reference-a-pocket-guide-for-data-science-programming-1st-
edition-antonello-lobianco/

OR CLICK HERE

DOWLOAD EBOOK

Browse and Get More Ebook Downloads Instantly at https://textbookfull.com


Click here to visit textbookfull.com and download textbook now
Your digital treasures (PDF, ePub, MOBI) await
Download instantly and pick your perfect format...

Read anywhere, anytime, on any device!

Julia Quick Syntax Reference: A Pocket Guide for Data


Science Programming 1st Edition Antonello Lobianco

https://textbookfull.com/product/julia-quick-syntax-reference-a-
pocket-guide-for-data-science-programming-1st-edition-antonello-
lobianco-2/
textbookfull.com

C# 7 Quick Syntax Reference: A Pocket Guide to the


Language, APIs, and Library Mikael Olsson

https://textbookfull.com/product/c-7-quick-syntax-reference-a-pocket-
guide-to-the-language-apis-and-library-mikael-olsson/

textbookfull.com

C++17 quick syntax reference: a pocket guide to the


language, APIs and library Third Edition Olsson

https://textbookfull.com/product/c17-quick-syntax-reference-a-pocket-
guide-to-the-language-apis-and-library-third-edition-olsson/

textbookfull.com

Haskell Quick Syntax Reference: A Pocket Guide to the


Language, APIs, and Library 1st Edition Stefania Loredana
Nita
https://textbookfull.com/product/haskell-quick-syntax-reference-a-
pocket-guide-to-the-language-apis-and-library-1st-edition-stefania-
loredana-nita/
textbookfull.com
C# 7 Quick Syntax Reference: A Pocket Guide to the
Language, APIs, and Library 2nd Edition Mikael Olsson

https://textbookfull.com/product/c-7-quick-syntax-reference-a-pocket-
guide-to-the-language-apis-and-library-2nd-edition-mikael-olsson/

textbookfull.com

C++20 Quick Syntax Reference : a pocket guide to the


language, APIs, and library 4th Edition Mikael Olsson

https://textbookfull.com/product/c20-quick-syntax-reference-a-pocket-
guide-to-the-language-apis-and-library-4th-edition-mikael-olsson/

textbookfull.com

C++20 Quick Syntax Reference A Pocket Guide to the


Language, APIs, and Library. 4th Edition Mikael Olsson

https://textbookfull.com/product/c20-quick-syntax-reference-a-pocket-
guide-to-the-language-apis-and-library-4th-edition-mikael-olsson-2/

textbookfull.com

Java quick syntax reference Second Edition Olsson

https://textbookfull.com/product/java-quick-syntax-reference-second-
edition-olsson/

textbookfull.com

Java EE 6 Pocket Guide A Quick Reference for Simplified


Enterprise Java Development 1st Edition Gupta Arun

https://textbookfull.com/product/java-ee-6-pocket-guide-a-quick-
reference-for-simplified-enterprise-java-development-1st-edition-
gupta-arun/
textbookfull.com
Antonello Lobianco

Julia Quick Syntax Reference


A Pocket Guide for Data Science Programming
Antonello Lobianco
Nancy, France

Any source code or other supplementary material referenced by the


author in this book is available to readers on GitHub via the book’s
product page, located at www.​apress.​com/​9781484251898 . For more
detailed information, please visit http://​www.​apress.​com/​source-code
.

ISBN 978-1-4842-5189-8 e-ISBN 978-1-4842-5190-4


https://doi.org/10.1007/978-1-4842-5190-4

© Antonello Lobianco 2019

This work is subject to copyright. All rights are reserved 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.

Trademarked names, logos, and images may appear in this book. Rather
than use a trademark symbol with every occurrence of a trademarked
name, logo, or image we use the names, logos, and images only in an
editorial fashion and to the benefit of the trademark owner, with no
intention of infringement of the trademark. The use in this publication
of trade names, trademarks, service marks, and similar terms, even if
they are not identified as such, is not to be taken as an expression of
opinion as to whether or not they are subject to proprietary rights.

While the advice and information in this book are believed to be true
and accurate at the date of publication, neither the authors nor the
editors nor the publisher can accept any legal responsibility for any
errors or omissions that may be made. The publisher makes no
warranty, express or implied, with respect to the material contained
herein.

Distributed to the book trade worldwide by Springer Science+Business


Media New York, 233 Spring Street, 6th Floor, New York, NY 10013.
Phone 1-800-SPRINGER, fax (201) 348-4505, e-mail orders-
ny@springer-sbm.com, or visit www.springeronline.com. Apress Media,
LLC is a California LLC and the sole member (owner) is Springer
Science + Business Media Finance Inc (SSBM Finance Inc). SSBM
Finance Inc is a Delaware corporation.
Introduction
This Julia quick syntax reference book covers the main syntax elements
of the Julia language as well as some of its more important packages.
The first chapter explains the basic skills needed to set up the
software you need to run and develop Julia programs, including
managing Julia packages.
Chapter 2 presents the many predefined types (integers, strings,
arrays, etc.) and the methods to work with them. Memory and copy
issues are also presented in this chapter, together with an important
discussion about the implementation of the various concepts
ofmissingness .
After the basic data types have been introduced, Chapter 3 deals
with how to organize them in a sequence of logical statements to
compose your program. Control flow, functions, blocks, and scope are
all discussed in this chapter.
In Chapter 4 , we extend our discussion to custom types—in Julia,
both primitive and composite types can be custom-defined—and to
their organization in the program, either using inheritance or
composition. This chapter will be of particular use to readers
accustomed to other object-oriented programs, in order to see how to
apply object-oriented concepts in Julia.
Chapter 5 explains how to retrieve the inputs needed by your
program from a given source (the terminal, a text/CSV/Excel/JSON file,
or a remote resource) and conversely, to export the outputs of your
program.
In Chapter 6 , we discuss a peculiar feature of Julia, that is, the
possibility to manipulate the code itself after it has been parsed, but
before it is compiled and run. This paves the way to powerful macro
programming. We discuss it and present the concepts ofsymbols
andexpressions in Chapter 6 .
Julia is a relatively new language, and while the package ecosystem
is developing extremely rapidly (as most packages can be written
directly in the Julia language alone), it is highly likely that you will still
need libraries for which a direct port to Julia is not yet available.
Conversely, your main workflow may be in another, slower, high-level
language and you may want to use Julia to implement some
performant-critical tasks. Chapter 7 shows how to use C, C++, Python,
and R code and their relative libraries in Julia and, conversely, embed
Julia code in Python or R programs.
The following chapter (Chapter 8 ) gives a few recommendations for
writing efficient code, with runtime performances comparable to
compiled languages. We also deal here withprogrammer’s efficiency ,
discussing profiling and debugging tools and with a short introduction
to runtime exceptions.
This completes the discussion of thecore of the language. Julia,
however, has been designed as a thin language where most features are
provided by external packages, either shipped with Julia itself (a sort of
Julia Standard Library) or provided by third parties.
Therefore, the second part of the book deals with this Julia package
ecosystem. Chapter 9 introduces the main packages for working with
numerical data: storage with data structure packages likeDataFrames
andIndexedTables ; munging withDataFramesMeta ,Query ,
andPipe ; and visualization with thePlot package.
If Chapter 9 deals with processing numerical data, Chapter 10 deals
with mathematical libraries for more theoretical work.JuMP is an
acclaimed “algebraic modeling language” for numerical optimization
(and can be in itself the primary reason to learn about Julia). We
present two complete examples with linear and non-linear models. The
second model is then rewritten to be analytically resolved withSymPy ,
which is a library for symbolic computation, e.g. the analytical
resolution of derivatives, integrals, and equations (and systems of
equations). Chapter 10 ends with a presentation ofLsqFit , a powerful
and versatile library to fit data. Finally, Chapter 11 concludes the book
with a series of tools that are of more general use, like composing
dynamic documents withWave , dealing with ZIP files withZipFile ,
and exposing a given Julia model on the web withInteract andMux .
Examples given in the text are intentionally trivial. They are minimal
working examples of the syntax for the concepts they explain. If you are
looking for recipes directly applicable to your domain, a “cookbook”
kind of book may be more convenient.
While each package has been tested specifically with Julia 1.2 and
1.3-rc4, thanks to the Julia developers’ commitment to a stable API,
they should remain relevant for the entire 1.x series. Concerning third-
party packages, we report the exact version we tested our code with.
The section entitled “Using the Package Manager” in Chapter 1 explains
how to update a package to a given version if subsequent versions of
the package break the API.
Is such cases, please report the problem to us using the form at
https://julia-book.com . We will regularly publish updates and
errata on this site, where a discussion forum focused on the book is also
available.
Acknowledgments
This work has been supported by the French National Research Agency
through the Laboratory of Excellence, ARBRE, part of the
“Investissements d’Avenir” program (ANR 11 – LABX-0002-01).
I want to thank Germá n Gonzá lez-Morris for his valuable help in
finding errors in the code and improving the description of the
language. I want to also thank Mark Powers, the Apress coordinating
editor, for his numerous “check ins” that pushed me to continue and
finish the book.
This has been possible thanks to the understanding and support of
my family.
Table of Contents
Part I: Language Core
Chapter 1:​Getting Started
1.​1 Why Julia?​
1.​2 Installing Julia
1.​3 Running Julia
1.​4 Miscellaneous Syntax Elements
1.​5 Packages
1.​5.​1 Using the Package Manager
1.​5.​2 Using Packages
1.​6 Help System
Chapter 2:​Data Types and Structures
2.​1 Simple Types (Non-Containers)
2.​1.​1 Basic Mathematic Operations
2.​1.​2 Strings
2.​2 Arrays (Lists)
2.​2.​1 Multidimensional​and Nested Arrays
2.​3 Tuples
2.​4 Named Tuples
2.​5 Dictionaries
2.​6 Sets
2.​7 Memory and Copy Issues
2.​8 Various Notes on Data Types
2.​8.​1 Random Numbers
2.​8.​2 Missing, Nothing, and NaN
Chapter 3:​Control Flow and Functions
3.​1 Code Block Structure and Variable Scope
3.​2 Repeated Iteration:​for and while Loops, List
Comprehension, Maps
3.​3 Conditional Statements:​if Blocks, Ternary Operator
3.​4 Functions
3.​4.​1 Arguments
3.​4.​2 Return Value
3.​4.​3 Multiple-Dispatch (aka Polymorphism)
3.​4.​4 Templates (Type Parameterization​)
3.​4.​5 Functions as Objects
3.​4.​6 Call by Reference/​Call by Value
3.​4.​7 Anonymous Functions (aka “Lambda” Functions)
3.​4.​8 Broadcasting Functions
3.​5 Do Blocks
3.​6 Exiting Julia
Chapter 4:​Custom Types
4.​1 Primitive Type Definition
4.​2 Structure Definition
4.​3 Object Initialization and Usage
4.​4 Abstract Types and Inheritance
4.​4.​1 Implementation of the Object-Oriented Paradigm in
Julia
4.​5 Some Useful Functions Related to Types
Chapter 5:​Input/​Output
5.​1 Reading (Input)
5.​1.​1 Reading from the Terminal
5.​1.​2 Reading from a File
5.​1.​3 Importing Data from Excel
5.​1.​4 Importing Data from JSON
5.​1.​5 Accessing Web Resources (HTTP)
5.​2 Writing (Output)
5.​2.​1 Writing to the Terminal
5.​2.​2 Writing to a File
5.​2.​3 Exporting to CSV
5.​2.​4 Exporting Data to Excel
5.​2.​5 Exporting Data to JSON
5.​3 Other Specialized IO
Chapter 6:​Metaprogramming and Macros
6.​1 Symbols
6.​2 Expressions
6.​2.​1 Creating Expressions
6.​2.​2 Evaluating Symbols and Expressions
6.​3 Macros
6.​3.​1 Macro Definition
6.​3.​2 Macro Invocation
6.​3.​3 String Macros
Chapter 7:​Interfacing Julia with Other Languages
7.​1 Julia ⇄ C
7.​2 Julia ⇄ C++
7.​2.​1 Interactive C++ Prompt
7.​2.​2 Embed C++ Code in a Julia Program
7.​2.​3 Load a C++ Library
7.​3 Julia ⇄ Python
7.​3.​1 Embed Python Code in a Julia Program
7.​3.​2 Use Python Libraries
7.​3.​3 PyJulia:​Using Julia in Python
7.​4 Julia ⇄ R
7.​4.​1 Interactive R Prompt
7.​4.​2 Embed R Code in a Julia Program
7.​4.​3 Use R Libraries
7.​4.​4 JuliaCall:​Using Julia in R
Chapter 8:​Effectively Write Efficient Code
8.​1 Performance
8.​1.​1 Benchmarking
8.​1.​2 Profiling
8.​1.​3 Type Stability
8.​1.​4 Other Tips to Improve Performance
8.​2 Code Parallelization
8.​2.​1 Adding and Removing Processes
8.​2.​2 Running Heavy Computations on a List of Items
8.​2.​3 Aggregate Results
8.​3 Debugging
8.​3.​1 Introspection Tools
8.​3.​2 Debugging Tools
8.​4 Managing Runtime Errors (Exceptions)
Part II: Packages Ecosystem
Chapter 9:​Working with Data
9.​1 Using the DataFrames Package
9.​1.​1 Installing and Importing the Library
9.​1.​2 Creating a DataFrame or Loading Data
9.​1.​3 Getting Insights About the Data
9.​1.​4 Filtering Data (Selecting or Querying Data)
9.​1.​5 Editing Data
9.​1.​6 Editing Structure
9.​1.​7 Managing Missing Values
9.​1.​8 The Split-Apply-Combine Strategy
9.​1.​9 Pivoting Data
9.​1.​10 Dataframe Export
9.​2 Using IndexedTables
9.​2.​1 Creating an IndexedTable (NDSparse)
9.​2.​2 Row Filtering
9.​2.​3 Editing/​Adding Values
9.​3 Using the Pipe Operator
9.​4 Plotting
9.​4.​1 Installation and Backends
9.​4.​2 The Plot Function
9.​4.​3 Plotting from DataFrames
9.​4.​4 Saving
Chapter 10:​Mathematical Libraries
10.​1 JuMP, an Optimization Framework
10.​1.​1 The Transport Problem:​A Linear Problem
10.​1.​2 Choosing Between Pizzas and Sandwiches, a Non-
Linear Problem
10.​2 SymPy, a CAS System
10.​2.​1 Loading the Library and Declaring Symbols
10.​2.​2 Creating and Manipulating Expressions
10.​2.​3 Solving a System of Equations
10.​2.​4 Retrieving Numerical Values
10.​3 LsqFit, a Data Fit Library
10.​3.​1 Loading the Libraries and Defining the Model
10.​3.​2 Parameters
10.​3.​3 Fitting the Model
10.​3.​4 Retrieving the Parameters and Comparing them with
the Observations
Chapter 11:​Utilities
11.​1 Weave for Dynamic Documents
11.​2 Zip Files
11.​2.​1 Writing a Zip Archive
11.​2.​2 Reading from a Zipped Archive
11.​3 Interact and Mux:​Expose Interacting Models on the Web
11.​3.​1 Importing the Libraries
11.​3.​2 Defining the Logic of the Model
11.​3.​3 Defining Controls and Layout
11.​3.​4 Providing Widgets to Web Users
Index
About the Author and About the Technical
Reviewer

About the Author


Antonello Lobianco, PhD
is a research engineer employed by a French Grande école (Polytechnic
University). He works on biophysical and economic modeling of the
forest sector and is responsible for the Lab Models portfolio. He uses
C++, Perl, PHP, Python, and Julia. He teaches environmental and forest
economics at the undergraduate and graduate levels and modeling at
the PhD level. He has been following the development of Julia as it fits
his modeling needs, and he is the author of several Julia packages
(search for sylvaticus on GitHub for more information).

About the Technical Reviewer


Germán González-Morris
is a polyglot software architect/engineer with 20+ years in the field. He
has knowledge of Java (EE), Spring, Haskell, C, Python, and JavaScript,
among others. He works with web distributed applications. Germá n
loves math puzzles (including reading Knuth) and swimming. He has
tech reviewed several books, including an application container book
(Weblogic), as well as titles covering various programming languages
(Haskell, TypeScript, WebAssembly, Math for Coders, and RegExp, for
example). You can find more information on his blog (
https://devwebcl.blogspot.com/ ) or Twitter
account(@devwebcl) .
Part I
Language Core
© Antonello Lobianco 2019
A. Lobianco, Julia Quick Syntax Reference
https://doi.org/10.1007/978-1-4842-5190-4_1

1. Getting Started
Antonello Lobianco1

(1) Nancy, France

1.1 Why Julia?


With so many programming languages available, why create yet
another one? Why invest the time to learn Julia? Is it worth it?
One of the main arguments in favor of using Julia is that it
contributes to improving a trade-off that has long existed in
programming—fast coding versus fast execution.
On the one side, Julia allows the developer to code in a dynamic,
high-level language similar to Python, R, or MATLAB, interacting with
the code and having powerful expressivity (see Chapter 6, for example).
On the other side, with minimum effort, developers can write
programs in Julia that run (almost) as fast as programs written in C or
FORTRAN.
Wouldn’t it be better, though, to optimize existing languages, with
their large number of libraries and established ecosystems, rather than
create a new language from scratch?
Well, yes and no. Attempts to improve runtime execution of dynamic
languages are numerous. PyPy (https://pypy.org), Cython
(https://cython.org), and Numba
(https://numba.pydata.org) are three notable examples for the
Python programming language. They all clash with one fact: Python
(and, in general, all the current dynamic languages) was designed
before the recent development of just-in-time (JIT) compilers, and
hence it offers features that are not easy to optimize. The optimization
tools either fail or require complex workarounds in order to work.
Conversely, Julia has been designed from the ground up to work
with JIT compilers, and the language features—and their internal
implementations—have been carefully considered in order to provide
the programmer with the expected productivity of a modern language,
all while respecting the constraints of the compiler. The result is that
Julia-compliant code is guaranteed to work with the underlying JIT
compiler, producing in the end highly optimized compiled code.

The Shadow Costs of Using a New Language

If it is true that the main “costs” of using a new language relate to


learning the language and having to abandon useful libraries and
comfortable, feature-rich development editors that you are
accustomed to, it is also true that in the Julia case these costs are
mitigated by several factors:
The language has been designed to syntactically resemble
mainstream languages (you’ll see it in this book!). If you already
know a programming language, chances are you will be at ease
with the Julia syntax.
Julia allows you to easily interface your code with all the major
programming languages (see Chapter 7, “Interfacing Julia with
Other Languages”), hence reusing their huge sets of libraries
(when these are not already ported to Julia).
The development environments that are available—e.g., Juno
(https://junolab.org), IJulia Jupiter kernel
(https://github.com/JuliaLang/IJulia.jl), and
VSCode Julia plugin
(https://github.com/JuliaEditorSupport/julia-
vscode)—are frankly quite cool, with many common features
already implemented. They allow you to be productive in Julia
from the first time you code with it.
Apart from the breakout in runtime performances from traditional
high-level dynamic languages, the fact that Julia was created from
scratch means it uses the best, most modern technologies, without
concerns over maintaining compatibility with existing code or internal
architectures. Some of the features of Julia that you will likely
appreciate include built-in Git-based package manager, full code
introspection, multiple dispatches, in-core high-level methods for
parallel computing, and Unicode characters in variable names (e.g.,
Greek letters).
Thanks to its computational advantages, Julia has its natural roots in
the domain of scientific, high-performance programming, but it is
becoming more and more mature as a general purpose programming
language. This is why this book does not focus specifically on the
mathematical domain, but instead develops a broad set of simple,
elementary examples that are accessible even to beginner
programmers.

1.2 Installing Julia


Julia code can be run by installing the Julia binaries for your system
available in the download section
(http://julialang.org/downloads/) of the Julia Project
website (https://julialang.org).
The binaries ship with a Julia interpreter console (aka, the “REPL”—
Read, Eval, Print, Loop), where you can run Julia code in a command-
line fashion.
For a better experience, check out an Integrated Development
Environment, for example, Juno (http://junolab.org/) an IDE
based on the Atom (https://atom.io) text editor, or IJulia
(https://github.com/JuliaLang/IJulia.jl), the Julia
Jupiter (http://jupyter.org/) backend.
Detailed setup instructions can be found on their respective sites,
but in a nutshell, the steps are pretty straightforward.
For Juno:
Install the main Julia binaries first.
Download, install, and open the Atom text editor
(https://atom.io).
From within Atom, go to the Settings ➤ Install panel.
Type uber-juno into the search box and press Enter. Click the
Install button on the package with the same name.
For IJulia:
Install the main Julia binaries first.
Install the Python-based Jupyter Notebook server using the
favorite tools of your OS (e.g., the Package Manager in Linux, the
Python spip package manager, or the Anaconda distribution).
From a Julia console, type using Pkg;
Pkg.update();Pkg.add("IJulia");Pkg.build("IJuli
a").
The IJulia kernel is now installed. Just start the notebook server
and access it using a browser.
You can also choose, at least to start with, not to install Julia at all,
and try instead one of the online computing environments that support
Julia. For example, JuliaBox (https://juliabox.com/), CoCalc
(https://cocalc.com/doc/software-julia.html),
Nextjournal (https://nextjournal.com), and Binder
(https://mybinder.org).

Some tricks for Juno and IJulia

Juno can:
Enable block selection mode with .
Run a selection of code by selecting it and either selecting Run
Block or typing on Windows and Linux or
on Mac.
Comment/uncomment a block of code with
(Windows and Linux) or (Mac) .

IJulia:
Check out the many keyboard shortcuts available from Help ➤
Keyboard Shortcuts.
Need to run Julia in a computational environment for a team or
a class? Use JupyterHub
(https://github.com/jupyterhub/jupyterhub), the
multi-user solution based on Jupyter.

1.3 Running Julia


There are many ways to run Julia code, depending on your needs:
1. Julia can run interactively in a console. Start julia to obtain the
REPL console, and then type the commands there (type exit() or
use CTRL+D when you are finished).

2. Create a script, i.e. a text file ending in .jl, and let Julia parse and
run it with julia myscript.jl [arg1, arg2,..].Script
files can also be run from within the Julia console. Just type
include("myscript.jl").

3. In Linux or on MacOS, you can instead add at the top of the script
the location of the Julia interpreter on your system, preceded by #!
and followed by an empty row, e.g. #!/usr/bin/julia (You can
find the full path of the Julia interpreter by typing which julia
in a console.). Be sure that the file is executable (e.g., chmod +x
myscript.jl).
You can then run the script with ./myscript.jl.

4. Use an Integrated Development Environment (such as those


mentioned), open a Julia script, and use the run command specific
to the editor.

You can define a global (for all users of the computer) and local (for
a single user) Julia file that will be executed at any startup, where you
can for example define functions or variables that should always be
available. The location of these two files is as follows:
Global Julia startup file:
[JULIA_INSTALL_FOLDER]\etc\julia\startup.jl (where
JULIA_INSTALL_FOLDER is where Julia is installed)
Local Julia startup file:
[USER_HOME_FOLDER]\.julia\config\startup.jl (where
USER_HOME_FOLDER is the home folder of the local user, e.g.
%HOMEPATH% in Windows and ~ in Linux)
Remember to use the path with forward slashes ( / ) with Linux.
Note that the local config folder may not exist. In that case, just create
the config folder as a .julia subfolder and start the new
startup.jl file there.

Julia keeps all the objects created within the same work session
in memory. You may sometimes want to free memory or “clean up”
your session by deleting no longer needed objects. If you want to do
this, just restart the Julia session (you may want to use the trick
mentioned at the end of Chapter 3) or use the Revise.jl
(https://github.com/timholy/Revise.jl) package for
finer control.

You can determine which version of Julia you are using with the
versioninfo() option (within a Julia session).

1.4 Miscellaneous Syntax Elements


Julia supports single-line ( # ) and multi-line ( #= [...] =# )
comments. Multi-line comments can be nested and appear anywhere in
the line:

println("Some code..") JULIA


#=
Multiline comment
#= nested multiline comment =#
Still a comment
=#
println(#= A comment in the middle of the line =#
"This is a code") # Normal single-line comment
You don’t need to use semicolons to indicate the end of a statement.
If they’re used, semicolons will suppress the command output (this is
done automatically in scripting mode). If the semicolon is used alone in
the REPL, it allows you to switch to the OS command shell prompt in
order to launch a system-wide command.
Blocks don’t need to be surrounded by parentheses, but they do
require the keyword end at the close.

While indentation doesn’t carry any functional meaning in the


language, empty spaces sometimes are important. For example,
function calls must uses parentheses with the inputs strictly
attached to the function name, e.g.:

println (x) # rise an ERROR TEXT

println(x) # OK

In Julia, variable names can include a subset of Unicode symbols,


allowing a variable to be represented, for example, by a Greek letter.
In most Julia development environments (including the console), to
type a Greek letter, you use a LaTeX-like syntax. This involves typing \,
then the LaTeX name for the symbol (e.g. \alpha for α), and then
pressing Tab to confirm. Using LaTeX syntax, you can also add
subscripts, superscripts, and decorators.
, α, y1,
All the following are valid, if not crazy, variable names: x1, x̃
y(a+b), y2, , and .
Note, however, that while you can use y2 as a variable name, you
can’t use 2y, as the latter is automatically interpreted as 2 * y.
Together with Unicode, this greatly simplifies the transposition in
computer code of mathematical equations.
If you come from a language that follows a zero-indexing standard
(such as C or Python), one important point to remember is that Julia
arrays are one-based indexed (counting starts from 1 and not 0). There
are ways to override this behavior, but in many cases doing so probably
would do more harm than good.

1.5 Packages
Julia developers have chosen an approach where the core of Julia is
relatively light, and additional functionality is usually provided by
external “packages”.
Julia binaries ship with a set of these packages (think to it as a
“Standard Library”) and a powerful package manager that is able to
download (typically directly from GitHub repositories), pre-compile,
update, and solve dependencies, all with a few simple commands.
While registered packages can be installed simply by using their
name, unregistered packages need their source location to be specified.
At the time of this writing, over 2,400 registered packages have been
published.
Knowing how packages work is essential to efficiently working in
Julia, and this is why I have chosen to introduce package management
early in the book and complement the book with a discussion of some
common packages.

1.5.1 Using the Package Manager


There are two ways to access package management features,
interactively and as an API from within other Julia code:
The interactive way is to type ] in the REPL console to enter a
“special” pkg mode. The prompt will then change from julia> to
(vX.Y) pkg>, where vX.Y is the current Julia version.
You can then run any package manager commands or go back to
the normal interpreter mode with BACKSPACE.
The API way is to import the pkg module into your code (using
Pkg) and then run Pkg.command(ARGS). Obviously, nothing
inhibits you from using the API approach in an interactive session,
but the special package mode has tab completion and other goodies
that make it more comfortable to use.
Note that the two interfaces are not 100% consistent, with the API
interface being slightly more stringent.
Some of the useful package commands are explained in the
following list:
status: Retrieves a list (name and version) of the locally installed
packages.
update: Updates the local index of packages and all the local
packages to the latest version.
add pkgName: Automatically downloads and installs a given
package. For multiple packages use add Pkg1 Pkg2 or
Pkg.add(["Pkg1","Pkg2"]).
add pkgName#master, add pkgName#branchName, or add
pkgName#vX.Y.Z: Checks out the master branch of a given
package, a specific branch, or a specific release, respectively.
free pkgName: Returns the package to the latest release.
rm pkgName: Removes a package and all its dependent packages
that have been installed automatically only for it.
add git@github.com:userName/pkgName.jl.git: Checks
out a non-registered package from a Git repository (here, it’s GitHub).

1.5.2 Using Packages


To access the functionalities of a package, you need to either use or
import it. The difference is as follows:
Using a package allows you to access the package functions directly.
Just include a using mypackage statement in the console or at the
beginning of the script.
Importing a package does the same, but helps in keeping the
namespace clean, as you need then to refer to the package functions
using their full names, as myPkg.myFunction. You can use aliases
or choose to import only a subset of functions (that you can then
access directly).
For example, to access the function plot(), which is available in
the package Plots, you can do the following (see the “Plotting” section
in Chapter 9 for specific plotting issues):
Access the package function directly with using myPackage :

using Plots JULIA


plot(rand(4,4))
Access the package functions using their full names with import
myPackage :

import Plots JULIA


const pl = Plots # This (optionally) creates an
an alias, equivalent to Python `import Plots as
pl`. Declaring it constant may improves the
performances.
pl.plot(rand(4,4)) # `Equivalent to
Plots.plot(rand(4,4))`
Access the package functions directly with import
myPackage:myfunction :

import Plots: plot # We can import


multiplefunctions at once using commas JULIA
plot(rand(4,4))

Finally, you can also include any Julia source files using this line:

include("MyFile.jl") :

When that line runs, the included file is completely ran (not only
parsed) and any symbol defined there becomes available in the scope
(the region of code within which a variable is visible) relative to where
the include was called.
You can read more about packages in the relevant section
(https://julialang.github.io/Pkg.jl/v1/) of the Julia
documentation, or by typing help or help COMMAND in pkg mode to
get more details on the package manager commands.

Across this book, I refer to several packages, either in the


standard library or third-party packages. When I state that a given
function belongs to a given package, remember to add using
PackageName in order to run the code in the examples (I will not
repeat this each time).

1.6 Help System


Julia comes with an integrated help system that retrieves usage
information for most functions directly from the source code. This is
true also for most third-party packages.
Typing ? in the console leads to the Julia help system, and the
prompt changes to help?>. From there, you can search for the
function’s API.

In non-interactive environment like IJulia notebooks, you can use


?search_term to access the documentation.

In Juno, you can right-click to open the contextual menu and choose
Show Documentation to bring up documentation for the object.

If you don’t remember the function name exactly, Julia is kind


enough to return a list of similar functions.

While the actual content returned may vary, you can expect to see
the following information for each function you query:
Its signature
One-line description
Argument list
Hints to similar or related functions
One or more usage examples
A list of methods (for functions that have multiple implementations)
© Antonello Lobianco 2019
A. Lobianco, Julia Quick Syntax Reference
https://doi.org/10.1007/978-1-4842-5190-4_2

2. Data Types and Structures


Antonello Lobianco1

(1) Nancy, France

Julia natively provides a fairly complete and hierarchically organized


set of predefined types (especially the numerical ones). These are
either scalar—like integers, floating-point numbers, and chars,—or
container-like structures able to hold other objects—like
multidimensional arrays, dictionaries, sets, etc.
In this chapter, we discuss them, and in the Chapter 4, where we
cover Julia custom types, we consider their hierarchical organization.
Every value (even the primitive ones) has its own unique type. By
convention types start with a capital letter, such as Int64 or Bool.
Sometimes (such as for all container-like structures and some non-
container ones), the name of the type is followed by other parameters
inside curly brackets, like the types of the contained elements or the
number of dimensions. For example, Array{Int64,2} would be used
for a two-dimensional array of integers.
In Julia terminology, these are referred as to parametric types. In
this book, we will use T as a placeholder to generically indicate a type.
There is no division between object and non-object values. All
values in Julia are true objects having a type. Only values, not variables,
have types. Variables are simply names bound to values. The ::
operator can be used to attach type annotations to expressions and
variables in programs. There are two primary reasons to do this:
As an assertion to help confirm that your program works the way you
expect.
Another Random Document on
Scribd Without Any Related Topics
The Project Gutenberg eBook of The Southern
Literary Messenger, Vol. I., No. 6, February,
1835
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: The Southern Literary Messenger, Vol. I., No. 6, February, 1835

Author: Various

Editor: James E. Heath

Release date: March 28, 2017 [eBook #54451]


Most recently updated: October 23, 2024

Language: English

Credits: Produced by Ron Swanson

*** START OF THE PROJECT GUTENBERG EBOOK THE SOUTHERN


LITERARY MESSENGER, VOL. I., NO. 6, FEBRUARY, 1835 ***
THE

SOUTHERN LITERARY
MESSENGER:
DEVOTED TO
EVERY DEPARTMENT OF
LITERATURE
AND

THE FINE ARTS.

Au gré de nos desirs bien plus qu'au gré des vents.


Crebillon's Electre.

As we will, and not as the winds will.

RICHMOND:
T. W. WHITE, PUBLISHER AND PROPRIETOR.
1834-5.

CONTENTS OF VOLUME I, NUMBER 6


VIRGINIA HISTORICAL AND PHILOSOPHICAL SOCIETY

VIRGINIA GAZETTEER: by Mr. Joseph Martin

SONNET—THE SEA: by A. L. B. M.D.


SKETCHES OF THE HISTORY and Present Condition of Tripoli, with some
accounts of the other Barbary States (No. IV): by R. G.

REMARKS ON A NOTE TO BLACKSTONE'S COMMENTARIES, VOL. I, PAGE 423: by a


Virginian

THE ROMANCE OF REAL LIFE

EXTRACT FROM A LADY'S ALBUM

THE PRAYER: by Octavian

SELECTIONS FROM MY PORT FOLIO: by P. H.

LETTERS FROM NEW ENGLAND.—NO. 4.: by a Virginian

EXTRACTS FROM MY MEXICAN JOURNAL

ARTICLES EXTRACTED FROM THE "AMERICAN ANNALS OF EDUCATION"


HEINROTH ON THE EDUCATION OF INFANCY
EFFECTS OF MATERNAL INDULGENCE

AN ADDRESS ON THE SUBJECT OF LITERARY ASSOCIATIONS TO PROMOTE


EDUCATION: by James M. Garnett

THE CONTRAST: OR, A FASHIONABLE AND AN UNFASHIONABLE NEW ENGLAND WIFE:


by S. H.

HINTS TO STUDENTS OF GEOLOGY.—NO. II: by Peter A. Browne, Esq.

LETTERS FROM A SISTER

ORIGINAL LITERARY NOTICES


AN ORATION on the Life and Character of Gilbert Motier de
Lafayette: by John Quincy Adams
EULOGY on La Fayette: by Edward Everett
THE BEAUTIES of the Court of Charles the Second; a series of
Memoirs, Biographical and Critical, illustrating the Diaries of Pepys,
Evelyn, Clarendon, and other contemporary writers: by Mrs.
Jameson
CALAVAR; or The Knight of the Conquest: a Romance of Mexico.

JUDGE BLACKSTONE—A Poet.


THE LAWYER'S FAREWELL TO HIS MUSE: by Sir Wm. Blackstone

LINES: submitted by H. E. J.

THE EXILE

THE MINIATURE: by Geo. P. Morris

EPIGRAM. THE MISTAKE CORRECTED

THE SPIDER: by Eliza

DIALOUGE, From the Italian of Francisco da Lemene: by R. H. Wilde

FROM THE NOTE BOOK OF MY MOTHER

THOUGHTS ON SEEING THE EVENING STAR

JEU DE MOTS.—ON A NAME: by A. Z.

MISS MARTINEAU
LINES. ON MISS MARTINEAU

EPITAPH. ON A YOUNG LADY

EPIGRAM. ON A WALTZING GIRL: by Q.


ANOTHER.—ON THE SAME: by Q.

LINES: by Monos

THE TRUE FOUNDATION

TRUTH AND FALSEHOOD


LINES TO MISS H—— M——On her talking against slavery

TRUST NOT: by A L. B. M.D.

VARIETY

EDITORIAL REMARKS

EXTRACTS FROM THE LETTERS OF CORRESPONDENTS

TO CORRESPONDENTS, CONTRIBUTORS, &C.

SOUTHERN LITERARY MESSENGER.

VOL. I.] RICHMOND, FEBRUARY


1835. [NO. 6.

T. W. WHITE, PRINTER AND PROPRIETOR. FIVE DOLLARS PER ANNUM.

VIRGINIA HISTORICAL AND PHILOSOPHICAL SOCIETY.

We promised to present in our present number a more detailed


account of the proceedings of the late anniversary meeting of this
valuable institution, which we trust is destined to retrieve the
character of our state from the charge of long indifference to the
vast resources it contains, both in materials for scientific research
and in memorials of its past civil and political history. We should
sincerely lament if so noble an effort to diffuse throughout the
country a taste for science and elegant literature, should fail for
want of encouragement, but we think we perceive a growing
conviction of its importance, and an increasing disposition to
promote its objects. These objects, as declared in the constitution of
the society, are "to discover, procure and preserve whatever may
relate to the natural, civil and literary history of this state; and to
patronize and advance all those sciences which have a direct
tendency to promote the best interests of our citizens." What
intelligent Virginian is there who does not feel inclined to co-operate
in the attainment of so much good? Who does not desire that the
strife and bitterness of politics should be allayed by the diffusion of a
spirit which shall unite and harmonize the most discordant elements,
and establish a point where all men of every sect and party may rally
for the interests of their country, and forget the unhappy differences
which distract and divide them. It is certainly an extraordinary fact
that, with one honorable exception, no similar institution seems ever
to have been established in Virginia, during the more than two
centuries of its civilized existence. The exception stated is recorded
by Gerardin, in his continuation of Burk's History. It was an
association formed for literary and scientific purposes, as far back as
the administration of Governor Fauquier, who was himself a lover
and patron of learning; but it was principally indebted for its origin
to Dr. Small, an able professor at William and Mary,—and afterwards
among its members and most active friends, were enrolled the
honored names of Jefferson and Wythe, John Page and the
venerable Bishop Madison. The last gentleman was its secretary and
curator, when the stirring and eventful scenes of the revolutionary
war put a period to its existence.

The present society was organized in December, 1831, and there


have been three anniversary meetings since, at each of which very
able addresses were delivered. One only, (Professor Cushing's) has
as yet been spread before the public; but we understand that the
orations of Messrs. Maxwell and Tucker will also be published.
We stated in the last number of the Messenger that Mr. Maxwell
presented to the society at its late meeting an ancient pistol, alleged
on plausible authority to have been the property of Captain John
Smith, the father of Virginia. We have not been able to learn the
precise particulars of its history, but we understand there is no doubt
that it was sent by a former Governor of Canada to General
Washington as the property of Smith. It bears upon a silver
ornament on its handle or butt, the initials J. S.; and in the form and
shape of its barrel and some other peculiarities, it has undoubted
marks of antiquity. There was another valuable relic presented to the
society, through the standing committee, which deserves to be
particularly mentioned. It is the identical silver badge or medal
furnished the King of the Potomac Indians, under a law of the
Colonial Assembly of Virginia, which passed in March 1661. See
Hening's Statutes at Large, vol. 2, p. 142. This curious relic was
found in the county of Caroline a year or two since, and presented to
the society by W. G. Minor, Esq. of that county. On its face the words
"Ye King of"—and on the reverse—"Patomeck," are engraved in the
ancient orthography—and on both sides are rude devices, attesting
the imperfect state of the arts at the period referred to.

The society has already collected many valuable mineral specimens


and Indian antiquities—also various books and manuscripts,—a more
particular account of which we shall spread before our readers in
some of our future numbers. The trustees of the Richmond Academy
have, we learn, assigned one of the rooms in the spacious building
they have erected, for the uses of the society as a place of deposite
and arrangement of its various acquisitions; and it is with much
pleasure we perceive that the legislature, by a joint resolution, has
directed the library committee to present to the society copies of
such books, maps, &c. as belong to the library fund. These examples
of liberality in our public functionaries, are proofs of the growing
interest which is felt in the cause of science and literature.—James
McDowell, Esq. of Rockbridge, has been selected to deliver the next
anniversary address, and Professor Dew, of William and Mary,
chosen alternate. The following gentlemen were appointed officers
for the present year, to wit:

JOHN MARSHALL, President; PROFESSOR CUSHING, first Vice President;


JUDGE CLOPTON, second Vice President; JAMES E. HEATH, Corresponding
Secretary and Librarian; GUSTAVUS A. MYERS, Recording Secretary;
WM. P. SHEPPARD, Treasurer; and Judge Francis T. Brooke, Dr. Robert
Briggs, Conway Robinson, Robert C. Nicholas, Charles B. Shaw, John
S. Myers, Dr. Richard A. Carrington and Rowland Reynolds, Members
of the Standing Committee.

VIRGINIA GAZETTEER.

Our readers are probably most of them aware, that a work bearing the above title,
has been for some time in the Charlottesville press, and will soon make its
appearance before the public. We have been favored by the very deserving and
enterprising publisher, Mr. JOSEPH MARTIN, with 240 pages of the volume, and have
given them a cursory reading; not sufficient, indeed, to pronounce decidedly upon the
character of the work, but enough to convince us of its great utility, and of the
general ability and industry with which it has been compiled. We shall take occasion
when the work is published, to examine its contents more particularly;—for the
present, we remark, that the editor in his preliminary and General Description of
Virginia, has borrowed very copiously, and without acknowledgement, that we have
seen, from an article bearing the title "Virginia," in the Americana Encyclopædia.
Whilst it is not expected, that in a work like the Gazetteer, its whole contents should
be original; it is but an act of literary justice, we conceive, that the sources from
which material aid has been derived, should be acknowledged. Of course, we confine
ourselves to such matter as is not original. We have taken the liberty to transfer to
our pages, the account contained in the Gazetteer, of "the City of Richmond"—
subjoining in the form of notes, a few observations rendered necessary by the change
of circumstances, since that account was written.

RICHMOND CITY, the metropolis of Virginia, is situated in the county


of Henrico, on the north side of James river, and immediately at the
great falls, or head of tide water. Lat. 37° 32' N., long. 25° 54' W of
W. Its location is uncommonly delightful, and has often excited the
admiration of strangers. Perhaps the most glowing, and yet most
faithful picture which has ever been drawn of its natural beauties, is
from the pen of the eminent and lamented author of the British Spy.
"I have never met," says that enchanting writer, "with such an
assemblage of striking and interesting objects. The town dispersed
over hills of various shapes; the river descending from west to east,
and obstructed by a multitude of small islands, clumps of trees, and
myriads of rocks; among which it tumbles, foams and roars;
constituting what are called the falls; the same river at the lower end
of the town, bending at right angles to the south, and winding
reluctantly off for many miles in that direction; its polished surface
caught here and there by the eye, but more generally covered from
the view by the trees; among which the white sails of the
approaching and departing vessels exhibit a curious and interesting
appearance: then again on the opposite side, the little town of
Manchester built on a hill, which sloping gently to the river, opens
the whole town to the view, interspersed as it is with vigorous and
flourishing poplars; and surrounded to a great distance by green
plains and stately woods;—all these objects falling at once under the
eye, constitute by far the most finely varied and most animated
landscape that I have ever seen." The truth and beauty of the
foregoing sketch may be realised from numberless positions or
points of view, extending from the high hills to the west, which
overlook the James river canal, as far as the Church Hill, the eastern
barrier of the city. From the latter elevation, perhaps the landscape
combines greater variety and grandeur, than from any other point.
Shockoe hill, however, is the favorite residence of the citizens. This is
divided from the other by the valley of Shockoe creek, and is a high
and spacious plain occupied by the principal public buildings, and by
numerous private edifices, some of which are of elegant and
expensive construction. The Capitol, or State House, stands in the
centre of a beautiful park or square, near the brow of the hill, and
from its size and elevated position is the most conspicuous object in
the city. The exterior of the building is of admirable proportions, and
its fine columns of Ionic architecture seen from a distance, have a
very imposing effect. It was formed from a model of the Maison
Carree at Nismes,—brought by Mr. Jefferson from France. Its interior
construction, however, is neither elegant nor convenient. In a large
open saloon or hall, in the centre of the building, is a marble statue
of Washington, executed with great skill by Houdon, a French artist.
There is also a bust of Lafayette, occupying one of the niches in the
wall. Besides the statue it is still in contemplation to erect a superb
monument to the memory of Washington on the capitol square. The
fund which was dedicated to this object was originally raised by
private subscription, and is now loaned out at interest by direction of
the legislature. Its present amount is about $18,000. When this
monument is erected, it will add to the attractions of one of the
finest promenades in the Union. The square, which contains about
nine acres, is enclosed by a handsome railing of cast iron, and is
ornamented by gravelled walks, and a variety of forest and other
trees. The Governor's House is a plain, neat building, adjoining the
square, and on a part of the public domain. The City Hall, which is
also contiguous to the State House, is a costly and elegant building
of Doric architecture. It is devoted to the use of the City Courts and
Council, and other officers of the Corporation. The other public
buildings, are the Penitentiary and Manufactory of Arms—both
extensive establishments, and well adapted to their respective
purposes. The Bank of Virginia and Farmer's Bank, are connected
under one roof, and together constitute a handsome edifice on the
principal street.

Richmond is not deficient in benevolent institutions. Besides a very


spacious Poor House, which stands in the suburbs of the city,—there
is a Female Orphan Asylum, supported in part by funds of the
corporation, and partly by private liberality. Its funds have been
principally raised however for several years past, by an annual fair
held at the City Hall. This institution is incorporated by the
legislature, and is under the management of female directors. There
is also a school for the education of poor children of both sexes,
upon the Lancasterian system, founded in 1816, which with some
fluctuations in its progress, is still in a prosperous condition. It is
now under the superintendence of trustees appointed by the City
Council, and is sustained by an annual contribution from the Literary
fund of the state, together with an appropriation from the city
treasury. A suitable building was erected for the accommodation of
the school, soon after its first establishment, and hundreds have
received from it the benefits of elementary instruction, who would
probably have been otherwise the victims of ignorance and
depravity.

The city has not been so fortunate in other institutions for the
cultivation of the mind. A few good schools it is true have
occasionally existed, where a competent knowledge of the classics
and some of the sciences might be obtained, but none of these
sources of instruction have been commensurate with the wants of
the citizens. It is a remarkable circumstance, that the metropolis of
the state, containing as it does considerable wealth and population,
—many distinguished and well informed men, and much boasted
refinement, should yet be destitute of a single academical institution.
As far back as 1803, a charter was obtained from the state by some
of the prominent citizens, for the establishment of an academy by
lottery and private subscription. A few thousand dollars were raised,
—a site was injudiciously selected a mile beyond the limits of the city
—and the basement story of the building erected, but no further
progress was made. Within the present year, however, the vacancies
in the Board of Trustees have been filled, and there is some prospect
of reviving the institution.1
1 We are happy to have it in our power to state, that by the liberality of the City
Council, an elegant and costly building has been erected by the trustees, which is
now near completion. It may be mentioned, however, with regret, that an
unsuccessful application has been made to the Legislature for an annual endowment
out of the surplus of the Literary Fund—but it ought also in justice to be added, that
measures have been adopted for collecting information preparatory to a just and
equitable distribution of the Literary Fund surplus, by the next General Assembly.
Indeed, the munificent patronage bestowed by the Legislature of 1834-5, upon works
of internal improvement—is of itself, sufficient to exempt that body from the reproach
of leaving to its successors, something to do for the great cause of education.

Besides this marked deficiency in the means of educating youth,


there are few or no associations of an intellectual character among
persons of maturer years. Whilst the northern cities can boast of
their literary and scientific societies, the capital of the ancient
dominion scarcely contains one which deserves the name. An
honorable exception, it is true, may be mentioned in the "Virginia
Historical and Philosophical Society," which was established in 1831,
and has since been incorporated;—but as its members are principally
dispersed through the state, and few of the citizens of Richmond
manifest any zeal in its welfare, it can scarcely be considered an
association of the city, either in its origin or character. About 20
years since a Museum was erected principally by individual
enterprize; which was designed as a repository of the fine arts, and
of natural curiosities. This institution however, has for a long time
languished for want of patronage.

Societies however of a moral and religious cast, are numerous,


active and flourishing. Various associations exist for promoting
temperance, for colonizing the free people of color, for aiding
missionaries, for the distribution of the Bible and religious tracts, and
for various other objects of a similar character. The encouragement
also which is given to Sabbath schools is extensive and beneficial.
The means of religious instruction are very considerable, and
probably in due proportion to the wants of the city. The
Episcopalians have 3 churches or houses of worship;—the
Presbyterians 2, the Baptists 3, the Methodists 3, the Roman
Catholics 1, and this last congregation are now constructing a new
and elegant building, which will probably rival any in the city for the
style of its architecture. The Baptist Seceders or followers of
Alexander Campbell, have 1 place of worship,—the Unitarians and
Quakers 1 each,—and the Jews a handsome Synagogue in a retired
and handsome situation.

The Monumental Church, one of the three belonging to the


Episcopalians, and of which the venerable Bishop of Eastern Virginia
has long been the Rector,—has acquired a melancholy celebrity from
the circumstance that it occupies the site of the Richmond Theatre,
which was destroyed by fire in December 1811; on which tragical
occasion the Governor of the Commonwealth, and 70 or 80
respectable persons of both sexes perished miserably in the flames.
Long will that mournful event be remembered by those who survived
or witnessed its horrors!—Either from the deep impressions which it
produced or from other causes,—the taste for theatrical exhibitions
has not kept pace with the increase of wealth and population. The
commodious Theatre which succeeded the old one,—which is placed
in a far more eligible situation, and is of much safer construction, is
only occasionally patronized, when the appearance of some
attractive star, or celebrated performer, is announced.

Richmond was first established by act of Assembly, as early as 1742,


and became the seat of Government of the state in 1779. Various
legislative acts have passed from time to time enlarging its corporate
powers and privileges. Nine persons are annually chosen from each
of the three wards into which the city is divided, who when
assembled elect out of their own body a recorder, and 11 aldermen,
who exercise judicial functions. The same persons also elect from
their own body, or from the citizens at large, a Mayor, who is both a
judicial and executive officer. The remaining 15 members constitute
the legislative council of the city, and as such, are authorised to raise
and appropriate money, and to enact all such ordinances as are
necessary for the due execution of the powers conferred by the
charter. The valuation of real property within the city according to
the assessment of 1833, was $6,614,550. The revenue raised for
corporation purposes may be stated in round numbers at $60,000,
besides which, the city contributed as its quota of the state tax in
the year 1833, nearly $9,000. This large amount of taxation is
principally derived from real and personal property, and from
licenses to merchants, ordinary keepers, &c. The number of
wholesale merchants, paying license tax in 1833, as appears by the
returns of the State Commissioner was 20;—retail ditto 326,
auctioneers 7, lottery ticket venders 7, ordinary keepers 43, and
keepers of houses of private entertainment 9. According to the same
returns there were 739 horses and mules, 157 coaches, 9 carryalls,
and 54 gigs.

The expenses of the city are considerable. The principal items of


appropriation are $12,000 for a sinking fund, to pay the interest, and
redeem gradually the corporation debt; $4,000 for the poor; $1,700
to the Lancasterian Free School and Orphan Asylum; $4,000 for
repairing the streets; and $8,500 for the support of a night watch.
The remaining expenses are on account of the public markets, fire
companies, salaries of officers, paving of streets and various
contingencies. The city debt at this time (1834) amounts to
$136,150;—$95,000 of which, bearing an interest of 5 per centum
only, was incurred on account of the water works. These works were
commenced in September 1830, under the direction of Albert Stein,
an accomplished Engineer from Holland, and were completed as far
as originally designed, at the end of the ensuing year. Since that
time, a second pump and wheel, and a third reservoir have been
added; making the cost of the whole work about $100,000. The
pumps are each calculated to raise from the river, and propel into
the reservoirs at a distance of 800 yards, and at a considerable
elevation 400,000 gallons of water in 24 hours. These pumps are
designed to operate alternately, either being competent to fill the
reservoirs in sufficient time. The reservoirs will each of them contain
1,000,000 gallons, and double lines of pipes extend from them to
the pump house on the margin of the river. The main pipe from the
reservoirs to the intersection of H and 1st streets is 2,058 yards in
length; and the smallest pipes extend from this through the principal
streets, lessening in diameter to the point of greatest depression
from the level of the reservoirs, a distance of about three miles. Fire
plugs are placed at convenient distances along the line of pipes, and
afford an ample supply of water for extinguishing fires. In the lower
part of the city the pressure is sufficient to force the water to the
tops of the houses through hose, without the aid of engines. Three
hundred and forty houses and tenements are already furnished with
water, and the rents which are daily increasing, amount at this time,
April 1834, to $4,000. The annual expense of superintendence, &c.
is $1,000. These works may justly be considered the pride of the
city. The water which they supply is not only pure and wholesome,
but for a considerable part of the year is sufficiently clear to be used
without filters.

The exports of domestic produce from Richmond to foreign countries


are very considerable. In the year 1833, their value in American
vessels, was

$2,466,360 00
And in foreign vessels, 498,131 00
Making the aggregate of $2,964,491 00

The value of domestic produce shipped coastwise to the principal


Northern Cities, cannot be ascertained correctly. It is believed to be
at least equal if not greater than the amount exported to foreign
countries, and if such be the fact, the total value of produce shipped,
may be estimated at nearly $6,000,000. The import trade, however,
bears no proportion to the other. The value of merchandize imported
into the district of Richmond from foreign countries for the year
1833, amounted to only $209,963, and the duties paid to the
Government of the United States to $75,120. Of this latter sum,
$7,197 was paid on merchandize brought by foreign vessels.
In 1833, 5 schooners, 9 barks, 37 brigs, and 30 ships, in all 81
vessels, cleared from the port of Richmond for foreign countries, the
tonnage whereof amounted to 22,331, or an average of 275 tons to
each vessel. In the same year 4 schooners, 6 brigs, 2 barks, and 3
ships entered from foreign countries,—making in the aggregate,
3,412 tons, or 227 to each vessel.

No inconsiderable part of the produce shipped from the city is


brought down the James River Canal. This important improvement
commences at Maiden's Adventure, on James river about thirty miles
distant, and terminates in a deep and commodious basin in the heart
of the town. The tolls paid to the James River Company on produce
descending in the year 1833, amounted to $43,949, and on various
articles carried up the Canal to $10,139, making in the aggregate,
$54,088. Among the items brought down, may be enumerated
upwards of 15,000 bbds. of tobacco, 152,000 barrels of flour,
133,000 bushels of wheat, 677,664 bushels of coal, 1,374 tons of
bar and pig iron; and 2,230,900 lbs. of manufactured tobacco.
Among the ascending articles may be mentioned, nearly 31,000
sacks of salt, 297 tons of bar and pig iron, and upwards of 3,000
tons of plaster, lime, &c.

The proximity of the coal mines to Richmond, constitutes that


mineral a valuable article of commerce. Besides the quantity brought
down the canal, there were more than 2,000,000 of bushels (4
pecks to the bushel) transported on the Chesterfield rail road in
1833, the tolls on which amounted to $87,813 30. The Chesterfield
rail road, terminates on the Manchester side of the river, and
deserves to be honorably mentioned as the first successful
enterprize of the kind in the state of Virginia. It was planned and
executed under the direction of Moncure Robinson, a distinguished
Engineer, and it owes much in its original design and final
accomplishment, to the perseverance and patronage of Mr. Nicholas
Mills, one of the few proprietors of its stock, and an owner of one of
the extensive coal mines at the upper termination of the road.
James river from Richmond to the ocean, presents a tedious and
somewhat obstructed navigation. This with the circumstance that
she is surrounded by rival towns, each having its peculiar
advantages of location,—will probably prevent the metropolis from
ever attaining a high degree of commercial importance.2 There is no
doubt, however, of its final destination as a manufacturing city,—as
there is probably no spot in the Union endowed by nature with finer
facilities for that kind of industry. From the commencement of the
rapids a few miles above, the fall is upwards of 100 feet to the level
of tide water, and in all this space there is scarcely a limit to the
extent of water power which exists. In the city and its vicinity, there
are already several flourishing establishments which deserve to be
mentioned. The Gallego flour mills having been destroyed by fire in
the spring of 1833, their present proprietor, Mr. Chevallie, is
rebuilding them at a more convenient site on the bank of the James
river basin, and upon a much more improved and enlarged plan. The
mill house which is nearly completed, is six stories high from the
foundation and covered with tin. It is 94 feet long by 83½ wide, and
is calculated for 20 pair of stones to be worked by three water
wheels. Connected with it, is another building 80 feet square, and
four stories high, in which the wheat will be received and cleaned.
The two together present a front on the basin of 163½ feet, and the
whole appearance is very imposing. The old Gallego mills ground
upwards of 200,000 bushels of wheat in the eight months preceding
their destruction. It is probable that the operations of the new
establishments will be much more extensive. The Gallego brand, and
indeed that of the city mills generally, has acquired much celebrity in
the South American markets and elsewhere.
2 The question as to the future commercial rank of Richmond, derives additional
weight and importance from recent acts of the Virginia Legislature. The passage of
the law for connecting the James and Kanawha rivers, and uniting the east and west
by canals or rail roads—if the scheme should be carried out with energy and
resolution corresponding with the noble spirit in which it has been adopted,—must
undoubtedly make the Metropolis of the Old Dominion, a place of much importance.
The contemplated rail road from Richmond to the Potomac, which has also received
the fostering aid of the state, cannot fail likewise to produce consequences beneficial
to the whole country, on the line of the improvement.

Haxall's Mills, have also a high reputation: they are five stories high
and of nearly equal dimensions with Chevallie's. They work 14 pair
of stones, with four water wheels, and grind about 200,000 bushels
wheat annually. This year that quantity will probably be exceeded, as
it is contemplated to add four additional pair of stones.

Rutherford's Mill works eight pair of stones by two water wheels,


and grinds about 90,000 bushels of wheat annually.

Mayo's Mill in Manchester opposite to Richmond, works six pair of


stones by three water wheels, and grinds also about 90,000 bushels
of wheat annually.

In the city and its vicinity, there are five corn or grist mills, two
manufactories for cut nails, and rolling and slitting iron, two saw
mills, and one iron foundery, whose operations are extensive.

The Richmond Cotton Manufactory is a large and important


establishment. It was established by Cunningham & Anderson, in the
year 1829, and sold by them with all its appendages, to the
Richmond Manufacturing Company, incorporated by an act of the
Virginia Legislature in the winter of 1831. The building is of stone
and brick, four stories high, 146 feet long, and 44 feet wide, situated
upon the north bank of the James, a few hundred yards west of the
Armory, receiving its water power from the James river canal,
immediately below the Penitentiary. The water is also conveyed from
the canal in iron pipes of six inches bore to the building, thence up
the stair-way to within five feet of the eaves, from which in case of
accident by fire, every floor except the upper one, can be flooded in
a few seconds, by simply turning a cock and using a hose. In this
factory are employed from 60 to 70 white operatives and 130 blacks,
from the age of 14 and upwards:—a large proportion of both
descriptions are females. It runs 3,776 spindles, and 80 looms,
together with all the necessary preparatory machinery for spinning
and weaving, of the most approved kinds, and consumes about
1,500 pounds of raw cotton per day.

The fabrics are heavy,—negro shirtings 29 inches wide, 4-4


sheetings and ¾ shirtings of No. 16 yarn, and cotton yarns from No.
5 to 20—all of which are celebrated for their superior quality. The
capital employed is $120,000.

The Gallego Manufacturing Company was incorporated in January


1834, and the capital subscribed is $150,000. The buildings, which it
is supposed will be commenced the present year, will be located
near the Gallego Mills. The Franklin Company for the manufacture of
paper, has also been recently incorporated, and the capital nearly
subscribed.

Besides the manufactures produced at the Penitentiary on state


account, the city has its due proportion of the various mechanic
trades, and private manufactories. Of printing establishments there
are as many as 11, (perhaps an undue proportion) from two of
which there are issued daily, political and commercial papers,—from
one, a semi-weekly political—from four, weekly Religious,—and from
one, a monthly journal devoted to literature, &c. The others are
either Book or Job Offices. The number of professional men is also
considerable, and it is the more remarkable that so many members
of the medical faculty should find employment in a city proverbial for
the salubrity of its climate. Situated at the point of demarcation
between the upper and lower districts, it is fortunately exempt from
many of the maladies which are peculiar to both regions. It is
neither visited by the enervating autumnal diseases of eastern
Virginia, nor by the more violent and inflammatory attacks which
belong to the upper country. The yellow fever, that scourge of cities
more populous and commercial, has never prevailed.

The population of Richmond has nearly trebled in 30 years. By the


census of 1800, the free whites numbered,
2,837
Slaves, 2,293
Free colored persons, 607
5,737

By the census of 1830, the free whites amounted to

7,755
Slaves, 6,349
Free colored, 1,956
16,060

The several classes have increased in nearly corresponding ratios.

Richmond has been frequently reproached for a want of hospitality,


and if this virtue consists in unreserved and indiscriminate attention
to strangers and visiters,—the reproach is probably not altogether
unfounded. It must be acknowledged too, that the manners and
customs of what are called the leading classes, are not characteristic
of the old Virginia character,—which was frank, simple and
unostentatious. In almost all considerable towns, even in republican
America, artificial castes or classes exist, which are founded
principally upon the possession of wealth, or the mysterious
refinements of fashion, and have but little reference either to moral
or intellectual distinction. It is probable that this vice of cities is one
of the chief sources of that prejudice which is felt towards them by
the people of the country. These remarks, however, are not to be
construed into a sweeping censure upon towns—for although in all
dense populations, there is always a greater or less degree of
human infirmity,—there is also an equal concentration of the more
virtuous and noble qualities of our nature.
For the Southern Literary Messenger.

SONNET—THE SEA.

BY A. L. B. M.D.

There's silent grandeur in the boundless waste


Of Ocean's bosom when the winds are still,
And quiet beauty, like the moonbeam traced
In lengthened shadows on some snow-clad hill;
There's fiercer grandeur in the chainless sea,
When the storm-spirit wakes it from its rest,
And the high waves are dashing wild and free,
As the white foam they bear upon their breast.
The thunder's voice is louder on the sea,
The lightning flashes with a wilder glare,
And landsmen know not of the dangers, he,
Whose home is on the Ocean's wave, must dare;
Yet it is pictured in its mighty roar,
And in the wrecks which strew the rock-bound shore.

For the Southern Literary Messenger.

SKETCHES OF THE HISTORY

And Present Condition of Tripoli, with some accounts of the other


Barbary States.
No. IV.

Egypt was then in an unsettled state, and a few details respecting its
situation may be permitted, although not absolutely connected with
the present subject.

For many years previous to the invasion of the French (1797) Egypt
had been nominally governed by a Turkish Pasha; but the power was
in reality possessed by a soldiery of a peculiar and formidable
character, who under Beys or Chiefs chosen from their own body,
ruled the country with absolute sway. These troops were called
Mamelukes, from the Arabic word signifying slaves, their numbers
being recruited entirely by the purchase of young men from the
regions of the Caucasian chain, who were transferred to Egypt,
instructed in the use of arms, and at a proper age enrolled; they
fought entirely on horseback, and were considered by Buonaparte as
the finest cavalry in the world. No person born in Egypt could be
enlisted; and marriage being discouraged, if not prohibited among
them, they had no feelings which were likely to interfere with their
esprit de corps. Each Bey held a particular district of the country in
subjection, keeping as many Mamelukes as he could purchase and
maintain, paying tribute to the Porte when he could not avoid it, and
supplying his expenses by wresting from the miserable inhabitants
every thing except the bare means of subsistence. The Pasha had
thus little else to do than collect the tribute, which he effected by
the aid of Turkish troops, and by fomenting dissensions among the
Beys.

The Sultan had indeed made several attempts to recover his


authority, of which the only one worthy of note was that conducted
by the Capoudan Pasha Hassan in 1786, which is mentioned in the
second number of these Sketches. This expedition was but partially
successful. The Beys soon regained their power, which they
exercised with additional insolence and rapacity towards all classes;
and when the French under Buonaparte entered Egypt, it was
ostensibly for the purpose of restoring the country to its former
master, "their ancient ally," and of thus revenging the insults
committed on citizens of the Republic by the tyrannical Mamelukes.

The invaders found twenty-three Beys united against them under the
command of Mourad, the most powerful of these chiefs; their forces
consisted of eight thousand Mamelukes, and a vast number of Arabs
and irregular troops. European skill and discipline, as might have
been expected, prevailed, and the Beys having been defeated in
several desperate conflicts, lost their confidence in each other;
some, among whom was Mourad, joined the Turks, others sided with
the French, and the remainder endeavored to maintain their position
in the upper country. When the French had been expelled, the
Sultan was determined to re-establish his dominion entirely, and to
extirpate the Mamelukes, if possible. In pursuance of this plan, at
the time of Eaton's arrival, a desultory but devastating warfare was
carried on between the Turkish troops and those of the Beys, who
occupied the banks of the upper Nile and the oases of the adjoining
desert. It was with one of these Chieftains named Mahomed Elfi,
that Hamet had taken refuge, and he was then at the village of
Minieh, about one hundred and fifty miles above Cairo, at the head
of a few refugee Tripolines and Arabs, closely pressed by the forces
of the Turkish Pasha.

The arrival of an American ship of war created a great sensation in


Lower Egypt, and many surmises as to its objects. The French
consul Drovetti, an able but unprincipled man, who has until lately
maintained a great influence in the government of Egypt, denounced
Eaton and his followers as "British spies who were endeavoring to
open an intercourse with the Mamelukes," and employed every
dishonorable means to defeat their plans, and have them expelled
from the country. They were however ably assisted by Major Misset,
the British resident, to whom Eaton carried letters of
recommendation from Sir Alexander Ball, Governor of Malta. After a
few days spent at Alexandria they sailed for Rosetta, where having
engaged a boat, they arrived at Cairo on the 8th of December. To
this place they were fortunately accompanied by Doctor Mendrici, an
Italian with whom Eaton had been intimate at Tunis, and who was
then physician to the Pasha; he proved very serviceable in
representing their objects in the true light, and in counteracting the
artifices of the French consul.

The Turkish Viceroy of Egypt at that time was Koorsheed, who


afterwards (1821-3) as Pasha of the Morea, distinguished himself by
the defeat and destruction of Lord Byron's old friend Ali Pasha of
Albania, and by his efforts to put down the insurrection of the
Greeks, at its commencement; Mahomet Ali, who has since risen to
supreme power in the country, was then merely the commander of
the Albanian troops. Koorsheed is represented by Eaton as an
intelligent and really high minded man; and after the true objects of
the strangers had been made known to him by Mendrici and Misset,
he did not hesitate to grant them a private interview, which took
place on the 9th of December. In it Eaton played his part well, and
succeeded so far in interesting the Pasha, that he agreed to assist
him in his efforts to detach Hamet from the Mamelukes, provided
the Prince should not have compromised himself, by any open act in
concert with those rebels.

Eaton had previously despatched messengers to Hamet, from


Alexandria, Rosetta and Cairo, directing him to proceed to
Alexandria; and since his arrival at the capital, he had discovered
three of the Prince's former high officers, who gave him more
minute information as to their master's circumstances. There were
great difficulties, not only in detaching him from the Mamelukes, but
even in communicating with him to any effect. The war between the
two parties in Egypt was one of extermination, and from the
characters of the combatants on both sides, neither passports nor
flags of truce were likely to afford much protection to their bearers;
moreover, it was very improbable that Elfi Bey would suffer a person
so well acquainted with his strength and his plans as Hamet must
have been, to quit his encampment and go among his enemies. The
enterprising American however exerted himself to obtain farther
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!

textbookfull.com

You might also like