Take the 2-minute tour ×
Programmers Stack Exchange is a question and answer site for professional programmers interested in conceptual questions about software development. It's 100% free, no registration required.

I know that .Net provides the feature to mix several languages within the same application (there are some constraints of course, but this is not essential). Theoretically, this might be done because the languages supported by .Net do not fully expose all the features it can provide. IL does of course. So when you need a feature that the current language doesn't provide, you could write it in another .Net language. The whole code would be translated into IL, and so you would gain more features.

From my personal experience, I was writing a project in C# and needed to integrate a small project written in C++ under .Net. When I consulted with some more experienced programmers, they said that it would be much easier to "translate" the C++ code into C# than integrate it. Since I had little time, it was what I did, and it was quite easy (the project was quite small).

So my question is, has anyone experienced a real-life situation when mixing languages is an absolute necessity?

share|improve this question

closed as primarily opinion-based by MichaelT, gnat, Corbin March, Yusubov, maple_shaft Sep 2 '13 at 12:53

Many good questions generate some degree of opinion based on expert experience, but answers to this question will tend to be almost entirely based on opinions, rather than facts, references, or specific expertise.If this question can be reworded to fit the rules in the help center, please edit the question.

add comment

3 Answers 3

up vote 4 down vote accepted

The best real-world scenario I've encountered is when you want to access C++ classes from a managed environment, say from a C#-based application.

C# can access unmanaged COM classes using COM Interop, or unmanaged C-style APIs like the Win32 API using P/Invoke/DllImport, but it can't access normal non-COM C++ classes and APIs. If you've got a need to do that, easiest way is to write a component in C++/CLI.

Since the component is a managed, .NET component, it can be easily called by your C# code. Since it's C++, it can instantiate C++ objects and call unmanaged APIs. Everyone is happy.

share|improve this answer
add comment

This feature can be used in ASP.NET website development.

I had an occasion where project was initially developed in VB.NET and required some new additions (new web-forms). After analyzing pros and cons as well as timeline, i have decided to add new forms in C#, as it was my primary language of development. Everything went pretty well for that small project.

However, there might be some disadvantages/side-effects for relatively big projects, where languages are mixed.

Note: you can use only one .NET language in ASP.NET web application

share|improve this answer
add comment

I did work on a project where we had a UI written in VB.NET, and calculations written in C#. This was primarily due to the UI developer not having experience in C#, and the calculation developer having no experience in VB.NET. With .NET, everything just worked together.

Ideally, the developers should have agreed on the language, but it did work for a rapid project completion time (no language ramp up).

share|improve this answer
add comment

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