Currently, despite being a C-extension there are a lot of dynamic features we have to deal with. When 0.x/1.x was designed, one of the highlights in the framework's design we had in mind was the possibility of being loosely coupled and allow users to do things like override any method, intercept method execution, add additional methods that read/update internal properties, etc.
Basically, the framework is ready to naturally accept any kind of external action from the PHP side, this makes Phalcon look like a pure PHP framework, reducing the impact that a C-framework could result in developers who are used to only PHP frameworks. All this ease and flexibility has a performance cost in 0.x/1.x. The truth is that we do not always want or need to extend phalcon's classes, hack or replace their internal properties or completely/partially replace them with our own classes.
So, Zephir will give the opportunity to produce more low-level code if a developer decide he/she wants to sacrifice flexibility (or doesn't need it at all) by getting more performance. The 1.x codebase is in fact, very high level because it tends to make everyone happy implementing all these features I mentioned above.
Another important topic is the fact that most of the current codebase is written with the intention of allow PHP developers to understand the code, readable code for a PHP developer is far from what can be done in C, Zephir gives us the opportunity to produce code less readable (in C) but more efficient in its execution.
The following parts of Phalcon will remain in C since their performance is better:
- Volt parser
- Annotations parser
- PHQL parser/cache
- Phalcon\Escaper
- Phalcon\Kernel
- Cssmin/Jsmin
- Some parts of Phalcon\Db that deal with PDO structures