What are the benefits (and drawbacks) of a weakly typed language?

后端 未结 7 918
情书的邮戳
情书的邮戳 2020-12-11 00:52

I\'m a big fan of PHP and it\'s obviously a very weakly-typed language. I realize some of the benefits include the general independence of changing variable types on the fly

7条回答
  •  慢半拍i
    慢半拍i (楼主)
    2020-12-11 01:55

    See this table, showing the results of the PHP == operator applied to pairs of empty or other principal values of various types, such as 0, "0", NULL and "". The operator is non-commutative, and the table is quite unintuitive, to say the least. (Not that it would make much sense to ask if a string is equal to an array, in fairness -- but you can do that in a weakly typed language, which is the pitfall, and may Turing help you if the language tries to "help" you.)

提交回复
热议问题