C Sharp |
The CLR is the Common Language Runtime. This allows multiple languages to be compiled to a standard in which the JIT (Just-in-Time) compiler can interpret.
=Compiled (JITted) Code Cache and ngen.exe=
From the article:
The resulting binary code is stored temporarily (in a memory cache), so if the program uses that portion of code again, the cached version is used. However this is only in effect during the runtime of the program. If a .NET application is run again, this compilation process is done again.
I happen to know that certain libraries and executables are compiled to native code and stored in some sort of cache on the hard drive under some conditions. ngen.exe is part of the procedure that makes this possible. Someone (or myself) should do the research to make the necessary corrections to the article.
09:53, 18 Jan 2004 (UTC)
Actually, this is technically incorrect. I am pretty sure that the object code is usually written to disk, but I might be wrong. Certain run-time optimizations may prevent this, I am not sure. : In .Net object code is normaly never writen to disk, JIT compile it when needed and that s all (So the MSIL->x86 compilation appends for every launch) but that s true that you could ngen your assemblies and then the object code will be used) :The standard practice is what do microsoft : using ngen to generate native assemblies during the setup of the program : 28 June 2005 21:57 (UTC)
=Complete Hash=
Certain cynics have suggested that C# should be pronounced complete hash .
: See-Pound is also sometimes used (by me, at least!). - 07:09, 18 Nov 2003 (UTC)
: Cynics of nearly everything have alternate pronunciations/spellings for products they wish to jeer. Point 09:53, 18 Jan 2004 (UTC)
=Is C# Just a Java Clone=
: Many sources say that C# is more or less a copy of 02:26 30 Dec 2002 (UTC)
::C# has many of the same features as Java, but also has some noticeable differences. It is obvious that the C# designers used a lot of concepts from Java, but they took some from C++ as well.
::The big differences are in the actual class heirarchies and actual executable representation. Java has a big set of base classes, as does C#. But Java s and C# s class libraries bear little resemblance to one another.
::A Java executable contains byte-code which must be executed via a Java Virtual Machine (JVM). Similarly, C# executables contain MSIL which must be JITted via the .NET framework (or the CLR). The JVM converts byte code into binary code as it is executed. The binary output of C# code is cached and used again if the program uses that part of the code again. So C# may be faster in execution since it caches the binary code and most JVM s do not.
::Critics state that C# is MS s attempt to kill Java. Who knows if this is true, but the reality is that C# fixed and added a lot of features that Java excluded. Java still has its place as does C# now.
::Feel free to include any of this information in the article as you see fit.
::— 20:43 9 Jul 2003 (UTC)
:::I think beginners are helped if there is a clear distinction made between programming languages, used to express a programming idea, and the mechanisms supplied to interpret that language. Is it really true that C# programs will only ever be interpreted by the .NET framework 18:57, 15 Apr 2004 (UTC)
::Well, that Microsoft s plan. They plan to install the .NET Framework on all future versions of their operating systems (the MSIL is portable in this manner), but I don t think they ll stop anyone who wants to write their own version of the CLR for a different OS. Being Microsoft, they ll just change it so often that it will be impossible to keep it as up to date as the Windows CLR. Why do you ask — 19:09, Apr 15, 2004 (UTC)
: [http://www.csharphelp.com/archives/archive96.html Java And C-Sharp Compared ] has a pretty good comparison of the two languages. - 20:45, 15 Apr 2004 (UTC)
::There is a lot of politics here, no question. Microsoft is Microsoft. Windows needed a new development platform. A Java-like language with a supporting runtime was a natural choice - it was popular, easier to program (in some ways) than C/C++, and could cleanly support multiple languages, even multilanguage projects.
::If Java was open source, Microsoft wouldn t be able to touch it. Java is corporate sponsored by Sun, which has been a clear enemy of Microsoft (in the 90 s the CEO was very vocal about MS). So Microsoft could not invest in Java without giving huge credibility and control to Sun. Even then, Java and a JVM alone would not unify the platform the same way .NET does. The natural choice was to make a similar language, C#, and a new runtime (CLR).
:Dude, sign your posts.
Use ~~~ or ~~~~ (the latter timestamps your signature, like mine). 15:41, Jul 6, 2004 (UTC)
:C# is hardly a Java clone. One could claim that Java is a C++ clone, ad infitum if you wanted to start equivocating wildly. C# has had from the beginning strong Java influences, yes, but not a clone. C# retains the concept of pointers, enumerations (just added in J2SE5... wtf, they skipped 3.5 numbers!), event handling (it is a first class citizen in the language, so to speak), operator overloading (Java needs this to be a better OO language, IMO), the foreach loop, and others. Moreover, IMO, C# has the right amount of verboseness, having programmed in both Java and C# extensively, I say it is smarter to write bool rather than boolean .
::I don t think Java, or any other language for that matter, needs operator overloading to be a better OO language. After all, it s just syntactic sugar for method calls. In fact, I think Java needs to get rid of the way you can call static methods via instance references to be a better OO language. 07:40, 21 Apr 2005 (UTC)
::: Syntactic sugar Come on! It makes statements a lot more readable... someClass + someInt is more readable (and more concise) than someClass.toInt() + someInt. 01:21, 1 Jun 2005 (UTC)
:Just wanted to agree with the last reply - C# is FAR from a Java clone. It is somewhat similar syntactically but the fact that it s part of the 07:57, 19 Dec 2004 (UTC)
=Delphi s Influence=
C# s chief architect is Anders Hejlsberg, the brains behind Turbo Pascal and arguably the main brain behind Delphi. The similarities between C# and Delphi are striking to anyone familiar with both languages. This point deserves a bit of expansion, I think: you can t grok C# if you only think about Java and C++, because a lot of the stuff that s alien to both is part of Delphi.
: Quite true. C# addresses a number of problems and annoyances that are found in C++, much more so than Java did. I can certainly see the Delphi influence in C#, although It s probably more obvious in the IDE than in the language itself. C# also takes programming languages a step beyond existing languages with the concept of attributes. -- 5 July 2005 13:35 (UTC)
=Paragraph Too Technical=
The following paragraph needs elaboration (better language, more context, eg. comparsion with Java JIT compilers which have been around for some years now; language too technical. From a user point of view it is important too know if the programs are as slow as Java programs or not.)
The verb to jit is not generally known. 
When the program is executed, the .NET framework JITs the intermediate code into machine language as it is run. The JITting is very fast and is not noticeable on most modern personal computer. As different parts of the program are used, they are JITted. Once JITted, that portion of the program does not need to be JITted again for that run (the program will use the JITted version). Each time a .NET application is run, it needs to be JITted in this fashion. Because the .NET applications require this JITting, only computers with the .NET framework can run .NET applications.
-- 13:07 9 Jul 2003 (UTC)
:How s this
: When the program is executed, the .NET framework JITs the intermediate code into binary code as it is run. The JITting is very fast and is not noticeable on most modern personal computer. As different parts of the program are used, they are JITted and the resulting binary code is cached. If the program uses that portion of code again, the cached binary version is used. Each time a .NET application is run, it needs to be JITted in this fashion. Because the .NET applications require this JITting, only computers with the .NET framework can run .NET applications.
: I m technical, so it s hard for me to see what is too technical about this paragraph (I wrote it originally). I included links for JIT which I realize is unfamiliar to many people. I d appreciate someone unfamiliar with the field to take a swipe at it, but the whole JITting thing is pretty technical. I don t know if it can be made any easier to understand. But just because it s hard to grasp doesn t mean it shouldn t be included. I read TONS of stuff in Wikipedia that I don t understand.
— 20:28 9 Jul 2003 (UTC)
:: I gave it a try. I avoided using the abreviation jit as a verb. I added two subtitles. It would be nice to have something about the syntax as well. -- 22:25 9 Jul 2003 (UTC)
:::The syntax is similar to both Java and C++. For example, in C++ you might use class.foo() or class->foo() depending on the situation. In Java and C#, you always use the dot notation (i.e. class.foo()).
:::C# also has a really nice feature called Properties . With a Property, you can get/set values in classes in a more familiar manner while still hiding information. Let me put this into plain English. In C++ or Java, to get or set a private member, you d have to do this: ::::int foo = myClass.GetFoo(); ::::myClass.SetFoo( foo ); :::However, with properties in C#, you can do this: ::::int foo = myClass.Foo; ::::myClass.Foo = foo; :::It looks like you are setting and getting a public member, but in reality you are accessing the private instance of foo (notice capilization). The manner in which properties are declared in C# looks like this: public class Bar { private int foo; ... public int Foo { get { return foo; } set { foo = value; } } ... } :::Note the special keywords get , set and value . The example above just returns and sets the private member, but anything can be put into the get/set routines--they behave just like regular functions.
:::C# also won t allow you to directly access memory like you can in C++ (it is similar to Java in this manner). But you can access memory directly if you enclose the code in a block declared as unsafe . If you do this, you, the programmer, are responsible for releasing any memory you allocate as the GC won t.
:::There are other differences, but these are the two big ones that come to mind. — 14:25 10 Jul 2003 (UTC)
=C# to C#=
I noticed ). If no one objects, I ll change it back to C#. Any objections
Also, I changed the notation in the example from the K&R/Java style to the C++/C# style which is preferable for C# code. — 14:19, 4 Aug 2003 (UTC)
No, wait, this is how MS themselves format it on the box... 03:56, 17 Nov 2003 (UTC)
Lookylooky [http://shop.microsoft.com/Referral/Productinfo.aspsiteID=11510] :) I suspect MS couldn t be bothered to always render C# as C#... 04:06, 17 Nov 2003 (UTC)
Microsoft marketing uses a logo that resembles .net but you ll find Microsft explictly states it s more corretly .NET , so I expect C# versus C# is the same, but I haven t looked for the style/trademark guide that says so. — 19:07, 17 Nov 2003 (UTC)
Perhaps it ll be best to sup the sharp once, and leave the rest. I don t know :) 10:11, 17 Nov 2003 (UTC)
I m a total newb but I undid Nohats use of the proper sharp symbol mainly because it was showing up as a square in Internet Explorer and Opera. So I think the symbol used wasn t UTF-8 or something. Using a superscript version of the regular # seems to work best because it shouldn mess up searches too much. Pardon me if I goofed up, a newb still getting his bearings. 13:31, 1 August 2005 (UTC)
:You were absolutely right about this, Foofy. The large majority of readers (more than 95%) will just see screwed up characters, not the intended character, regardless of which is more correct. Let s stick to # and think about our readers. 18:52, 1 August 2005 (UTC)
=Should Remove Marketing Entry=
The Marketing entry in this article seems out of place, narrowly focused, and frankly it reads like an opinion more then a fact. I favor removing it, but wanted to solicit opinions before I did so. 14 Jun 2004
:Well, I think it s in place. It doesn t discuss the technical aspects of the language, but it s relevant. The section could probably have a better name, but other than that, I think it should stay. But I m biased since I wrote it in the first place. — 19:43, Jun 14, 2004 (UTC)
::I wasn t trying to make a judgement on relevance. Instead, I was making a judgement on whether the statements in the section are fact or opinion. The statement that Mobile Software can be developed out of the box with C# and not so with C++ is a fact. The assertion that this has to do with marketing or that it is meant to move people off of the C++ language is not a documented fact; and so in this context it is an opinion. I am attempting to follow the guidelines found here here
::If the section stated that the opinions are opinions, and if the section was re-titled as politics and marketing, then that might be a way of improving the entry such that it doesn t need removing altogether. Frecklefoot, are you open to my taking a stab at such as modification -- 20:23, Jun 14, 2004 (UTC)
Absolutely.
That s what s so great about being Wiki. But that point of view is not just mine, but of course that doesn t make it a fact either (I m not anti-MS, but it is something that is rather glaring about VS.NET). — 21:03, Jun 14, 2004 (UTC)
:I agree that this is not quite NPOV. Also, how is being able to develop a C# mobile app from visual studio an example of MS s aggressive marketing of C# When you re in there, try tacking that as well. -- 21:39, 14 Jun 2004 (UTC)
The marketing entry removed. Placing it here so it can rewritten or re-added at some point:
:==Marketing== :Microsoft is aggressively marketing C# as well as the other .NET languages. For example, purchasers of the latest version of Visual Studio .NET (Microsoft s popular Integrated development environment) can immediately develop mobile device applications in C#. To develop mobile device applications in other languages, such as C++ (which Visual Studio supports), developers have to download a separate IDE which does not integrate with Visual Studio. With these barriers, Microsoft is motivating developers to abandon C++ and switch to C#.
To 14:51, Jun 24, 2004 (UTC)
:A possible reason for MS to do this, as you say, is to move developers to C#. A more likely reason is that the team that built this functionality only had a limited budget and put it into the language they used the most. However, even if they were motivated as you supposed, I don t think this falls into what is gererally considered as marketing. -- 21:19, 25 Jun 2004 (UTC)
Well, that is a reasonable assumption except for the fact that they removed the mobile C++ functionality . MS doesn t have plans to put it back in–they are going to keep it separate. But you re right, Marketing probably isn t the best place for this; I just couldn t think of a better section. 00:41, Jun 26, 2004 (UTC)
I think you re wrong when you say that they removed mobile C++ functionality. Could you clarify what you meant The latest C++ compiler for mobile processors is out (version 4) and you could use managed C++ to develop for a mobile device, since it compiles to MSIL instead of native bytecodes. Feel free to correct me if I misinterpreted what you wrote or got something wrong.
I misspoke myself a little. To develop for mobile devices in C++, one cannot use Visual Studio.NET. One must download a seperate IDE. It is similar to Studio.NET, but lacks many of its features. On the other hand, one may develop mobile device applications in Studio.NET using any other language but C++. Yes, you can use managed C++, but that s just the point: why allow Managed C++ but not C++ Studio .NET is supposed to be a full-fledged C++ IDE, but one cannot use it to develop mobile applications in C++, just the .NET languages. HTH.
19:45, Jan 10, 2005 (UTC)
=MSIL or CIL=
I m not trying to point fingers, but 14:51, Jun 24, 2004 (UTC)
:Perhaps relevant: http://dotnet.di.unipi.it/EcmaSpec/PartitionIII/index.html uses CIL. - 17:24, 30 Jun 2004 (UTC)
:: CIL is very common. MSIL is used in documentation and obviously specifically in reference to .NET. CIL is the ECMA spec as mentioned above (obviously critical to the Common Language Infrastructure / CLI). Technically, the CLR is the Microsoft implementation of the CLI. Therefore, it s not incorrect to say MSIL, denoting the Microsoft runtime as a target platform. From one programmer to another, that makes sense. Of course, when you say .NET, you mean Microsoft anyway. I m not aware of any inconsistency in MSIL from CIL spec.
::Basically, MSIL is to CIL as CLR is to CLI and .NET is to CLS (Common Language Specification). I have seen MSIL/CIL, CLR/CLI, and .NET/CLS (often without the slash).
:: O Reilly .NET Framework (2nd ed.) mentions MSIL only in the glossary, index, and Appendix D (Common Utilities). However I don t remember it in any of the book s chapters and all the common utilities (ilasm.exe, ildasm.exe, etc.) binaries are neutrally named. No hybrid names that I remember - mostly IL.
:: The Mono Project uses the term MSIL/CIL, according to a Google site: search. This is also used in mailing lists. That hybrid term communicates to me IL code that conforms to spec and .NET (right now an artificial difference as .NET should fully support CIL).
:: Microsoft documentation uses MSIL, IL, and CIL.
:: I would use IL in general, but we should conform to what s common. It s not good form to use MSIL to refer to all CIL (because we do have a spec and things like Mono), but I don t see anything wrong with using MSIL/CIL.
::Microsoft Reference: http://msdn.microsoft.com/net/ecma/ ::Mono Project: http://www.mono-project.com/
:: 04:47, 12 Jul 2004 (UTC)
:: If memory serves me, CIL is actually the *old* name. I have at least one early-release .NET book that uses the phrase CIL, but all references on Microsoft s documentation was changed to MSIL by the time the Framework was released. I m pretty sure it was a purely cosmetic name change, that is, MSIL == CIL. Searching Google for CIL dotnet shows a number of references, but mostly from 2002/2003 timeframe. For all I know, MS changed the name just so they could say missle when talking about their technology :) 15:02, 29 Apr 2005 (UTC)
:: IL is intermediate language, the problem is that it is generic and could be used widely (java .class are in an intermediate language). MSIL is the first name that this technology got, but when microsoft standardized it they needed to remove the microsoft (MS) part of the name, so they choosen comon intermediate language CIL. But the name MSIL doesn t disapear. Actualy if you speak of the 2.0 version of the platform it could be wrong to speak about CIL, because the standardized version is still the 1.0 version. 28 June 2005 22:08 (UTC)
= C# does NOT use Virtual Machine =
Neither stack-based , nor any other. Therein lies its main difference between Java and .NET. Java bytecode runs on VM, .NET Intermediate Language gets compiled upon its execution and only then it is executed. VM is simply not needed in this arrangement because .NET never executes bytecode directly (though one can definitely write a VM that will execute MSIL).
:But the compilation is done by a virutal machine of sorts: the .NET framework. Without it, you can t run a CIL (or MSIL) program. The framework is present, constantly compiling any CIL code that needs to be executed. That s close enough to a VM for me.
:And, dude, sign your posts. Use ~~~ or ~~~~. The latter is preferred by most, as it adds a timestamp to your signature.
15:47, Jul 6, 2004 (UTC)
:: Actually, if I understand the technology properly, the Framework installation actually changes the native process loader for Windows platforms. There is no virtual machine involved, merely calls into the JIT compiler.
:: For non-Windows platforms, the similarities are much closer; you need to explicitly run the mono program on a Mono application for it to work, though I m not sure the internal workings of that. At any rate, the original point is technically accurate that C# doesn t use a VM -- at best, .NET uses a VM and C# compiles to .NET MSIL. Perhaps that s a better way to phrase it, or leave the VM/not-a-VM discussion for the .NET article
:: 14:57, 29 Apr 2005 (UTC)
::: Pointless trivia: the framework does change the native process loader but it doesn t need to on 32-bit windows. A pure MSIL binary is still a standard win32 x86 binary containing a single x86 instruction: a jump to CorExeMain in mscoree.dll. The loader only needs to be changed to allow truly cross-platform MSIL binaries.
::: The question of whether .NET uses a VM is fairly meaningless. Both Java and .Net define VMs in their specifications. Both Java and .Net implement their specifications by JITing the byte code into native code. (And there are interpreters for both, but they are slower.) The fact that Java uses an EXE to implement its VM (so all java processes have the same name) and .Net uses a DLL (so processes have their own names) actually makes no significant difference. For example, this doesn t have any implications for security. Indeed, the fact that .Net apps on Linux run in the same syle as Java apps shows the equivalence of the two approaches.
::: 10 Oct 2005
= C# Critique =
I wrote a C# critique at http://www.heron-language.com/c-sharp-critique.html which I believe should be added to the external links. I won t add it myself because that could be construed as blatant self-promotion.
:I read it, not bad. I added it to the list, but we should probably trim a few if the list gets any longer. Get too many links and the list becomes worthless. Next time, dude, sign your post (anyone can still go back in the history and see who made the post, but signing saves them the extra work). You can sign your post by using 3 tildes (~~~) or 4 (~~~~). The latter gives your signature a timestamp. If you re concerned about privacy, create an account. If you sign posts without an account, your IP address is shown. With an account, just your username is shown without any other information. Peace.
13:51, Jul 7, 2004 (UTC)
Have a look at the OpCodes enumeration in System.Reflection.Emit. The MSIL is stack-based. Obviously compiled MSIL is targeted to a platform. phx
= Category: Java programming language family =
Why was this article added to the this category C# is not part of the Java family of languages in any formal sense -- it may have been influenced by a lot of Java features, but it was influenced by C++ and Delphi features as well. There are pretty significant aspects of the language (and especially the base class libraries) that differ from Java. I d say this category ought to be reserved for languages that have some kind of formal relationship with Java (e.g. they compile down to Java bytecode in their standard implementation, they can seemlessly interop with Java, the language is an extensive of Java like 03:21, 21 Aug 2004 (UTC) *You are correct in your depiction of C#,Java,Pizza. However, the intention of the family categorization in suggestions and its purpose is to fuzzily relate languages according to their overall structure (Pascal,PL/I|
|