Julia within org-mode: what about a new ob-julia?

Hi,

I’m very new to Julia (and just beginning to learn this language). I’m currently mostly an R user, which I use within Emacs using ESS and org-mode.

ESS has pretty good support for Julia, but I still have found no satisfying way to use Julia within org-mode. I read this thread about emacs-jupyter, but I simply did not manage to make it work for now. Furthermore, I would be more enthusiastic for a simple and lightweight elisp solution, as advocated in this (old) thread. (This would be closer to my current org-babel + R workflow.)

There used to be an old ob-julia package for that, but it is now orphaned and broken. Several individual forks do exist, e.g. here or here, but none of them seems to be totally okay for the latest versions of Julia.

So, are there here some folks who would also like to resuscitate this package ob-julia in a common, “official” and durable effort? :wink: I’m not a great emacs lisp programmer but I do have some notions and I would be glad to be involved in this effort — I’m just not good enough in lisp to do that alone.

Thanks, and see you!

4 Likes

There could be another way - create an emacs-jupyter alternative but based on Pluto.jl.

2 Likes

This might be slightly easier to create (?) but probably harder to maintain (and less safe) in the long run. I’m not sure that relying on sophisticated tools such as Pluto or Jupyter is actually the best way to bring back Julia into org-mode. A very light and simple solution, similar to the ob-R exporter for the R language or the good old ob-julia, would probably do the job for most people without introducing complex dependencies. But since I know very little about both Julia and Elisp, I’m clearly not in the best position to figure out what could be the best option :wink:

1 Like

I don’t use it myself, but my understanding was that https://git.nixo.xyz/nixo/ob-julia was supposed to be relatively functional. If you have specific issues with it, it’s probably worth opening an issue there.

2 Likes

Unfortunately, https://git.nixo.xyz/nixo/ob-julia does not have a MELPA recipe (https://github.com/melpa/melpa/blob/master/README.md#recipe-format).

but https://git.nixo.xyz/nixo/ob-julia does not have a MELPA package so you cannot install it using the list-packages interface.

Sorry for the now triple post, but when I post something, I don’t see it show up. What is going on here?

Now editing my post. I posted three times and the above sentence is the only one that showed up. Is there a bug in the web site?

Apologies, your post got flagged by the spam detector (posts with lots of external links by new users often get flagged). I have now restored it.

Welcome to discourse!

1 Like

Thank you. Good to know there is an active spam detector.

New users can’t post more than 2 links. Makes sense.

Here is a translation table to bypass that limit for this info:

git.nixo.xyz == h t t p s : / / g i t . n i x o . x y z / n i x o / o b - j u l i a
gjkerns ==      h t t p s : / / g i t h u b . c o m / g j k e r n s / o b - j u l i a / b l o b / m a s t e r / o b - j u l i a - d o c . o r g # r e s u l t s - v a l u e 

For what it’s worth, I took quite a bit of time trying to install the
“ob-julia” inside git.nixo.xyz but ran into a conflict whereby there
are two ob-julia.el’s in the system if you do that, and that is how I
discovered that gjkerns was already installed into my setup!

The one provided by the org-plus-contrib package is loaded first, and
the ob-julia.el from inside git.nixo.xyz never got found in the load
path.

The one coming in by way of org-plus-contrib looks to be the same
“old” package from looking at the header in its ob-julia.el file, at
.emacs.d/elpa/org-plus-contrib-20200914/ob-julia.el, since it contains
this at the top:

;; See https://github.com/gjkerns/ob-julia/blob/master/ob-julia-doc.org
;; for detailed instructions on how to get started.  The git repository
;; contains more documentation: git://github.com/gjkerns/ob-julia.git

It could be argued that the one coming from org-plus-contrib should be
removed, and replaced with the one from git.nixo.xyz, but I cannot
tell if the latter is better since I cannot give up on using the
org-plus-contrib package since it contains things I rely upon already
in my setup that I cannot disturb just to experiment with Julia+Org
integration.

Testing the gjkerns version of ob-julia.el shows that using :results output works:

#+NAME: with-results-output
#+BEGIN_SRC julia :results output
  rand(2,3)
#+END_SRC

#+RESULTS: with-results-output
: "somefile.org"
: 2×3 Array{Float64,2}:
:  0.471239   0.297008  0.663586
:  0.0963117  0.585604  0.642755

but using :results value this gives no output:

#+NAME: with-results-value
#+BEGIN_SRC julia :results value
  rand(2,3)
#+END_SRC

#+RESULTS: with-results-value

So, as found before, the one at gjkerns is broken indeed, but this is
proof of it.

2 Likes

I think posts will just get put in the moderator queue: usually mods are pretty quick to approve valid posts, so no encoding should be necessary.