Microsoft Advances C# With the M# Language
Microsoft is working on a new high-level systems programming language known as M# (pronounced "M Sharp") that aims to deliver type safety and performance.
In a blog post entitled “C# for Systems Programming,” Joe Duffy, an architect and developer working on the Midori operating system incubation project at Microsoft, said the M# project is a research effort that Microsoft is working on and he welcomes technical dialogue on the language. While an M# product announcement is not imminent, Duffy said he will continue to post more about M# in the coming months – with the ultimate goal of open-sourcing the technology.
Microsoft’s goal with M# was to deliver a language that provided developers with type safety and productivity as well as performance. Typically, you tend to get one or the other. However, as described, M# appears to be a general purpose programming language that is safe, productive and performant.
Type safety is the extent to which a programming language discourages or prevents type errors. A type error is erroneous or undesirable program behavior caused by a discrepancy between differing data types for the program's constants, variables and methods.
“With respect to M#, I think we should keep in mind that there has been an age-old struggle in computer science to deliver highly productive development models that are also efficient and high-performance,” said Al Hilwa, an analyst with IDC. “As automation becomes more sophisticated and we head towards driverless cars for example, it stands to reason that automated code generation should improve. So it makes sense that Microsoft should try to keep pushing to bridge the divide of productivity and performance.”
According to this report, which highlighted M#, Microsoft has been working on the Midori OS since 2008. Midori is a non-Windows operating system project that stems from Microsoft Research’s "Singularity" effort to deliver a microkernel-based operating system written as managed code. The Midori project required a new language and the team decided to base it on C#.
“The next question is, ‘Why base it on C#?’" Duffy said in his post. “Type safety is a non-negotiable aspect of our desired language, and C# represents a pretty darn good ‘modern type-safe C++’ canvas on which to begin painting. It is closer to what we want than, say, Java, particularly because of the presence of modern features like lambdas and delegates.”
He noted that there are other candidate languages in this space, including the D language and Rust, and Go. “But when we began, these languages had either not surfaced yet, or had not yet invested significantly in our intended areas of focus,” Duffy said. “And hey, my team works at Microsoft, where there is ample C# talent and community just an arm’s length away, particularly in our customer-base.”
Aleks Bromfield, a Google engineer who previously worked on M# at Microsoft, posted about the language’s error model. “Like the rest of the language, the error model was designed with the goal of being safe, fast and easy,” Bromfield said. “By safe, I mean that the language should prevent as many bugs as possible. By fast, I mean that the error model should impose the smallest possible burden on the runtime performance of programs that use it. By easy, I mean that the error model should help programmers be more productive, rather than getting in their way.”
Meanwhile, Duffy said before Microsoft can open source the M# language the team needs to “button up a few aspects of the language” move to the company’s Roslyn compiler as a service codebase “so the C# relationship is more elegant.”
"That a new operating system needs to be accompanied by a new programming model through a new language or a framework is common in the industry, but it is also risky," IDC's Hilwa warned. "OS and programming language designers should keep in mind that coming up with new metaphors for constructing applications may find a skills gap in the industry which can detract from adoption. Additionally, dealing with developer issues is not alone a key for success, but it is required to have developers on your side to be successful."