# Suggestion --- Julia Version Header in .jl files

**URL:** https://discourse.julialang.org/t/suggestion-julia-version-header-in-jl-files/16316
**Category:** Internals & Design
**Created:** [October 14, 2018, 6:59pm UTC](https://discourse.julialang.org/t/suggestion-julia-version-header-in-jl-files/16316 "2018-10-14T18:59:00Z")
**Posts on this page:** 9
**Page:** 1

<div class="post-metadata">

### Author: ![iwelch](https://avatars.discourse-cdn.com/v4/letter/i/8c91f0/32.png) [@iwelch](https://discourse.julialang.org/u/iwelch)
#### Post date: [October 14, 2018, 6:59pm UTC](https://discourse.julialang.org/t/suggestion-julia-version-header-in-jl-files/16316/1 "2018-10-14T18:59:00Z")

</div>

May I suggest that we ask Julia .jl code files in the future to start with a very short (and possibly optional) header line, such as

julia 1.0

If the language in the future changes in a breaking way, then there is a fallback to keep old code going, without holding back good changes for subsequent versions. This is related to requiring package versions ids.

---

<div class="post-metadata">

### Author: ![chakravala](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/chakravala/32/6832_2.png) [@chakravala](https://discourse.julialang.org/u/chakravala)
#### Post date: [October 14, 2018, 6:59pm UTC](https://discourse.julialang.org/t/suggestion-julia-version-header-in-jl-files/16316/2 "2018-10-14T18:59:44Z")

</div>

Julia packages already have a `REQUIRE` file in which a Julia version bound can be specified.

---

<div class="post-metadata">

### Author: ![iwelch](https://avatars.discourse-cdn.com/v4/letter/i/8c91f0/32.png) [@iwelch](https://discourse.julialang.org/u/iwelch)
#### Post date: [October 14, 2018, 7:01pm UTC](https://discourse.julialang.org/t/suggestion-julia-version-header-in-jl-files/16316/3 "2018-10-14T19:01:26Z")

</div>

this is good for packages. it is not the case for user files. to allow breaking language changes, I think it needs to be in the .jl files themselves, both users and packages.

---

<div class="post-metadata">

### Author: ![chakravala](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/chakravala/32/6832_2.png) [@chakravala](https://discourse.julialang.org/u/chakravala)
#### Post date: [October 14, 2018, 7:05pm UTC](https://discourse.julialang.org/t/suggestion-julia-version-header-in-jl-files/16316/4 "2018-10-14T19:05:19Z")

</div>

Seems like a good idea to me, I agree it could be useful. One thing you could do is write a macro or function that checks the julia version at the beginning, for example

```nohighlight
julia> check(version) = VERSION ≠ version && throw(error("wrong Julia version"))
check (generic function with 1 method)

julia> check(v"1.2.0")
ERROR: wrong Julia version
Stacktrace:
 [1] check(::VersionNumber) at ./REPL[3]:1
 [2] top-level scope at none:0

```

could throw an error if your Julia version is not correct. That’s one way I could see of doing it, if it does not end up being included in the `Base` language, you could open an issue on JuliaLang github page.

---

<div class="post-metadata">

### Author: ![tshort](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tshort/32/43_2.png) [@tshort](https://discourse.julialang.org/u/tshort)
#### Post date: [October 14, 2018, 8:22pm UTC](https://discourse.julialang.org/t/suggestion-julia-version-header-in-jl-files/16316/5 "2018-10-14T20:22:05Z")

</div>

I like the `check(version)` idea. I’ve been using [direnv](https://direnv.net/) to help with Julia versioning and environment handling per directory. It works great once set up (on Linux; Windows is tough).

[https://github.com/direnv/direnv/pull/389#issuecomment-415260868](https://github.com/direnv/direnv/pull/389#issuecomment-415260868)

---

<div class="post-metadata">

### Author: ![iwelch](https://avatars.discourse-cdn.com/v4/letter/i/8c91f0/32.png) [@iwelch](https://discourse.julialang.org/u/iwelch)
#### Post date: [October 14, 2018, 9:28pm UTC](https://discourse.julialang.org/t/suggestion-julia-version-header-in-jl-files/16316/6 "2018-10-14T21:28:54Z")

</div>

everyone can do this for their own code.

however, the big advantage of prescribing the use of such a feature is that it will give the julia language developers more freedom and flexibility to deprecate aspects in the distant future. and the time to implement this feature is right now, when it is not hurting anyone.

it could also be _required_ as a comment, like `#!julia 1.0`

a secondary advantage is easy recognition of julia source code (by `file`).

/iaw

---

<div class="post-metadata">

### Author: ![Yifan\_Liu](https://avatars.discourse-cdn.com/v4/letter/y/4da419/32.png) [@Yifan\_Liu](https://discourse.julialang.org/u/Yifan_Liu)
#### Post date: [October 15, 2018, 4:43am UTC](https://discourse.julialang.org/t/suggestion-julia-version-header-in-jl-files/16316/7 "2018-10-15T04:43:57Z")

</div>

This sounds a good idea. However, I have never see this kind of stuff automatically generated in any programming language I have used. Maybe it is better to be left to user decision. Actually there are lot of things to be checked. Do we also need to check if a specific package has been installed? Do we also need to check if a specific package has the specific version the current file needs? etc.

I am not sure if this kind of version control tasks cannot be solved by just one header code…

---

<div class="post-metadata">

### Author: ![Liso](https://avatars.discourse-cdn.com/v4/letter/l/898d66/32.png) [@Liso](https://discourse.julialang.org/u/Liso)
#### Post date: [October 15, 2018, 5:21am UTC](https://discourse.julialang.org/t/suggestion-julia-version-header-in-jl-files/16316/8 "2018-10-15T05:21:28Z")

</div>

Consider shebang ([Shebang (Unix) - Wikipedia](https://en.wikipedia.org/wiki/Shebang_(Unix))).

In unix world it is standard way how to chose interpreter for script. For example you could have Julia 0.6.x and Julia 1.x installed and use:

```julia
#!/usr/bin/env julia0
println("Hello, World! $VERSION")

```

to choose Julia 0.6.x - if you will have julia0 linked (in $PATH) to appropriate Julia 0.6.x binary.

---

<div class="post-metadata">

### Author: ![Tamas\_Papp](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tamas_papp/32/25949_2.png) [@Tamas\_Papp](https://discourse.julialang.org/u/Tamas_Papp)
#### Post date: [October 15, 2018, 6:10am UTC](https://discourse.julialang.org/t/suggestion-julia-version-header-in-jl-files/16316/9 "2018-10-15T06:10:17Z")

</div>

> [@chakravala](#):
>
> One thing you could do is write a macro or function that checks the julia version at the beginning

I guess

```julia
@assert v"1.0.0" ≤ VERSION 

```

and similar could work, without introducing any extra constructs.
