Question

I'm confused about the purpose of the CLS (Common Language Specification) in the .NET Framework.

My understanding is that, with .NET, we can write a library with one language and use it in another language, and that the CLR enables this functionality. I do know that the purpose of the CLS is to fully interact with other objects regardless of the language they were implemented in.

What is the CLS exactly; what is its purpose?

Was it helpful?

Solution

The CLS is a guide-line intended for developers of components, as well as compiler-writers. It specifies what is allowed and what is not allowed in order to generate components, and build support for languages, in such a way that they are portable - and fully compatible to be consumed/interacted with from all CLS-compliant languages that can run in the CLR.

While the CLR has specifications that are exposed and enforced by the implementation. The CLS is just a guideline. You can still write components that break the CLS, but will work fine in the CLR. But in that case they might not be inter-operable with certain languages.

Obviously, the CLS is very important for compiler writers and language designers. But even as a component developer, it's important to stay within the lines of the CLS if you're striving for full inter-operability.

OTHER TIPS

I think with .Net we can write a library with one language and use it in another language and to do this there is the CLR, What is the CLS exactly, what is its purpose?

While this language integration is fantastic, the truth is that programming languages are very different, So to help you with this or to make CLR achieve this -

Microsoft has defined the Common Language Specification (CLS) that details for compiler vendors the minimum set of features their compiler must support, if these compilers are to generate types compatible with other components written by other CLS compliant languages on top of the CLR.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top