Pros and cons of weak and strong typing

4.1k views Asked by At

I'm making the transition from Java to PHP/Javascript and discovering 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?

3

There are 3 answers

2
BenjaminB On BEST ANSWER

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)

0
Mr.Wizard On

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

0
jondavidjohn On

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.