Metaprogramming in .NET

Microsoft® “Roslyn” CTP

metaprogramming: The classic definition for a metaprogram is “a computer program that writes new computer programs”
by @KevinHazzard and @JasonBock

JavaScript eval() as metaprogramming example

from Metaprogramming in .Net by @KevinHazzard and @JasonBock

Initial state

Simple multiplication

Injection values into local execution scope

C# is multiparadigm language

"Languages are losing their classifications. No longer can we say that a language is just an object-oriented language, or just a dynamic language, because so many of them borrow from lots of different ideas

Anders Hejlsberg talk about C# 3.0

object-oriented: class-based and statically typed

imperative

C# 2.0: generic programming

C# 3.0: functional/declarative: LINQ, Rx

C# 4.0: dynamic: DLR, microORM

Microsoft® “Roslyn” CTP

Traditionally, compilers are black boxes.Source code goes in one end, magic happens in the middle, and object files or assemblies come out the other end.

As compilers perform their magic, they build up deep understanding of the code they are processing, but that knowledge is unavailable to anyone but the compiler implementation wizards.

The core mission of the Roslyn project: opening up the black boxes and allowing tools and end users to share in the wealth of information compilers have about our code.

Bootstrapping for compilers

Bootstrapping is the process of writing a compiler in the target programming language which it is intended to compile.