# Compile-time vs run-time actions

**URL:** <https://discourse.julialang.org/t/compile-time-vs-run-time-actions/17035>\
**Category:** General Usage\
**Created:** [November 1, 2018, 3:56am UTC](https://discourse.julialang.org/t/compile-time-vs-run-time-actions/17035 "2018-11-01T03:56:09Z")\
**Posts on this page:** 1\
**Showing post:** 5

<div class="post-metadata">

**Author:** ![Vic](https://avatars.discourse-cdn.com/v4/letter/v/9e8a1a/32.png) [@Vic](https://discourse.julialang.org/u/Vic)\
**Post date:** [November 2, 2018, 3:36pm UTC](https://discourse.julialang.org/t/compile-time-vs-run-time-actions/17035/5 "2018-11-02T15:36:50Z")

</div>

You are all right in the sense that I had not fully baked in my head the ideas before first writing them here. I’ve edited the post with important changes.

> [@yuyichao](#):
>
> No. There can be side effects.

Right, I had realized that only after Ist posting ; I’ve corrected now.

> [@StefanKarpinski](#):
>
> In Julia, there is no semantic distinction between compile time and run time—everything behaves as if it is done at run time. The implementation can do something at compile time if there’s no behavioral difference between doing it at compile time and doing it at run time (aside from timing).

Right that the only difference is in duration taken by first- vs subsequent- calls of a function.  
I wanted to find out whether I can predict when the difference will be big, that’s why I asked about that “rule of thumb”.

As exemplified in a [reply](https://discourse.julialang.org/t/variable-binding-re-assignment-argument-passing-let-scope/16840/34), a function like

```julia
function f()
...
# ANY number of assignments with complex arithmetic expressions
# but which can be modeled by a (acyclic) dependency graph
# and don't involve side-effects
...
return(last_variable) # asssume last_variable is bound to a number -type value
end

```

and one like

```julia
function g()
   return(100)
end

```

will take exactly the same amount of time of execution, at all subsequent calls of the function (in a given program or REPL session). While first call of `f()` may take much much longer than `g()`.

---

_[View the full topic](https://discourse.julialang.org/t/compile-time-vs-run-time-actions/17035)._
