Exploring shared philosophies in Julia and Emacs

Gabriele Bozzola (he/him/his) - GitHub: @sbozzolo Website: https://sbozzolo.github.io LinkedIn: gabrielebozzola

The following image shows where the talk is in the schedule for Sat 2024-12-07. Solid lines show talks with Q&A via BigBlueButton. Dashed lines show talks with Q&A via IRC or Etherpad.

Format: 10-min talk ; Q&A: BigBlueButton conference room https://media.emacsconf.org/2024/current/bbb-julia.html Etherpad: https://pad.emacsconf.org/2024-julia
Etherpad: https://pad.emacsconf.org/2024-julia
Discuss on IRC: #emacsconf-dev
Status: Q&A open for participation

Times in different time zones:
Saturday, Dec 7 2024, ~1:00 PM - 1:10 PM EST (US/Eastern)
which is the same as:
Saturday, Dec 7 2024, ~12:00 PM - 12:10 PM CST (US/Central)
Saturday, Dec 7 2024, ~11:00 AM - 11:10 AM MST (US/Mountain)
Saturday, Dec 7 2024, ~10:00 AM - 10:10 AM PST (US/Pacific)
Saturday, Dec 7 2024, ~6:00 PM - 6:10 PM UTC
Saturday, Dec 7 2024, ~7:00 PM - 7:10 PM CET (Europe/Paris)
Saturday, Dec 7 2024, ~8:00 PM - 8:10 PM EET (Europe/Athens)
Saturday, Dec 7 2024, ~11:30 PM - 11:40 PM IST (Asia/Kolkata)
Sunday, Dec 8 2024, ~2:00 AM - 2:10 AM +08 (Asia/Singapore)
Sunday, Dec 8 2024, ~3:00 AM - 3:10 AM JST (Asia/Tokyo)
Find out how to watch and participate
Duration: 09:17 minutes

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.

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.

Questions or comments? Please e-mail emacsconf-org-private@gnu.org