开发者

Can a programming language be part of a platform? (C# and Java related)

He's the deal: I'm making some theorical research on .NET and Java platforms for my graduation course and I reached a cloudy area: Can C# be considered part of the .NET Framework? Analog to this, is Java (the programming language)开发者_StackOverflow社区 considered part of the Java platform?

Let me review the facts:

  1. .NET is a development platform specified by the ECMA-335 Standard; it is an implementation of this standard, if you will. C# however, is an implementation of another standard, ECMA-334 which states clearly that its implementation does not require an implementation of the ECMA-335 standard - the CLR in Microsoft's case (which a lot of people mistakenly call .NET when there's a lot more to it than just the CLR).

  2. Also, we have Mono, a different implementation of the ECMA-335, on which C# also runs (from everything I read, it is implied that Novell doesn't have a ECMA-334 implementation of its own, which is perfectly reasonable), but C# is not PART of Mono.

  3. There's the fact that I read somewhere that a programming language is not part of a platform, but unfortunatelly I can't seem to find the source.

  4. There's also the fact that Wikipedia "Computing Platform" article states that a programming language is a platform; Wiki is, however, virtually worthless if you want your research to be taken seriously.

  5. Microsoft seems to promote C# as a part of .NET, but being .NET a multi-language platform, wouldn't be so every language that supports/is supported by it?

So far, I only spoke of .NET, but I also need an answer regarding Java. Actually, a general response would be the best.

So, can anyone help me to put the pieces together? Reference material is much appreciated.


On a different issue, I've found A LOT of books out there that explain the inner workings of the CLR, isn't anything on the same lines for the JVM? I mean, there's the Specification, of course, but I was aiming for something easier to digest, I'm not planning to build a Java compiler after all..


As everybody seems to notice, it depends on your definitions.

But Ecma 334 (and/or some other Ecma doc) also specify MSIL (or CIL), and that definitely is part of the platform.

And I think C# is not part of the platform, the MS compiler just targets the CLR by outputting MSIL. it's not so hard to imagine an implementation for another platform, managed or unmanaged.

Java confuses the issue a little by having both a platform and a language called Java but it's not so hard to see the distinction.

So, can a language be part of a Platform? Yes, see MSIL.
But most languages (including C# and Java) are not.

A lot of languages (C, C++) make an active effort to be portable across platforms.


Are you asking in general? If so then it would seem to me that surely the answer is yes, a programming language can be part of a platform. For instance, the ECMA-335 standard includes a specification of the CIL programming language. It could have pointed to the C# language as well and referenced the ECMA-334 standard. It just doesn't.

This is really a question of loose vs. tight coupling applied on a broad scale. Loose is generally preferred as a design choice. Tight is nonetheless always an option.


Thinking about the question a bit more, I think I understand better what you are uncertain about. There's the CLI, specified by ECMA-335, and then there's .NET, which is obviously tied to Microsoft.

The CLI does not include C#; on that much I think we can agree. Does .NET?

Honestly, I'm not really sure. Considering .NET is a product maintained by Microsoft, I suppose it's really up to them whether C#, VB.NET, F#, etc. are or are not a "part of" .NET. Same goes for Sun with Java and the "Java platform."


Going back a bit further(1978), the distintion between UCSD Pascal & the UCSD p-System was often blurred, such that most users refered to UCSD Pascal as the operating system.


C# is a programming language. It was developed by Microsoft within the .NET initiative and later approved as a standard by Ecma (ECMA-334) and ISO (ISO/IEC 23270). Mono, DotGNU and DotNetAnywhere are not ".NET" implementations of C#. So C# is part of .NET, Mono, DotGNU and DotNetAnywhere.

Java programming language is also a language, which runs on the Java Platform. Remember, the JVM can run many programming languages (Scala, Groovy, JRuby, Jython). Then you have the different Java "platforms": Java Standard Edition, Java Enterprise Edition, and Java Mobile Edition. Each of these follow certain specifications defined by the Java Community Process, and they include the Java programming language.


Sun/Oracle's thinking on the subject pertaining to Java:

Java technology is both a programming language and a platform.

Later:

A platform is the hardware or software environment in which a program runs. ... The Java platform differs from most other platforms in that it's a software-only platform that runs on top of other hardware-based platforms.

So I would say according to their definition, the Java Language is not "part" of the Java platform. Just as C99 isn't part of of the Unix platform, etc.

In practice, though, the lines are somewhat blurred. The Java Language is probably more coupled to the Java Platform than they would like to admit. The Java API (the libraries) are said to be part of the Java Platform, not the language, and yet the language is coupled to certain classes or interfaces (for example, the for-each loop depends on java.lang.Iterable and java.util.Iterator).

In general, the designers attempt to contain the coupling to the java.lang package, that being for language support. That's why you see special cases like String, Object, etc. in java.lang.


From a purely theoretical standpoint, language and platform are seperate. The language specification of C# defines ONLY its structure and syntax; how it should look and act from the perspective of the programmer. From an object-oriented perspective, the language is an interface (quite literally), and platforms are implementations of it. There are many C/C++ IDEs out there, all of which can conform to the ANSI C++ specification for the language itself (some include extra gizmos). If you wanted to, you could write a compiler that will accept C# code files and produce Java intermediate instead of MSIL, or even native machine code (though as C# was designed for a managed-code platform, some features of a native-code language, like the ability to explicitly destroy objects, may need to be added to the spec to make it work).

In the real world, C# is all-but-inseperable from the .NET Framework because Microsoft developed the language spec, and MS's implementation (.NET) is by far the most prolific. So, the language is usually considered part of the platform, to the point that hardly anybody says C#.NET anymore. There are ports of the language spec (usually written for workalikes of the MS platform), but when you just say C#, developers assume you are talking about C# in the context of the .NET Framework.


A simple answer could be yes and no, as you said, it's a cloudy area. You will probably find some arguments for, and some against, both equally valid.

But my point of view is that c# is not a part of .NET. C# is designed for platforms like .NET and puts quite specific demands of the platform, like managed memory, that 32 bit assignments can be implemented atomically, etc.

Turn the question around, does .NET require c#? Throw c# out and you still have VB.NET, etc. C# can be thought of as a plugin that requires a platform with a specific interface, where .NET implements that interface.

As a "Yes" argument you could ask the rhetorical question what .NET would be without c#. Would it even survive?


Not C# or Java related but, for instance, SmallTalk platform includes not only the language and the VM but also the IDE. So I guess the answer to your question is: yes - a programming language can be a part of a platform.


C# does depend on certain .NET classes (specifically, in mscorlib) to implement its special constructs, though I suppose you could create equivalents for a different backing runtime.

  • foreach depends on IEnumerable or IEnumerable<T>
  • using depends on IDisposable
  • Lambda expressions can resolve to special generic representation objects Expression<>
  • yield return is also tied into the .NET enumeration model

So C# isn't completely independent of at least some aspects of .NET and the CLR, though you could, in principle, get the same behavior by creating a runtime/compiler that provides only the minimal subset of .NET features required to implement the language features. I don't think it would be particularly useful, however, since the language and runtime have grown and evolved together.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜