pythonironpythonrazor

Iron Python vs Razor


I have a little bit of experience with the new Razor syntax, but none with Iron Python. I was wondering do both meet the same needs? Is one favored by Microsoft over the other (or will be)? Appreciate your thoughts, as I'm toying with the idea of learning Iron Python, but if Razor can meet the same need, I probably won't.


Solution

  • To expand on the answer given by PaulStack:

    Razor is a templating engine (with a slant towards templating XML-style documents, e.g. HTML web pages) that is available as a View Engine in MVC 3 as well as the default page syntax in ASP.NET Web Pages (which is part of the WebMatrix stack). The Razor parser uses assumptions about the structure of XML documents as well as constructs available in the two supported programming languages (C# and Visual Basic) to minimize the number of transition characters that are required to go between code mode and markup mode.

    While it has been written with a focus on emitting HTML, it has been generalized to support arbitrary text templating tasks (though in some cases you might need to use special transition tokens to force switches between code and text).

    On the other hand, IronPython is a programming language. It is not a templating engine, though naturally it can be used to write code that emits a stream of text.

    If you are already comfortable with C# (or VB) then I would suggest you try Razor. It's a fairly simple extension of the language syntax and allows for very smooth transitions between markup and code.