Scott Hanselman

JavaScript Has Won: Run Flash with Mozilla Shumway and Develop Silverlight in JS with Fayde

February 13, '15 Comments [54] Posted in Open Source | Silverlight
Sponsored By

Well this is some amazing news that has been a long time coming. You can take your Flash apps and run them without Flash, and take your Silverlight apps and (almost) run them without Silverlight.

If you still don't think JavaScript has won the web, please read on.

Shumway - Flash in JavaScript and HTML 5

The Mozilla Project "Shumway" has been a long time coming (as long ago as 2012, but it's now ready to be looked at more deeply).

Chris Peterson, a Program Manager on the Mozilla Shumway says:

"Shumway is in a race to stay relevant as Flash fades from the web, but there will always be a long-tail of Flash content that would/will be lost when Adobe or browsers stop supporting the Flash plugin."

Think about that. We've all largely got "Evergreen Browsers" now that update themselves as often as weekly, but sometimes it feels like Adobe Flash is being attacked daily, so we're told to update that as well. Flash itself has more than fallen from grace, as Chris points out, it's fading from the web itself. Fast forward a year or so when there is no more Flash installed, but there's still Flash on the web. Enter Shumway - it's a renderer for SWF (Flash files) without native code! Shumway literally.

Why is it called Shumway? Again, Chris:

"The name "Shumway" is derived from "Gordon Shumway", the actual name of the TV character ALF: Flash -> Flash Gordon -> Gordon Shumway -> Shumway."

That's awesome. What else is awesome? "Shumway is written in TypeScript. It has an ActionScript interpreter and a JIT that generates JavaScript, compiled using eval()."

Shumway makes Flash into HTML5

So Shumway is an HTML experiment that uses TypeScript (a modern typed JavaScript compiler/transpiler) to read ActionScript and resources and JIT the result into evaluated JavaScript. Fantastic. It's also open source and on GitHub. Even better, the Firefox Nightly is using Shumway for Flash videos on Amazon.com. This is the beginning of their test, I presume, to sunset Flash in Firefox.

Fayde - Silverlight in JavaScript and HTML5 Canvas

At the same time, there's The Fayde project. Also Open Source, Fayde also compiles to JavaScript. But Fayde transforms Silverlight into HTML5 Canvas and JavaScript! It's an implementation of a XAML engine in JS. Here's a near-Silverlight implementation of the classic Todo application, expressed on the web without plugins. Not enough? Here's a complex Fantasy Football app written in a Silverlight-like environment but running in your browser, again, without Silverlight.

Fayde - Silverlight in HTML5

To be clear, there are significant architectural differences between these two projects. Shumway reads the binary SWF format and tries to Be Flash, while Fayde is reimagining, if you will, that takes the Silverlight concepts of ViewModels and Views in XAML and adds TypeScript (a comfortable language for the C#-familiar) with the result rendered on a Canvas. It's not a Silverlight Emulator, it's a Silverlight-like implementation and app development pattern for HTML5. It's open source, and they are looking for participation, so head over and get involved! Fayde may be the Silverlight migration strategy you've been looking for.

Aside: From my perspective, it's not unreasonable to imagine taking something like JSIL (listen to my podcast on this amazing project) or a similar IL->JS system and combine it with Fayde to somehow run XAPs as well.

I love how crazy JavaScript is and what people have been able to do with it. Now, go run this PC Emulator (~virtual machine) written by Fabrice Bellard in JavaScript. It's Linux, on a 486, in your browser, in JavaScript. *brain explodes*

Have a lovely day and enjoy today's Open Web.

About Scott

Scott Hanselman is a former professor, former Chief Architect in finance, now speaker, consultant, father, diabetic, and Microsoft employee. He is a failed stand-up comic, a cornrower, and a book author.

facebook twitter subscribe
About   Newsletter
Sponsored By
Hosting By
Dedicated Windows Server Hosting by ORCS Web

Should I use HTML5 or Silverlight? One man's opinion.

May 4, '11 Comments [75] Posted in ASP.NET | Musings | Silverlight
Sponsored By

I was in Belgium and The Netherlands this last week presenting and talking to folks in the community. After I presented on ASP.NET MVC 3, HTML5 and jQuery, one fellow came up after and said, "Should I use Silverlight or HTML5. I don't understand what Microsoft's strategy is or what to use in my app."

Since I work for the Web Platform and Tools team (ASP.NET, IIS, etc) I spend a lot of time working, coding, and thinking about the web. However, I'm not an official strategist, or marketing guy.  But I do have an opinion; one that is mine and no one else's.

That said, I don't think it's that hard and I'm surprised there's so much confusion about this (both outside and inside Microsoft.)  Companies have their official positions but then there's the realities of the web. Here's what the young man asked me and what I told him.

NOTE: I'm talking only about Silverlight in web browsers, not Silverlight for Phone, Games, Out of Browser, High Trust, and other environments that are uniquely Silverlighty.

Should I use HTML5 or Silverlight in my Applications? If you're embracing jQuery, where does Silverlight fit in?

Even though browsers like Chrome release and update very often, not every company is going to upgrade all their browsers every week or even twice a year. Some enterprises will be on Firefox 3.6 for a while longer, or (hopefully not) IE6. Browser plugins like Silverlight and Flash can add new functionality faster. They are called plugins for a reason. They plug-in and add something.

HTML5 isn't 100% done, but today it's already a collection of things that can be used now. Your web apps should use techniques like progressive enhancement to detect available features. As newer browsers include useful features like geolocation and video that used to require plugins, then older plugins become unnecessary. Plugins rev and add new more advanced features like DVR-like video and hardware-accelerated 3D. Those features will eventually find their way into browsers in a few years and the cycle will continue.

Silverlight 5 will become Silverlight 6, Flash 10 will become Flash 11 and HTML5 will become HTML6. Each new spec will add new features, innovating, and pushing the others forward . The web will be pushed forward by all these and more.

There's no question that advanced media apps, 3d, DVR video scenarios shine on Silverlight. Silverlight CAN do some things that HTML5 can't.

If you are creating an application for the web that needs images, links and text boxes, some animations and interactivity, there's no reason you shouldn't use HTML. With new JavaScript libraries like Modernizr, jQuery along with Polyfills, you can even use many HTML5 features and still have good functionality on ALL major browsers - not just the most recent generation.

If your application is internal or a line of business app and is what I call a basic "text boxes over data" application, you have a few choices. You can certainly use Silverlight and its databinding features, or you can use JavaScript libraries like KnockoutJS and write it in HTML. It depends on where you and your company's core skillset lies. Both are good choices and both aren't going anywhere.

If Silverlight has a feature that you need that isn't a part of mainstream browsers, consider a web app that is both HTML/JavaScript and Silverlight. I'm consistently surprised that people feel the need to make Silverlight apps that fill the entire browser but consist of mostly text, images, links, etc. Don't try to make Silverlight act like it's HTML. It's not. Plugins are complimentary to the web, they are not the web. Use them in complementary ways to make the best experiences you can.

If you need basic video like YouTube, use <video> tags if your browser supports the codecs you need, and a plugin if not. However, if you need live video, adaptive smooth streaming, DVR functionality, H.264, or other features that aren't part of HTML5, then again, use a plugin.

Also consider your own productivity and happiness and the tools you want to use. Think about your users, your dev team and their overall happiness.

Apps in C and C++ have their place in games and uniquely native scenarios. Apps using managed languages and XAML balance easy development and deployment flexibility. Apps in HTML and JavaScript work everywhere on the web. Perhaps one day we'll be able to easily mix and match these styles in the best of all worlds.

Until then, it's simple. Use HTML when it makes sense to your solution. Use a plugin when it provides unique functionality. Rinse, repeat. Apply common sense, and a little hair gel.

About Scott

Scott Hanselman is a former professor, former Chief Architect in finance, now speaker, consultant, father, diabetic, and Microsoft employee. He is a failed stand-up comic, a cornrower, and a book author.

facebook twitter subscribe
About   Newsletter
Sponsored By
Hosting By
Dedicated Windows Server Hosting by ORCS Web

NuGet Package of the Week #3 - PhoneyTools for Windows Phone 7

March 21, '11 Comments [0] Posted in NuGet | NuGetPOW | Silverlight | WinPhone
Sponsored By

image Have you implemented the NuGet Action Plan? Get on it, it'll take only 5 minutes: NuGet Action Plan - Upgrade to 1.1, Setup Automatic Updates, Get NuGet Package Explorer.

The Backstory: I was thinking since the NuGet .NET package management site is starting to fill up that I should start looking for gems (no pun intended) in there. You know, really useful stuff that folks might otherwise not find. I'll look for mostly open source projects, ones I think are really useful. I'll look at how they built their NuGet packages, if there's anything interesting about the way the designed the out of the box experience (and anything they could do to make it better) as well as what the package itself does.

PhoneyTools includes new controls, classes and techniques for Windows Phone 7

I've heard that since NuGet is bundled with ASP.NET MVC that some folks think it's just for Web Development. This weeks package is one for Windows Phone 7. You can make packages for pretty much whatever you like. Looks like there are already 26 libraries that are tagged with "phone" on the NuGet site.

These tools are by Shawn Wildermuth and include a bunch of useful classes and controls that make Windows Phone application creation easier.

image

I'll fire up Visual Studio with Windows Phone Tools that I downloaded from http://create.msdn.com. (See how clean my Visual Studio looks? Yours can be tidy as well.)

My Totally Nothing Windows Phone 7 App

You can see that I created a totally basic do-nothing Windows Phone 7 application and that the NuGet Package Manager Console is docked at the bottom.

I type:

PM> Install-Package PhoneyTools
'SilverlightToolkitWP (≥ 4.2011.2.1)' not installed. Attempting to retrieve dependency from source...
Done.
Successfully installed 'SilverlightToolkitWP 4.2011.2.1'.
Successfully installed 'PhoneyTools 0.5'.
Successfully added 'SilverlightToolkitWP 4.2011.2.1' to WindowsPhoneApplication2.
Successfully added 'PhoneyTools 0.5' to WindowsPhoneApplication2.

Looks like PhoneyTools brought in the SilverlightToolkitWP as a dependency. If I want to poke around, I can double click on the NuPkg (which is associated with the NuGet Package Explorer you can get here with ClickOnce) and see what's going on.

NuGet Package Explorer - PhoneyTools.0.5 (11)

Looks like he's got his project's assembly as well as an install.ps1 and uninstall.ps1 in the tools folder. What's in there?

References to assemblies are added by convention automatically

The install.ps1 and uninstall.ps1 run automatically when you, ahem, install and uninstall. He's got a check for the version of NuGet in there (that looks like it was copy/pasted from one of my packages) as well as a manual stop to add a reference. That extra line for adding References is not needed. I know Shawn so I'm sure he'll be fine with me using this as a teaching moment as it's not 100% obvious how this new stuff works.

param($installPath, $toolsPath, $package, $project) 

if ($host.Version.Major -eq 1 -and $host.Version.Minor -lt 1)
{
"NOTICE: This package only works with NuGet 1.1 or above. Please update your NuGet install at http://nuget.codeplex.com. Sorry, but you're now in a weird state. Please 'uninstall-package PhoneyTools' now."
}
else
{
$project.Object.References.Add("AgiliTrain.PhoneyTools"); #don't need this
}

It might seem intuitive to add the reference manually, but assemblies that are in the lib folder will actually be added and removed automatically as references just because they are in the lib folder! There's no need to do it manually.

In fact, you can have one package that includes versions of assemblies for many different Framework Versions. From the NuGet documentation on Supporting Multiple .NET Framework Versions and Profiles:

\lib
\MyAssembly.dll
\MyAssembly.Core.dll
\Net40
\MyAssembly.dll

In projects that target the .NET Framework 2.0 and the .NET Framework 3.5, NuGet copies both MyAssembly.dll and MyAssembly.Core.dll. But in projects that target the .NET Framework 4, only MyAssembly.dll from the Net40 folder will be copied. If you want MyAssembly.Core.dll to be installed in a project that targets the .NET Framework 4, you must include it in the Net40 folder

For Silverlight, he should do:

lib    
\sl4
\AgiliTrain.PhoneyTools.dll

And when NuGet 1.2, he can use \sl4-wp. That way someone can release a package that includes a different payload for Silverlight 4 vs. Silverlight on the Windows Phone 7.

Playing with PhoneyTools

Now that I've got the PhoneyTools installed, what can I do? According to the PhoneyTools CodePlex project, this is a project that contains several classes and controls for use with Windows Phone 7 applications. There are plans for:

And the word is that he's targeting Mix for the first release. This release is in beta. There's nice simple utility stuff like automatically fading "toast" style messages...

FadingMessage.Show("Doing something important...");

That do what you'd expect (you can make them look like whatever)...

image

To more sophisticated controls like an alternative SelectSwitch:

SelectSwitch

And a SimpleLongListSelector Control that handles a lot of boring work for you and makes creating a giant long list with categories easy so that this XAML:

<my:SimpleLongListSelector x:Name="longList">
<my:SimpleLongListSelector.ItemTemplate>
<DataTemplate>
<StackPanel Orientation="Horizontal">
<Image Source="{Binding ImageUrl}"
Height="75" />
<TextBlock Style="{StaticResource PhoneTextNormalStyle}"
Text="{Binding Name}" />
</StackPanel>
</DataTemplate>
</my:SimpleLongListSelector.ItemTemplate>
</my:SimpleLongListSelector>

Along with this LINQ query against a data source:

// For Complex Object and ItemTemplate
var qry = from g in games
orderby g.Genre, g.Name
group g by g.Genre into genre
select genre;

longList.SetGroupingItemsSource<Game>(qry.ToList());

Gives you a nice clean result, and you can click on the category headers to quickly jump to another category.

ItemTemplate

There's lots more, and remember that we noticed the Silverlight Toolkit for Windows Phone "'SilverlightToolkitWP" was a NuGet package as well? There's lot of info on that Toolkit at Tim Heuer's blog as it contains useful controls and classes as well. Between Phoney and the Silverlight Toolkit I think I'm ready to write my app.

Please continue to insist on NuGet packages for useful stuff. Put pressure on the groups you work with and convince them this is a useful thing.

Also, please join me at TechEd 2011 in Atlanta as I present DEV338 NuGet: Microsoft .NET Package Management for the Enterprise!

I'm glad folks are using NuGet for more than just Web Apps. I hope you do to, Dear Reader.

Related Links

About Scott

Scott Hanselman is a former professor, former Chief Architect in finance, now speaker, consultant, father, diabetic, and Microsoft employee. He is a failed stand-up comic, a cornrower, and a book author.

facebook twitter subscribe
About   Newsletter
Sponsored By
Hosting By
Dedicated Windows Server Hosting by ORCS Web

Hanselminutes Podcast 252 - ReactiveUI extensions to the Reactive Framework (Rx) with Paul Betts

February 8, '11 Comments [3] Posted in Learning .NET | Open Source | Podcast | Silverlight
Sponsored By

image "Scott sits down with Paul Betts and talks about extending the Reactive Framework. We currently manage our UI events as they are pushed to us. How does programming - and asynchronous programming - change if we change the way UI events are consumed? The Rx Reactive Framework extends .NET, and Paul's extended that with his Open Source Reactive UI framework. Let's see if Paul can teach Scott a new trick."

Download: MP3 Full Show

Links from the Show

NOTE: If you want to download our complete archives as a feed - that's all 252 shows, subscribe to the Complete MP3 Feed here.

Also, please do take a moment and review the show on iTunes.

Subscribe: Subscribe to Hanselminutes or Subscribe to my Podcast in iTunes or Zune

Do also remember the complete archives are always up and they have PDF Transcripts, a little known feature that show up a few weeks after each show.

Telerik is our sponsor for this show.

Building quality software is never easy. It requires skills and imagination. We cannot promise to improve your skills, but when it comes to User Interface and developer tools, we can provide the building blocks to take your application a step closer to your imagination. Explore the leading UI suites for ASP.NET AJAX,MVC,Silverlight,Windows Forms and WPF. Enjoy developer tools like .NET Reporting, ORM, Automated Testing Tools, Agile Project Management Tools, and Content Management Solution. And now you can increase your productivity with JustCode, Telerik’s new productivity tool for code analysis and refactoring. Visit www.telerik.com.

As I've said before this show comes to you with the audio expertise and stewardship of Carl Franklin. The name comes from Travis Illig, but the goal of the show is simple. Avoid wasting the listener's time. (and make the commute less boring)

Enjoy. Who knows what'll happen in the next show?

About Scott

Scott Hanselman is a former professor, former Chief Architect in finance, now speaker, consultant, father, diabetic, and Microsoft employee. He is a failed stand-up comic, a cornrower, and a book author.

facebook twitter subscribe
About   Newsletter
Sponsored By
Hosting By
Dedicated Windows Server Hosting by ORCS Web

Hanselminutes Podcast 241 - The MVVM Pattern with Laurent Bugnion

November 19, '10 Comments [2] Posted in Open Source | Podcast | Silverlight | WPF
Sponsored By

Scott talks to Laurent Bugnion about the often misunderstood Model-View-ViewModel (MVVM) pattern. What's the different between this pattern and MVC? Can I use this pattern for Silverlight, WPF and Windows Phone 7, and what Open Source projects can support this pattern?

Links from the Show

NOTE: If you want to download our complete archives as a feed - that's all 241 shows, subscribe to the Complete MP3 Feed here.

Also, please do take a moment and review the show on iTunes.

Subscribe: Subscribe to Hanselminutes Subscribe to my Podcast in iTunes

Download: MP3 Full Show

Do also remember the complete archives are always up and they have PDF Transcripts, a little known feature that show up a few weeks after each show.

Telerik is our sponsor for this show.

Building quality software is never easy. It requires skills and imagination. We cannot promise to improve your skills, but when it comes to User Interface and developer tools, we can provide the building blocks to take your application a step closer to your imagination. Explore the leading UI suites for ASP.NET AJAX,MVC,Silverlight,Windows Forms and WPF. Enjoy developer tools like .NET Reporting, ORM, Automated Testing Tools, Agile Project Management Tools, and Content Management Solution. And now you can increase your productivity with JustCode, Telerik’s new productivity tool for code analysis and refactoring. Visit www.telerik.com.

As I've said before this show comes to you with the audio expertise and stewardship of Carl Franklin. The name comes from Travis Illig, but the goal of the show is simple. Avoid wasting the listener's time. (and make the commute less boring)

Enjoy. Who knows what'll happen in the next show?

About Scott

Scott Hanselman is a former professor, former Chief Architect in finance, now speaker, consultant, father, diabetic, and Microsoft employee. He is a failed stand-up comic, a cornrower, and a book author.

facebook twitter subscribe
About   Newsletter
Sponsored By
Hosting By
Dedicated Windows Server Hosting by ORCS Web
Page 1 of 10 in the Silverlight category Next Page

Disclaimer: The opinions expressed herein are my own personal opinions and do not represent my employer's view in any way.