# Julia static compilation

**URL:** <https://discourse.julialang.org/t/julia-static-compilation/296>\
**Category:** General Usage\
**Tags:** question\
**Created:** [November 14, 2016, 5:43pm UTC](https://discourse.julialang.org/t/julia-static-compilation/296 "2016-11-14T17:43:21Z")\
**Posts on this page:** 20\
**Page:** 2

<div class="post-metadata">

**Author:** ![datnamer](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/datnamer/32/3471_2.png) [@datnamer](https://discourse.julialang.org/u/datnamer)\
**Post date:** [April 13, 2017, 3:25pm UTC](https://discourse.julialang.org/t/julia-static-compilation/296/21 "2017-04-13T15:25:55Z")

</div>

I’m specifically interested in the static compile with minimal runtime usecase. Anyone have any idea how far out that is? 1.0 or post 1.0?

---

<div class="post-metadata">

**Author:** ![tknopp](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tknopp/32/3569_2.png) [@tknopp](https://discourse.julialang.org/u/tknopp)\
**Post date:** [April 13, 2017, 7:52pm UTC](https://discourse.julialang.org/t/julia-static-compilation/296/22 "2017-04-13T19:52:17Z")

</div>

for 3) I have created an issue here:  
[https://github.com/JuliaLang/Juleps/issues/23](https://github.com/JuliaLang/Juleps/issues/23)

1. is actually a pretty nature thing in context of package precompilation, see:  
[https://github.com/JuliaLang/julia/issues/16330](https://github.com/JuliaLang/julia/issues/16330)

---

<div class="post-metadata">

**Author:** ![onpentox](https://avatars.discourse-cdn.com/v4/letter/o/ea5d25/32.png) [@onpentox](https://discourse.julialang.org/u/onpentox)\
**Post date:** [May 3, 2017, 9:03am UTC](https://discourse.julialang.org/t/julia-static-compilation/296/23 "2017-05-03T09:03:20Z")

</div>

Ability to make proprietary packages is absolutely mandatory for further language adaptation.

---

<div class="post-metadata">

**Author:** ![Evizero](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/evizero/32/10118_2.png) [@Evizero](https://discourse.julialang.org/u/Evizero)\
**Post date:** [May 3, 2017, 9:29am UTC](https://discourse.julialang.org/t/julia-static-compilation/296/24 "2017-05-03T09:29:41Z")

</div>

> [@onpentox](#):
>
> Ability to make proprietary packages is absolutely mandatory for further language adaptation.

While I personally tend to agree with you on some level, can we please make an effort in keeping the tone appropriate for a scientific community and phrase opinions for what they are, opinions, instead of making claims with **absolute certainty** that no un-clairvoyant being has any business making.

---

<div class="post-metadata">

**Author:** ![Marius\_Kruger](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/marius_kruger/32/904_2.png) [@Marius\_Kruger](https://discourse.julialang.org/u/Marius_Kruger)\
**Post date:** [May 17, 2017, 9:03pm UTC](https://discourse.julialang.org/t/julia-static-compilation/296/25 "2017-05-17T21:03:26Z")

</div>

My use case is to run a julia script and exit in under 2 seconds.  
My experiments with a fairly simple script[1] is that it takes between 1.5 and 3 seconds.  
Is there any way to use any pre-compilation to make this runtimes more consistent?

[1] It just reads a 19K JSON file and writes out a one line file.

---

<div class="post-metadata">

**Author:** ![musm](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/musm/32/3675_2.png) [@musm](https://discourse.julialang.org/u/musm)\
**Post date:** [May 17, 2017, 10:51pm UTC](https://discourse.julialang.org/t/julia-static-compilation/296/26 "2017-05-17T22:51:59Z")

</div>

That might be related to the slow startup time of Julia compared to e.g. Python

```julia
time julia -e ""
real 0m0.323s
user 0m0.356s
sys 0m0.720s

 time python -c ""

real 0m0.018s
user 0m0.012s
sys 0m0.004s

```

---

<div class="post-metadata">

**Author:** ![fengyang.wang](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/fengyang.wang/32/104_2.png) [@fengyang.wang](https://discourse.julialang.org/u/fengyang.wang)\
**Post date:** [May 19, 2017, 5:27am UTC](https://discourse.julialang.org/t/julia-static-compilation/296/27 "2017-05-19T05:27:06Z")

</div>

I don’t think static compilation will make startup time any faster.

---

<div class="post-metadata">

**Author:** ![gdkrmr](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/gdkrmr/32/2791_2.png) [@gdkrmr](https://discourse.julialang.org/u/gdkrmr)\
**Post date:** [June 23, 2017, 1:16pm UTC](https://discourse.julialang.org/t/julia-static-compilation/296/28 "2017-06-23T13:16:55Z")

</div>

I just tried to compile the following program with `BuildExecutable.jl` and julia 0.5 (0.6 failed):

```julia
main() = begin end;

```

```julia
$ time ./test_exec/test_exec 

real	0m0.285s
user	0m0.212s
sys	0m0.096s

```

the same as:

```julia
$ time julia-0.5 -e "main()=begin end;main();"

real	0m0.268s
user	0m0.220s
sys	0m0.072s

```

both runs oscillate around 270ms  
julia 0.6 is a little bit faster ~240ms

```julia
$ time julia-0.6 -e "main()=begin end;main();"

real	0m0.236s
user	0m0.180s
sys	0m0.072s

```

but doesn’t beat 0.4:

```julia
$ time julia-0.4 -e "main()=begin end;main();"

real	0m0.162s
user	0m0.116s
sys	0m0.064s

```

---

<div class="post-metadata">

**Author:** ![JaredCrean2](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jaredcrean2/32/3574_2.png) [@JaredCrean2](https://discourse.julialang.org/u/JaredCrean2)\
**Post date:** [June 23, 2017, 4:23pm UTC](https://discourse.julialang.org/t/julia-static-compilation/296/29 "2017-06-23T16:23:07Z")

</div>

What is the dominant cost of startup (assuming there is a single dominant cost)?

---

<div class="post-metadata">

**Author:** ![ahwillia](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ahwillia/32/105_2.png) [@ahwillia](https://discourse.julialang.org/u/ahwillia)\
**Post date:** [December 16, 2017, 5:35pm UTC](https://discourse.julialang.org/t/julia-static-compilation/296/30 "2017-12-16T17:35:50Z")

</div>

Is there any update on this? I’m thinking about implementing some of my current project in Cython, but I would love it if I could use Julia instead. But I need to integrate whatever I do into Python seemlessly (from a user perspective, I’d like them to not know Julia is even there!)

---

<div class="post-metadata">

**Author:** ![ChrisRackauckas](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/chrisrackauckas/32/77_2.png) [@ChrisRackauckas](https://discourse.julialang.org/u/ChrisRackauckas)\
**Post date:** [December 16, 2017, 5:43pm UTC](https://discourse.julialang.org/t/julia-static-compilation/296/31 "2017-12-16T17:43:42Z")

</div>

There have been some successful uses of [https://github.com/JuliaComputing/static-julia](https://github.com/JuliaComputing/static-julia)

---

<div class="post-metadata">

**Author:** ![StefanKarpinski](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/stefankarpinski/32/24_2.png) [@StefanKarpinski](https://discourse.julialang.org/u/StefanKarpinski)\
**Post date:** [July 16, 2018, 3:25pm UTC](https://discourse.julialang.org/t/julia-static-compilation/296/32 "2018-07-16T15:25:02Z")

</div>

6 posts were split to a new topic: [Reluctance to switch to Julia; PyPy and Cython](https://discourse.julialang.org/t/reluctance-to-switch-to-julia-pypy-and-cython/12420)

---

<div class="post-metadata">

**Author:** ![ChrisRackauckas](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/chrisrackauckas/32/77_2.png) [@ChrisRackauckas](https://discourse.julialang.org/u/ChrisRackauckas)\
**Post date:** [July 16, 2018, 11:19pm UTC](https://discourse.julialang.org/t/julia-static-compilation/296/33 "2018-07-16T23:19:56Z")

</div>

The current state of this work is at [https://github.com/JuliaLang/PackageCompiler.jl](https://github.com/JuliaLang/PackageCompiler.jl)

---

<div class="post-metadata">

**Author:** ![johnh](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/johnh/32/3615_2.png) [@johnh](https://discourse.julialang.org/u/johnh)\
**Post date:** [July 17, 2018, 9:33am UTC](https://discourse.julialang.org/t/julia-static-compilation/296/34 "2018-07-17T09:33:19Z")

</div>

One of the arguments for static compilation seems to be the commercial code and obfuscation argument.  
…  
I throw it open for discussion - when commercial Julia codes are being sold, will it be important to have obfuscated code? I do not have the answer.  
I am assuming here there are no commercial Julia codes being sold at the moment. There may well be!

---

<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:** [July 17, 2018, 9:42am UTC](https://discourse.julialang.org/t/julia-static-compilation/296/35 "2018-07-17T09:42:11Z")

</div>

> [@johnh](#):
>
> I throw it open for discussion - when commerical Julia codes are being sold, will it be important to have obfuscated code?

An important question, but please consider opening a new topic.

---

<div class="post-metadata">

**Author:** ![johnh](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/johnh/32/3615_2.png) [@johnh](https://discourse.julialang.org/u/johnh)\
**Post date:** [July 17, 2018, 10:40am UTC](https://discourse.julialang.org/t/julia-static-compilation/296/36 "2018-07-17T10:40:24Z")

</div>

New topic [Commercial codes using Julia - code obfuscation?](https://discourse.julialang.org/t/commercial-codes-using-julia-code-obfuscation/12429)

---

<div class="post-metadata">

**Author:** ![RoyiAvital](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/royiavital/32/571_2.png) [@RoyiAvital](https://discourse.julialang.org/u/RoyiAvital)\
**Post date:** [July 17, 2018, 3:37pm UTC](https://discourse.julialang.org/t/julia-static-compilation/296/37 "2018-07-17T15:37:41Z")

</div>

Having the ability to create C Compatible Dynamic / Static Library from Julai Function would be amazing!

Making all the development in Julia, including the Unit Tests and then producing Dynamic / Static Library (With corresponding `h` File on all OS’s) would be a killer feature.

Many companies I know use MATLAB to do just that.  
The Signal Processing Algorithm team does all the development on MATLAB then create a generated Code (Or Library) which is compiled with the whole project (Developed by the software team).  
If Julia can generate much more efficient Compiled Library which has superior performance it will make a big step forward for those teams.

I understand it will come later on (Which is logical) yet I hope not too far in the future.  
Is it realistic to have such feature within 2019?

---

<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:** [July 17, 2018, 4:14pm UTC](https://discourse.julialang.org/t/julia-static-compilation/296/38 "2018-07-17T16:14:47Z")

</div>

> [@RoyiAvital](#):
>
> If Julia can generate much more efficient Compiled Library which has superior performance it will make a big step forward for those teams.

It would be nice to get grant from governements because more code could consume less energy and it could help prevent climate change! 😉

---

<div class="post-metadata">

**Author:** ![dingbo8128](https://avatars.discourse-cdn.com/v4/letter/d/ed8c4c/32.png) [@dingbo8128](https://discourse.julialang.org/u/dingbo8128)\
**Post date:** [February 15, 2019, 1:12am UTC](https://discourse.julialang.org/t/julia-static-compilation/296/39 "2019-02-15T01:12:28Z")

</div>

Any process on this feature ? It’s an excited feature. I expect somthing like “julia -c myscript.jl -o myapp.exe”

---

<div class="post-metadata">

**Author:** ![sdanisch](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/sdanisch/32/1406_2.png) [@sdanisch](https://discourse.julialang.org/u/sdanisch)\
**Post date:** [February 15, 2019, 10:02am UTC](https://discourse.julialang.org/t/julia-static-compilation/296/40 "2019-02-15T10:02:49Z")

</div>

Yes, [PackageCompiler](https://github.com/JuliaLang/PackageCompiler.jl) offers this!

[Previous page](https://discourse.julialang.org/t/julia-static-compilation/296.md?page=1)
