# Is package a library?

**URL:** https://discourse.julialang.org/t/is-package-a-library/71924
**Category:** New to Julia
**Tags:** question
**Created:** [November 23, 2021, 12:39am UTC](https://discourse.julialang.org/t/is-package-a-library/71924 "2021-11-23T00:39:25Z")
**Posts on this page:** 8
**Page:** 1

<div class="post-metadata">

### Author: ![Evian-Zhang](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/evian-zhang/32/31022_2.png) [@Evian-Zhang](https://discourse.julialang.org/u/Evian-Zhang)
#### Post date: [November 23, 2021, 12:39am UTC](https://discourse.julialang.org/t/is-package-a-library/71924/1 "2021-11-23T00:39:25Z")

</div>

I am new to Julia, and I wonder what a package is.

I am quite familiar with Rust. In Rust, a crate can either be a library or an executable. As far as I read, the examples interpreting what package is are all about libraries, which another file can re-use the code in this package.

So if I just want to make a project for myself to use (which is much like an executable, but in interpreting languages, I can’t come up with a good name) rather than a library for others to use, should I make this project a package?

I know I can just use `julia xxx.jl` to run a Julia file, but I prefer `Project.toml` and `Manifest.toml` to make it more re-productable.

---

<div class="post-metadata">

### Author: ![jling](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jling/32/212909_2.png) [@jling](https://discourse.julialang.org/u/jling)
#### Post date: [November 23, 2021, 12:45am UTC](https://discourse.julialang.org/t/is-package-a-library/71924/2 "2021-11-23T00:45:24Z")

</div>

as you already know Project.toml and Manifest.toml gives you reproducibility. You’re totally free to make your own utility package, just create a pkg at somewhere and `]dev path_to_your_pkg` and then you can just `using MyPkg` like normal.

---

<div class="post-metadata">

### Author: ![melonedo](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/melonedo/32/15503_2.png) [@melonedo](https://discourse.julialang.org/u/melonedo)
#### Post date: [November 23, 2021, 12:59am UTC](https://discourse.julialang.org/t/is-package-a-library/71924/3 "2021-11-23T00:59:17Z")

</div>

Note that `julia --project=/path/to/project script.jl` will run the package in a specific project.  
If you are not developing a package, you can just activate that project in the REPL and [add the packages](https://docs.julialang.org/en/v1/stdlib/Pkg/) you need.

---

<div class="post-metadata">

### Author: ![Evian-Zhang](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/evian-zhang/32/31022_2.png) [@Evian-Zhang](https://discourse.julialang.org/u/Evian-Zhang)
#### Post date: [November 23, 2021, 1:12am UTC](https://discourse.julialang.org/t/is-package-a-library/71924/4 "2021-11-23T01:12:56Z")

</div>

Does this mean that “package” is more of a utility, and the `main()` function of my project is encouraged to write in a plain file that uses that package?

---

<div class="post-metadata">

### Author: ![pdeffebach](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/pdeffebach/32/10320_2.png) [@pdeffebach](https://discourse.julialang.org/u/pdeffebach)
#### Post date: [November 23, 2021, 1:16am UTC](https://discourse.julialang.org/t/is-package-a-library/71924/5 "2021-11-23T01:16:56Z")

</div>

I would just put it all in one module and have the module export the function `main()`. But yes, in general a “project” that isn’t intended to be used by others should still look like the packages you see on github, imo.

---

<div class="post-metadata">

### Author: ![Evian-Zhang](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/evian-zhang/32/31022_2.png) [@Evian-Zhang](https://discourse.julialang.org/u/Evian-Zhang)
#### Post date: [November 23, 2021, 1:18am UTC](https://discourse.julialang.org/t/is-package-a-library/71924/6 "2021-11-23T01:18:39Z")

</div>

I want to avoid using REPL since the code may develop in many days but codes in REPL can’t persist.

> `julia --project=/path/to/project script.jl`

I can’t quite understand which is what in this command. To be more specific, I have a Julia file

```Julia
import PackageA
import PackageB

function utility()
# ...
end

function main_logic()
# ...
end

```

which part should I put into `/path/to/project` and which part should be put into `script.jl`?

---

<div class="post-metadata">

### Author: ![melonedo](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/melonedo/32/15503_2.png) [@melonedo](https://discourse.julialang.org/u/melonedo)
#### Post date: [November 23, 2021, 1:28am UTC](https://discourse.julialang.org/t/is-package-a-library/71924/7 "2021-11-23T01:28:22Z")

</div>

`path/to/project` is where your Project.toml and Manifest.toml is at, since you already have a project for that.

In this specific case, you could create a script.jl:

```julia
include(“utility file”)
main_logic() # or move the body of main_logic here

```

since everything in a julia file is executed. In contrast, only `main` is executed in C.

If you are interested, [VideoIO.jl](https://github.com/JuliaIO/VideoIO.jl/tree/master/gen) contains an executable independent of the main package.

---

<div class="post-metadata">

### Author: ![sylvaticus](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/sylvaticus/32/203883_2.png) [@sylvaticus](https://discourse.julialang.org/u/sylvaticus)
#### Post date: [November 23, 2021, 8:16am UTC](https://discourse.julialang.org/t/is-package-a-library/71924/8 "2021-11-23T08:16:41Z")

</div>

I like to think to a julia package as a software “piece” (in Julia, a module) plus the metadata to facilitate its discovering and interation with other software “pieces” (the Project.toml and Manifest.toml) and a conventional structure to facilitate its testing and documentation.
