DCSIMG
October 2010 - Posts - IronShay

October 2010 - Posts

IronRuby and IronPython are Officially Handed Over to the Community, IronRuby Tools for VS is Out and More!

I’m so happy! finally some good news about IronRuby!

As you might know, IronRuby and IronPython got to a dead-end inside Microsoft a few months ago, a move that set a firestorm within the community which demanded Steve Balmer’s head on a stick (yea, we’re loco here in the DLR land!). Since then we lived in uncertainty regarding the future of these languages, walked among the crowd with tears in our eyes and prayed every night to the God of open-source to help us in these horrible times.

But yesterday evening everything changed! and changed for the better!

When Open-Source becomes Open-Source

I’m thrilled to say that Microsoft announced yesterday that they were handing IronRuby and IronPython over to the community! completely! And not just that, there will be new coordinators of these projects who will lead them to greatness. The coordinators for IronRuby will be Miguel de Icaza and Jimmy Schementi. For IronPython the new coordinators will be Miguel de Icaza, Michael Foord, Jeff Hardy, and Jimmy Schementi. These are incredibly talented people who are capable of taking these languages to great new heights and convert them from “very cool and nice-to-have” to “breath-taking OMFG give it to me give it to me now!!!”.

IronRuby 1.1.1

In addition to the great news from above, IronRuby 1.1.1 has been released yesterday with exciting new and anticipated features.
Pay attention that this version is tagged as alpha, which means that there are still some things that do not work so good or are missing.

Compatible with Ruby 1.9.2

IronRuby is closing the gap with MRI (the official Ruby implementation) and provides compatibility with Ruby 1.9.2. Here, watch:

IronRubu 1.1.1 using Ruby 1.9.2 Features

IronRuby Tools for Visual Studio

So the most voted feature in Microsoft Connect site and one of the main reasons that kept .NET developers away is now a thing of the past. IronRuby can now be developed from within your beloved Visual Studio IDE!
The new tools contain: Ruby colorizer and syntax checker, interactive loop window, directory based project, and templates for common Ruby applications (including Ruby on Rails 3, Sinatra, Gems and Silverlight based browser scripting app). Here, watch:

IronRuby New Project dialog inside Visual Studio

IronRuby Interactive inside Visual Studio

Ruby syntax highlighting and the Interactive console inside Visual Studio

Download NOW!!!!!!!!!!11

Quick! go, download, install and let the awesomeness take over: http://ironruby.codeplex.com/releases/view/49097

Exciting times!

All the best,
Shay.

kick it on DotNetKicks.com Shout it

Posted by shayf | with no comments
תגים:

Right Underneath Scott Guthrie!

My recent post – 5 Reasons to be excited about ASP.NET MVC 3 has made it to the front page of http://asp.net! I’m just 2 rows under Scott Guthrie!

The front page of http://asp.net

Mom will be proud! Smile

Shay.

Posted by shayf | with no comments
תגים:,

The Razor View Engine Basics

[cross-posted from my main blog: http://www.ironshay.com/post/The-Razor-View-Engine-Basics.aspx]

If you’ve been following me, you probably noticed that I became quite excited with the new view engine of ASP.NET MVC 3 – the razor view engine. If you’re familiar with it then you might agree or disagree with me, but if you don’t then this is a great time for you to make up your mind!

In this post I assume you are familiar with the concept of view engines. If not, please watch this before.

Let’s start.

At Sign (@) Galore

The razor view engine is all about the at sign (@). Unlike the inelegant <% %> signs of the common web forms view engine, here all you need is the at sign.
Basically, starting an expression with the at sign will lead to this expression being evaluated and output the result to the page. For example:

@DateTime.Now

This expression will end up printing the current date and time to the response stream. It is the equivalent of the following web forms view engine code:

<%: DateTime.Now %>
Note
At sign expressions are html encoded!
If you’re sure your output is OK and you don’t want it to be html encoded, you need to provide an IHtmlString object, or simply do:
@MvcHtmlString.Create("<b>BOLD!</b>")

By now some of you might be scratching your heads, moving anxiously in your sits or eating Ben & Jerry's uncontrollably… all of this because something is disturbing you with that line of code… something is missing…

It’s Magic! Magic!!!!!!11

Well, you were right! something is, indeed, missing… we only started the expression with the at sign, but we never told the framework where the expression ended!!! God help us all!!!

Do not worry. This is part of the charm of Razor – if your expression is a single call, there is no need to enclose it in some sort of way, you just write the expression after the at sign (and make sure it’s immediately after the at sign! for example, @ DateTime.Now will raise an exception).

Wait! But what about the times I wanna use blocks of code? or when I want to write out the result of 1 + 1? No problem, I have the solution for you! (how many times have you heard that before, right?)

So for simple expressions like additions (1 + 1, “Shay” + “ “ + “ Friedman”…) you enclose the expression in brackets. For example:

@(1 + 1)
@("Shay" + " " + "Friedman")
A Moment of Truth
What will happen if you write:
@"Shay" + " " + "Friedman"
?
... think for a moment ...
Answer: a "Parser Error" exception. Yes, get used to it.

Now, sometime you need actual code blocks like loops or conditions… and these brackets won’t help you there, son. And look carefully, because this is where it gets a bit… surprising.

Code Blocks and Razor Sitting in a Tree, K-I-S-S-I-N-G

Let’s start with the simplest use case – you want to set a variable within your view. How would you do that? @int a = 1; ? no no no. To do that, you enclose the code block within curly brackets, with an at sign at the beginning of course. For example, the next sample will output 1 to the page:

@{
    int a = 1;
}
@a

This was a very simple sample though… what about conditions for example? I’m glad you asked!

One way to write conditions (or any block of code), is by using the curly brackets solution:

@{
    string s = String.Empty;
    if (DateTime.Now.Year == 1980)
    {
        s = "Man you're so 80's!";
    }
    else
    {
        s = "It's the new millenium dude!";
    }
}
@s

This approach might become handy from time to time, but more commonly we’d want to write something out inside the condition. For these common occasions, you can use the next syntax:

@if (DateTime.Now.Year == 1980) {
    <p>Man, you're so 80's!</p>
} else {
    <p>It's the new millenium dude!</p>
}

Pay attention - it’s code and then html, and then code again, and then html again! Has your brain exploded yet?

So what happened here? in razor, everything blends together elegantly. The idea here is that razor understands when you write code and when you write html and can operate accordingly. This means that the next sample is valid as well:

@if (DateTime.Now.Year == 1983) {
    if (DateTime.Now.Month == 9) {
        <p>Wow, this month Shay is born!</p>
    } 
} else {
    <p>It's the new millenium dude!</p>
}

But this makes you ponder – is the next sample possible:

@if (DateTime.Now.Year == 1980) {
    Man, you're so 80's!
} else {
     It's the new millenium dude!
}

Though one might think it would be a valid razor syntax, it isn’t. This is because razor is smart, but it’s no genius… razor can’t tell if “Man, you’re so 80’s!” is code or html. Think of a sentence like “if pigs could fly” – is this a C# syntax error or plain text? because of this limitation, you have two options to do that – start the html part with html tags (like the previous sample that includes <p> tags) or use a <text> tag as follows:

@if (DateTime.Now.Year == 1980) {
    <text>Man, you're so 80's!</text>
} else {
     <text>It's the new millenium dude!</text>
}

Loops are very similar, too:

@{ var list = new List<string>() {"Razor","Rocks!"}; }
@foreach (var item in list) {
    <b>@item</b>
}

The Twitter Account Catastrophe

My twitter account is @ironshay, what’s yours? WAIT! WAIT!!!!111ONE all hell broke loose!!! TWITTER ACCOUNTS HAVE AN AT SIGN AT THE BEGINNING!!!!

That does it. If someone at Twitter thought about rewriting with ASP.NET MVC, now there’s no chance they’d go for it.

Hold you horses twitter! razor has a solution for you but you will have to write double at signs for that. For example, @@ironshay in a razor file will result in @ironshay in the response stream.

Here you go, Twitter can reconsider.

Read More!

This was a basic introduction to razor. If you liked what you read, I recommend you to read further and become the master of razor!

All the best,
Shay.

kick it on DotNetKicks.com Shout it

Posted by shayf | 1 comment(s)
תגים:, ,

5 Reasons to be Excited about ASP.NET MVC 3

It’s already been 6 months since ASP.NET MVC 2 was released and version 3 is already taking shape. I, personally, am thrilled about that because this version seems to put ASP.NET MVC, in terms of maturity and functionality, on the first line along with other MVC frameworks out there like RoR.

I’ve put together 5 main reasons why I’m excited about this upcoming version. What about you?

1. The Razor View Engine

I said it before and I’ll say it again – the razor view engine is so cool!!! I really like the clean code I get when using it. In short, the razor view engine uses at signs (@) to indicate code blocks. For example, these are legit lines of code in razor:

@foreach (var item in Model) {
    <b>@item.FullName</b>
}

 

2. New Helpers

Helpers is an area ASP.NET MVC has been lacking at, compared to other MVC frameworks. MVC 3 will have new helpers that tend to close that gap:

  • Chart – helps creating charts. Very nice!
  • WebGrid – renders a collection of objects as a grid including paging and sorting. Should output a plain HTML table. Hopefully that’s all there is to it…
  • WebImage – helps in creating images. This also contains methods for basic image operations like rotating – cool!
  • WebMail – used to send emails.

The next helpers have been referred to as “task-based helpers”. They should have been a part of the beta version but they’re not there… I hope they’ll make it to the release version because they are just pure awesomeness:

  • Video – contains methods like Video.Flash, Video.Silverlight and Video.MediaPlayer which allow adding their corresponding HTML tags with ease.
  • Twitter – contains basic twitter operations like rendering the twitter stream for a specified user or the results of a given search.
  • ReCapcha – helps using the reCAPTCHA service.
  • Gravatar – helps consuming a user’s avatar from the Gravatar service.
  • Analytics – provides different methods like GetGoogleHtml, GetStatCounterHtml or GetYahooHtml that render the required javascript code for the different analytics services.

3. Support for Unobtrusive jQuery-Based Ajax

In ASP.NET MVC 3, Ajax.ActionLink, Ajax.RouteLink, Ajax.BeginForm and Ajax.BeginRouteForm will use JQuery to connect to the server. In addition, they will not use inline javascript, and instead they will call functions placed within javascript files.

Same thing applies to client-side validation.

4. Better Extensibility with new Dependency Injection Support

ASP.NET MVC 3 will contain numerous extensibility possibilities. Almost anything can be extended using DI, which opens so much opportunities. Just what extensibility means!

Read Brad Wilson’s post for a detailed guide to these new extensibility features.

 

5. NuPack Integration

NuPack is Microsoft’s new packaging system and it is fully integrated with ASP.NET MVC 3. Right click on the References folder in the Solution Explorer and choose “Add Package Reference…”:

The new Add Package Reference option

Now the NuPack UI will open and you can choose from the various different libraries on the online gallery:

NuPack

Pretty cool.

Well, these were my 5 reasons. So browse to http://go.microsoft.com/fwlink/?LinkID=191795, download the beta version and get excited too!

All the best,
Shay.

P.S. I’m not an ASP.NET MVP nor ASP Insider. Everything in this post was taken from various official blog posts and public web sites. Although the sources are as official as they can get (Scott Gu, Phill Haack…) this is only the beta version and as you know, in software – it ain’t over until the very last commit. Therefore, I recommend you check the release notes of every new version to see that no breaking changes were included.

kick it on DotNetKicks.com Shout it

Posted by shayf | with no comments

It’s not a Baby Boom, It’s a Microsoft Product Boom!

The last few months were a bit hectic if you stayed tuned to announcements coming from Microsoft regarding new products. It honestly looks like some folks down in Redmond haven’t seen home for a while.

Even though I don’t agree with the need for some of these new products, I think it’s a great thing that the .NET Framework is becoming even bigger than it used to be and we, as a result, get more options. Good!

So what’s new?

May – IIS Developer Express

This is a web server that’s aimed to reduce the amount of unexpected surprises when moving a web application from the ASP.NET Development Server (“Cassini”) to a real IIS Server. It does that by combining features from both servers and giving you a server that’s on the one hand, easy to use and develop on and on the other hand, has a full web server feature set.
Further reading: IIS Developer Express overview, Scott Gu’s blog post

June – SQL Server CE 4

SQL Server CE (Compact Edition) is Microsoft’s free embedded database engine. On version 4 it can, for the first time, work inside an ASP.NET application. This is pretty cool because now you can use it for web sites with a small database instead of messing around with XML files or purchasing an SQL Server hosting.
By the way, this is not a new concept. You could’ve done this before using SQLite, for instance.
Further reading: SQL Server Compact Team’s blog post, Scott Gu’s blog post

July – The Razor View Engine for ASP.NET MVC

For those of you who’re into ASP.NET MVC, Microsoft released a new and cool view engine named Razor. Razor will be a part of ASP.NET MVC 3 and will join to the default web form view engine and the open source view engines – Spark and NHaml.
It provides a minimalistic way of writing views by massively using the at sing (@). I strongly recommend you to check out Scott Gu’s blog post about it to get the feeling of how it’s gonna be.
I believe this view engine will slowly move up to the top of the charts and eventually become the most popular view engine in the ASP.NET MVC world. That’s my take on it at least.
Further reading: Scott Gu’s blog post, Inside Razor Part 1, Inside Razor Part 2, Inside Razor Part 3

July – WebMatrix

This is a web development tool which is targeted mostly to beginners and non-Microsoft developers. By using templates, you’ll be able to create web applications in no-time and without understanding what you’re doing too much.
It’s not really my cup of tea but I guess a lot of people will find it very handy.
Further reading: Official site, Learning materials, Scott Gu’s blog post

August – Visual Studio LightSwitch

LightSwitch is a tool for creating LOB applications without writing any code (unless you need special customization). The result application has a database and uses Silverlight 4 for its UI.
Everything is wizard and designer based in LightSwitch which makes it perfect for beginners (not sure about the others). 
Trying it out took me back about 10-15 years to when MS-Access Forms were prospering. I’ll let you decide.
Further reading: Somasegar’s announcement of LightSwitch, LightSwitch Developer Center, Official Site

August – IronRuby Mess

Well, that’s not a new product actually… But I thought it was worth mentioning here (I’ll let you figure out yourself why I care :-) ). At the beginning of August, the project manager of IronRuby left Microsoft and posted a blog post which kind of set a firestorm on twitter, the blogosphere and I guess internally in Microsoft as well. There were no new news since then, the project is not dead but it is advancing very slow…
Further reading: Jimmy Schementi’s blog post, My take on the situation, Microsoft’s official response

September – Internet Explorer 9 Beta

Microsoft has been slowly losing its dominance in the browser world to FireFox and new kid in the block – Google Chrome. Internet Explorer 9 is Microsoft’s attempt to get back into the game and get these lost percentage back. The beta showcases nice performance improvements, great usage of the computer hardware to display complex graphics and full HTML5 compatibility.
Further reading: Test Drive site, Guide for developers, IE Team blog

September – Web Farm Framework 2.0 Beta

The Web Farm Framework, aka WFF, simplifies the provisioning and deployment of web server infrastructure. The idea here is that you configure everything you need on a single server (called the primary server) and then use WFF to replicate and provision the exact same configuration across all of the other web servers in the farm.
Further reading: Official documentation, Scott Gu’s post

September – Windows Phone 7 Developer Tools

Windows Phone 7 is Microsoft’s try to close the gap with Google Android and Apple’s iPhone mobile platforms. I’ve heard people saying it’s going to fail miserably and heard others saying it’s gonna be a huge success. I honestly have no idea what will happen – on the one hand, it does look like a cool platform but on the other hand, it might be too little too late… time will tell, I guess.
Anyway, this developer tools package includes everything you need to write Windows Phone applications. Even though the actual device is not publicly available at the moment, you will still be able to use the included emulator to write applications.
By the way, the official release date for Windows Phone 7 devices is very soon - October 11th.
Further reading: Windows Phone Development Center, Scott Gu’s blog post, Microsoft Windows Phone 7 Release Date Confirmed

October – ASP.NET MVC 3 Beta

ASP.NET MVC 3 is the next version of ASP.NET MVC. It will include various new features and improvements, making this framework much more mature and ready for mass-usage.
It seems to me that version 3 will finally allow ASP.NET MVC to compete with other popular MVC web frameworks like Ruby on Rails.
Join the party people, MVC is the sane way of writing web applications today (until someone comes up with a better approach).
Further reading: Phil Haack’s blog post, ASP.NET MVC 3 Beta release notes, ASP.NET MVC 3 Road Map

October – NuPack

This one was a total surprise for me… I haven’t seen it coming at all. NuPack is Microsoft’s new packaging system, aimed to ease the process of finding and installing .NET libraries. This is a great addition to the .NET world and something I, personally, have been wishing for. This is very new and I hope it gets adopted by the .NET community. The sooner the better!
This is not a new concept. It has been around for years in the Ruby world (RubyGems) and in the Perl world (CPAN).
I also recommend you to watch the OpenWrap project which is an open-source package manager for .NET currently developed by Sebastien Lambla.
Further reading: Official site, Scott Gu’s blog post, Scott Hanselman’s blog post, Phill Haack’s blog post

I’m sure I missed some products but you get the idea – they’re on fire! 10 new releases in 6 months!

In conclusion, I think it’s good that as .NET developers, we now get more options to choose from and more mature tools to work with.
My wish for the future is that apart from Microsoft making the .NET world better, we will also see the community making the .NET world better with awesome open-source projects.

All the best,
Shay.

Share: kick it on DotNetKicks.com Shout it

Posted by shayf | 1 comment(s)

The Official Response from Microsoft about the IronRuby Situation

A few days ago someone asked on the IronRuby mailing list if there were news about the future of IronRuby. In return, Tomas Matousek, the last active IronRuby developer inside Microsoft, posted Microsoft’s official position (which apparently was published some time ago):

"At this time, we have no announcements to make beyond what we announced in July 2010 — that we were putting these [IronRuby and IronPython] under the Apache License v2.0. Clearly, there is customer and community interest in these languages. With many organizations running mixed IT environments, we continue to value community feedback on how we can support their interoperability needs, and we remain committed to supporting multiple tools and languages that provide developers with the most choice and flexibility.".

I’m not quite sure what that means but hey, at least we got something :)

Live well and prosper!
Shay.

Related reading: Keep Your Chin Up Child and Wipe the Tears from your Eyes

Posted by shayf | with no comments
תגים:,