DEV Community

Muhammed Shafin P
Muhammed Shafin P

Posted on

Introducing PCL Playground — A Python + C Online Compiler

I’m excited to share PCL Playground, a simple yet powerful tool that allows you to write and run both Python and C code in a single file, directly from your browser. This project is aimed at developers, students, and hobbyists who want to experiment with systems-level C programming while leveraging the flexibility and ease of Python — all in one environment.
At the heart of this project is a custom format called .pcl (Python-C Linked). With this format, you can define C functions inside special %c blocks and then use them directly within %py Python blocks. The compiler takes care of stitching everything together, compiling the C code into a Python-compatible shared object, and executing the Python code with access to it.
You can try it online, right now, at:
🔗 https://hejhdiss.github.io/pcl-playground/
This online interface is fully static and hosted via GitHub Pages, while the backend compilation and execution are handled securely using a Flask API hosted on Render’s free tier.

For example, you can run a .pcl file like this:

%c name=math export=add
int add(int a, int b) {
return a + b;
}
%endc

%py requires=math
print(“3 + 4 =”, add(3, 4))
%endpy

Behind the scenes, the backend acts as an API that receives your .pcl code submission. It first creates a temporary .pcl file on the server, then extracts and compiles the C part using gcc, links it with Python using ctypes, and then executes everything in a secure, temporary environment. The results are sent back and displayed instantly in the web interface.
The entire project is open-source. You can find the source code of the online playground here:
📁 https://github.com/hejhdiss/pcl-playground
And the core compiler engine that handles .pcl parsing and execution is available separately here:
📁 https://github.com/hejhdiss/pcl

If you find it interesting, feel free to star it, use it in your projects, or even contribute!

hashtag#Programming hashtag#SoftwareDevelopment hashtag#OpenSource hashtag#DeveloperTools hashtag#CodeNewbie hashtag#PCLPlayground hashtag#PythonCLinked

Top comments (0)