r/cprogramming • u/Many-Prompt2364 • Sep 17 '26
Write, compile & run C in a Jupyter Notebook
Hi all,
I'm sharing a side project of mine as I thought there might be some interest here!
A couple of years ago I decided to write a Jupyter Notebook kernel to reduce the friction for students new to compiled languages, as part of a condensed online pre-Master's introduction to C/C++. Thus, c-kernel was born!
c-kernel is a Jupyter Notebook kernel which simplifies the learning curve for new programmers by allowing you to write & compile code directly in a notebook. It takes care of compiling, linking & executing your cells behind the scenes, but still shows you the commands used to build your code. It removes the barrier of having to get students set up with a command-line and compiler and helps them start coding straight away.
Alternative Solutions
- jupyter-c-kernel - a significant inspiration for
c-kernel, but it has a number of limitations that I wanted to improve upon for my use-case. This project also seems to be unmaintained. - xeus-cling - a popular solution based on the C++ interpreter cling. Using an interpreter, it abstracts away a little more than I'd like for actually teaching students to write self-contained programs, such as headers/source files, and hides how source code turns into an executable.
If you find it interesting or useful, please let me know, and maybe leave a ✭ on GitHub!
1
u/Many-Prompt2364 Sep 17 '26
I'm posting this from a shadow account as this project links to my real name, but I'd be happy to verify my main account with the mods if there's any concern around new accounts sharing links to projects.
1
u/Ill_Translator8176 Sep 17 '26
Cool project! Might give it a try. For educational purposes definitely a great idea.
1
u/schakalsynthetc Sep 17 '26
Nice. I especially like how you handle the compiler command line, I can see this as the basis for a C tutorial with a short introduction to the shell woven into it, so students aren't stumped when/if they do have to deal with the shell.
I don't see a make dependency mentioned in the "installing" doc so I'm guessing you're assembling the command lines in python? I ask because now I'm wondering about incorporating make somehow and making it possible to see the generated Makefile in the notebook, for teaching purposes.
1
u/scallywag_software Sep 22 '26
This is a cool project, nice work!