Programmers (generally) define a programming language that they know best or are most often used. I amPHPProgrammer, John is a JavaScript programmer, and DHH is a Ruby programmer. Schwarz and Randal are Perl programmers. Every programmer may look at the problem differently, but one or two of them will be considered as the best.
Whenever I hear that PHP is not respected, I feel very hurt as a PHP developer.
Although we must use PHP as a language for Web applications, it is a bad language and should not be encouraged or supported beyond the need.
Alas, when I heard that the language I use is poorly evaluated, some people may say that you should not care about others' comments on the language you choose, as long as you acknowledge it by yourself. I think I really should not, and the statement implies that not only is the language bad, the developer rotten, but also our PHP developer bad.
So what should we do to close others' big mouths? Can we respect the PHP language? Can we make PHP developers respected? Let's analyze some aspects and we can do this.
I. Break everything
PHP7 should break everything. PHP developers should accept the rule of breaking backward compatibility between versions. As long as a large number of backward compatible languages are not allowed, PHP7 will be a highly respected language.
1. Create a specific core language
Delete all library methods and keep the core methods in the object set. You should be able to write PHP 7 without any external libraries or extensions and a complete language for basic input/output, string processing and mathematics. Any external library should be extended through approval.
2. Everything is treated as an object
Take Java objects from Ruby, Smalltalk, and (main) and treat everything as objects. Integers are objects, strings are objects, and each of them can operate on them. I don't believe in the idea that Ruby and Smalltalk are required by PHP to send messages to each other between objects, the method to call an object is the best.
3. consistent naming methods and Classes
One of the biggest complaints of PHP is that it constantly needs to be checked, (needle, haystack) or (haystack, needle), or some_function (), or function_some (), or someFunction (), A consistent format must be specified.
4. Make things strict
Try to pass a floating string to a method? This is a warning.
5. Everything is Unicode
All strings in PHP6 are Unicode, which is good. I suggest PHP7 should also be maintained.
6. Central start point
Create a primary class or initialize it. All code execution comes from this.
7. Clear C code
I am not a C expert, but if you are familiar with Ruby C code to PHP C code, you can easily understand PHP and Ruby. I am very familiar with PHP, so it is easier for me to write extensions.
8. Get rid of eval ()
Eval () is evil. If you are using it, this is the wrong idea: it will break the PHPUnit and discard it from now on.
9. Support Operator Overloading
Because everything is an object, developers only need to know how to operate the object.
10. Allowed method Signature
True method signatures are allowed, so programmers can have different parameter lists or return methods of the same name.
- class A {
- public int function doSomething(int $a, float $b) {
- // Same as $a->*($b->to_int());
- int $c = $a * $b->to_int();
- return $c;
- }
- public float function doSomething(int $a, float $b, float $c) {
- // Same as calling $a->*($b->*($c)); since * is a method on each object $a and $b.
- float $d = $a * $b * $c;
- return $d;
- }
- }
11. Create a PHP Virtual Machine (PVM)
I'm not sure this is possible because I am not a language designer, but it will be a good PHP virtual machine. It can execute PHP bytecode and allow a clear heap and stack.
12. Delete copy-on-write (COW)
COW is a rather unfamiliar concept. If you do not know its existence and use new development, it may lead to problems.
13. Official PHP specifications released
Similar to W3C HTML5 specifications, PHP specifications allow developers to implement their own PHP versions and ensure that there are specific examples for compilation.
2. Respect for Language
Efforts should be made to ensure respect for language. We should try to recruit developers to make PHP 7 with very powerful functions. We should release huge code security, make it easy to read, and teach new developers to program in the right way.
I don't know Ruby's madness, but I respect the Ruby language. I see the power of Ruby on Rails. It is a very good framework, but I don't like it. If we can get the approval or respect of well-respected developers, PHP will go further.
3. Dear developers
From the above understanding, we need a very well-respected PHP development core team. They published code, held lectures, and showed people how to do things in the correct way. This team will soon be respected by many developers.
Conclusion
I'm excited about the future of PHP. I doubt that my ideas will be executed, but I really believe they will help the whole society. I am very excited when the world's second largest website announced that they are helping PHP build a great community. PHP will not disappear, and it will get better and better. As long as we try to improve it and improve it, PHP will one day become a language universally respected by developers.
Finally, I am not a language designer. My thoughts may be totally nonsense. If I am not correct, please politely let me know and I will be happy to talk about it. Let's work together to make PHP a language that is highly respected, powerful, fast, and efficient. If any compilation error occurs, correct it!