strongly typed

  • Thread starter Thread starter Mark
  • Start date Start date
M

Mark

Just wanted to confirm that my understanding of a strongly typed language is
correct:

1. .NET is a strongly typed language because each variable / field must be
declared a specific type (String, Int, Float, etc...)
2. VB 6 and VBScript were not strongly typed because both allowed you to ...

dim blah

.... which creates a variant.

3. Java, C#, etc are also a strongly typed language because each variable
must be declared a specific datatype, again like String, Int32, etc.

Correct? Is there more to it?

Thanks!

Mark
 
Nobody else has chimed in yet, so here are my thoughts...

Mark said:
Just wanted to confirm that my understanding of a strongly typed language is
correct:

1. .NET is a strongly typed language because each variable / field must be
declared a specific type (String, Int, Float, etc...)
2. VB 6 and VBScript were not strongly typed because both allowed you to ....
dim blah

... which creates a variant.

..Net is not a language - it's a set of technologies - including languages
like VB.NET, C#, managed C++, J# and also things like a common language
runtime (CLR) that includes the just-in-time (JIT) compiler, garbage
collector, etc, and also the classes of the base class library (BCL).

I don't know if I would say that the framework itself is strongly typed or
not. I suppose it is since every object will, be definition, have a type
associated with it (even if it is just object). But anything can be cast to
object, and that gets rid of some of the benefit of typing. For example,
you can put any object onto an ArrayList. The object will have a type, but
the ArrayList won't care. Nor will the method that pulls the object off the
arraylist, until it finds out that what it got wasn't necessarily the same
type that it was expecting.

And languages don't have to be strongly typed to use the framework. VB.NET
by default is not strongly typed, unless you use Option Strict. You are
right that VB 6 and VBScript were not strongly typed.
3. Java, C#, etc are also a strongly typed language because each variable
must be declared a specific datatype, again like String, Int32, etc.

I would agree with the following addition. Strongly typed, to me, means
that you can't just change the type of things on the fly, unless very
specific rules are followed or you indicate exactly what you mean (casting).
For example, you can't do this in c#:

Double x = 8;
Single y = x;

You must make it specifically clear that you want to cast from a high
precision number to a lower one:

Single y = (Single) x;

So I think that's the other half of being strongly typed.
 
Back
Top