[Seeking feedback] Blog post about "Modern Julia workflows"?

I like that one. @jacobusmmsmit @hill ?

Efficient Julia workflows?
Less frustrating Julia workflows?

2 Likes

I wish they were “Simple” Julia workflows


3 Likes

Good Julia workflows

Smart Julia Workflows
Effective Julia Workflows

2 Likes

+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)
  1. Install juliaup in the Windows store. (Link directly to it, not the Github page)
  2. 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 type juliaup 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.
  3. 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.
  4. 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
  5. 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 ;).
  6. Probably the most important package is Revise.jl. Install it by typing ] to enter Pkg mode, and then type add 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.
  7. 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.

  1. 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, typing includet(“./test.jl”) won’t reflect changes if, say, we wanted a 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 called main:
function main()
	a = 1:10
	b = 2 .^ a
	return [a b]
end

main()
  1. You can check that Ctrl+A+Enter works as usual. (If the main() at the end were not there, you would only be defining a function called main, but not actually running it. To run it, type main() in the REPL.)

    • Now to check that Revise works, type includet(“./test.jl”). This will include the file and track any changes to main() as long as the REPL is running. Notice that nothing will be printed. That’s fine – in the REPL, type main() to display the result.
    • Change the second line to a = 1:20. Save the file.
    • Type main() again in the REPL. Revise detects that main() has changed, and the function now prints out the first 20 powers of 2.

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 :sweat_smile:). Thank you for your suggestions, I’ll add those if we missed some of them.

6 Likes

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”.

1 Like

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.

1 Like

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?

1 Like

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.

2 Likes

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!

18 Likes

This is excellent! Thanks for the package :slight_smile: I feel this should be somewhere on the official website if not already?

1 Like

It is already there:

7 Likes