Julia

After 14 years of developing software primarily in Common Lisp, Michael Fiano gave Julia a try.

Eventually, he switched to using Julia as his main programming language [1].

From 2008 to 2022, I was writing my code exclusively in Common Lisp, every day. I was able to get my ideas into working code quickly and effectively.

– Michael Fiano [1:1]

Julia is gaining active users in the community of Physics researchers, and:

Julia has the potential to become the major programming language in numerical physics.

– Carsten Bauer [2]

[Julia] looks like Python, feels like Lisp, and runs like C++ or Fortran.

– Jane Herriman [3]

Installing Julia

Try brew install julia (MacOS). Alternatively, go to https://julialang.org/downloads/.

Run the REPL: julia.

To be able to run this book as notebooks, install Jupyter: pip3 install --user jupyter.

Calling Python functions

Say you have an existing codebase written in Python. How to call a function from a .py file?

As wrapping a Python library using PyCall is very easy, the most important Python libraries have been already wrapped in Julia, like Pandas in Pandas.jl, Scikit-learn in ScikitLearn.jl, etc.

– Antonello Lobianco [4]

An example, citing [4:1], would be:

using PyCall

py"""
def sumMyArgs (i, j):
  return i+j
def getNElement (n):
  a = [0,1,2,3,4,5,6,7,8,9]
  return a[n]
"""

a = py"sumMyArgs"(3,4)          # 7
b = py"sumMyArgs"([3,4],[5,6])  # [8,10]
typeof(b)                       # Array{Int64,1}
c = py"sumMyArgs"([3,4],5)      # [8,9]
d = py"getNElement"(1)          # 1

Further reading

  1. Discussion of [1:2]: https://news.ycombinator.com/item?id=32745318

  1. https://mfiano.net/posts/2022-09-04-from-common-lisp-to-julia/ ↩︎ ↩︎ ↩︎

  2. https://juliacon.org/2018/talks_workshops/35/ ↩︎

  3. https://juliaacademy.com/p/intro-to-julia ↩︎

  4. https://stackoverflow.com/questions/66648841/how-to-call-a-python-function-from-a-julia-program ↩︎ ↩︎