Developer ditches C++ for C23 when rewriting a PHP extension, here is why
A developer forked the dormant DataStax Cassandra PHP driver after it stopped compiling on PHP 8 and began rewriting it, initially choosing C++. Attempts to use C++ abstractions like RAII and smart pointers around PHP's Zend Engine API introduced hard-to-trace memory bugs rather than simplifying the code. The core issue is that the Zend Engine controls its own memory lifecycle through custom allocators and request-scoped functions, making C++ standard containers and destructors incompatible without significant adapter code. A particularly dangerous conflict arises because Zend's error-handling uses setjmp/longjmp, which can bypass C++ destructors and cause undefined behavior during stack unwinding. The developer concluded that C23 aligns more naturally with the Zend Engine's C-based rules, making the extension simpler and safer to maintain than a C++ approach would allow.
This is an AI-generated summary. ShortSingh links to the original source for the complete article.
Discussion (0)
Log in to join the discussion and vote.
Log in