UP | HOME

Support via Liberapay

Julia Code Blocks in Babel

Babel support for Julia

Introduction

The documentation for Julia describes it as "a flexible dynamic language, appropriate for scientific and numerical computing, with performance comparable to traditional statically-typed languages … [that] features optional typing, multiple dispatch, and good performance, achieved using type inference and just-in-time compilation, implemented using LLVM."

Julia code blocks can be used in Org to define functions, filter and analyze data, create graphics and figures, and produce reproducible research papers.

Requirements and Setup

Julia code blocks in Org require a working Julia installation. Julia is available for FreeBSD on ARM, Linux on ARM or x86, macOS on ARM or x86, and Windows. See below for further requirements for sessions with Julia.

There is julia-mode in Melpa for Emacs. It requires Emacs Speaks Statistics (ESS).

Org mode can be configured to use Julia by creating an entry for it in org-babel-load-languages. Typically, org-babel-load-languages will contain many entries. The example below omits other languages.

(org-babel-do-load-languages
 'org-babel-load-languages
 '((julia . t)))

Babel Features for Julia Code Blocks

Header Arguments

There are no Julia-specific default header arguments.

Babel support for Julia defines two Julia-specific header arguments, :width and :horizontal.

Sessions

Sessions are fully supported through ESS. Two Julia packages must be added to the Julia configuration to enable sessions to work: DataFrames and CSV.

Sessions can be used to define functions, set up variables, and share code between source blocks.

Examples of Use

Here is the standard Hello World example in Julia.

In the Org mode buffer:

#+begin_src julia :results output
print("Hello World!")
#+end_src

HTML export of the code block:

print("Hello World!")

HTML export of the result:

Hello World!

Documentation from the orgmode.org/worg/ website (either in its HTML format or in its Org format) is licensed under the GNU Free Documentation License version 1.3 or later. The code examples and css stylesheets are licensed under the GNU General Public License v3 or later.