Learn Julia language for data science and data analytics About This Book Set up Julia's environment and start building simple programs Explore the technical aspects of Julia and its potential when it comes to speed and data processing Write efficient and high-quality code in Julia Who This Book Is For This book allows existing programmers, statisticians and data scientists to learn the Julia and take its advantage while building applications with complex numerical and scientific computations. Basic knowledge of mathematics is needed to understand the various methods that will be used or created in the book to exploit the capabilities for which Julia is made. What You Will Learn Understand Julia's ecosystem and create simple programs Master the type system and create your own types in Julia Understand Julia's type system, annotations, and conversions Define functions and understand meta-programming and multiple dispatch Create graphics and data visualizations using Julia Build programs capable of networking and parallel computation Develop real-world applications and use connections for RDBMS and NoSQL Learn to interact with other programming languages-C and Python--using Julia In Detail Julia is a highly appropriate language for scientific computing, but it comes with all the required capabilities of a general-purpose language. It allows us to achieve C/Fortran-like performance while maintaining the concise syntax of a scripting language such as Python. It is perfect for building high-performance and concurrent applications. From the basics of its syntax to learning built-in object types, this book covers it all. This book shows you how to write effective functions, reduce code redundancies, and improve code reuse. It will be helpful for new programmers who are starting out with Julia to explore its wide and ever-growing package ecosystem and also for experienced developers/statisticians/data scientists who want to add Julia to their skill-set. The book presents the fundamentals of programming in Julia and in-depth informative examples, using a step-by-step approach. You will be taken through concepts and examples such as doing simple mathematical operations, creating loops, metaprogramming, functions, collections, multiple dispatch, and so on. By the end of the book, you will be able to apply your skills in Julia to create and explore applications of any domain. Style and approach This book demonstrates the basics of Julia along with some data .. Cover 1 Copyright 3 Credits 4 About the Authors 5 About the Reviewer 6 www.PacktPub.com 7 Customer Feedback 8 Table of Contents 9 Preface 15 Chapter 1: Understanding Julia's Ecosystem 20 What makes Julia unique? 21 Features and advantages of Julia 22 Installing Julia 23 Julia on Ubuntu (Linux) 24 Julia on Fedora/CentOS/Red Hat (Linux) 24 Julia on Windows 25 Julia on Mac 25 Building from source 25 Understanding the directory structure of Julia's source 26 Julia's source stack 26 Julia's importance in data science 27 Benchmarks 28 Using REPL 29 Using help in Julia 31 Plots in REPL 34 Using Jupyter Notebook 34 What is Juno? 38 Package management 40 Pkg.status() – package status 41 Pkg.add() – adding packages 42 Working with unregistered packages 43 Pkg.update() – package update 43 METADATA repository 44 Developing packages 44 Creating a new package 44 A brief about multiple dispatch 45 Methods in multiple dispatch 46 Understanding LLVM and JIT 47 Summary 48 References 49 Chapter 2: Programming Concepts with Julia 50 Revisiting programming paradigms 51 Imperative programming paradigm 51 Logical programming paradigm 52 Functional programming paradigm 53 Object-oriented paradigm 55 Starting with Julia REPL 56 Variables in Julia 57 Naming conventions 59 Integers, bits, bytes, and bools 60 Playing with integers in REPL 61 Understanding overflow behavior 62 Understanding the Boolean data type 63 Floating point numbers in Julia 64 Special functions on floating point numbers 65 Operations on floating point numbers 66 Computations with arbitrary precision arithmetic 67 Writing expressions with coefficients 68 Logical and arithmetic operations in Julia 68 Performing arithmetic operations 68 Performing bitwise operations 69 Operators for comparison and updating 70 Precedence of operators 71 Type conversions (numerical) 72 Understanding arrays, matrices, and multidimensional arrays 72 List comprehension in Julia 74 Creating an empty array 74 Operations on arrays 76 Working with matrices 76 Different operation on matrices 77 Working with multidimensional arrays (matrices) 78 Understanding sparse matrices 80 Understanding DataFrames 80 NA data type in DataArray 81 The requirement of the NA data type 81 DataArray – a series-like data structure 82 DataFrames – tabular data structures 83 Summary 85 Chapter 3: Functions in Julia 86 Creating functions 87 The special ! 89 Function arguments 89 Pass by values versus pass by reference 90 Pass by sharing 90 The return keyword 90 Arguments 91 No arguments 92 Varargs 92 Optional arguments 94 Understanding scope with respect to functions 94 Nested functions 97 Anonymous functions 98 Multiple dispatch 100 Understanding methods 101 Recursion 103 Built-in functions 105 An example using simple built-in functions 108 Summary 112 Chapter 4: Understanding Types and Dispatch 113 Julia's type system 114 What are types? 114 Statically-typed versus dynamically-typed languages 114 So, is Julia a dynamically-typed or statically-typed language? 115 Type annotations 115 More on types 117 The Integer type 118 The Float type 118 The Char type 119 The String type 119 The Bool type 119 Type conversions 120 The subtypes and supertypes 122 The supertype() function 123 The subtype() function 123 User-defined and composite data types 125 Composite types 127 Inner constructors 128 Modules and interfaces 130 Including files in modules 133 Module file paths 134 What is module precompilation? 135 Multiple dispatch explained 137 Summary 139 Chapter 5: Working with Control Flow 140 Conditional and repeated evaluation 140 Conditional evaluation in detail 142 Short-circuit evaluation 146 Repeated evaluation 147 Defining range 151 Some more examples of the for loop 152 The break and continue 153 Exception handling 154 The throw() function 157 The error() function 159 The try/catch/finally blocks 160 Tasks in Julia 161 Summary 163 Chapter 6: Interoperability and Metaprogramming 164 Interacting with operating systems 164 Filesystem operations 165 I/O operations 169 Example 172 Calling C and Python! 173 Calling C from Julia 173 Calling Python from Julia 176 Expressions and macros 177 Macros 181 But why metaprogramming? 182 Built-in macros 184 Type introspection and reflection capabilities 190 Type introspection 191 Reflection capabilities 192 Summary 193 Chapter 7: Numerical and Scientific Computation with Julia 194 Working with data 194 Working with text files 197 Working with CSV and delimited file formats 200 Working with DataFrames 201 NA 203 DataArrays 205 DataFrames 205 Linear algebra and differential calculus 206 Linear algebra 207 Differential calculus 209 Statistics 210 Simple statistics 211 Basic statistics using DataFrames 214 Using Pandas 215 Advanced statistics topics 216 Distributions 216 TimeSeries 218 Hypothesis testing 219 Optimization 222 JuMP 222 Convex.jl 224 Summary 226 Chapter 8: Data Visualization and Graphics 227 Basic plots 227 Bar graphs 231 Histograms 232 Pie charts 233 Scatter plots 234 3-D surface plots 236 Vega 238 Area plots 240 Aster plots 241 Choropleth map 243 Heatmaps 243 Ribbon plots 244 Wordcloud 245 Scatter plots 247 Gadfly 248 Interacting with Gadfly using the plot function 248 Plotting DataFrames with Gadfly 251 Summary 257 Chapter 9: Connecting with Databases 258 How to connect with databases? 258 Relational databases 259 SQLite 260 MySQL 261 NoSQL databases 262 MongoDB 263 Introduction to REST 266 What is JSON? 267 Web frameworks 271 Summary 275 Chapter 10: Julia’s Internals 276 Under the hood 276 Femtolisp 277 The Julia Core API 277 Performance enhancements 278 Global variables 278 Type declarations 278 Fields with abstract types 278 Container fields with abstract type 280 Declaring type for keyword arguments 280 Miscellaneous performance tweaks 280 Standard library 282 LLVM and JIT explained 285 Parallel computing 288 Focusing on global variables 291 Running loops in parallel 293 TCP sockets and servers 295 Sockets 297 Creating packages 298 Guidelines for package naming 299 Generating a package 299 Summary 300 Index 301 Learn Julia language for data science and data analytics About This Book Set up Julia's environment and start building simple programs Explore the technical aspects of Julia and its potential when it comes to speed and data processing Write efficient and high-quality code in Julia Who This Book Is For This book allows existing programmers, statisticians and data scientists to learn the Julia and take its advantage while building applications with complex numerical and scientific computations. Basic knowledge of mathematics is needed to understand the various methods that will be used or created in the book to exploit the capabilities for which Julia is made. What You Will Learn Understand Julia's ecosystem and create simple programs Master the type system and create your own types in Julia Understand Julia's type system, annotations, and conversions Define functions and understand meta-programming and multiple dispatch Create graphics and data visualizations using Julia Build programs capable of networking and parallel computation Develop real-world applications and use connections for RDBMS and NoSQL Learn to interact with other programming languages?C and Python - using Julia In Detail Julia is a highly appropriate language for scientific computing, but it comes with all the required capabilities of a general-purpose language. It allows us to achieve C/Fortran-like performance while maintaining the concise syntax of a scripting language such as Python. It is perfect for building high-performance and concurrent applications. From the basics of its syntax to learning built-in object types, this book covers it all. This book shows you how to write effective functions, reduce code redundancies, and improve code reuse. It will be helpful for new programmers who are starting out with Julia to explore its wide and ever-growing package ecosystem and also for experienced developers/statisticians/data scientists who want to add Julia to their skill-set. The book presents the fundamentals of programming in Julia and in-depth informative examples, using a step-by-step approach. You will be taken through concepts and examples such as doing simple mathematical operations, creating loops, metaprogramming, functions, collections, multiple dispatch, and so on. By the end of the book, you will be able to apply your skills in Julia to create and explore applications of any domain. Style and approach This book demonstrates the basics of Julia along with some da..