views:

161

answers:

3

Hello folks,

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.

+4  A: 

Razor is a view engine for ASP.NET MVC 3 - so i believe it has nothing to do with the space that IronPython occupies

if im wrong then i have certainly missed something

PaulStack
Thanks, I saw this post and it got me thinking about using Razor as more than a view engine for MVC http://blog.andrewnurse.net/2010/07/22/UsingTheRazorParserOutsideOfASPNet.aspx thus the question. I know I can include namespaces in existing Razor code, so it got me confused (still am) if it will compete with things like Iron Python and a .net implementation of Ruby.
infocyde
+1  A: 

I was at a talk by one of the guys working on IronPython and IronRuby. The general sentiment he seemed to express is that IronPython is not as up to the task of building modern ASP.NET MVC sites as IronRuby or C# are. That said, this could have changed since then.

But you're comparing apples to oranges here. IronPython is a full-fledged dynamic language. Razor is just a markup language and view engine for defining views in an ASP.NET MVC site. The controllers and most of the code for the application must still be written in an actual language (such as C#, Python, or the like).

Rohan Singh
+5  A: 

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.

marcind