# Critique my workflow for small models in Julia

**URL:** <https://discourse.julialang.org/t/critique-my-workflow-for-small-models-in-julia/105089>\
**Category:** General Usage\
**Created:** [October 17, 2023, 5:45pm UTC](https://discourse.julialang.org/t/critique-my-workflow-for-small-models-in-julia/105089 "2023-10-17T17:45:18Z")\
**Posts on this page:** 5\
**Page:** 1

<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:** [October 17, 2023, 5:45pm UTC](https://discourse.julialang.org/t/critique-my-workflow-for-small-models-in-julia/105089/1 "2023-10-17T17:45:18Z")

</div>

In the process of iterating through lots of toy economic models and writing small scripts to analyze them (make plots, etc.).

I’ve gotten into the following workflow, and I’m wondering if (a) it’s reasonable (b) Other people share it and (c) if other people have formalized it into a package.

The workflow attempts to balance the ease of running a script at the REPL with

1. use `] generate MyModel` because ultimately I will want things in a package
2. `] add` a bunch of packages
3. Write my functions inside the `MyModel` module
4. Write a `main` function inside `MyModel`
5. In the REPL, run `using Revise; using MyModel; exportall(MyModel)`. The last command sends all names to `Main`
6. Make `main` look like this

```julia
function main()
@eval Main begin # everything available at the REPL
...
end
end

```

1. Go to `src/MyModel.jl` and copy and paste all the `using` statements into the REPL so that everything is available at the REPL.
2. Run `main()` at the REPL. Everything inside `main` is visible.
3. Use `@infiltrate` extensively while debugging.

The reason for `main` with `@eval` is so that I can take things inside `main` and easily spit them out into helper functions that are also in the `MyModel` module.

This gives me the best balance of having a package and having stuff accessible at the REPL.

Anyone else do this? I use Sublime Text and a terminal, btw.

---

<div class="post-metadata">

**Author:** ![tbeason](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tbeason/32/15898_2.png) [@tbeason](https://discourse.julialang.org/u/tbeason)\
**Post date:** [October 17, 2023, 6:04pm UTC](https://discourse.julialang.org/t/critique-my-workflow-for-small-models-in-julia/105089/2 "2023-10-17T18:04:53Z")

</div>

Honestly, I have been using Pluto to do all of my prototyping. I think it strikes an alright balance between interactivity and composition of features.

---

<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:** [October 17, 2023, 6:58pm UTC](https://discourse.julialang.org/t/critique-my-workflow-for-small-models-in-julia/105089/3 "2023-10-17T18:58:45Z")

</div>

Aside from my preference for the terminal (I like window pop-ups, its snappier, consistency across languages), I feel like Pluto wouldn’t work since I want my code to basically _be_ a package, with the exception of `main`, which is like a script.

---

<div class="post-metadata">

**Author:** ![mbaz](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mbaz/32/17295_2.png) [@mbaz](https://discourse.julialang.org/u/mbaz)\
**Post date:** [October 17, 2023, 7:15pm UTC](https://discourse.julialang.org/t/critique-my-workflow-for-small-models-in-julia/105089/4 "2023-10-17T19:15:18Z")

</div>

Since I started using the [contextual module REPL feature](https://julialang.org/blog/2023/04/julia-1.9-highlights/#contextual_module_repl) I feel less need to export stuff to Main.

---

<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:** [October 17, 2023, 7:28pm UTC](https://discourse.julialang.org/t/critique-my-workflow-for-small-models-in-julia/105089/5 "2023-10-17T19:28:03Z")

</div>

Thanks! Yeah that might be the solution here, to prevent the annoying copying and pasting the `using` statements into the REPL.
