Trusted answers to developer questions
Trusted Answers to Developer Questions

Related Tags

julia
modules
packages
communitycreator

What is Julia - Modules and Packages

Joy Kareko

Grokking Modern System Design Interview for Engineers & Managers

Ace your System Design Interview and take your career to the next level. Learn to handle the design of applications like Netflix, Quora, Facebook, Uber, and many more in a 45-min interview. Learn the RESHADED framework for architecting web-scale applications by determining requirements, constraints, and assumptions before diving into a step-by-step design process.

Overview

Modules and packages are easy ways to organize code for easy access and easy use.

We can think of modules and packages as the sets or units of code used to simplify tasks and processes that would otherwise be tedious or cumbersome.

Essentially, modules and packages make the coding easier.

In Julia, we use modules and packages in a similar manner.

Differences between packages and modules in Julia

Functions related to each other and their definitions are stored together in units known as modules in Julia.

Syntax

The syntax to write our module in Julia takes the below form:

module my_modulename


end

The functions/names/constants etc., can come between the module and end.

One or more modules can be stored in a package. Packages in Julia always have .jl suffix at the end, by convention.

How to download and use a module/package in Julia

As with most languages, Julia comes with many inbuilt modules and packages for use. It’s advisable to check if the package or module you need is available before writing your own. To use a package/module in Julia, we have to download the package to our local machine and then import it to be available for use.

In Julia’s command line, we need to type ] the right square bracket.

That opens up the package manager. We can then download and install whichever package we need using the add keyword.

julia> ]
(v1.0) pkg> add DataFrames
... downloading messages....
(v1.0) pkg>

On Jupyter notebooks, use the below structure:

Import the package manager again and then use add to install any module/package.

import Pkg
Pkg.add("DataFrames")

To use the module, specify the keyword using.

For instance:

using DataFrames

We can also specify a set of modules:

using Calculus, DataFrames

RELATED TAGS

julia
modules
packages
communitycreator

Grokking Modern System Design Interview for Engineers & Managers

Ace your System Design Interview and take your career to the next level. Learn to handle the design of applications like Netflix, Quora, Facebook, Uber, and many more in a 45-min interview. Learn the RESHADED framework for architecting web-scale applications by determining requirements, constraints, and assumptions before diving into a step-by-step design process.

Keep Exploring