3

In C#, is there any reason to say strongly typed vs just typed? When someone says typed class, I think of some type other than object. Nearly everything except object is typed in C#.

Once you define a class that is not object, that class is a type. It doesn't get anymore typed from there.

By the way, this isn't a question about type safety (valid memory access and object assignment compatibility).

asked Jun 19, 2013 at 22:06
9
  • 2
    Who says "typed class"? All classes are types.. Commented Jun 19, 2013 at 22:15
  • This comes up when talking about generics and type inference. "typed object" is another one. Commented Jun 19, 2013 at 22:15
  • 1
    @4thSpace can you link to or quote an example? Commented Jun 19, 2013 at 22:16
  • Not online. These conversations are in person. Commented Jun 19, 2013 at 22:18
  • 2
    See ericlippert.com/2012/10/15/… Commented Jun 19, 2013 at 22:33

4 Answers 4

6

The terms strongly and weakly typed refer to the rigidity of the rules of the language regarding implicit type conversions. A strongly typed language is much more strict on what implicit conversions it accepts, while a weakly typed one is more relaxed. In other words, lots of languages have types, but only a subset of them have strong typing.

You might be confusing those terms with the terms static and dynamic typing, which refer to knowledge of types at compile type or at runtime, respectively. In this sense, perhaps you've heard the term typed as a shorthand for statically typed. (Although I can't say that I agree with using the term typed, I think it's the only interpretation that seems to make sense.)

answered Jun 19, 2013 at 22:12
Sign up to request clarification or add additional context in comments.

Comments

3

Your nomenclature is incorrect. it is not strongly typed vs just typed

It's strong vs. weak typing

Once you talk about it in those terms, then there is a big distinction to be made.

You can read about it all over teh Googles.

http://en.wikipedia.org/wiki/Strong_and_weak_typing#Definitions_of_.22strong.22_or_.22weak.22

Edit:

There is no such thing as just a Typed language. You have Dynamic vs Static and Weak vs Strong typing which are addressing two different types of issues. Another reference article

What is the difference between a strongly typed language and a statically typed language?

answered Jun 19, 2013 at 22:10

6 Comments

No, that's not the question. I'm very familiar with the differences between weak/strong types. I hear people mention "typed" and "strongly typed" as if they are interchangeable. Again, this is in reference to C# only.
Based on your edit, the best thing is to ask someone to clarify what they mean by just "typed"? I always implied they meant "strongly typed". Maybe that was wrong to do.
Of course there's such a thing as a typed language and an untyped language. For example, the typed lambda calculus is a typed language and the untyped lambda calculus is an untyped language.
I can't say I'm an expert on the topic but I was pretty sure untyped was equivalent to dynamically typed. stackoverflow.com/questions/9154388/…
What if a language has no types whatsoever? How can it be "dynamically typed" in that case?
|
1

Be aware, the latest C# language specifications do not actually use the term "strongly typed" in their description of the language. This in contrast to, for instance, the Java language specification where they are very explicit in stating it is strongly typed.

Since the C# language specification does not use the term, it also does not define it. This is one of the reasons you're having a hard time getting an answer to your question. You can make a case however that even though by its specification, C# is not explicitly a "strongly typed" language, it does nevertheless have most of the characteristics of a strongly typed language.

To answer your C# question, I recommend taking a look at the Java language specification (Java resembles C# very closely and many of the fundamentals are very similar if not identical). In Chapter 4 it states:

The Java programming language is also a strongly typed language, because types limit the values that a variable (§4.12) can hold or that an expression can produce, limit the operations supported on those values, and determine the meaning of the operations. Strong static typing helps detect errors at compile time.

I'm providing this answer while I recognize other answers provide links to information on Wikipedia about strong typing in general, the question concerns C# specifically. I find the Java definition is more useful and to the point to the OP.

answered Jul 27, 2013 at 16:36

1 Comment

Though, msdn did say somewhere C# is a strongly typed.
0

Another angle that is not trying to define if a language is strong or weak or static or dynamic.

I am guilty of saying 'strongly typed'. Especially when I am working with a particular project that we are maintaining. This horrible codebase uses DataTable for pretty much everything and values are fetched as object, from columns by index with a lot of casting in the application code. And there are no comments explaining what the hell is going on.

Part of this system are now being rebuilt using EF and Linq. And now we are projecting queries into pocos/dtos. So having a service with a method that returns as generic list of a certain type is what I refer to when I say strongly typed. It's the service and its methods that are strongly typed, I am not talking about C# itself.

answered Jun 20, 2013 at 6:43

Comments

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.