Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why are Visual Studio projects restricted to a single language?

This is question is inspired by the question: In what areas does F# make "absolute no sense in using"?

In theory, it should be possible to use any .NET supported language in a single project. Since every thing should be compiled into IL code, then linked into a single assembly.

Some benefits would include the ability to use say F# for one class, where F# is more suited to implement it's function, and C# for another.

Is there some technical limitation I'm overlooking that prevents this sort of setup?

like image 307
CodeNaked Avatar asked Mar 25 '11 14:03

CodeNaked


People also ask

How do I add another language to Visual Studio?

To do so: Choose the Language packs tab in the Visual Studio Installer. Select the language you prefer. Follow the prompts.

Can I change Visual Studio language?

Once the installer is launched, click on Modify to modify the current installation of Visual Studio. 3. Then, you'll want to click on the Language Packs tab and select the language pack that you wish to install.

What language is Visual Studio written in?

JavaScript. The JavaScript editor in Visual Studio supports EcmaScript 6 and has the most advanced IntelliSense engine on the market. JavaScript is a first-class language in Visual Studio.

How do I change the project type in Visual Studio?

You can change this by going to the project property page (right click Properties) and change the Output Type combo box. It is possible to have other project types supported by the project system but they are fairly few and are not definitively associated with a project template.


2 Answers

A project is restricted to a single language because, under the hood, a project is not much more than an MSBuild script which calls one of the command-line compilers to produce an assembly from the various source code files "contained" in the project folder. There is a different compiler for each language (CSC.exe is for example the one for C#), and what each project has to do to turn its "contained" source code into an assembly differs with each language.

To allow multiple languages to be compiled into a single assembly, the project would basically have to produce an assembly for each language, then IL-Merge them. This is costly, requires complex automation and project file code generation, and in most circumstances it's a pretty fringe need, so the VS team simply didn't build it in.

like image 68
KeithS Avatar answered Oct 02 '22 04:10

KeithS


While projects are restricted to a single language, a solution is not... and solutions can contain multiple projects.

like image 25
Powerlord Avatar answered Oct 02 '22 03:10

Powerlord