Exploring shared philosophies in Julia and Emacs
Gabriele Bozzola (he/him/his) - GitHub: @sbozzolo Website: https://sbozzolo.github.io LinkedIn: gabrielebozzola
Format: 10-min talk ; Q&A: BigBlueButton conference room
Status: TO_CAPTION_QA
Talk
Q&A
00:00.089 Q: Do you have any suggestions for interactive debugging of Julia code in Emacs? 01:08.286 Q: Can you call out something that Julia has that Emacs does not, and which could benefit Emacs? 02:36.797 Q: Is there a way to use lisp syntax with Julia, like hy for python or lisp flavoured erlang? 03:51.168 Q: Have you tried the Julia Snail package for Emacs? It tries to be like SLY/SLIME for Common Lisp. 04:22.940 Q: Is there a data inspector for a Julia REPL available that you can use in Emacs? 05:24.443 Q: Have you tried literate programming Julia (using Org babel or some other means) in Emacs?
Description
While seemingly disparate, the Julia programming language and Emacs share a surprising kinship. This talk delves into the common design principles and philosophies that unite these powerful tools, focusing on their shared emphasis on extensibility, customization, and interactive development. I'll explore how both Julia and Emacs empower users to tailor their experience through powerful metaprogramming and a rich ecosystem of extensions. I'll discuss the REPL-driven workflows that foster exploration and experimentation in both environments. Furthermore, I'll examine how their active and passionate communities drive innovation.
Discussion
Questions and answers
- Q: As someone who uses Julia, Emacs and Julia in Emacs, I feel
like Julia's integration with Emacs is lacking. I haven't found
any way to debug Julia code that works as well as edebug for elisp,
SLY/SLIME for common lisp, or gdb for many other languages (with gud
or realgud). Both Debugger.jl and Infiltrator.jl are difficult to
use interactively. Do you have any suggestions for interactive
debugging of Julia code in Emacs? (Adding to my question: Do other
editors do a better job of interactive Julia debugging?)
- A: GB: Debbuger.jl and Infiltrator.jl are the main debugging tools available in Julia at the moment. Both of them are not great (yet) and can use some work. Debugger is going to see major performance improvements in future releases thanks to work in the core language. Unfortunately, I don't see anything better for interactive debugging that is avilable now or in the near future. Most of the julia community is clustered around VS code, but the situation is not better
- Q: Can you call out something that Julia has that Emacs does not, and
which could benefit Emacs?
- A: GB: The Julia community is active and more tightly knit than other communities (e.g., the Python one), JuliaCon is an in-person event that brings people together. Emacs is also doing great in this.
- Q: Is there a way to use lisp syntax with Julia, like hy for python
or lisp flavoured erlang?
- A: Julia used to have a femtolisp interpreter built-into its REPL.
- A: GB: I am not aware, but it might be possible to write a package to do that.
- Q: Have you tried the Julia Snail package for Emacs? It tries to be
like SLY/SLIME for Common Lisp.
- A: GB: Yes, but I settled on julia-repl (with vterm). I didn't test julia-snail too much because I found julia-repl easier to setup and use the way I wished.
- Q: Along the same lines as question 1 -- is there a data inspector
for a Julia REPL available that you can use in Emacs?
- A: good mode, other good tooling; room for improvement in this area
- A: GB: No, I don't think anything of that sort is available
- Q: Have you tried literate programming Julia (using Org babel or
some other means) in Emacs?
- A: Literate programming in Julia: Pluto (Jupyter-style, in the browser), emacs-jupyter (in Emacs)
Notes
- Great, now I wanna learn Julia...
- Highly recommend it. Especially if you do any sort of scientific computing. It's an amazing language
- Lots of things to like. Perhaps the most Dylan-like modern language?
- Got me interested in Julia, great talk
- Sooooo emacs written in julia?
- Amazing, thank you
- M-x clap
- Great talk [13:10]
- Thank you for the talk! \o/
- Thank you!
- I've been so happy ditching python for julia for all my scientific research needs
- Some of these features, like the interactivity and the decompiler reminds of Common Lisp
- One of Julia's best features (multiple dispatch) was inspired by
Common Lisp's defgeneric/defmethod.
- I would also add that Julia takes the idea further than Common Lisp ever did, because you can't opt-out of being generic in Julia, so it's everywhere and used pervasively.
- In Common Lisp, you had to opt-in, so it wasn't as apparent how powerful this way of organizing code could be.
- Got me interested in Julia, great talk
- Sooooo emacs written in julia?
- akirakyle: First Guile Scheme (re: Robin's talk, next), then Julia!
- Yes
- So julia is like using CLOS everywhere?
- Sort of, but with the llvm runnig full optimized native code generation for every argument type a function is called with
- also julia --lisp is built in!
- emacs-jupyter works with julia quite well btw
- org-babel also works well
- def looking forward to the julia talk
- It would be great to integrate pluto with emacs, but currently very hard to figure out best way to do so
- That would be interesting for sure
- Pluto.run(auto_reload_from_file=true) is the best right now
- Problem is pluto is very tied to browser
- I dislike leaving emacs for things
- But Pluto is a great tool
- Same, I suppose one could alternatively say the problem is emacs can't be very easily tied to the browser
- As opposed to vscode where such integrations are easier
- Although, on the other hand, I am happy emacs isn't tied to a browser
- It's better in general
- Yes it shouldn't be tied to a browser, but it also would be very helpful for emacs to have better access to rendering content that requires a dom/js environment in an emacs window
Transcript
Hello, I'm very excited to tell you about shared philosophies between the Julia programming language and Emacs. While Julia and Emacs might look like different pieces of software, I think there is profound commonalities between the two. Let's start by introducing Julia. Julia is a high-level dynamic programming language. Julia is free and open source software and is used primarily for scientific computing. The reason Julia is used for scientific computing is that while Julia is high level and has a syntax that looks like Python or MATLAB, Julia can be high performance. I use it to develop climate models that run on hundreds of GPUs. Models that are traditionally developed with C, C++, or Fortran. But how is this possible? How can Julia be high performance but also high level at the same time? What makes Julia, Julia? Well, what makes Julia, Julia is the idea of multiple dispatch. Multiple dispatch is the concept where a function call is resolved by looking at the types of every single argument involved. So, let's explore this with this example. Here, I define a function add that takes two objects and sums them together. And I call add with two different types. First with just integers and second with floats. So, let's look at what this produces. Here is the output of add in Julia. So, first we have add, a function with one method. I'm going to explain this in a second. And then we have our return values 12 and 12.0. What we cannot see here is that Julia has specialized code for the two different function calls. For integers and for floating points. Let's make this more explicit by specifically providing a new method for the case with floating point. So here, now I have an add function specifically for floating point. Instead of taking A + B, this returns A exponent B. Let's call this. And what we can see here is that now we have two methods. So, we add a new method to the same function. This is a method that is specifically for floating points. And instead of having the value 12, we have 100. And this is where the trick lies. Julia compiles the most, um, specialized version that can be compiled. So, a version with integers, a version with floats. And in this, compiling is an actual compilation with LLVM with optimization and so on. This is not just ahead of time compilation. Soon as the Julia knows the type, a function is compiled if it's not compiled already and then it's used. When types are stable and well inferred, this can lead to code that is as performant or comparable to C and Fortran. So, this is what makes Julia, Julia. Multiple dispatch with just ahead of time compilation of highly efficient code. So now, what makes Emacs, Emacs? Well, in my opinion, what makes Emacs, Emacs is interactivity, extensibility, and community. And I claim that Julia has the same three. Interactivity, extensibility, and community are three key pillars for Julia. More specifically, Julia encourages a REPL-driven, introspective, interactive workflow. It's largely open to extension and modification to the point that most of Julia is written in Julia. And Julia has a thriving and welcoming community with lots of packages. So, let me showcase a little bit of this REPL-driven, introspective, interactive workflow with the hope that commonalities with Emacs will emerge naturally. So, let's start by opening a Julia REPL. Here, I have a Julia REPL. Let me give you a tour of the Julia REPL. So, the REPL comes with lots of useful features, from a shell to a package manager. So, for example, let's add the random package. Um, yeah, I have the random package. I can look at what's inside. We have the statistics with random in this particular environment. Environments are fully declarative. So here we have the dependencies of this environment. And I can explore in this manifest, the specific versions that are used. So we have a shell, we have a package manager, and then we have a very powerful help system. So, for example, I can ask for help for length. And here we can see we have, well, the help for length. Lots of information about how to call length, the expected return values, examples. And now you can probably start seeing that this is not that different from calling length. So this is the output for length, or for help for length in in Emacs. So we have help, and we can do more. We can even look at the source code for length. So now, what we can see here is that now, well, we cannot see because it's zoomed in because the font size is huge, but in this page here, we can see the implementation of length. It's this line here in the middle, or these few lines here in the middle. And as you... Let's do this again. As we can see here at the bottom, what we are looking at, this is the source code of Julia. We can change this. There's even a macro edit if you want to change its length. And yeah, I use the word macro. Julia supports metaprogramming. And actually metaprogramming is one of the key features in Julia. It's used extensively in the core, but it's also used extensively in packages, both to extend the Julia ecosystem and functionalities, but also to develop full domain specific languages. Some of the useful macros are, well, I don't know, like time. Here, we have a built-in basic performance tool in in in Julia. And I want to showcase more introspection, macros. But for that, I'm going to do it slightly different. I'm going to open a file example.jl where I define a function, or our function add, there was an asterisk and I will go back to that in a second. So now, I am going to include this this file, and I can call my function add, one and two, and we get three. And now, what I can do is this. I can look at what code gets compiled when I call my when I call 1 + 2. And here, now we can see that there is some integer stuff. But if I make this floating point, now the compiled code changes. Now, maybe assembly code is a little bit too hard to read, so I can look at the LLVM IR representation. In this case we can see that there is promotion. The promotion will probably go away if I make everything float. So this we have F add, floating point add for a double, but we can also look at the Julia lowered representation after the abstract syntax tree is produced. The reason I put this in a file is because now what I can do is I can change this. And now, one and two will be two. So this to me is very reminiscent of how I work in Emacs, where there is a global state that I can access and modify any time with no restrictions. And this happens in in Julia too. Typically, we don't want to modify functions that are in other packages or they are in base, but we can do that. For example, I can change what is plus for integers. And if I change with this plus and make it so that any two integers return zero, well, I can do this. This will break Julia because, well, Julia is built in Julia. So if we break this, well, nothing will work. But I can do that. This to me is one of the signs of the powerful, introspective, and powerful interactive type of workflows that Julia enables. Finally, I want to talk about the general registry. This is the equivalent of Melpa. It comes with with Julia. But this is very akin to Melpa. It's built upon Git essentially. It's collaborative, as relies heavily on GitHub, GitLab. It's heavily automated. And comes with lots and lots of tools and packages. What's beautiful about all these tools and packages is that in the same way many of Emacs packages just play nicely with each other without any input from the developers, the same is true for Julia packages. The Julia packages are highly composable, so two developers can develop two distinct packages that end up playing nicely together for free because of the intrinsic structure, intrinsic way Julia objects are built. So, with all of this, I also want to mention that the community, in addition to have all these packages, is highly active, highly collaborative. The community meets regularly on places like Slack, as opposed to the Emacs community that I'd say maybe meets on Reddit. So, with all of this, I want to thank you for your attention, enjoy Emacs, and enjoy Julia.Q&A transcript (unedited)
Questions or comments? Please e-mail emacsconf-org-private@gnu.org