I assume this is due to the same C # database project that you mentioned in the question.
It is technically possible to implement entire layers of recording in C / C ++ or in any other language. And technically it is possible to have everything else in C #. I'm currently working on an application that uses unmanaged code for some high-performance low-level materials and C # for business logic and top-level management.
However, the complexity of the task should not be underestimated . A typical way to do this is to develop a contract that both parties can understand. The contract will run in a managed language, and the managed language will cause calls for its own application. If you've ever tried calling a C ++ method from C #, you get this idea ... Plus, every call to unmanaged code has a pretty significant overhead, which can lead to the loss of the whole idea of โโpoor performance.
If you are really interested in high-performance relational databases, use one low-level language.
If you want to have a naive but fully operational database implementation, just use C #. Do not mix these two languages โโif you do not fully understand the complexity. See Raven DB, a document-based NoSQL database built entirely in C # only.
Will my unmanaged C # code compile in IL and run on the CLR?
No, there is no such thing as unmanaged C #. C # code will always be compiled into IL code and executed using the CLR. This is a case of managed code that calls unmanaged code. Unmanaged code can be implemented in several C / C ++ / Assembly languages, etc., but the CLR will not know what is happening in this code.
Update from the comment. There is a tool (ngen.exe) that can compile C # directly into its own architecture code. This tool is designed to improve the performance of a managed application by removing the JIT compilation step and translating native code directly into an executable image or library. However, this code is still โmanagedโ using CLR memory: memory allocation and collection, controlled streaming, application areas, exception handling, security, and all other aspects are still controlled by the CLR. Thus, although C # can technically be compiled into native code, this code does not work as a standalone native image.
How it works?
Managed code interacts with unmanaged code. There are several ways to do this:
- Via code through .Net Interop. It's relatively fast, but it looks a bit ugly in code (plus it's hard to maintain / test) ( good article with C # / C / Assembly samples )
- A much slower approach, but more open to other languages: web services (SOAP, WS, REST and company), priority (for example, MSMQ, NServiceBus, etc.), and also (possibly) interprocess communication. Thus, an unmanaged process is on one end, and a managed application is on the other.
oleksii
source share