4thSpace
4thSpace

Reputation: 44312

Is Razor related to .NET like LINQ is?

Anders Hejlsberg decribes LINQ as syntactic sugar. In other words, it is still C#. Just that they have added some shortcuts so you don't have to code everything by hand that LINQ is creating for you. But the C# language and .NET runtime did not undergo any structural changes.

Is Razor the same way?

I'm not sure how it lines up when things are expressed as layers. For example, is this correct?

Razor
 ^
ASP.NET
 ^
C#
 ^
.NET

I believe it is correct but I'm not sure how ASP.NET fits in. Razor is ASP.NET right except that it adds a few syntactic extras or is it more than that?

What exactly is ASP.NET adding?

Upvotes: 0

Views: 202

Answers (2)

Robert Harvey
Robert Harvey

Reputation: 180798

  1. Linq isn't just syntactic sugar. The shorthand form of Linq in C# is, but you don't need that at all to use Linq.

  2. Linq is a bunch of things. It is a collection of extension methods over IEnumerable & IQueryable, it is lambdas and anonymous types and yield and a deferred execution pipeline. Linq involves everything Microsoft added to .NET in Framework 3.5.

  3. Razor is a template engine for rendering HTML.

Upvotes: 5

basarat
basarat

Reputation: 275907

Your figure is sort of correct in terms of dependency graph. However It is best to think of razor as a template language for the web written in C#

In some ways the graph is in accurate. E.g C# does not really depend on .NET in general. You could write a non .NET runtime for C#.

Similarly Razor does not need to depend on ASP.NET. In fact its current implementation depends on classes found in ASP.NET MVC which only indirectly depends on ASP.NET conventional.

Saying Razor is to ASP.NET link Linq is to C# is a bit in accurate. Linq is a set of functions found in System.Linq namespace e.g. Where http://msdn.microsoft.com/en-us/library/system.linq.enumerable.where.aspx . C# provides a handy syntax to call these functions for you i.e http://msdn.microsoft.com/en-us/library/bb310804.aspx

Razor however does not have such a clear seperation of syntax vs. backend function calls.

Upvotes: 3

Related Questions