DEV Community

Muhammed Shafin P
Muhammed Shafin P

Posted on

A Language That Seamlessly Combines C and Python – My Dream Project

As someone passionate about programming and curious about how languages can work together, I’ve been developing an idea for a new kind of language—a hybrid that lets you write C and Python side-by-side in the same script, with simple code-level links between them. I call it the Python-C Linked Language (PCL).

In a .pcl file, you could define C code in one block, Python code in another, and link them effortlessly using a few special directives. For example:

filename: hello.pcl (PCL = “Python-C Linked”)

%c name=mylib export(add, Vec)

include

typedef struct {
double x, y;
} Vec;

int add(int a, int b) {
return a + b;
}
%endc

%py requires(mylib) import(add, Vec)
def main():
print("2 + 3 =", add(2, 3))

v = Vec(1.0, 2.0)
print("Vector (x, y):", v.x, v.y)
Enter fullscreen mode Exit fullscreen mode

%endpy

This format keeps C and Python clean, separate, and readable, while the compiler handles symbol exporting, struct mapping, and wrapper generation automatically using tools like ctypes, pycparser, or cffi.

While exploring this idea, I naturally looked at existing solutions like Cython and Mojo. Cython is incredibly powerful for performance, but it blends Python and C-like syntax within the same code block, which can make the code harder to follow. Mojo, on the other hand, is a new language with its own syntax focused on high performance, especially for AI workloads. My idea with PCL is different: instead of learning a new language or mixing syntax styles, you simply write native C and native Python as separate blocks and link them through simple export() and import() tags. This keeps both languages in their original, familiar form—just more connected.

I’m still at the early stages of learning compiler design, but this concept excites me deeply. I believe it could help developers build efficient, readable, and modular hybrid programs more easily. If anyone has experience in C/Python integration, language tooling, or compiler internals, I’d love to hear your thoughts—or even collaborate.

Would a language like this be useful to you?

programming #python #cprogramming #compiler #cython #mojo #opensource #devtools #learning #hybridlanguage

Top comments (0)