Is Node.js better than ASP.NET, ASP.NET MVC?

Is Node.js better than ASP.NET, ASP.NET MVC?

What I’m writing is in no way a ciricism of Node.js but the hype that some have blindly bought into. Javascript is a great language and Node.js is a good API built on Google’s V8 engine but it’s not the end all and be all that some people make it out to be.

But isn’t Node.js faster than ASP.NET? Well is depends.
Are we talking about development time?
Are we talking about time to first byte?
Are we talking about

But isn’t ASP.NET slow? Efficient, asynchronous .NET code can run circles around blocking Node.js code any day. Remember that while Node.JS allows you to develop non-blocking code, it is possible to still write blocking, synchronous code with Node.js.

Yes, Node.js makes writing non-blocking code easier, but so does .NET. I can write efficient, non-blocking code in .NET just as well as I could write in-efficient, blocking code in Node.js.

Javascript is a great, minimalistic language.
V8 is an amazing virtual machine…similar to Sun/Oracles JVM (Java) and Microsoft’s .NET framework and CLR.
Node.js is a phenominal set of libraries that have been built acount Google’s V8 engine.

It is a good language and platform, but it’s not the end all and be all that some people make it out to be.

BUT but…NPM!!

  • Java has maven and ivy
  • .NET has Nuget
  • Node.js has NPM

The package manager pattern has been around for a long time and has made things much easier for developers. NPM is a great package manager but it’s nothing new.

The dominance of Node.js (the new hotness) over ASP.NET and other (lets say older) server side technologies is accepted as canon in certain circles. Which is better? Like most open ended questions such as this one, the answer is depends?

Many people like to ask questions like “What’s the best language to use for XYZ?” and the answer is always the same…’It depends!’

Further Reading

  • http://www.haneycodes.net/to-node-js-or-not-to-node-js/

Deploying LESS changes to a Windows Azure Website via Git

In developing vacashare.com, I am using LESS to generate my CSS as I have found the technology to be a developer-friendly way of generating clean, flexible CSS. The Web Essentials extension for Visual Studio 2012 automatically compiles my LESS files into a .css and .min.css files ready for production use. The automated CSS generation combined with .NET Bundling allows for clean CSS for development and debugging purposes and a minified version for my production site. Having Web Essentials generate my .css file(s) doesn’t work, though, if the .less file is modified outside of Visual Studio.

Git publishing has been set up to the Azure website but any modifications to the LESS files are not compiled into a new CSS file until the project is opened in Visual Studio and Web Essentials does its thing. Any CSS changes made can be deployed by the Git publish but the changes will be overwritten when the .less file is modified in Visual Studio and the .css files are generated anew.

We are testing out MSBuild tasks that will allow the LESS files to be compiled into CSS files at compile time so that styling changes can be made without requiring Visual Studio (or even a Windows PC) and can be deployed via a Git Push. Installing .Less Msbuild Tasks into the Visual Studio project exposes a new build action “DotLess”. Look through the entire list of possible actions as the list is not in alphabetical order and may appear to be missing at first glance.

Build Action - DotLess

Once the tasks are installed into your project and the DotLess build action is set for the .less files, you can test things by making a change to the .less file and compiling the solution directly by command line using Msbuild.

The next test is to checkout our Git repository on non-Windows PC (in this case, Mac OSX Mavericks), making a modification to the .less file, kicking off a new build of the site using Git Publishing, and confirming that the site reflects the new styles.

ASP.NET MVC4 Project + SQL CE 4 limitations

With the official RTM release of Visual Studio 2012 and the MVC 4 project (also available for VS 2010), I have been using some of the features of new features and out of the box features of hte MVC 4 project to ease the development of my user stories.

SQL CE 4 made database backends much simpler by allowing developers to utilize a SQL engine even if you don’t have it installed on your computer and the zero-config usage is great. SQL CE does have some its limitations and the OAuthWebSecurity class  exposes one such limitation: Transasction Scopes.

Given a development environment with a SQL CE 4 database, you can register a number of authentication providers such as Facebook and Google out of the box with no issues.

Dictionary<String,Object> facebookPermissions = new Dictionary<string,object>() ;
facebookPermissions.Add( "scope", "email" );
OAuthWebSecurity.RegisterFacebookClient(
  appId: "My Facebook App ID",
  appSecret: "My Facebook App Secret",
  displayName: "Facebook",
  extraData: facebookPermissions
);

OAuthWebSecurity.RegisterGoogleClient();

The limitation materializes when trying to disassociate the authentication provider (in this case, Google) from the base account. If you are using SQL CE 4 and the code made available to you with the out of the box ASP.NET MVC 4 project, you will get the following error when attempting to disassociate the account with the OAuth provider.

The connection object can not be enlisted in transaction scope.

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.InvalidOperationException: The connection object can not be enlisted in transaction scope.

Source Error:

Line 110: using (var scope = new TransactionScope(TransactionScopeOption.Required, new TransactionOptions { IsolationLevel = IsolationLevel.Serializable }))
Line 111: {
Line 112:  bool hasLocalAccount = OAuthWebSecurity.HasLocalAccount(WebSecurity.GetUserId(User.Identity.Name));
Line 113:   if (hasLocalAccount || OAuthWebSecurity.GetAccountsFromUserName(User.Identity.Name).Count > 1)
Line 114:   {

iOS ‘native’ web apps with HTML5

I’ve been considering iOS development recently but I don’t have a Mac on which to develop. Alternatively, I have been looking into HTML5 ‘native’ web apps. These are web apps that look and feel like native iOS applications.

I am using my Batch Image Resize web app for my R&D on this topic.

Installation

The web app can be installed via Safari’s ‘Add to Home Page’ feature.

It looks like a native App

As per the Apple Developer Guide, adding the elements below will allow the site to act like a native app when access from your iOS device.

‘apple-touch-icon’ defines the image to use for the icon.

‘apple-touch-startup-image’ defines the splash screen image.

The ‘apple-mobile-web-app-capable’ meta tag allows the page opened via your home screen to behave like a native app. When I open the ‘app’, I see it in full screen browser with no address bar at the top or any of the menus at the bottom.

<link rel="apple-touch-icon" href="/path/to/custom-icon.png"></link>
<link rel="apple-touch-icon-precompsed" href="/path/to/custom-icon.png"></link>
<link rel="apple-touch-startup-image" href="/path/to/startup-image.png"></link>
<meta name="apple-mobile-web-app-capable" content="yes"> <!-- Full Screen --></meta>

Reference

https://labs.ericsson.com/developer-community/blog/beyond-html5-audio-capture-web-browsers
http://developer.apple.com/library/safari/#documentation/iPhone/Conceptual/SafariJSDatabaseGuide/Introduction/Introduction.html

Integrating Google Web Fonts

.post-434 { font-family: ‘Jura’; }

Historically, web designers have been limited to the fonts they can use in live text. Enter Google Web fonts. This will allow you to integrate any website.

I have used the Google Web Fonts API to integrate the Jura font for this post by adding the following to my HTML:

<link href="http://fonts.googleapis.com/css?family=Jura&v1" rel="stylesheet" type="text/css" />
<style>
* { font-family: 'Jura'; }
</style>

You can view more font options on the Google Web Fonts site.

Why did I choose this font? I wanted to use something that was easily differentiable from the surrounding content.

Siobahn has a more thorough article on using the Google Web Fonts API here: http://wpmu.org/how-to-use-the-google-font-directory-with-wordpress/

Source control strategy for WordPress sites

My background is more in software and web application development, not website development. So when I started doing a few websites on the side, I wanted to translate some of the tools and processes that I use everyday as a developer to this new role. As I compared the different CMS options, WordPress was the winner in my eyes with a good balance of usability, maintainability, and customizability.

Having chosen WordPress, my attention shifted to finding a version control mechanism for the works in progress. The look and feel for WordPress sites are managed by themes. WordPress allows your to create a child theme based on an existing theme by assigning the ‘template’ property in the header for style.css (the only required file in a child theme). You can read more about creating a child theme here: http://codex.wordpress.org/Child_Themes.

The content is maintained in the WordPress database (MySQL) and WordPress has a good mechanism for managing historical versions. The parent theme (in my case the new Twenty Eleven theme that came with WordPress 3.2) can be downloaded at any time, there’s no point in adding it to version control. Developing the child themes, I now have my handful of modified files under source control along with a simple FTP upload that serves as my deployment. Branching also works because I can deploy the branch to a 2nd theme folder (lets say ‘twentyeleven_custom_branch’) and preview the site with the new theme without actually activating the updated theme.

Migrating Multiple WordPress Sites to a single Multisite

Until recently, I have been using WordPress solely for more this blog. With the release of version 3.0, I decided to read through the release notes and noticed some great features. With the addition of custom post types introduced in version 2.9, WordPress makes a dandy content management system.

Discussing this with Morton (@mor10) at MIX 2011 only further solidified my decision to use WordPress as a CMS for production websites.

With all of the sites that I am building using WordPress, managing the different sites (each is installed as a standalone site) has become a hassle. Before I start on other sites, I am taking this opportunity to migrate all of my sites that I am hosting into a single Multisite implementation. WordPress has some documentation on how to do this; I will document any hiccups I come across and their resolution.

Further Reading

Production Sites

Here are a couple sites I’ve implemented using WordPress 3.1