john wen

Hello

I want to ask something about unmanaged code such as COM:

COM codes is equal to specific OS code

Then OS translates the COM code into machine code

Or is COM codes simply machine code

Please respectively answer 3 questions in detail.
JohnWen



Re: Visual C# Language For unmanaged code: Does Operating System translate specific OS codes into machine code?

Mattias Sjogren

There's no such thing as "COM codes", COM is a component model. COM object may be implemented in native or managed code.






Re: Visual C# Language For unmanaged code: Does Operating System translate specific OS codes into machine code?

john wen

Is COM object implemented in machine code
Or is COM object implemented in specific Operating System code

John Wen
4 - July - 07





Re: Visual C# Language For unmanaged code: Does Operating System translate specific OS codes into machine code?

Peter Ritchie

john wen wrote:
Is COM object implemented in machine code
Or is COM object implemented in specific Operating System code

John Wen
4 - July - 07
Depends on the object. An object can be implemented in whatever programming language a user sees fit. That could be C++, C#, VB, assembler, etc.

There's no such thing as "operating system code" when implementing a COM object. Do you mean a specific Operating System's API






Re: Visual C# Language For unmanaged code: Does Operating System translate specific OS codes into machine code?

john wen

Hello

What is specific Operating System API told by you

My definition of "Operating System code" is that like an intermediate language IL under CLR Platform which translates or compiles the IL into machine code, the OS translates or compiles the Operating System code of the COM object into machine code of the COM object also. And I mean the COM is implemented in such Operating System code which shall be compiled by the Operating System into machine code. Am I right

So I think the CLR plus .NET Framework class library is similar to the Operating System plus COM objects. Am I right

John Wen
4 - July - 07





Re: Visual C# Language For unmanaged code: Does Operating System translate specific OS codes into machine code?

Peter Ritchie

IL is OS inspecific. Using "operating system code" as a synonym for "IL" doesn't make sense. The OS does none of the translating; it's the framework that does the translating (in this case the .NET framework).

A COM object can be native code (pre-compiled to machine code), managed code (IL), interpretted code, etc. It's up to the developer to decide what language/framework they want to implement their object in.






Re: Visual C# Language For unmanaged code: Does Operating System translate specific OS codes into machine code?

john wen

Peter Ritchie

What form is the COM object implemented in Machine code or higher level code

Since I always thought the Operating System was a translator which translates specific OS code into machine code, I want you to tell me if Operating System is translator or not

Please answer the above 2 questions for me. Thank you very much.

John Wen
5 -July - 07





Re: Visual C# Language For unmanaged code: Does Operating System translate specific OS codes into machine code?

Mattias Sjogren

john wen wrote:


What form is the COM object implemented in Machine code or higher level code

We've already answered that a couple of times in this thread. It can be both.

john wen wrote:


Since I always thought the Operating System was a translator which translates specific OS code into machine code, I want you to tell me if Operating System is translator or not


The OS is not a translator in the way you're suggesting.






Re: Visual C# Language For unmanaged code: Does Operating System translate specific OS codes into machine code?

john wen

"What form is the COM object implemented in Machine code or higher level code


We've already answered that a couple of times in this thread. It can be both"

If the COM object is implemented in higher level code, then I am eager to know how can that higher level code be translated or changed into machine code Note that in the past I thought it was Operating system which did such translation.


John Wen
5 - July - 07





Re: Visual C# Language For unmanaged code: Does Operating System translate specific OS codes into machine code?

Peter Ritchie

john wen wrote:
"What form is the COM object implemented in Machine code or higher level code


We've already answered that a couple of times in this thread. It can be both"

If the COM object is implemented in higher level code, then I am eager to know how can that higher level code be translated or changed into machine code Note that in the past I thought it was Operating system which did such translation.


John Wen
5 - July - 07

It depends on how the developer coded the COM object. There's basically three three ways of deploying compiled code: native, intermediate language, or interpreted.

Native means that machine code is generated at compile time, for a specific processor or processor instruction set. The code is ready to run and nothing needs to be translated, the OS simply points the instruction at an entry point and starts running.

Intermediate language requires a runtime, or framework. The code is compiled into a binary that kickstarts that runtime when first accessed. It's that runtime that checks to see if IL to machine translation has been done or not and does the translation if needed. Once the translation has been done that generated machine code is stored for later use and likely never needs to be generated again.

Interpreted is similar to IL but the machine code executed is transient (in memory) and doesn't stick around after the code has been executed.

If you're writing COM objects in a .NET language you'll always be in the IL case. A COM object is a binary that has registered entry points. With a .NET COM object those entry points point to stubs or proxies that first go into the framework to initialize it and begin the just-in-time (JIT) compilation process, if needed. Once the framework is initialized and the machine code is generated it is then called. The next time those entry points are called they'll effectively go right into the machine code.

What are you interested in this sort of thing






Re: Visual C# Language For unmanaged code: Does Operating System translate specific OS codes into machine code?

IsshouFuuraibou

To add to this topic. The Operating System is just a manager. At it basic level it is there to manage access to hardware between multiple processes. It does not have built-in support for compiling/interpreting any language at all, this functionality is added. It may be added at any time, but it is still not a part of the kernel (OS).

Native code/Machine Language refers to code that runs on the CPU. The problem with this type of code is that it will only run on that type of CPU (and possibly older or newer version). For example you couldn't take a native code executable from a Core 2 Duo machine and put it on a AMD X2 machine and expect it to work (fully). Or for the stark comparison, you can't take a x86 (intel) program and run it on the PowerPC chip (what Macs used to use). A lot of code compiled to this will actually use generic enough machine language to be run on multiple types of the x86 processor. However there are some performance optimization in the Core 2 Duo that aren't in the AMD X2 and vice versa.


To give some examples:
Native compiled languages: C, Basic, C++
Framework languages/Intermediate Language: C#/VB.Net/C++.Net (anything .Net), Java (it compiles to a java bytecode that gets converted by the java runtime on the end system).
Interpreted: Lisp, ProLog.


it is the compiler's (including the Just-In-Time compiler's) or the interpreter's job to create machine code, including specific optimized machine code.