Technology

Forget Rust! Filip Pizlo's Fil-C Aims to Revolutionize Memory Safety in C and C++

2024-11-16

Author: Wei Ling

Introduction

In a bold move to re-energize the C and C++ programming communities, Filip Pizlo, a senior director of language engineering at Epic Games, has introduced an innovative project called Fil-C—a memory-safe variant of the popular programming languages that aims to eliminate the frustrations of memory safety without requiring developers to pivot to Rust.

Background

Pizlo's creation comes following the anticipation surrounding TrapC, another memory-safe C-fork set to debut next year. In a message addressing the excitement, Pizlo shared, 'I wanted to make you aware of Fil-C—a passion project of mine that is currently available and achieves everything that TrapC aims for, including full memory safety. Plus, it’s completely free to use!'

The Need for Memory Safety

The critical push for memory safety has been fueled by escalating vulnerabilities in large codebases. Traditional C and C++ programming, reliant on manual memory management, often invite bugs like out-of-bounds errors, which can lead to serious exploits. As a result, programmers are increasingly advised to shift to languages like Rust, known for its memory safety features and robust performance.

Community Response to Rust

However, while Rust has emerged as a favored choice, its steep learning curve has drawn criticism from seasoned developers. Many in the community, particularly those entrenched in C and C++, are hesitant to abandon the languages they’ve mastered. Pizlo recognizes this sentiment, stating, 'My focus is on delivering memory safety without forcing developers to learn a new programming language.'

Fil-C Unveiling

Fil-C was unveiled at the recent SPLASH 2024 conference, where Pizlo elaborated on the motivations behind his endeavor. Despite being labeled 'unsafe,' he expressed deep affection for both C and C++, emphasizing their richness and the vast library of legacy code already written in these languages. He states, 'C and C++ are incredible, but their memory management flaws make them hazardous. That’s why I created Fil-C—not just to improve safety but to ensure that developers can continue using the languages they love.'

Limitations of Fil-C

It’s essential to note that while Fil-C is an exciting alternative, there are limitations. Right now, it supports only Linux on x86_64 architectures and performs slower than traditional C—between 1.5x to 5x, largely due to its innovative pointer encoding system known as MonoCaps. However, Pizlo is optimistic about future improvements, hoping to bring the slowdown down to a manageable 1.5x in the worst-case scenarios.

Compatibility and Adoption

Moreover, Fil-C does not seek full compatibility with traditional C/C++ (referred to as 'Yolo-C/C++'), a choice made to encourage users to transition fully to the memory-safe world rather than inadvertently reintroducing vulnerabilities by linking legacy files.

Currently, several C programs can be compiled with Fil-C with minimal adjustments, such as bzip2 and zip, while others like CPython and SQLite simply require minor modifications. Pizlo believes this will pave the path for broader acceptance of memory-safe practices in existing C codebases.

Conclusion

With prominent tech players rallying around programming languages that promise memory safety, Pizlo's Fil-C could prove to be a game-changer for developers who are passionate about C and C++ yet concerned about security. As memory safety challenges persist, Fil-C offers hope and innovation for coders who refuse to let go of their beloved languages. Will Fil-C be the key to ushering in a new era for C and C++? Only time will tell!