-1

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?

James P.
  • 19,313
  • 27
  • 97
  • 155
  • All pros abd cons are task dependent – Andrey Sboev Apr 09 '11 at 19:45
  • 1
    might interest you as well : http://stackoverflow.com/questions/3376252/what-are-the-benefits-and-drawbacks-of-a-weakly-typed-language – Spyros Apr 09 '11 at 20:16
  • 1
    similar questions: http://stackoverflow.com/q/1489674, http://stackoverflow.com/q/4470012, http://stackoverflow.com/q/47972, http://stackoverflow.com/q/2025353, http://stackoverflow.com/q/880410, http://stackoverflow.com/q/3376252 – WReach Apr 10 '11 at 00:31

3 Answers3

5

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)

BenjaminB
  • 1,809
  • 3
  • 18
  • 32
  • "The release occurs later." - any evidence of that? If we don't talk about some 100 lines trivial programs, I doubt that. – Ingo Apr 10 '11 at 10:27
  • PHP is the only one out of your listed languages that was developed purely for the context of the web. The context of the web only deals with strings. – Pete Sep 18 '13 at 10:15
1

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.

jondavidjohn
  • 61,812
  • 21
  • 118
  • 158
1

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

Mr.Wizard
  • 24,179
  • 5
  • 44
  • 125