advantages, disadvantages, and difficulties of writing a language to use .NET

13,273

The hardest part will be designing an effective programming language. Many people have dedicated their entire careers to the task. Since there have been many questions on here about language design and general parsing questions, I'll focus specifically on the aspect of targeting the CLR.

Advantages

  • Generating byte code in binary form is fairly straightforward using the System.Reflection.Emit namespace and the awesome new System.Linq.Expressions abilities in .NET 4.0. This setup is one of the leading motivators in my personal desire to target the CLR.
  • Your code will benefit from many of the optimizations built into the CLR's JIT and memory manager.
  • In general, you'll be able to build a working compiler for your language in less time if you choose to target the CLR vs. building your own native code.

Disadvantages

  • It'll only run on platforms that the .NET framework runs on. If you avoid P/Invoke calls, then with the help of the Mono project this shouldn't be the problem.
  • You'll have to lower the semantic constructs in your language to a form representable in CIL instructions and the CLI object model. For procedural, strongly-typed, optionally object oriented languages, this is rather simple. For functional or dynamically typed languages, this can be quite a challenge, but you may get some help from the DLR if you need those features.
  • In general, you won't have convenient access to machine intrinsic functions, so for a language targeting high-performance/vectorized scientific computing, you may face some performance problems with the current implementations. Mono is actively working on the issue, but neither Mono or the .NET Framework have this in place as "an established technology."

Difficulties (Not counting the language and compiler front-end)

  • The most "interesting" aspect is laying out your method of expressing your language's semantic constructs under the restrictions of the CLR.
  • There's not too much more to say here. Compared to other targets, it's quite easy to target the CLR.

Summary

The CLI is a great option for people working on new language implementations. It allows you to take your mind off the common compiler back-end and focus on the semantics of the language itself. I might not recommend someone create a new language, but if you decide to, the CLI will be a good friend on your journey.

Share:
13,273
RCIX
Author by

RCIX

Lua is underrated!

Updated on June 05, 2022

Comments

  • RCIX
    RCIX almost 2 years

    I'm thinking about possibly designing/building a language at some point, and what are the advantages, disadvantages, and difficulties of writing it to run on the .NET framework/CLR?