Basics of Julia & Numerical Computation Part 1

Basics of Julia & Numerical Computation Part 1

Getting started with scientific computing

ยท

3 min read

Introduction

Over the years, data scientists and researchers have sought a language that has an easy learning curve and is equally powerful. Computer scientists, therefore, have resorted to the more efficient C/C++ language at the cost of a steeper learning curve. In contrast, others resort to python, which fails in comparison to the efficiency of C/C++ language to cater for the entry boundary caused by a steeper learning curve.

Note: Many libraries have been developed to optimize code in python. Notable among them is NumPy.

As an aspiring computer scientist who seeks to venture into the field of scientific computing and data science, it was essential to find a language with an easy learning curve while keeping its efficiency on par with the C/C++ language or even better. This search led me to the julia language. No language fits these criteria better than it. Julia looks like python, feels like Lisp, and runs like C, thereby being efficient and yet easy to learn.

This julia series covers fundamental syntax and the core concepts to get you started in the julia programming language. It goes beyond the basic syntax to applying concepts to solve mathematical and scientific problems.

Installing Julia

  • For detailed instructions on installing julia on your specific platform, click here.
  • You can also find the binary releases here.

Let's Get Started

Displaying Values

  • To display values, use the print or println function.
  • print() displays the value as it is. Any succeeding print statements join themselves to the previous output.
print("Hello world!")
print("My name is David")

# Outputs "Hello world!My name is David"
  • println() displays the value and appends a new line to its end. Hence, succeeding println (or print)statements will be displayed on a new line.
println("Hello world!")
println("My name is David")
print("I love julia lang")

# Outputs 
# "Hello world!"
# "My name is David"
# "I love julia lang"

How To Assign Variables

Things To Note

  • Julia is case-sensitive.
  • Variable names must begin with a letter (A-Z or a-z), underscore (_), or a subset of Unicode code that points to a value greater than 00AD (e.g. letters and math symbols).

Julia allows naming variables with mathematical and scientific symbols, making it easier to understand the math in your code because it can be written in the traditional math format.

  • Use the typeof() function to check the data type of a variable. We'll cover data types in a later part of this series :).
# Assigning values to variables

variable = 42
_num = 0

Using Unicode Characters In Code

Inserting Emojis

  • \: is used to trigger the insertion of an emoji in julia.
  • Syntax:
    • \:emoji_name
    • Use <tab> to select the emoji.
\:smile:     # press <tab>
# displays ๐Ÿ™‚

\:people_hugging:         # press <tab>
# displays ๐Ÿซ‚

Inserting Scientific Characters (or latex notations)

  • Their insertion is triggered by using the backslash (\) and using <tab> to select them.
\alpha         # press <tab>
# displays ฮฑ
\sum         # press <tab>
# displays โˆ‘

Data Types In Julia

  • Just like every programming language, julia has its data types.
  • Julia's typesetting system does not require you to explicitly state a data type while writing your code (though you can), but each value is converted into its data type before it runs.
  • Since julia types are runtime objects, it eliminates the time the compiler would have used to identify the type of each variable, adding to julia's runtime efficiency.
  • The data types that exist in julia include:
    • Integers
    • Floating point numbers
    • Strings
    • Characters
    • Boolean

I will cover the data types in julia in more detail in the next part of this series.


References

  • Julia Academy.
  • Julia Docs.
  • Curiosity.
ย