开发者

Pros and cons of weak and strong typing

开发者 https://www.devze.com 2023-02-23 01:17 出处:网络
I\'m making the transition from Java to PHP/Javascript and 开发者_如何学JAVAdiscovering all the practical aspects of using a weakly typed language.

I'm making the transition from Java to PHP/Javascript and 开发者_如何学JAVAdiscovering all the practical aspects of using a weakly typed language.

As I'm in a position to fully compare the two I'd like to know the pros and cons of each approach. Also, are there any other forms of typing out there?


A weakly dynamically typed programming language (like PHP) made that the programmer's mistakes occur as non-coherent behaviours (for instance, the program gonna display stupid informations).

With a strongly dynamically typed language (like python), the programming mistakes causes error message. It makes the mistakes easier to uncover and diagnosis but in general the program became not usable after the message has been shown.

Finally, with a strongly statically typed language (like Java, Ada, OCaml, Haskell, ...) some mistakes can be uncovered at compile time and hence reduce the risk to provide an bugged program. (but the release occurs later)


Yes. Python uses Dynamic Typing.

Generally it's a matter of personal preference and the role that the architects of a given language's intended use.

PHP (a scripting language) for example makes sense to be weakly typed, as the tasks it generally performs are far less complex, and require less constraints then say a compiled language.


Regarding your final question, Mathematica is said to be "typeless."

High-level, typeless, dynamic language with consistent symbolic syntax and semantics across all data, functions, and interfaces


PHP/javascript can be used to develope better looking UI's than Java. PHP will be having less constraints and easy to learn and execute than java.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号