Sunday, 4 January 2015

Julia (julialang) : Using EMACS

The hardest bit of learning any new language for me is always figuring out how to use it with EMACS.

EMACS is much harder to learn to use than any programming language.

If you're new to Julia, and following this to learn, then I very strongly advise that you use almost any other editor.

One way to use any editor to play with julia is to use the editor to create this file:

#!/usr/bin/julia

using Images
using DataFrames

img=imread("./trainResized/1.Bmp")
labels=readtable("./trainLabels.csv")

print("Hello!")
print(img)
print(labels)
and then to save it as firststeps.jl

You can then run it with

julia --load firststeps.jl

and it will execute the commands in the file, and then leave you at a julia prompt where you can continue to play.

As you get incantations working, then you can cut and paste them from the terminal where you are working back into an editor.

But I went through the pain of learning EMACS a long time ago, and it is the case that once you have got the hang of it, you feel completely crippled in any other editor. I mean, will your editor turn your nice new program into a snippet of syntax highlighted html than you can cut and paste into blogger?

So for my fellow middle-aged computer scientists, on Debian 8, install emacs itself, and ess (emacs speaks statistics, which used to be for R and S, but now includes Julia support)

Create the file as above, which should be nicely syntax highlighted since ess will recognise the .jl file as Julia and highlight accordingly, and then

M-x ess-load-file

Will start an inferior julia process, and then pass it the command : include("/home/john/julia/kaggle/firststeps.jl")

leaving you with a running interpreter in a buffer *julia*

You can then use C-Enter to paste single lines from firststeps.jl into the *julia* buffer.

It is not exactly SLIME, but it is a damned sight better than almost any other approach I can think of. If you're already an EMACS user.

As I say, if you're not, just don't. You will spend the next year of your life fighting EMACS and messing with configuration files.


1 comment: