Finding perfect Julia IDE or a text editor is a matter of preference. There are quite a few options available.
In my first blog post about Julia, I listed all the options and mentioned that I will be using VS Code as the Julia IDE and Pluto interactive notebooks as my main tools.
To keep things easy, for now, I decided to work with Julia using either Pluto interactive notebooks or VS Code with Julia extension, depending on the project. I am going to go over the installation of both options in detail in this post.Me in May 2021
It turns out, it was silly to decide on this before actually spending some time coding and getting a feel for each tool, to develop a preference and polish the workflow.
What I use Julia for.
First, I’d like to give you some background, why I decided to learn JuliaLang. I began to learn Julia when I started my undergraduate summer research internship in May 2021 in one of the labs in our Physics department. Some projects this research group was working on were using Julia Language to perform complex and lengthy computations and simulations. Some computations take weeks to finish. Later, we will be using Julia to utilize our GPU hardware to increase the computational power even more.
These are all the areas where Julia shines!
Jupyter Notebook vs VS Code.
When I first started learning Julia, I was not sure what IDE or text editor to use. There seemed to be so many options. It was difficult to settle on something particular and use it as an exclusive option.
As I began working on a project (this is essentially how I learned the language – learning by doing), I needed to collaborate with other people. We worked on the same code. I initially was responsible for making it parallel and created two versions: multithreaded and distributed. Later I transitioned to work on the visualization part of the simulation data. Folks were using Jupyter Notebook to write their code, and since the project was joint, so did I.
At that time I was still trying to go back and forth between using Jupyter and VS Code. I should mention that I never used Jupyter before starting to learn Julia. Coming from coding in Python and MATLAB I was more accustomed to working with IDEs rather than text editors.
And so VS Code felt familiar. It also provided a better errors description and had shown in which line of code the error was. My workflow was not very efficient. I would start writing in Jupyter when I get the error messages, If I could not understand which line of code raises this error, I would copy the code and paste it into the VS Code to try and debug it. After fixing things, I would copy the script back to Jupyter. Amateurish indeed!
VS Code and the integrated REPL terminal.
VS Code code pop-up documentation on hover is super convenient! TAB completion works great too. And it is extremely convenient having two terminal windows open within the same editor window: Julia REPL on the bottom left and the regular
zsh (or whatever you use) on the bottom right.
I still use both VS Code and Jupyter. I’m hoping to switch to VS Code primarily one day. For some quick interactive checks of parts of the code, I could then use integrated Julia REPL. There is even a number of keyboard shortcuts available to execute parts of the code from the editor in Julia REPL. This is described very well in this post.
Rediscovering Pluto Notebooks
So, what about Pluto? Initially, I did not like it. I was not fond of the syntax highlighting in particular and the background colour of the notebook looks outdated to me. I still wish there was an easy way to change colour themes, light and dark ones alike. Though the official documentation says that it’s possible to change a theme, I have not been able to do so yet. At least not for any light-coloured theme. I was also missing a tools bar on the top of the notebook.
Over time, I developed a strong preference to write everything in Jupyter. I like the interactivity, to be able to check each line of code right away. I even like the standard colour theme a lot! It is clean and modern, and it uses the Julia Language Logo colour theme, which I like so much;)
But then, some of the people on Twitter, that I follow and respect a lot, began to talk about how they love Pluto and its many useful functionalities that Jupyter does not have. At the same time, I began working on the visualization part of my project. I was constantly being annoyed by how small the plots were appearing in Jupyter:
It made it not practical to check something quickly when plotting. I started to search for alternatives. VS Code is not interactive enough and plots in the plotting window were also not large enough to make out the little details in plotting when I would make some changes. I am aware of the option to use
savefig() function to save the plots as an image, but again, the whole point is to be able to check the output quickly while writing the code, before saving the final version of the plots.
As a last resort, I decided to give Pluto another try. Surprise, surprise! The plots were showing up within the notebook with the perfect size! Check this out.
Another cool feature is to be able to make the plots themselves interactive. Changing a few parameters with the slider would change the plot in real-time.
You can find the code file on my GitHub profile here.
The magic of
The second biggest reason I like using Pluto is the interactive data cells. Say, if you have a function that outputs a multi-dimensional array, it’s very easy to follow the structure of the resulting data array.
Interactive Data Cells
I also enjoy the feature exclusive to the Pluto notebooks, which sets the namespace for the notebook to global. This means, changing a variable in one cell will automatically update it in the other cells. I.e. Pluto tracks dependencies between cells. Sometimes this may interfere with the quick exploration of parameters, as it will automatically re-run all the cells, dependent on the cell that you would like to make a change to. If you do not want the other cells to run again, there is now a new feature added recently, that allows disabling some of the cells, which will prevent them from running.
Another super convenient feature is the live documentation, which can be seen in the video above on the bottom right. Works very much the same as the documentation pop-up on hover in the VS Code.
There have been claims from the Julia community members, that Pluto is being developed with the goal of becoming a self-sufficient tool for production.
And lastly, maybe not necessarily related to the programming as such, but look at this beautiful blog post created with a Pluto Notebook!
The Julia REPL
Let’s not forget about the Julia REPL!
I still use it all the time when I quickly need to verify something. For example, testing how certain functions work, quickly constructing multi-dimensional arrays of needed size and structure. Doing some checks like this sometimes interferes with the namespace of the Puto notebook and throws errors, therefore I like using the REPL for these tasks.
My workflow is constantly changing. More and more I find myself using Pluto to write my Julia programs. Who knows, maybe one day, I’ll use it exclusively.
For now, my preferred Julia IDEs/editors are (in no particular order):
- Pluto Notebooks
- Jupyter Notebooks
- Julia REPL
- VS Code with Julia extension.