|
| 1 | +.. _man-workflow-tips: |
| 2 | + |
| 3 | +*************** |
| 4 | + Workflow Tips |
| 5 | +*************** |
| 6 | + |
| 7 | +Here are some tips for working with Julia efficiently. |
| 8 | + |
| 9 | +REPL-based workflow |
| 10 | +------------------- |
| 11 | + |
| 12 | +As already elaborated in :ref:`man-interacting-with-julia`, Julia's |
| 13 | +REPL provides rich functionality that facilitates an efficient |
| 14 | +interactive workflow. Here are some tips that might further enhance your |
| 15 | +experience at the command line. |
| 16 | + |
| 17 | +A basic editor/REPL workflow |
| 18 | +~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
| 19 | + |
| 20 | +The most basic Julia workflows involve using a text editor in |
| 21 | +conjunction with the ``julia`` command line. A common pattern includes |
| 22 | +the following elements: |
| 23 | + |
| 24 | + - **Put code under development in a temporary module.** Create a file, |
| 25 | + say ``Tmp.jl``, and include within it :: |
| 26 | + |
| 27 | + module Tmp |
| 28 | + |
| 29 | + <your definitions here> |
| 30 | + |
| 31 | + end |
| 32 | + |
| 33 | + - **Put tests of your code in another file.** Create another file, say |
| 34 | + ``test_tmp.jl``, which begins with :: |
| 35 | + |
| 36 | + import Tmp |
| 37 | + |
| 38 | + and includes tests for the contents of ``Tmp``. The value of using |
| 39 | + :obj:`import` versus :obj:`using` is that you can call :obj:`reload` |
| 40 | + ``("Tmp")`` instead of having to restart the REPL when your |
| 41 | + definintions change. Of course, the cost is the need to prepend |
| 42 | + ``Tmp.`` to uses of names defined in your module. (You can lower that |
| 43 | + cost by keeping your module name short.) |
| 44 | + |
| 45 | + - **Lather. Rinse. Repeat.** Explore ideas at the ``julia`` command |
| 46 | + prompt. Save good ideas in your ``test_tmp.jl`` file. Occasionally |
| 47 | + restart the REPL, issuing :: |
| 48 | + |
| 49 | + reload("Tmp") |
| 50 | + include("test_tmp.jl") |
| 51 | + |
| 52 | + editing these two files as you go. |
| 53 | + |
| 54 | +Simplify initialization |
| 55 | +~~~~~~~~~~~~~~~~~~~~~~~ |
| 56 | + |
| 57 | +To simplify restarting the REPL, put project-specific initialization |
| 58 | +code in a file, say ``_init.jl``, which you can run on startup by |
| 59 | +issuing the command:: |
| 60 | + |
| 61 | + julia -L _init.jl |
| 62 | + |
| 63 | +If you further add the following to your ``.juliarc.jl`` file :: |
| 64 | + |
| 65 | + isfile("_init.jl") && require("_init.jl") |
| 66 | + |
| 67 | +then calling ``julia`` from that directory will run the initialization |
| 68 | +code without the additional command line argument. |
| 69 | + |
| 70 | +Browser-based workflow |
| 71 | +---------------------- |
| 72 | + |
| 73 | +It is also possible to interact with a Julia REPL in the browser via IJulia_. See the package home for details. |
| 74 | + |
| 75 | +.. _IJulia: https://github.com/JuliaLang/IJulia.jl |
0 commit comments