Julia coding guidelines
Our recommendations for creating and maintaining reliable scientific software in Julia.
Good default choices
- Version control: GitHub
- de facto standard for open source software
- provides all necessary tools for developing software in a team
- includes Continuous Integration pipelines for continuous testing
- Continuous integration: GitHub actions
- comes integrated into GitHub already
- large template library from which your workflow can be put together
- Testing framework: Test.jl
- standard library option for unit tests, rough analogon to Python’s UnitTest library
- Documentation: Documenter.jl
- Markdown based
- includes doctests for code examples
- can be seen as an analogon to Sphinx
- Profiling:
- Profile.jl:
- Part of the Julia standard library.
- Can be used to profile allocations and CPU - time
- various visualizations available via separate packages (ProfileView.jl, FlameGraphs.jl, ProfileVega.jl)
- BenchmarkTools.jl: For more high-level, statistical information about execution time.
- Profile.jl:
Tooling
Julia is a relatively young language with a smaller community than, say, Python, C++ or Matlab. As such, the selection of tools is a bit more limited. Some suggestions:
- IDE/Code Editor:
- Visual Studio Code: Free. The de-facto standard in the community. Provides support for linting, test discovery, formatting and more. Recommended way to go.
- Juno: Free. Build on top of Atom. Atom is no longer supported by Microsoft/GitHub, and Juno is only maintained and wont receive new features. Only consider this if you already have an Atom-based workflow and are unwilling to switch.
- Sublime Text: Free, but will ocassionally ask you to buy it. Syntax highlighing for Julia is available, but support for other functions is less developed than in the other two.
- Code Formatting:
- automatic formatting is available via VSCode’s Julia plugin or through Juno.
- Linting:
- linting is available via VSCode’s Julia plugin or through Juno.
Recommended libraries
- Arrays and vectors (numpy analogon):
- standard library core contains classes for dense, n-dimensional arrays analogous to numpy-arrays.
- SparseArrays.jl: Part of the standard library. Supports sparse vectors and matrices.
- Tensors.jl and TensorOperations.jl: For higher-order-Tensor math.
- Linear Algebra:
- LinearAlgebra.jl: Standard library module for linear algebra operations like matric traces, in verse, multiplication and so on.
- Data analysis and data transformation:
- DataFrames.jl and DataFramesMeta.jl for tabular data. Julia’s analog to Pandas known from Python. Use this for higher performance.
- Query.jl Apply common data-analysis workflows like split-apply-combine, filter etc to almost any iterable Julia datastructure. Useful when working with data that’s available in various different formats.
- Data input/output and storage:
- Visualization:
- Plots.jl: Julia Frontend with a homogeneous interface for various well known plotting packages like matplotlib, plotly or GR.
- Makie.jl: Feature-complete plotting package in pure Julia.
- AlgebraOfGraphics.jl Provides support for the grammar-of-graphics paradigm based on Makie.jl .
- VegaLite.jl: Provides access to VegaLite from Julia, particularly useful for making interactive graphics.
- Machine Learning/Deep Learning:
- SciKitLearn.jl for having access to the python based scikit-learn library in Julia.
- Flux.jl for deep learning applications.
Have a look at the JuliaHub package database to find other packages for your use case.
Style guides and best-practices:
Much has already been written about how to write good Julia code which needs not be repeated here. Here are some starting points: