3 ms·
> Language interoperability is another: it's still astonishingly hard to combine languages within a single software artefact unless they're C and C++ or similar
by AnimalMuppet 6y ago
> Language interoperability is another: it's still astonishingly hard to combine languages within a single software artefact unless they're C and C++ or similar things that produce platform-native binaries.
Earlier, you mentioned F#. How easy is it to combine C# and F#?
- pjc50 6y agoThe internet has plenty of examples: https://connelhooley.uk/blog/2017/04/30/f-sharp-to-c-sharp https://connelhooley.uk/blog/2017/04/30/f-sharp-to-c-sharp (I've not actually done it myself, writing functional-style C# is enough for me)
- JoeMayoBot 6y agoBoth languages run on the CLR, compiling to the same set of bytecode. The enables cross-language interop - one of the original promises of .NET. By targeting the Common Language Specification (CLS) they can communicate. The best way to get them to communicate is to use the CLSCompliant attribute, set to true, which generates warnings on non-compliant code so it can be fixed. Here's more detail: https://docs.microsoft.com/en-us/dotnet/standard/language-independence-and-language-independent-components https://docs.microsoft.com/en-us/dotnet/standard/language-in... That details the C# point of view (a little VB too) and here's an SO post on how to add the CLSCompliant attribute to F#: https://stackoverflow.com/questions/21028833/writing-cls-compliant-code-in-f https://stackoverflow.com/questions/21028833/writing-cls-com... I remember these concepts being very important in the early days of .NET because companies had heavy investments in legacy code, including COM, C, C++, other .NET languages (various forms of interop) and needed integration and/or upgrade migration paths. Language interop came into play because some companies thought (not taking an opinion here) it might be a good idea for developers to use the language of their choice.