I like that one. @jacobusmmsmit @hill ?
Efficient Julia workflows?
Less frustrating Julia workflows?
I wish they were âSimpleâ Julia workflowsâŠ
Good Julia workflows
Smart Julia Workflows
Effective Julia Workflows
+1 Reminds me of the fantastic Scott Meyerâs Effective C++ books.
So I read the other post you had in the âwrite doc PRs not blog postsâ post on why this is being done as a blog post. I understand the justification on your side, but I think an official blog post will still have limited discoverability, so the issue you mention here may not be fully mitigated until such information is contained in the docs, either under âWorkflow Tipsâ or, ideally, as the beginning of a new document separate from the manual, accessible from the Julia website with one click. Perhaps a button next to âDocumentationâ â that would be a button that beginners will very likely click.
If Iâm a beginner, the list as it is right now is pretty overwhelming, since itâs not clear which ones provide large improvements vs. those that are incremental. IMO I wouldnât consider anything in the âOptimizing codeâ section suitable for beginners. Iâll suggest the following tutorial which could be included as a separate feature. This will get people on the right track for the workflow instead of typing julia file.jl
like theyâre used to in Python. Everything else, like OhMyREPL and BenchmarkTools, are intermediate to advanced, done after the very basics have been figured out (OhMyREPL is best paired with startup.jl
, and we should cater to new users who are not interested in performance optimizations).
Step-by-step tutorial (Windows users)
- Install
juliaup
in the Windows store. (Link directly to it, not the Github page) - Open PowerShell and type
juliaup add 1.9
to install the latest 1.9 version.- Type
juliaup status
to confirm which version you have installed. When new releases like 1.10 come out, simply typejuliaup update
to update to the latest version. - In the start menu, click on Julia to open the REPL. You can pin this to the taskbar and use it as a calculator.
- Type
- If you want to use an editor, install VSCode with the Julia language plugin. Otherwise, you can use Jupyter or Pluto for notebooks. (Link to a comparison between Jupyter and Pluto) Below, we assume youâre using VSCode.
- If you are using juliaup, VSCode will automatically find the Julia installation for you â skip to step 5. Otherwise, if you installed the binaries directly from the website, do the following:
- In VSCode, enter
Ctrl+,
to open up the settings. - In the top bar, type
julia.executable
. Youâll need to paste the filepath to the executable from there. If you used default installation settings, it should look something like this:C:/users/username/AppData/Local/Programs/Julia-1.9.2/bin/julia.exe
- In VSCode, enter
- Type
Alt+J+O
to open the REPL in VSCode. (J+O stands for âJulia open.â) Besides being able to run Julia code, the REPL has a built-in package manager (type]
), a help mode (type?
), and a shell mode (type;
). - Probably the most important package is Revise.jl. Install it by typing
]
to enter Pkg mode, and then typeadd Revise
. This package will automatically update function definitions in a running Julia session. Since Julia has a relatively long startup time, for maximum convenience, we recommend keeping the current REPL session open for as long as possible.- Unlike most packages, VSCode is set up to run Revise.jl upon starting up Julia. That way, you donât need to type in
using Revise
every time you open the REPL.
- Unlike most packages, VSCode is set up to run Revise.jl upon starting up Julia. That way, you donât need to type in
- To run code, you have a few choices. To illustrate, create a new file called
test.jl
with the example code to print out powers of 2:
a = 1:10 # defines a vector of the first 10 natural numbers
b = 2 .^ a # defines a vector that takes the first 10 powers of 2. The dot indicates element-wise operation.
[a b] # defines a matrix whose columns are a and b
There are three choices you have to run this code:
- With the cursor on the window with the code, hit
Ctrl+A+Enter
to select all and execute the highlighted code to the REPL. - Press the play button near the top of the screen to execute the active file in the REPL.
- Type
include(â./test.jlâ)
into the REPL.
Notice that in all of these, the last line is returned.
- Where does Revise come in? By default, the
includet
function that Revise exports will track changes to function definitions, not data. Since we didnât define any functions, typingincludet(â./test.jlâ)
wonât reflect changes if, say, we wanteda
to go from 1 to 20. It is good practice to write our code in functions, especially for more complex code, so letâs define a function calledmain
:
function main()
a = 1:10
b = 2 .^ a
return [a b]
end
main()
-
You can check that
Ctrl+A+Enter
works as usual. (If themain()
at the end were not there, you would only be defining a function calledmain
, but not actually running it. To run it, typemain()
in the REPL.)- Now to check that Revise works, type
includet(â./test.jlâ)
. This will include the file and track any changes tomain()
as long as the REPL is running. Notice that nothing will be printed. Thatâs fine â in the REPL, typemain()
to display the result. - Change the second line to
a = 1:20
. Save the file. - Type
main()
again in the REPL. Revise detects thatmain()
has changed, and the function now prints out the first 20 powers of 2.
- Now to check that Revise works, type
Lastly, my suggestion for the blog post title would be âImproving Julia workflows.â
I agree, but while writing the blog I also discovered an additional benefit of doing it: putting all of these tips in a single place. I know of no other website containing that many resources in the same spot. And once we put them all in the documentation, they will probably much more scattered, but it helps to gather them first.
Besides, it also prompted new developments, like improvements to Franklin.jl and PkgTemplates.jl, or the brand new StartupCustomizer.jl.
Thatâs why we ended up splitting the post in three pages. If you check out the preview at https://modernjuliaworkflows.github.io/, I try to make it clear that not everything should be read at once by a beginner.
I agree that this is what we want as a priority, and it roughly corresponds to the first page of the blog (still being written ). Thank you for your suggestions, Iâll add those if we missed some of them.
EDIT: Clearly, the question of whether to include âmodernâ is bikeshedding and isnât worth more than perhaps one or two minutesâ thought.
I agree that âJulia workflowsâ is boring, or lacks something.
Take 1. On the other hand âModern Julia xxxâ always reminds of the Modern Perl stuff from several years ago that was meant in part to promote the idea that Perl is as real or as good a language as Python, which wasnât really true. In any case it didnât work. This isnât a rational take, itâs more an involuntary association.
Take 2. âModern Python âŠâ is all over the place, too. And you see old, non-optimal, Python practices persisting. If I were an intermediate Python programmer (maybe I am :)) I might hope to find an article with a title like this that was to the point and useful (good luck with that); in principle you might find one that was useful, in particular because of all of the out of date info on the web.
Likewise, Julia has changed, and many people (myself included) would like to know of some state of the art workflows.
Take 3. âModern PythonâŠâ or (âModern YYYâ) is a marketing tactic to make your article stand out. Something thatâs necessary because of the volume of Python stuff. In fact, if you search, youâll find itâs not good enough. You need to read the series on âHypermodern Pythonâ. I donât find a âsupermodernâ version. The author could be a francophone. Several years ago at least, in french it was common to jump right over âsuperâ directly to âhyperâ.
I would like to replace jupyter notebook with jupyterlab (version 4+) . Should we also discourage using vscode-jupyter? Iâ ve seen a few issues related to using vscode-jupyter.
Oh, I experience it quite often, that languages ship compilers, editor extensions, and all of that.
And only separate, and not as part of a reproducible dev container and similar.
My Julia plugin for VSCode - same as that for F#, as an example â does fail at some parts (it shows no syntax errors at all) and I ask myself why we donât ship complete packages, that are reproducible.
Sounds like a good idea. Wanna open an issue?
To be honest, I find Jupyter via VSCode to be by far the best way to start with Julia.
Everything else has performance issues, that kills the fun out of experimentation.
Due to the fact, that Jupyter kernels are evaluated piece by piece, and because I always clearly see, which functions/variables are still loaded, there is much less room for confusion and performance bottlenecks.
I would much rather fix the issues, then just dropping the platform.
FWIW, after struggling a bit with it, in fact this is all you need:
I even showcase this to new users, easy as it is, given these simple steps.
What steps should the Julia community take to bring Julia to the next level of popularity? - #577 by JackaChou another example of bad vscode-jupyter . You should try jupyterlab 4 instead.
When it comes to «modern workflows», Dev Containers should be mentioned. E.g.
Update: the second page of the blog (on package creation and sharing) is complete!
This is excellent! Thanks for the package I feel this should be somewhere on the official website if not already?