On Fri, 2014-05-23 at 13:52 +0100, Andrea Faulds wrote:
On 23 May 2014, at 12:36, Dmitry Stogov <dmitry@zend.com> wrote:
Please take a look at
https://wiki.php.net/rfc/fast_zpp
Thanks. Dmitry.
This looks like a great idea. I like how it’s not only faster, but it
seems to be more readable.
More readable? - I feel exactly the opposite. Yes, we get rid of void
pointers but use a pattern easy to understand. This looks like macro
hell.
If we break APIs anyways: Can't we go for C++ which allows providing
high level APIs with high performance ...
Totally agreed!
I strongly believe we should upgrade to C++. All platforms already support C++, and C++11 support is spreading quickly.
We wouldn't need to convert everything to C++ (classes and stuff). We could start compiling with a C++ compiler and use C++ as needed and where it makes sense. In particular we could use it to replace some macros in the Zend engine.
For this particular example, with C++ you could improve performance of parameter passing *without* changing the API at all. With templates one can basically evaluate functions at compile time, and therefore most of the code could be inlined (and let the "scanf" part be done at compile time).
C++ would also allow us to improve type safety and get rid of pointer aliasing rules violations which will cause trouble sometime if not fixed.
Finally, I don't think the current proposal (the new macros) is very readable. Moreover it requires substantial work to upgrade API users.
Nuno
P.S.: I've been a bit inactive in the past few years, but I'm really trilled by the fact that phpng is taking momentum :)