# Swift in Jupyter

**URL:** <https://forums.swift.org/t/swift-in-jupyter/81418>\
**Category:** LLDB\
**Tags:** repl\
**Created:** [July 31, 2025, 5:27am UTC](https://forums.swift.org/t/swift-in-jupyter/81418 "2025-07-31T05:27:15Z")\
**Posts on this page:** 17\
**Page:** 1

<div class="post-metadata">

**Author:** ![anutosh491](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/anutosh491/32/42337_2.png) [@anutosh491](https://forums.swift.org/u/anutosh491)\
**Post date:** [July 31, 2025, 5:27am UTC](https://forums.swift.org/t/swift-in-jupyter/81418/1 "2025-07-31T05:27:15Z")

</div>

Hi,

This is Anutosh here (a Project Jupyter and an llvm/clang member) but more importantly a swift newbie 🙂

At Project Jupyter, we are trying to bring all languages to the browser using JupyterLite & Web Assembly in the form of a REPL.

The latest one being C++ , one can now do C++

1. Completely in the browser, no local setup required whatsoever
2. Interactively in the form of a REPL

Feel free to try out the C++ kernels on this link [JupyterLite](https://jupyter.org/try-jupyter/lab/index.html)

You shall also find a few demo notebooks starting with cppxx.ipynb for demonstrating the use case

Feel free to explore anything from BLAS & LAPACK routines through Openblas & Xtensor, to interactive Jupyter widgets to Graphics using SDL.

1. You can also fetch any 3rd party lib/package as and when you want to use it (and its all gone as soon as you close the instance) . For eg

 ![image](https://global.discourse-cdn.com/swift/original/3X/0/0/00baa74423e7973310b9cf71270336533e0b93bd.png)

I plan to ideate more on having a similar kernel for swift just like we did for C++. I say this cause I see quite some similarities

A) For C++, we used clang-repl (based on clang & LLVM's ORC JIT and for this we compiled clang & lld using emscripten)

I see swift offers a repl too built on top of lldb (although architecturally different from clang-repl , I would like to ideate a bit on this)

I would like to discuss more here but being new to swift I have quite some doubts. I tried looking on swift's github trying to locate people/teams responsible for maintaining the swift REPL but wasn't successful.

As a first step could someone point me to the maintainers for this project so that I can put forward my doubts ?

---

<div class="post-metadata">

**Author:** ![compnerd](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/compnerd/32/2165_2.png) [@compnerd](https://forums.swift.org/u/compnerd)\
**Post date:** [July 31, 2025, 3:35pm UTC](https://forums.swift.org/t/swift-in-jupyter/81418/2 "2025-07-31T15:35:40Z")

</div>

This has been done before (incidentally, I was involved in 2 such attempts in the past). The first one was based on using LLDB directly via swift-jupyter as part of Google's Swift4TensorFlow project. The second attempt was based around the new VSCode notebook model.

The LLDB project itself is maintained as part of [llvm.org](http://llvm.org); we do have a fork of it primarily maintained by folks who are already part of the LLDB community.

---

<div class="post-metadata">

**Author:** ![compnerd](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/compnerd/32/2165_2.png) [@compnerd](https://forums.swift.org/u/compnerd)\
**Post date:** [July 31, 2025, 6:05pm UTC](https://forums.swift.org/t/swift-in-jupyter/81418/3 "2025-07-31T18:05:35Z")

</div>

If you want to pick up the work that I had started for the VSCode based approach: [VSCode jupyter notebook based REPL](https://forums.swift.org/t/vscode-jupyter-notebook-based-repl/73996) is the post and it links to the original PR.

---

<div class="post-metadata">

**Author:** ![anutosh491](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/anutosh491/32/42337_2.png) [@anutosh491](https://forums.swift.org/u/anutosh491)\
**Post date:** [August 1, 2025, 4:38am UTC](https://forums.swift.org/t/swift-in-jupyter/81418/4 "2025-08-01T04:38:39Z")

</div>

Hi,

Thanks for the reply.

I see the Swift Repl is probably a wrapper over LLDB (and this LLDB is maintained as a fork from llvm)

So my next questions is

1. Is it documented somewhere as to what efforts were taken by people working on the REPL to have this separate fork on lldb under swift ? After making the required changes on top of lldb what effort was taken to write the swift repl ? Would it make sense to push this work upstream ?

2. What's the library proving C/C++ API to interact with the swift REPL ? It is swiftImmediate by any chance ? ([swift/lib/Immediate at main · swiftlang/swift · GitHub](https://github.com/swiftlang/swift/tree/main/lib/Immediate))

Asking this cause as I said for the C++ kernel ([GitHub - compiler-research/xeus-cpp: Jupyter kernel for the C++ programming language](https://github.com/compiler-research/xeus-cpp)) whose link I attached above, we used libclangInterpreter from llvm ([llvm-project/clang/lib/Interpreter/CMakeLists.txt at main · llvm/llvm-project · GitHub](https://github.com/llvm/llvm-project/blob/main/clang/lib/Interpreter/CMakeLists.txt)) that exposes the API to interact with clang-repl.

Regards,  
Anutosh Bhat

---

<div class="post-metadata">

**Author:** ![compnerd](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/compnerd/32/2165_2.png) [@compnerd](https://forums.swift.org/u/compnerd)\
**Post date:** [August 1, 2025, 3:20pm UTC](https://forums.swift.org/t/swift-in-jupyter/81418/5 "2025-08-01T15:20:36Z")

</div>

> [@anutosh491](#):
>
> Is it documented somewhere as to what efforts were taken by people working on the REPL to have this separate fork on lldb under swift ? After making the required changes on top of lldb what effort was taken to write the swift repl ?

I'm not sure what the question here actually is intending to ask. LLDB requires forking because of the additional language mode. That language mode requires having the Swift compiler, which is not upstream. While it would be ideal to have the language support in upstream LLDB, that is a massive undertaking.

> [@anutosh491](#):
>
> Would it make sense to push this work upstream ?

What work are you referring to? The basis for the REPL has been upstreamed, and others in the community have used that to build additional REPLs, such as the one that mojo has.

> [@anutosh491](#):
>
> What's the library proving C/C++ API to interact with the swift REPL ?

Again, this is very unclear. Who is the actor interacting with the REPL. If you look at the code in the pull request I posted above, there is no library in the middle - it is simply communicating over stdin/stdout.

If this is in context of implementing a jupyter notebook, I would recommend against that. My experiences with writing a jupyter notebook kernel with the C++ APIs was that it is far too fragile. That is why the VSCode notebook approach dooes the direct communication.

---

<div class="post-metadata">

**Author:** ![anutosh491](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/anutosh491/32/42337_2.png) [@anutosh491](https://forums.swift.org/u/anutosh491)\
**Post date:** [August 13, 2025, 5:44am UTC](https://forums.swift.org/t/swift-in-jupyter/81418/6 "2025-08-13T05:44:43Z")

</div>

Hi,

Thanks for your reply. Clears few things for me .

> I'm not sure what the question here actually is intending to ask

By this I meant if it was documented anywhere as to what efforts were taken to come up with the swift repl once lldb was forked.

> Who is the actor interacting with the REPL

Let me explain what I wanted to convey here. When I say “interact with the REPL,” I mean interacting with the _interpreter_ that the Jupyter Kernel Protocol hooks into.

For example, in kernels for languages like C++, R, Python, or Octave that use the **xeus** framework, **xeus** handles the Jupyter Kernel Protocol part. As the docs put it:

“xeus is a library meant to facilitate the implementation of kernels for Jupyter. It takes the burden of implementing the Jupyter Kernel protocol so developers can focus on implementing the interpreter part of the kernel.”

This is the architecture as per the docs

 ![image](https://global.discourse-cdn.com/swift/original/3X/8/4/847d578e880aaefc86631bc629e19d133fd9a16d.png)

So the architecture works like this:

- **xeus** implements all the message-passing and protocol compliance.

- The _kernel developer_ implements an **interpreter** — the piece that actually takes the code from a `execute_request` message and runs it.

- This interpreter talks to the **C/C++ API of the language’s REPL/runtime**.

Examples:

1. [xeus-cpp](https://github.com/compiler-research/xeus-cpp)

2. [xeus-r](https://github.com/jupyter-xeus/xeus-r)

3. [xeus-python](https://github.com/jupyter-xeus/xeus-python/tree/main) Interpreter: CPython runtime via the **Python C API**

So in all these cases, the “interpreter” you implement in C++ is really a bridge:

- On one side, it receives code from Jupyter via xeus.

- On the other side, it calls into the **native REPL API** of the target language to run that code and return results.

So basically what I wanted to know is

1. If swift repl was based on a “SwiftInterpreter” class as such ? and if there is some way to interact with it through an API (for parsing and executing)
2. That being said according to the stuff I went through I understand that the swift repl is based on the concept of a “debugger” more than that of an “interpreter” (correct me if I am wrong)

I am still exploring more if I can find some proof of concept for a xeus-swift Kernel.

---

<div class="post-metadata">

**Author:** ![compnerd](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/compnerd/32/2165_2.png) [@compnerd](https://forums.swift.org/u/compnerd)\
**Post date:** [August 13, 2025, 2:23pm UTC](https://forums.swift.org/t/swift-in-jupyter/81418/7 "2025-08-13T14:23:18Z")

</div>

Depends on your view point I suppose. Ultimately, the debugger is a REPL - it reads commands, evaluates, and prints.

The Swift REPL relies on LLDB’s underlying implementation detail of JITing and code injection for the execution capabilities.

---

<div class="post-metadata">

**Author:** ![anutosh491](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/anutosh491/32/42337_2.png) [@anutosh491](https://forums.swift.org/u/anutosh491)\
**Post date:** [August 14, 2025, 8:03am UTC](https://forums.swift.org/t/swift-in-jupyter/81418/8 "2025-08-14T08:03:57Z")

</div>

Thanks again for your reply.

Yes I have been educating myself with the “debugger as a REPL” concept these days.

So I guess we can confirm

1. There’s no interpreter class as such being offered by Swift.
2. There’s no C++ API as such to interact with Swift repl and If I am looking to programmatically interact with Swift's REPL, I'd have to use LLDB's C++ API rather than anything provided directly by Swift.

Let me know if that’s correct ?

---

<div class="post-metadata">

**Author:** ![augusto2112](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/augusto2112/32/10731_2.png) [@augusto2112](https://forums.swift.org/u/augusto2112)\
**Post date:** [August 15, 2025, 4:29pm UTC](https://forums.swift.org/t/swift-in-jupyter/81418/9 "2025-08-15T16:29:03Z")

</div>

> There’s no C++ API as such to interact with Swift repl and If I am looking to programmatically interact with Swift's REPL, I'd have to use LLDB's C++ API rather than anything provided directly by Swift

Unfortunately there is no API at all. You would need to launch the lldb process in repl mode and communicate with it via stdin/stdout.

---

<div class="post-metadata">

**Author:** ![anutosh491](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/anutosh491/32/42337_2.png) [@anutosh491](https://forums.swift.org/u/anutosh491)\
**Post date:** [August 18, 2025, 8:44am UTC](https://forums.swift.org/t/swift-in-jupyter/81418/10 "2025-08-18T08:44:21Z")

</div>

Hey Augusto,

Thanks a lot for the reply. I was just looking at Swift Immediate and thinking if this could help ([swift/include/swift/Immediate/Immediate.h at main · swiftlang/swift · GitHub](https://github.com/swiftlang/swift/blob/main/include/swift/Immediate/Immediate.h))

Not sure if this can be put to use, Probably its not maintaining an incremental state or persistent variables (as maybe what clangInterpreter does for clang-repl) and is only meant to compile one chunk of Swift and run it then ?

---

<div class="post-metadata">

**Author:** ![anutosh491](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/anutosh491/32/42337_2.png) [@anutosh491](https://forums.swift.org/u/anutosh491)\
**Post date:** [September 10, 2025, 8:03am UTC](https://forums.swift.org/t/swift-in-jupyter/81418/11 "2025-09-10T08:03:23Z")

</div>

Hey @augusto2112 ,

Getting back after a while but I did some research.

Feel free to correct me if I am wrong here but this is what I realize

1. There was a compiler centric REPL even before the debugger centric one. (I think its this what I was looking for based on my questions above)

2. This also used to expose a runREPL ([Remove integrated REPL by slavapestov · Pull Request #31187 · swiftlang/swift · GitHub](https://github.com/swiftlang/swift/pull/31187/files#diff-635e50e7c59a5dd7f130c96baa9d1ce900a6aa73a51546937f1ea812b6dfa8f2L45))  
and it was probably this function that I would have ended up using for my usecase with Jupyter

3. It was finally removed here [Remove integrated REPL by slavapestov · Pull Request #31187 · swiftlang/swift · GitHub](https://github.com/swiftlang/swift/pull/31187)  
after some discussion on the RFC ([RFC: Removing the integrated REPL - #21 by dan-zheng](https://forums.swift.org/t/rfc-removing-the-integrated-repl/35441/21))

I think a compiler centric REPL would help me case so much more as mostly Jupyter Kernels implementing support for REPLs end up having interpreter/compiler based REPLs and not really debugger based :\

---

<div class="post-metadata">

**Author:** ![pedronahum](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/pedronahum/32/24130_2.png) [@pedronahum](https://forums.swift.org/u/pedronahum)\
**Post date:** [November 27, 2025, 6:39am UTC](https://forums.swift.org/t/swift-in-jupyter/81418/12 "2025-11-27T06:39:40Z")

</div>

Maybe you are interested, (@compnerd fyi) but I do have a working kernel, and can be used from colab as well.

> **[GitHub - pedronahum/swift-jupyter](https://github.com/pedronahum/swift-jupyter)**
>
> Contribute to pedronahum/swift-jupyter development by creating an account on GitHub.

---

<div class="post-metadata">

**Author:** ![compnerd](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/compnerd/32/2165_2.png) [@compnerd](https://forums.swift.org/u/compnerd)\
**Post date:** [November 27, 2025, 3:49pm UTC](https://forums.swift.org/t/swift-in-jupyter/81418/13 "2025-11-27T15:49:27Z")

</div>

Thanks @pedronahum.

One of the reasons that I had taken the alternative approach here was that there was a significant amount of complexity in our work with the Jupyter environment whilst working on S4TF. The VSCode environment could use the host image setup and allowed for a simpler setup for the kernel. I am still somewhat interested in seeing the VSCode based notebook.

However, having the traditional setup can still be good. Looking forward to what you end up with 🙂

Saleem

---

<div class="post-metadata">

**Author:** ![pedronahum](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/pedronahum/32/24130_2.png) [@pedronahum](https://forums.swift.org/u/pedronahum)\
**Post date:** [November 27, 2025, 7:12pm UTC](https://forums.swift.org/t/swift-in-jupyter/81418/14 "2025-11-27T19:12:31Z")

</div>

Hi @compnerd,

S4TF has been a huge source of motivation! I'm trying my best to keep some of those ideas alive.

Regarding the kernel, I’m looking for the most accessible way to get the Swift libraries I'm working on running on GPUs and TPUs, and this traditional setup felt like the safest path. I promise to keep everyone posted on how it goes!

Best,

Pedro N.

---

<div class="post-metadata">

**Author:** ![compnerd](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/compnerd/32/2165_2.png) [@compnerd](https://forums.swift.org/u/compnerd)\
**Post date:** [November 28, 2025, 12:29am UTC](https://forums.swift.org/t/swift-in-jupyter/81418/15 "2025-11-28T00:29:39Z")

</div>

> [@pedronahum](#):
>
> S4TF has been a huge source of motivation! I'm trying my best to keep some of those ideas alive.

I’m glad to hear that!

> [@pedronahum](#):
>
> Regarding the kernel, I’m looking for the most accessible way to get the Swift libraries I'm working on running on GPUs and TPUs, and this traditional setup felt like the safest path.

That makes sense. I’d point out the alternative option/consideration. The VSCode based approach that I was referring to is similar in that you have a Jupyter style notebook, but rather than requiring the docker container and everything else that entails, you simply run on the host. Look for a post that I made about a year or so ago about it (the PR for that is still on GH under the vscode-swift project).

But, given that runs on the host, I’m not sure if that will help with the TPU side, but you should be able to get a simpler setup that works across CPU and GPU I suspect.

---

<div class="post-metadata">

**Author:** ![pedronahum](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/pedronahum/32/24130_2.png) [@pedronahum](https://forums.swift.org/u/pedronahum)\
**Post date:** [November 28, 2025, 12:40pm UTC](https://forums.swift.org/t/swift-in-jupyter/81418/16 "2025-11-28T12:40:30Z")

</div>

Thanks for the additional considerations @compnerd. Will take a closer look. Maybe we can even piggy back parts of the code used to update the swift kernel. Let me check…

Best,

Pedro N.

---

<div class="post-metadata">

**Author:** ![AhmedAli](https://avatars.discourse-cdn.com/v4/letter/a/ecae2f/32.png) [@AhmedAli](https://forums.swift.org/u/AhmedAli)\
**Post date:** [January 22, 2026, 11:30am UTC](https://forums.swift.org/t/swift-in-jupyter/81418/17 "2026-01-22T11:30:27Z")

</div>

Happy to see C++ in Jupyter and hope Swift will follow soon!
