Discussion on improving Julia REPL for beginners

I wanted to start a discussion on some features that I think it would be nice to have in the Julia REPL by default, and some features that exist in ipython already.

  1. Convey difference visually between input prompt, expression’s return value and stdout

For example, here is Julia’s REPL when you run 1 + 1 and println(1 + 1).

Here’s the same thing with ipython.

With ipython, there’s a difference between what is stdout and what is the returned value of the expression evaluated. I’ve found when teaching beginners how to code, this can a big source of frustration or confusion.

  1. Having zsh or fish shell like completions.

You’ll notice in the screenshot above, when I type p in the ipython REPL the REPL hints that the history contains a expression that begins with the same character. In zsh or fish or ipython, I can hit the Right arrow key and this populates the prompt with that expression.

  1. TAB and S-TAB for autocompletion cycling

In the default Julia REPL, hitting TAB first completes to the longest common completion, and then further presses only prints the same completions over and over again. When there are a large number of completions, this results in the terminal history being polluted. It would be nice to cycle through options the way ipython does.

  1. Syntax highlighting

This can be achieved using OhMyREPL but it would be nice to get this by default.

I personally would like to see a better REPL out of the box, or at least an alternative REPL that one could alias to.

Are there other features one would like to see in a Julia REPL? I wanted to start a discussion to brainstorm some ideas here. I’m interested in making this happen and would be willing to work on it too.

For example, one feature that I’d like is if I ever run julia in a folder where there’s a Project.toml file, I’d like the julia> prompt to change to julia * > or something like that. In almost all instances, if I’m running julia in a folder where there’s a Project.toml, I’d imagine the user would want the environment activated by default or at least warn that there is an environment to be activated in that folder.

6 Likes

Most of the advanced users here tend to copy REPL code with the julia> prompt and the output:

julia> x = 1
1

julia> sin(x)
0.8414709848078965

This is a bit annoying to read and to cut and paste. It would be nice to have in the REPL menu a copy mode that would just copy the input after the prompt:

x = 1
sin(x)
4 Likes

You can also do this with OhMyREPL:

8 Likes

See Fish or ipython-like completion with tab key by bicycle1885 · Pull Request #43838 · JuliaLang/julia · GitHub

3 Likes

I added an easy way to get Ipython prompts with OMR: add an easy way to get Ipython prompts by KristofferC · Pull Request #270 · KristofferC/OhMyREPL.jl · GitHub

Screenshot 2022-06-17 at 22.42.59

6 Likes

Why would that be more useful? You can just paste that snippet into the REPL.

I would like to paste it into VS Code instead, run it from there and, if I like it, keep it for the future as a repository of good ideas.

And sorry, how do you paste it to the REPL with the prompt and the whole shebang?

Just paste it. Might not work on Windows.

Thanks, it doesn’t work on my Win 11 installation. Are there any Windows Julia users who have had success?

This is another feature I find myself using in ipython from time to time.

Is this something that could easily be added to OhMyREPL?

Yes, but that means you will hold on to all objects that was returned and they will not get GCed. Does Ipython really do that?

Yeah it seems like it does:

That is available in IJulia as well

1 Like