Hi, 

Everyone seems to agree on the same workflow, so I'll just mention my 
workflow as an alternative. 

Pros: 
 - don't need any Julia REPL restarts
 - don't need to prepend module name in (interactive) code.
 - variables, data structures etc all are retained during development. 

Cons:
 - in testing cycle, you're working in global namespace, really, and not in 
a module
 - changing type definitions do require a restart, so this doesn't work for 
developing a type hierarchy
 - testing true module functionality (e.g., making sure exports have not 
been forgotten) requires some extra effort
 - in developing, global variables used in testing sometimes make their way 
into a function definition.  Then you think the function works, but you 
forgot to declare the variable as a function argument.  

In ./src I have the main MyModule.jl, with `using`s, `export`s and 
`include()`s of all code, starting with `include("types.jl)"`. 
I further have file "nomodule.jl", which is very similar, but only has the 
`using`s and the `include()`s.  The first include, however, is replaced by 
a `require("types.jl")`. 

During development, every time I change some code, I do a 
`reload("nomodule")` from the REPL.  (really, `ctrl-r re <enter>` most of 
the times).  All variables are retained, so I usually have large, slowly 
loading data structures called `x` ready for testing without having to 
restart the REPL.   

This workflow evolved in the first few weeks of working with Julia, as a 
result of not really understanding what `require()`, `include()` and 
`using` do and what their (default) search path or default extension is. 
 But since then it has worked for me, so I'll probably stick with it for a 
while. 

Cheers, 

---david


On Tuesday, January 20, 2015 at 11:45:13 AM UTC+1, Tamas Papp wrote:
>
> Hi, 
>
> I am wondering what the best workflow is for iterative/exploratory 
> programming (as opposed to, say, library development).  I feel that my 
> questions below all have solutions, it's just that I am not experienced 
> enough in Julia to figure them out. 
>
> The way I have been doing it so far: 
> 1. open a file in the editor, 
> 2. start `using` some libraries, 
> 3. write a few functions, load data, plot, analyze 
> 4. rewrite functions, repeat 2-4 until satisfied. 
>
> I usually end up with a bunch of functions, followed by the actual 
> runtime code. 
>
> However, I run into the following issues (or, rather, inconveniences) 
> with nontrivial code: 
>
> a. If I redefine a function, then I have to recompile dependent 
> functions, which is tedious and occasionally a source of bugs 
> (cf. https://github.com/JuliaLang/julia/issues/265 ) 
>
> b. I can't redefine types. 
>
> I can solve both by restarting (`workspace()`), but then I have to 
> reload & recompile everything. 
>
> I am wondering if there is a more organized way of doing this --- eg put 
> some stuff in a module in a separate file and just keep reloading that, 
> etc. Any advice, or pointers to tutorials would be appreciated. 
>
> I am using Emacs/ESS. 
>
> Also, is there a way to unintern symbols (a la CL) that would solve the 
> type redefinition issue? 
>
> Best, 
>
> Tamas 
>

Reply via email to