Take the 2-minute tour ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

To my knowledge, thus far, I have thought that C# is and has always been a compiled language. I have recently started studying Unity3d and noticed that they give C# as an option for scripting and interacting with game objects through their API (along with JavaScript and a couple of other alternatives).

How is this done? Is C# actually being executed or is this an abstraction that is being converted to a different scripting language under the covers? It seems to me that there is some sort of interpretation going on for this functionality.

share|improve this question
2  
What are scripting languages? –  jco Mar 19 '13 at 20:18
    
en.wikipedia.org/wiki/Category:Scripting_languages languages interpreted at runtime rather than compile time. –  Brandon Clapp Mar 19 '13 at 20:20
2  
But JavaScript is compiled before being executed 99% of the time, and some Python implementations too. C(++) can be interpreted. I think that the terminology is flawed, as you're not talking about a property of the language, but the way you use it. But it seems that's not really important for the question... –  jco Mar 19 '13 at 20:25
    
"compiled" or "scripted" is not the property of programming language. When you are implementing the language specification, you can decide whether you want to "compile" it or "interpret" it. –  Ivan Kuckir Mar 19 '13 at 20:26
1  
That being said, what I have always interpreted as a "scripting language" is the basis of this definition. Perhaps the vocab should have been "interpreted" but I have always seen them one in the same. webopedia.com/TERM/S/scripting_language.html –  Brandon Clapp Mar 19 '13 at 21:59

2 Answers 2

Unity is using Mono behind the scenes. Every time you make a change to your C#/UnityScript scripts it recompiles the code almost instantly.

If you look in the data directory of a standalone unity player, you can see it has compiled all the scripts into Assembly-CSharp.dll, or similar.

So yes, the C# is being compiled.

share|improve this answer
    
Ah I see the .dll now in the data directory. This clears things up. –  Brandon Clapp Mar 19 '13 at 20:22
1  
+1 for actually answering the question and not turning it into a pompous semantic arm-wrestling match –  Jan Mar 20 '13 at 10:35
1  
@BrandonClapp if this answer solved your question, please mark it as correct. –  petervaz Mar 20 '13 at 18:12
    
Sorry for reviving this, but how does Unity handle the loading and unloading of the compiled DLL in the editor? Or should I start a new question? –  Jeff Sep 4 at 15:51

First, scripting languages are not necessarily interpreted languages. Some scripting languages such as Lua and Python can be either JIT-compiled or interpreted.

And, as for the question itself: because C# is a scripting language, but Microsoft does a good job on making it not look as such.

C# has everything a scripting language needs: dynamic typing, JIT-compiling rather than static compiling, runs in a virtual machine...

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.