About Julia and Lisp

Being amateur Common Lisp user I often find part of Julia quite familiar. Definitely some very good Lisp programmers are here and I will be glad to hear some of them reflection on Lisp family and Julia.


Check out julia --lisp and Meta.show_sexpr if you haven’t found them yet. :slight_smile:


Can you elaborate on what those things are?

when I do ?Meta.show_sexpr it says there’s no docs. Is this just breakage on my install?

Other than just for kicks, is there a reason for femtolisp to be embedded in Julia?

julia --lisp is just a little easter egg because it’s easily possible — Julia uses femtolisp to implement its parser. It can be handy if you’re hacking on the parser.

Meta.show_sexpr gains its documentation in version 1.2. https://docs.julialang.org/en/v1.3-dev/base/base/#Base.Meta.show_sexpr

1 Like

In the master branch of the docs, we now have



I’ve just recently been looking at rewriting some of the internal lisp code from flisp into julia. It’s kind of bittersweet to move on from that heritage but it will make the compiler more accessible and easier to modify if it’s written in one less language.

Kind of related to that, I’ve just updated https://github.com/swadey/LispSyntax.jl to bring it to julia 1.0 and you might find that package entertaining :slight_smile:

It’s worth noting that LispSyntax.jl is a simple and naive source rewriting system so it’s actually a lispy veneer over Julia semantics; probably more of a toy at this stage than something useful. Even so, the reason it gets away with being simple is that the lisp syntactic forms are really structurally similar to julia syntax.


I was under the impression that only the parser was written in FemtoLisp.

AFAIK it is especially well-adapted to parsing (compared to Julia), and not really the bottleneck at the moment, which is probably why changing this is not a priority.

1 Like

It’s not only the parser but also syntax lowering; this comprises several compiler passes in its own right; perhaps six or so, depending on how you count.


You are right, but I tend to lump these transformations with parsing. In any case, I think that FemtoLisp (which is a very neat and optimized Lisp implementation/dialect) is better suited to working with ASTs than Julia. Whether rewriting in Julia improves anything is not clear ex ante and needs to be demonstrated.

I think that using the built-in FemtoLisp for parsing and the influence of Lisp in Julia’s design are more or less orthogonal questions. I am not sure why FemtoLisp is brought up in this context.

1 Like

Well, flisp was (one of?) Jeff’s previous compiler projects. I’ve read a portion of the Julia and flisp internals and I think it’s interesting to see some elements of stylistic continuity between the two projects.


I guess you would have to ask Jeff for the details about this. IMO there is little overlap between the two that is specific to the influence of one language or person: the intersection of Julia with Lisp is functional programming (which becoming kind of standard on, not only because of Lisp), and multimethods (which AFAIK FemtoLisp does not have).

Instead of tracing Julia’s roots to this and that, I find it more fascinating to observe how the language explored ideas which are kind of a consequence of its design but were (partially) unforeseen or unintended. Julia, in its current state, incorporates a lot of great ideas from other languages, but at the same time has a lot of unprecedented ingredients and synergies.

1 Like

You forget homoiconic macro programming.

1 Like

I think that this is stretching the concept of homoiconic quite a bit: while the AST representations are Julia data structures, they are not used anywhere else in the language.

Cf Common Lisp ASTs which are themselves lists, which is the basic type of the language.

1 Like

I’m not an expert, just a beginner, but at first glance it seems like an Expr is just a structure, and structures are used everywhere.

1 Like

I think of homoiconicity as a continuum: the ideal is when you manipulate the AST with the same tools you use for most other things. Technically this is of course true for Expr (as you noted, it’s a struct), but it does not approach the integration of, say, CL.

In any case, I don’t think this matters much though, and Julia gained something very important in exchange (infix syntax).

That’s not an accident. Jeff does implore us to avoid Angering the Lisp Gods. :slight_smile:

As another point, the fact that nearly everything in Julia is an expression that evaluates to a value (as opposed to a statement) is also quite lispy.


Here’s what I wrote on the subject some time ago:

In particular I like Kent Pitman’s point that what’s important is not the ability to represent code as a data structure (which any language can do), but the willingness to do so and having a “common, agreed-upon choice so that there can be a rich community of program-manipulating programs that ‘do trade’ in this common representation.” Which seems to me to clearly apply to Julia. So Julia’s facility for metaprogramming is not so much a feature of the language per se as it is a feature of the tooling and the community. Of course, having syntax for quasiquotation and macros helps with that since they make metaprogramming easier to do and use.


The Reduce.jl symbolic rewriter I made is also a “lispy” transpiler, if anyone is interested. The REDUCE programming language is implemented on top of its own version of lisp.

The package translates between julia AST and REDUCE ast, and does not implement the full underlying lisp dialect, which would be needed to make a full native port of REDUCE to Julia. With a full transpiler of the underlying lisp, you could read in the computer algebra source code and turn it into pure Julia. In fact, that is how the REDUCE source is designed to compiled.

It was a real joy (and a lot of painful but fun debugging) to make this parser work between the two languages, but it really helped me learn the Julia AST metaprogramming concept very well.


Thank you, this looks great.

I understood that your package works with the CSL version of REDUCE. Given that the CSL interpreter used by REDUCE is said to be not well-documented (see paragraph “CSL documentation”) it seems like a big task to implement the full underlying Lisp dialect, if anyone would want to do it.

Has it been considered to implement some very elementary pure computer algebra directly in FemtoLisp for use in Julia? By “elementary” I am referring to the level of symbolic algebra presented for illustrative purposes in SICP.

For me, this would primarily be an educational exercise, with the added benefit of producing a result - even if just for personal use - that is directly usable in a mainstream language like Julia without requiring third-party software. (This is not to criticize your work in any way. On the contrary, I find it motivating. I merely think that the above “exercise” could give additional insight.)

Returning to the topic at hand, thanks for starting this thread. Julia’s Lisp background (and some constructive criticism by @jlperla that I received elsewhere online) have to some extent guided my decision to give Julia a try.

Julia code can’t directly call femtolisp code: https://github.com/JuliaLang/julia/issues/18029