Home  >  Article  >  Backend Development  >  Looking ahead to PHP7: What needs to change in PHP_PHP Tutorial

Looking ahead to PHP7: What needs to change in PHP_PHP Tutorial

WBOY
WBOYOriginal
2016-07-20 10:57:24911browse

Programmers (generally) define a good programming language as one they know best or use most often. I'm a PHP programmer, John is a JavaScript programmer, DHH is a Ruby programmer, and Schwartz and Randall are Perl programmers. Different programmers look at the problem differently, but there are always one or two that are collectively considered the best.

As a PHP developer, it hurts every time I hear PHP being disrespected.

Although we must use PHP as a language for web applications, it is a bad language and its use should not be encouraged, or supported beyond necessity.

Oops, when I heard that the language I use every day is given a bad evaluation, some people may say that you should not care about other people's evaluation of the language you choose, as long as you agree with it. I guess I really shouldn't, and what that statement implies is that not only does the language suck and the developers suck, but we PHP developers suck too.

So, what exactly should be done to shut down other people’s big mouths? Can we make the PHP language respected? Can we make PHP developers respected? Let’s analyze some aspects where we can do it at this point.

1. Break everything

PHP7 is going to break everything. PHP developers should accept the law of breaking backward compatibility between versions. As long as extensive backward compatibility is not allowed, PHP7 will be a highly respected language.

1. Create a specific core language

Remove all library methods and keep the core methods in the object set. You should be able to write PHP7 without any external libraries or extensions and a nice complete language for basic input/output, string handling and math. Any extension outside of the library should be approved.

2. Treat everything as an object

Take objects from Ruby, Smalltalk and (mainly) Java and treat it all as an object. Integers are objects, strings are objects, and each of them has methods that can be manipulated. I don't believe that PHP needs the notion of Ruby and Smalltalk to pass messages between objects, and calling methods on objects is the best.

3. Consistently named methods and classes

Since one of the biggest complaints about PHP is the constant need to check, (needle,haystack) or (haystack, needle) , or some_function(), or function_some(), or someFunction(), a consistent format needs to be developed.

4. Keep things strict

Try passing a float string into a method? This is a warning.

5. Everything is Unicode

All strings in PHP6 are Unicode, which is good, and I advocate that PHP7 should also be maintained.

6. Central startup point

Create a main class or initialization from which all code execution originates.

7. Clean up C code

I am not a C expert, but if you know more about Ruby’s C code to PHP’s C code, it can be very easy Understand the internals of PHP and Ruby. I'm very familiar with PHP, so writing my own extension is easier.

8. Get rid of eval()

eval() is evil. If you are using it then this is a wrong idea: this will break PHPUnit, discard it from now on.

9. Support operator overloading

Because everything is an object, developers only need to master the methods of operating objects.

10. Allowed method signatures

Allows true method signatures, so programmers can have methods with the same name with different parameter lists or return types.

<ol class="dp-c">
<li class="alt"><span><span class="keyword">class</span><span> A {   </span></span></li>
<li>
<span class="keyword">public</span><span> int </span><span class="keyword">function</span><span> doSomething(int </span><span class="vars">$a</span><span>, float </span><span class="vars">$b</span><span>) {   </span>
</li>
<li class="alt">
<span class="comment">// Same as $a->*($b->to_int());  </span><span> </span>
</li>
<li>
<span>int </span><span class="vars">$c</span><span> = </span><span class="vars">$a</span><span> * </span><span class="vars">$b</span><span>->to_int();   </span>
</li>
<li class="alt">
<span class="keyword">return</span><span> </span><span class="vars">$c</span><span>;   </span>
</li>
<li><span>}   </span></li>
<li class="alt">
<span class="keyword">public</span><span> float </span><span class="keyword">function</span><span> doSomething(int </span><span class="vars">$a</span><span>, float </span><span class="vars">$b</span><span>, float </span><span class="vars">$c</span><span>) {   </span>
</li>
<li>
<span class="comment">// Same as calling $a->*($b->*($c)); since * is a method on each object $a and $b.  </span><span> </span>
</li>
<li class="alt">
<span>float </span><span class="vars">$d</span><span> = </span><span class="vars">$a</span><span> * </span><span class="vars">$b</span><span> * </span><span class="vars">$c</span><span>;   </span>
</li>
<li>
<span class="keyword">return</span><span> </span><span class="vars">$d</span><span>;   </span>
</li>
<li class="alt"><span>}   </span></li>
<li><span>}  </span></li>
</ol>

11. Create a PHP Virtual Machine (PVM)

I’m not entirely sure this is possible Yeah, since I'm not a language designer, but it would be nice to have a PHP virtual machine. It can execute PHP bytecode and allows an explicit heap and stack.

12. Delete copy-on-write (COW)

COW is a fairly unfamiliar concept, if you don’t know its existence, to new developers , it may cause problems.

13. PHP official release specification

Similar to the W3C HTML5 specification, the PHP specification will allow developers to implement their own version of PHP and ensure that there are specific examples to Compile.

2. Respect language

Efforts should be made to respect language. We should try our best to recruit developers to make PHP7 with very powerful functions. We should make huge code safe, easy to read, and teach new developers to program the right way.

I don’t know about Ruby’s craziness, but I respect the Ruby language. I see its power, I see Ruby on Rails as a very good framework, it's just not my cup of tea. If we can gain recognition or respect from developers with good prestige, PHP will go further.

3. Respect developers

From the above understanding, we need a very respected PHP development core team. They release code, give talks, and show people the "right way" of doing things, and this team will quickly gain the respect of many developers.

Conclusion

I’m excited about the future of PHP. I highly doubt my ideas will be implemented, but I truly believe they will help society as a whole. I was so excited when the world's second largest website announced that they were helping PHP build great communities. PHP will not disappear, it will get better and better. As long as we work hard to improve it and improve it, one day PHP will become a language generally respected by developers.

Finally, I am not a language designer. My idea may be considered complete nonsense. If I'm incorrect somewhere, please politely let me know and I'll be happy to talk about it. Let's work together to make PHP a well-respected, powerful, fast, and efficient language. If there are any errors in compilation, please correct me!


www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/445773.htmlTechArticleProgrammers (generally) define a good programming language as one they know best or use most often. I'm a PHP programmer, John is a JavaScript programmer, DHH is a Ruby programmer, Schwa...
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn