What are the advantages and disadvantages of a weak language over a strong language? Can I use two languages, such as PHP and C #, for example?

Source: Internet
Author: User
Php Chinese network (www.php.cn) provides the most comprehensive basic tutorial on programming technology, introducing HTML, CSS, Javascript, Python, Java, Ruby, C, PHP, basic knowledge of MySQL and other programming languages. At the same time, this site also provides a large number of online instances, through which you can better learn programming... Reply content: before writing JavaScript, you can ignore the type of the variable and use it directly. Then various pitfalls ..
Clearly, it is well differentiated, but it is not clearly expressed in the language. In addition, some of the less intelligent types are automatically converted.
The weak type language is a good start, but you still cannot ignore the variable type if you want to be proficient.
In addition, if the problem can be solved outside the runtime, why should it be included. I have learned a lot about javascript recently. I knew that the weak language was easy to write, so I sacrificed a little performance and loaded a page with assert for more than two thousand times, proving that the effect was quite good. However, the browser does not tell me which assert is in any situation like Visual Studio. Even worse, in a language like C ++/C #, when an exception is caught, the debug information at the moment of throw is retained, javascript directly unwind the stack first and then catch it. it's hard to expand the content of the error object. I just watched the stack information and jumped over myself. However, at this moment, the local variable has been lost ......

Miss writing http://ASP.NET You can use Visual Studio to debug the code in the browser.

Php is also estimated to be similar. Weak types are not rigorous. when type requirements are strict, you must pay attention to exceptions. for example, when receiving a parameter, you must determine that the type is int, but all received by php can be treated as strings, you must use functions such as intval to convert your own data. sometimes, you need to "=" to make sure that the problem persists. C # you don't have to worry about this. if the type does not match, an error is returned when writing code.

A good example of the advantage of weak types is to operate json. php uses the json_decode function to convert it into an array. arrays are omnipotent in php and can be used as needed. C # The json solution is a bit complicated. every value must be converted to the corresponding type, that is, you must understand the structure and type of each value before parsing. I guess the subject actually wants to ask about the dynamic language and static language. in the "rigorous" language, it is usually a pre-defined value type, starting from beginning to end, the variable type is fixed.

Compared with the strong type, the disadvantages of the weak type are as follows:
(1) the weak type does not conform to "WYSIWYG" and the defined variable type is unpredictable and changeable.
(2) in order to be compatible with weak types, the language execution engine requires a lot of compatibility work, including type recognition, memory management, and type conversion, which increases the complexity of internal language processing, this will reduce the execution efficiency.
(3) variable types are uncontrollable. Therefore, a large number of variable types are "invisible conversions" during execution. developers do not know the implicit conversion rules, it is easy to produce unpredictable results. This feature is completely different from what you see is what you get.

However, there is a reason why they can develop and stand out.
Weak types and other language features reduce the barrier of programming languages. Programming language is a bridge between humans and machines. the ultimate pursuit is actually to "reduce the communication cost between humans and machines" and to pursue the realm of "everyone is programmable.
For example, from the machine language 0 and 1, then to the assembly language, the assembly language developed C, and then to the current script language. The threshold for programming learning is decreasing, and the number of programmers increases exponentially.
In addition, I believe that in the future, we will continue to develop languages with lower learning thresholds and promote the exponential growth of the number of programmers.

Weak languages also have the following advantages:
(1) shielding the language complexity and errors, such as memory management, pointers, and variable types. Although it shields complex features, it does not mean that they do not exist. this approach is friendly to people (easier programming and less consideration), but unfriendly to machines.
(2) high project development efficiency.
(3) low learning threshold.
Although it has many problems, it also contains obvious advantages.
PHP is widely used in Web development. Javascript rules browser-side development. these are not accidental phenomena, but they are chosen by voting with their feet.

Of course, there are specializations in the industry. different languages cannot be generalized to solve problems in different scenarios. For example, fastCSharp Whether it is development efficiency or operation efficiency, you are welcome to challenge PHPer at any time.
Weak language has two advantages: eval, which is not an advantage I really don't know; and eval, code is more elegant than a strong-type language (one line with a few clicks on the keyboard ).
Weak languages have too many weaknesses. it can be said that they are full, but many people do not want to admit it. The major benefit of the weak type lies in the convenience brought by the implementation of some other language features. Such as closures and callback functions. I don't understand PHP, But javascript relies heavily on callback functions and the derived error first callback pattern, which cannot be implemented in strong languages. Of course, there are other non-weak type implementations. for example, Ruby will use argument as hash to avoid problems such as inconsistent function signatures.

Many people mentioned that the ideal language should be optional static typing. Put it on strong/weak typing or the same, the best is optional weak typing. I only think that, unless necessary, the type of the check is not in the compilation period, so it should be dynamic typing as the default, explicitly declare static typing. However, the weak type should be the default strong type, explicitly declaring the weak type (that is, explicitly indicating the content convertible ).

However, there seems to be no one in such a language. XD can be used together. The advantage of PHP is that
PHP is the best language
Well, I have the responsibility to say it again.

PHP is a weak language. What are the common problems? For example.


  

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.