2 Julia Programming: Data Types and Structures

 

This chapter covers

  • Defining and using variables
  • Using operators and basic operations
  • Understanding data types and type hierarchy
  • Storing and retrieving data with Data Structures

You may already know how to program in Julia or you may be coming from another programming language. If you are in the first group, you may skip this and the next chapters and refer to them as reference whenever you need. If you are in the latter group you may use these chapters for a quick start to Julia. If you haven’t coded in Julia before I suggest going through the Appendix for installation guide.

2.1 Variables, Data Types and Operations

Types are at the very core of Julia programming language. Julia is a dynamically typed language like Python and R. This means, you don’t have to specify the type of a variable when you define it. On the other hand, there are times, when specifying data types in advance, increase the performance. For example, when reading large amounts of data, specifying the data type of columns in advance may increase performance. Or we can specify the data type as Float32 instead of Float64 to improve performance when dealing with numerical operations that involve large arrays of floating-point numbers. We can do the same when working with GPUs as they are designed to work with specific data types. Thus, we can say that Julia is an optionally typed language.

2.1.1 Variables

2.1.2 Type Hierarchy in Julia

2.1.3 Primitive Types and Composite Types

2.1.4 Parametric Types

2.1.5 Basic Operations

2.2 Data Structures

2.2.1 Tuples

2.2.2 Dictionaries

2.2.3 Ranges

2.2.4 Arrays

2.2.5 Vectors and Matrices

2.2.6 Multidimensional Arrays

2.2.7 Sets

2.3 Summary