Julia as a Second Language

This document was uploaded by one of our users. The uploader already confirmed that they had the permission to publish it. If you are author/publisher or own the copyright of this documents, please report to us by using this DMCA report form.

Simply click on the Download Book button.

Yes, Book downloads on Ebookily are 100% Free.

Sometimes the book is free on Amazon As well, so go ahead and hit "Search on Amazon"

Learn the awesome Julia programming language by building fun projects like a rocket launcher, a password keeper, and a battle simulator. Julia as a Second Language covers: • Data types like numbers, strings, arrays, and dictionaries • Immediate feedback with Julia’s read-evaluate-print-loop (REPL) • Simplify code interactions with multiple dispatch • Sharing code using modules and packages • Object-oriented and functional programming styles Julia as a Second Language introduces Julia to readers with a beginning-level knowledge of another language like Python or JavaScript. You’ll learn by coding engaging hands-on projects that encourage you to apply what you’re learning immediately. Don’t be put off by Julia’s reputation as a scientific programming language—there’s no data science or numerical computing knowledge required. You can get started with what you learned in high school math classes. About the technology Originally designed for high-performance data science, Julia has become an awesome general purpose programming language. It offers developer-friendly features like garbage collection, dynamic typing, and a flexible approach to concurrency and distributed computing. It is the perfect mix of simplicity, flexibility and performance. About the book Julia as a Second Language introduces Julia by building on your existing programming knowledge. You’ll see Julia in action as you create a series of interesting projects that guide you from Julia’s basic syntax through its advanced features. Master types and data structures as you model a rocket launch. Use dictionaries to interpret Roman numerals. Use Julia’s unique multiple dispatch feature to send knights and archers into a simulated battle. Along the way, you’ll even compare the object-oriented and functional programming styles–Julia supports both! What's inside • Data types like numbers, strings, arrays, and dictionaries • Immediate feedback with Julia’s read-evaluate-print-loop (REPL) • Simplify code interactions with multiple dispatch • Share code using modules and packages About the reader For readers comfortable with another programming language like Python, JavaScript, or C#. About the author Erik Engheim is a writer, conference speaker, video course author, and software developer.

Author(s): Erik Engheim
Edition: 1
Publisher: Manning
Year: 2023

Language: English
Commentary: Publisher's PDF
Pages: 400
City: Shelter Island, NY
Tags: Software Engineering; Programming; Functional Programming; Julia

Julia as a Second Language
brief contents
contents
preface
acknowledgments
about this book
Who should read this book?
How this book is organized
About the code
liveBook discussion forum
Other online resources
about the author
about the cover illustration
Part 1—Basics
1 Why Julia?
1.1 What is Julia?
1.1.1 Pros and cons of statically and dynamically typed languages
1.2 Julia combines elegance, productivity, and performance
1.3 Why Julia was created
1.3.1 Scientists need the interactive programming that dynamically typed languages offer
1.3.2 Developers in other fields also need the interactivity a dynamically typed language offers
1.4 Julia’s higher performance solves the two-language problem
1.5 Julia is for everyone
1.6 What can I build with Julia?
1.6.1 Julia in the sciences
1.6.2 Nonscience uses of Julia
1.7 Where Julia is less ideal
1.8 What you will learn in this book
Summary
2 Julia as a calculator
2.1 The Julia command line
2.2 Using constants and variables
2.2.1 Assigning and binding values to variables
2.2.2 Using the ans variable
2.2.3 What is a literal coefficient?
2.3 Different number types and their bit length in Julia
2.3.1 Writing numbers using different number formats
2.4 Floating-point numbers
2.4.1 Performing operations on integers and floating-point numbers
2.5 Defining functions
2.5.1 Storing function definitions in a file
2.5.2 Working with functions in the REPL
2.5.3 Functions everywhere
2.5.4 Functions to work with numbers
2.6 How to use numbers in practice
Summary
3 Control flow
3.1 Navigation and trigonometry
3.2 Boolean expressions
3.2.1 Compound statements
3.3 Looping
3.3.1 Flowchart
3.3.2 Making a mathematical table for the sine function
3.3.3 Range objects
3.3.4 For loops
3.4 Multiline functions
3.4.1 Implementing the sine trigonometric function
3.5 Implementing factorial
3.6 Factorial with recursion
3.7 If statements
3.7.1 If-else statements
3.7.2 Elseif clause
3.8 Throwing exceptions to handle errors
3.9 Control flow vs. data flow
3.10 Counting rabbits
3.10.1 Base case
3.10.2 Iteration vs. recursion
3.10.3 To return or not return
Summary
4 Julia as a spreadsheet
4.1 Analyzing pizza sales
4.2 Different types of arrays
4.3 Performing operations on arrays
4.4 Working with the statistics module
4.5 Accessing elements
4.6 Creating arrays
4.7 Mapping values in an array
4.8 Introducing characters and strings
4.9 Storing pizza data in tuples
4.10 Filtering pizzas based on predicates
4.10.1 Combining higher-order functions
4.11 Mapping and reducing an array
4.11.1 Sine table with map and reduce
4.12 Counting matches with Boolean arrays
Summary
5 Working with text
5.1 Making a pretty pizza sales table
5.1.1 Print, println, and printstyled
5.1.2 Printing multiple elements
5.1.3 Printing multiple pizzas
5.1.4 Align with lpad and rpad
5.1.5 Adding lines
5.2 Printing a trigonometric table
5.3 Reading and writing pizza sales to CSV files
5.3.1 Writing pizza sales to a file
5.3.2 Reading pizza sales from a file
5.4 Interacting with the user
Summary
6 Storing data in dictionaries
6.1 Parsing Roman numerals
6.2 Using the Dict type
6.3 Looping over characters
6.4 Enumerating values and indices
6.5 Explaining the conversion process
6.6 Using dictionaries
6.6.1 Creating dictionaries
6.6.2 Element access
6.7 Why use a dictionary?
6.8 Using named tuples as dictionaries
6.8.1 When do you use a named tuple?
6.8.2 Tying it all together
Summary
Part 2—Types
7 Understanding types
7.1 Creating composite types from primitive types
7.2 Exploring type hierarchies
7.3 Creating a battle simulator
7.3.1 Defining warrior types
7.3.2 Adding behavior to warriors
7.3.3 Using multiple dispatch to invoke methods
7.4 How Julia selects method to call
7.4.1 Contrasting Julia’s multiple dispatch with object-oriented languages
7.4.2 How is multiple dispatch different from function overloading?
Summary
8 Building a rocket
8.1 Building a simple rocket
8.2 Maintaining invariants in your code
8.3 Making objects with constructor functions
8.4 Differences between outer and inner constructors
8.5 Modeling rocket engines and payloads
8.6 Assembling a simple rocket
8.7 Creating a rocket with multiple stages and engines
8.8 Launching a rocket into space
Summary
9 Conversion and promotion
9.1 Exploring Julia’s number promotion system
9.2 Understanding number conversion
9.3 Defining custom units for angles
9.3.1 Defining angle constructors
9.3.2 Defining arithmetic operations on angles
9.3.3 Defining accessors to extract degrees, minutes, and seconds
9.3.4 Displaying DMS angles
9.3.5 Defining type conversions
9.3.6 Making pretty literals
9.3.7 Type promotions
Summary
10 Representing unknown values
10.1 The nothing object
10.2 Using nothing in data structures
10.2.1 What is a parametric type?
10.2.2 Using union types to end the wagon train
10.3 Missing values
10.4 Not a number
10.5 Undefined data
10.6 Putting it all together
Summary
Part 3—Collections
11 Working with strings
11.1 UTF-8 and Unicode
11.1.1 Understanding the relation between code points and code units
11.2 String operations
11.2.1 Converting from camel case to snake case
11.2.2 Converting between numbers and strings
11.2.3 String interpolation and concatenation
11.2.4 sprintf formatting
11.3 Using string interpolation to generate code
11.4 Working with nonstandard string literals
11.4.1 DateFormat strings
11.4.2 Raw strings
11.4.3 Using regular expressions to match text
11.4.4 Making large integers with BigInt
11.4.5 MIME types
Summary
12 Understanding Julia collections
12.1 Defining interfaces
12.2 Propellant tank interface example
12.3 Interfaces by convention
12.4 Implementing engine cluster iteration
12.4.1 Making clusters iterable
12.5 Implementing rocket stage iteration
12.5.1 Adding support for map and collect
12.6 Comparison of linked lists and arrays
12.6.1 Adding and removing elements
12.7 Utility of custom types
Summary
13 Working with sets
13.1 What kind of problems can sets help solve?
13.2 What is a set?
13.2.1 Comparing properties of sets and arrays
13.3 How to use set operations
13.4 How to use sets in your code
13.5 Searching for products using set operations
13.5.1 Defining and using enumerations
13.5.2 Creating test data to perform queries on
13.5.3 Searching for screws
13.5.4 Putting screw objects into sets
13.5.5 Looking up screws using dictionaries
13.6 Search in bug tracker using sets
13.7 Relational databases and sets
Summary
14 Working with vectors and matrices
14.1 Vectors and matrices in mathematics
14.2 Constructing a matrix from rows and columns
14.3 The size, length, and norm of an array
14.4 Slicing and dicing an array
14.5 Combining matrices and vectors
14.6 Creating matrices
Summary
Part 4—Software engineering
15 Functional programming in Julia
15.1 How does functional programming differ from object-oriented programming?
15.2 How and why you should learn to think functionally
15.3 Avoid deeply nested calls with function chaining
15.3.1 Understanding anonymous functions and closures
15.3.2 Using the pipe operator |>
15.3.3 Conveniently produce new functions using partial application
15.4 Implementing Caesar and substitution ciphers
15.4.1 Implementing the Caesar cipher
15.4.2 Implementing substitution ciphers
15.5 Creating a cipher-algorithm-agnostic service
15.6 Building an encryption service using object-oriented programming
15.7 Building an encryption service using functional programming
15.7.1 Defining a functional Caesar cipher
15.7.2 Defining a functional substitution cipher
15.7.3 Implementing a functional password-keeper service
Summary
16 Organizing and modularizing your code
16.1 Setting up a work environment
16.1.1 Using a package in the REPL
16.1.2 How modules relate to packages
16.2 Creating your own package and module
16.2.1 Generating a package
16.2.2 Adding code to your package
16.3 Modifying and developing a package
16.4 Tackling common misconceptions about modules
16.5 Testing your package
Summary
Part 5—Going in depth
17 Input and output
17.1 Introducing Julia’s I/O system
17.2 Reading data from a process
17.3 Reading and writing to a socket
17.4 Parsing a CSV file
17.4.1 Loading rocket engine data
17.4.2 Saving rocket engine data
Summary
18 Defining parametric types
18.1 Defining parametric methods
18.2 Defining parametric types
18.3 Type safety benefits from parametric types
18.4 Performance benefits from parametric types
18.5 Memory benefits of parametric types
Summary
Appendix A—Installing and configuring the Julia environment
A.1 Downloading Julia
A.3 On Linux
A.3.1 On macOS
A.3.2 On Windows
A.4 Configuring Julia
A.4.1 On Linux and macOS
A.4.2 On Windows
A.5 Running Julia
A.7 Installing third-party packages
Appendix B—Numerics
B.1 Different number types and their bit lengths
B.2 Overflow and signed and unsigned numbers
B.3 Floating-point numbers
index
Symbols
A
B
C
D
E
F
G
H
I
J
K
L
M
N
O
P
Q
R
S
T
U
V
W
X
Z