📜 ⬆️ ⬇️

Heavenly path in php

The idea of ​​the SKY project can be presented in different ways, but the shortest and simplest presentation is as follows. There are many websites on the Internet, the strength of which is mainly due to the text and photo-video content of users, but there is no one whose strength would be due to the user code. I will clarify: of course, there are websites that save user codes, for example, “packagist.org”, but there is not one that could reach the level of popularity of a social network with respect to code content (let's call this goal X), in which an active scrupulous analysis of all the details of the code is conducted. by many participants. So packagist's site is comparable to the SKY project that achieved goal X, just as you can match any installation of the phpbb forum with the Facebook site. At the moment, the SKY project is little known, but is this popularity possible? My opinion is, of course, and the key to this is simplicity, following the principles of KISS in the design of the code. IMHO, and php has achieved high popularity, primarily due to simplicity.

In general, I think “the right way in php” is a big annoying mistake. More precisely, some of its important fundamental principles. To write code to the global scope and use eval () in the code more widely, as is done in the SKY framework. At least, dear reader, I hope that you admit the reasonableness of the existence of two paths, and only which path is truly true, only time can show. Often the new is a well-forgotten old, I beg you, do not rush to think that the "SKY way" is a hopeless past.

Simple things always have more potential for development than complex ones. "SKY way" is the best basis, giving the opportunity to implement the idea of ​​the project, in which the "power of the site" would be determined by the code of the project users, when the level of development of the site is comparable to the social network, but only where the content is the code.

"SKY way" forms some small requests for changes in php at the moment, for example, it would be nice to have functions: get_context ($ deep) and filter_context ($ array). The first would produce an array of variables corresponding to the context of the depth level, where $ deep = 0 is its context of variables, 1 is the context of the function call level, which contains the get_context (1) code. The returned array is the same as for the callback function for set_error_handler (). The second would filter the array to display the programmer and analyze variables, while, for example, $ GLOBALS, should not be shown in a “pure” form, but only in a shortened form. "SKY way" does not follow the principle of isolation, when the programmer simply does not use the global scope for variables to avoid inadvertently redefining them in the development process. Instead, in the "SKY way" there are special means to prevent such errors, in particular, for example, using the above function get_context (). The principle of isolation and other principles that are used, for example, in Symfony and other currently popular Framework, lead to a very high level of complexity of the architecture, compared to the “SKY way”.
')
The second example. To avoid errors of the second kind, classically, it is recommended simply not to use eval (). But if the argument for eval () is code that is in a constant, there is absolutely no danger of using eval (). However, all the same, it is not recommended to use eval (), it is recommended to be wary of it “as fire”. In the "SKY way" this logic is considered erroneous. There is no alternative to eval (). On the contrary, the alternative that is used in Symfony and Framework with a similar architecture is considered questionable when eval () is not widely used, since such a way increases the complexity too much. Complicating the code architecture for reuse (KPI) in PHP is like “cutting the branch on which you are sitting.” But is it possible to use eval () without fear of putting applications at risk? Can. It is possible, for example, when using eval () to generate a PHP WARNING error, when it is not known for certain about the safe use of eval (), in other cases not to give an error. You can also, for example, in the Framework, make a registry using eval () to draw the attention of developers to these places in the code or use a combination method that is harmonious with PHP itself. I mean the registry contains text descriptions of security guarantees. By the way, you can imagine a situation where a novice programmer does not know about the danger of eval (), and the presence of the registry focuses his attention and due to this he will avoid security errors.

Also, as there are no ideal people and ideal programmers, there is no ideal code for which one could give an exact proof that the code is perfect. But you can conditionally call the ideal code, which is analyzed by a huge number of programmers and active iterations on the improvement of which never stop. This approach is proposed in the SKY project to achieve goal X, as well as the search for all other possible ways to create such code. This process of continuous improvement is called “crystallization” in the SKY project. The concept is similar to the term “optimization”, but the second implies a volitional decision to stop cultivation at some stage. The term "crystallization" may become relevant on the project SKY subject to the achievement of goal X.

The SKY project pays great attention to the potential frequency of using KPIs on real-world web applications. So the core of the SKY Framework (potentially the most commonly used code) is only three files, about 50 Kbytes in size, and it is this code that should be subject to maximum crystallization by the community. The flexibility of the code, including the kernel, is chosen lower in comparison, for example with the flexibility of the symfony components.

Due to the ultimate prosecution of KISS principles, many solutions in SKY are not typical or even opposed to those adopted by the community supporting “the right way in PHP”:

1) there is no need to use (at least as basic development tools) technologies in the Framework:

a) routing pages, as the mechanism is redundant. The really necessary tasks that they solve are easy to implement by simple manipulations in the application code.
b) ORM as a mechanism is redundant. There is no need to "make a wrapper" for an already concise SQL language.
c) Compiled templates are unnecessary. PHP alone provides enough tools to use the highest quality PHP templates.
d) The NAMESPACE mechanism is redundant. It solves the task of the development stage, at the execution stage, including at production installations, which in itself is even incorrectly logical.
d), etc., there is no need now to remember and list everything ...

2) SKY pays much more attention to the development phase. In SKY everything tries to be harmonious, like the world around it. SKY Framework comes with the DEV.SKY web application, which is focused on solving the tasks of the development stage much more than, for example, the console utility Symfony. I would say that in SKY, "the shoemaker has boots."

3) there is no vendor folder. Required recycling classes on packagist in accordance with the ideology of SKY. In SKY, it is allowed (but, of course, we try to avoid) editing KPIs, including the kernel, by application developers. Firstly, there are standard tools for modifying the kernel code (using the DEV.SKY application) —receiving the “cloud modification” code from a “clean cloud”; this allows replacing the high level of flexibility of the Symfony components with a SKY solution. “Clean Cloud” is a term of the SKY project, characterizing the conventionally ideal KPI, potentially capable of becoming a full-fledged replacement for at least 70% of the sites actually existing on the Internet. Secondly, updating the kernel code is simply often not required, since it is small, transparent and crystallized. Thirdly, updating the kernel code remains possible by merging (manual resolution of collisions) and does not present difficulties due to the fact that the code is small and simple. Also updates are rare, due to the fact that the code is crystallized (perfect). Fourth, trying to “leave” updates is rather good than bad. You can not be sure of the constant trustworthiness of trusted sources, it is not good to spend personal time on updating the obviously not perfect code.

4) Instead of packagist, the third wing code, like the SKY core, is stored in the code DB, on the same site, in the same SKY project. It makes no sense to collect more than 100K classes in PHP as a packagist, instead, it makes sense to have a much smaller number of classes on coresky.net, but to expose the code to crystallization, continuous improvement. There is no need to have alternative solutions for packagist, it is better to have uniform ideal solutions. In the SKY project, a clever idea will be appreciated even by an anonymous user, using a pyramidal system of ratings and bonuses. Any participant in the system will be able to easily influence any KPI code in SKY if it has valuable thoughts.

5) , etc., there is no need now to remember and list everything ...

On this site, habrahabr, I sometimes come across articles like this: PHP: a fractal of poor design . This article is an interesting job, but a minus to the author because he didn’t analyze the “reinforced concrete fact” didn’t answer the question - why PHP is the leader in web development. Without such an analysis, the article is seen as "crying crying ..". Even if the author wrote this article without a special order from the creators of competing languages, it has a 100% advertising (anti-advertising) character. By the way, my opinion: the PHP language is similar to a simple C / C ++ with the capabilities of a high-level language, this fact, first of all, and not the right marketing strategy or anything else, brought him popularity. The ability to extend the language with the help of the “extension” modules written in C and a good start time for development is also important. The author praises Perl, but Perl was before and lost in popularity, it is a fact. Like this article, which offers to completely abandon PHP, I see the “right way in PHP” as a similar, but more subtle marketing move, which offers to completely abandon other approaches to use only this one. It seems to me that the current large “army” of professionals, supporting the “right way in PHP” and a small number of professionals who feel that something is wrong in the “right way”, I consider myself to be the second. I ask the first not to be categorical in convictions, to allow the “heavenly path” to exist, the second I invite to the project for a more detailed study of what is already in the project SKY.

I also meet articles like this: PHP: the wrong way . IMHO, this is all - the timid attempts of the “minority army” to say “the right way in PHP” is in fact not true . This article contains the phrase:
But even KISS can be a threat to the project, if you bring it to the point of absurdity.

Thought true, but I do not like the angle of view. I would say this: with a completely specific statement of the problem, you should always adhere to the principles of KISS . Simply, the fact is that to make an error-free, well-defined formulation of the problem in the field of programming can be as difficult as the task itself. When completing a task, developers often make decisions that could be present in the formulation of the problem and that would be good, both for the one who sets the task and for the one who performs it. To use a complex solution, at a time when you can apply a simple one, is equivalent to throwing money down the drain. On the scale of humanity, complex decisions make extremely large losses of various resources.

In conclusion, I would like to note that this article and the SKY project are not only about creating web applications in PHP. When you achieve goal X, the consequences will be unimaginable is:

a) creating a free perfect KPI for both web development, but also for other programming. Creating a formal approach to getting the perfect code, not just for the web.

b) the PHP language is not a panacea, it is likely that the community will develop an ideal language, it is possible branches from PHP with the ability to convert old scripts. When achieving goal X, the impact of the SKY project on PHP developers will be strong. What is important is not a binding to a specific language, but a search for the correct canonical connections and ideal solutions in programming.

c) it is possible to create controlled artificial intelligence, in contrast to the recently published DEEPMIND newsletter, which, despite the adopted “ethics committee of AI”, probably works on the principle of “black box” and probably represents a threat. You cannot create a black box AI so that it is safe. Hackers know how to “hack everything”, but if the AI ​​is smarter than people, it will also break free. This problem is similar to the problem of CO 2 in the atmosphere and global warming: everyone understands everything, but continues to drive on gasoline, also with AI: I want to do the first time no matter what, but really working.

Source: https://habr.com/ru/post/313884/


All Articles