Home  >  Article  >  Backend Development  >  Will there be a unified language specification for PHP, Java, and Javascript?

Will there be a unified language specification for PHP, Java, and Javascript?

WBOY
WBOYOriginal
2016-12-01 00:01:20905browse

This question is used to imagine the future. You can not consider too many practical factors, such as business policies, government policies, etc.

First of all, the grammatical standards of ES6, java8, and php7 have some overlap with each other. The basic syntax of the three is also very similar.

From the perspective of application, the three languages ​​​​are quite engineering and are used to build very complex projects.

Although js can also be used to run on the browser side, the recent component framework has made front-end development similar to desktop applications. It can be said that if the browser can run java or php and allows to operate DOM, react can use this Implemented in both languages.

In terms of backend, the three languages ​​​​are not in contact for a day or two. Each function is complete, the development is agile, and the ecosystem is prosperous.

So, I think it is possible to unify language standards. If standards are unified, it is conceivable that programmers' learning costs will be greatly reduced, and they can pay more attention to front-end and back-end development technologies, programming language ideas and general grammatical features, instead of paying attention to various grammatical details, environmental dependencies and third-party programming. Third-party libraries, after all, third-party libraries will also become universal.

However, if a standard is really launched, there are still several troublesome questions:
Compilation or interpretation?
Strong type or weak type?
Event-driven or multi-threaded?
How to unify different package management?
How to run it on the browser side?
How to weigh garbage collection?

I’m curious what everyone thinks!

Reply content:

Indeed, the grammars of many modern languages ​​are increasingly similar. For example, the improvement of PHP's syntax makes it more and more like JavaScript (for example, the abbreviation of array(...) construct is [...]), and async/await introduced in various languages ​​​​are almost exactly the same, and Facebook recently The developed Reason is to transform the syntax of OCaml to be very similar to JS. So it seems that grammatical unification is not impossible in theory.

However, syntax, like all other parts, has the issue of maintaining compatibility. Counterexamples that break compatibility, such as python3. This is not true for the upgrade of a language itself, let alone different languages. To give another small example, there has been debate in JS as a language about whether to use optional semicolons, let alone other languages.

Even if it can be modified to be very close at the grammatical level, the more troublesome thing is at the semantic level. The "troublesome question" raised by the subject:
Compilation or interpretation?
Strong type or weak type?
Event-driven or multi-threaded?
How to unify different package management?
How to run it on the browser side?
How to weigh garbage collection?
In fact, it’s not a grammar problem at all.

Don’t talk about these big problems, let me give you another small example, still PHP and JS. Both arrays can be constructed using [1, 2, 3] and then accessed using subscript syntax like a[0]. And arrays in PHP and JS can also use strings as keys. Even if the string is a number, it will be the same as the numeric index. They look exactly the same. But arrays in PHP and JS are actually very different.

1. Both JS and PHP perform implicit type conversion on indexes. The indexes of JS are all naturalized into strings, so a[10] and a[10.1] are different. But PHP's index is first normalized to an integer, so a[10] and a[10.1] are the same.

2. In PHP:
<code class="language-text">$a1 = [1, 2];
$a2 = [0 => 1, 1 => 2];
$a3 = [1 => 2, 0 => 1];
</code>
Boy, don’t think too much. Even if several other languages ​​are willing to unify, do you think J8 boss Larry Ellison is willing? There will not be a unified standard

Hanyu Pinyin and English are both represented by 26 letters, but the content is very different no problem. PHP has JPHP, JS has Narshor, Python has Jython, and Java, needless to say, runs on the JVM itself.
So the "grand unification" mentioned by the questioner does not need to be realized at the language level. It is enough for them to be able to call each other. The only things that remain unchanged are C and Go.
It depends on whether the inventor of the language insists on his own taste. Even if there is such an opportunity, it will only be a new language that unifies the language specifications of php, js, and java. . . Just because there are many people who think this way, many people want to dominate the world, which results in more and more languages. Whether or not they are unified depends on the strength of the support, not the language characteristics. It is better to imagine the future than to make it yourself. Yes, the machine codes should be unified! do not hit me. . . Then my big php can't be turned into Armstrong's Spin Armstrong Hammer。◕‿◕。
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