views:

163

answers:

6

Possible Duplicates:
What is a strictly typed language?
What are the key aspects of a strongly typed language?

What does it mean that language is strongly typed?

+3  A: 

"Strong typing" can have slightly different meanings depending on context (or who you ask), but generally it means that a language will not implicitly convert one datatype to another.

mipadi
+1  A: 

The terminology around typing is dreadfully confusing. One interpretation is that of type safety - whether a language allows you to subvert the type system.

C and Delphi do, by having void * and Pointer types, respectively.

Java and C# does not: even though there's Object, you will get a runtime exception if you try casting a Foo to Object only to cast it into Bar (where Bar and Foo are not in the same inheritance chain).

Note that "strongly typed" is independent of manifest typing - declaring the types of your variables like C or Java - and latent typing, where you don't, like Smalltalk.

Frank Shearar
+1  A: 

Back in the day we didn't have these namby-pamby "dynamic" languages - men were men, boys were boys and ints were ints. A char by any other name was just a byte. We had to cast our variables explicitly both ways through an assignment operation. You kids today have it easy, doing arithmetic operations on strings and concating variables with a compiler error in the world! And you're all into this duck-type thing with weak values...

Seriously though, strong typing means that the language places restrictions on your data types. You have to explicitly give your variables a type (such as int or string) and you need to cast or convert them when you want to change them to another type. C++ and Java are examples of strongly typed languages. In those languages you can't do:

"12" / 3;

Since you can't divide a string by an integer. However some languages such as perl and python will let you do that, and "12" will be converted to 12 automagically.

Niki Yoshiuchi
Explicitly declaring types is a different trait, actually. Type inference can be had in strongly-typed languages too. See C# and F# for example.
Joey
There are also dynamic languages that are somewhat strongly typed such as Python, where data types can't change once a variable is declared. Javascript is truly weakly typed, as the datatype of a variable can change on the fly.
Keith Rousseau
Yeah, I'm familiar with type inference as my favorite language is OCaml. However you are still giving your variables types, you just aren't naming them. Also I wanted to simplify my answer. I did not realize that Python was strongly typed. Thanks for letting me know!
Niki Yoshiuchi
When exactly *was* "back in the day"? Lisp (the very first dynamically typed programming language) was created in 1958, only a few months after Fortran (the very first statically typed programming language). So, the only time when "we didn't have these namby-pamby dynamic languages" but only static languages was a brief period in the winter of 1957/58. (And if I remember correctly, 1958 was the first *implementation* of Lisp, the first *specification* was in 1954, if I'm not mistaken.)
Jörg W Mittag
Dynamic typing is actually the opposite of static typing, both of which are orthogonal to strong vs. weak typing.
mipadi