Wednesday, October 29, 2014

Angular AtScript

I heard some colleagues discuss if Angular.js will ever be written using TypeScript. The answer is no. In fact, the Angular.js team is using their own language AtScript to build Angular 2.0. The goal of AtScript is similar to the goal of TypeScript, it enhances the JavaScript language with some missing features without infringing upon its current capabilities.

Here are some of the enhancements and the philosophy behind the language from the Angular.js team design documents:

Enhancements

  • Type Annotations: Types allow us to explicitly express contracts between different parts of the system and to give these contracts names. For large teams with large codebases, where no single person knows the whole codebase, types become a key way to discuss and reason about the collaboration between different components of the system.

  • Field Annotations: Types are not only about contracts (API) but also about structure. In JavaScript the fields are implicit; they are created as a side effect of assignment. By giving the developer syntax to explicitly declare the fields, and warning upon implicit creation, we allow them to think about types in a more concrete way. By doing this we in no way sacrifice the flexibility of adding fields dynamically. We simply provide an optional tool to developers who can benefit from being more explicit.

  • Metadata Annotations: Many things in programming are best expressed in a declarative fashion. Declarative annotations allow frameworks to understand the meaning of your code without forcing a complex inheritance or lifecycle API. Examples where this technique has been used in the past include dependency injection libraries and web frameworks.

  • Type Introspection with Annotation Support: When we have annotations, it’s important to provide a consistent API that developers and frameworks can leverage to gain access to this information at runtime. The reflection API should also be backwards compatible with ES5 and ES6.

Philosophy

  • ES6 Baseline: ES6, or ECMAScript 6, is the latest version of the Ecma International language popularly know as JavaScript. It includes many improvements such as a formal class declaration syntax, promises, modules and consistent variable scoping.

  • Backwards Compatibility: Types, fields, metadata annotations and reflective access need to be added in a way which does not break the existing syntax or semantics of ES6/ES5. AtScript needs to be a more succinct way of expressing what is already possible in these languages. ES6/ES5 code must be valid AtScript code without any changes to the semantics. Any developer who has written ES6/ES5 code can immediately get started with AtScript. In other words, ES6/ES5 are strict subsets of AtScript. All the code you are used to writing today will work without alteration with AtScript, but now you can take advantage of the enhancements to the language which will allow you to express your ideas in a more concrete way.

  • Familiar Syntax: We desire to use a syntax which has been tried, is time tested and is most likely to become the next standard. This means using ':' to indicate type annotations (proposed in ES4 and used by TypeScript), '@' for metadata annotations (used by java, dart and others) and 'name:Type;' for field annotations (used by java, dart, TypeScript and others).

  • Pragmatic Approach: The goal is not to build a type system that is correct 100% of the time. Rather, we want to be flexible and useful in the vast majority of real-world scenarios.

  • Semantics Agnostic: Type system theory is a complex field with many tradeoffs. It is our explicit goal to leave the semantic discussion as well as the assertion system outside of the scope of AtScript. Instead we want to provide hooks for others to build runtime type assertion libraries and static analyzer tools with their own semantics. In this way we believe that we can spur innovation in the area of type systems by lowering the barrier to entry.

The Angular.js team was certainly inspired by TypeScript but they choose a different path:

The AtScript has been influenced by TypeScript and Dart. Here we would like to discuss why these existing solutions do not meet our needs.

TypeScript

  • Types are analyzed statically only.

    • Static analysis makes it difficult to have optional types, since static analysis can not analyze what is not typed. (type inference has its limits)

    • Static analysis can not be used to assert that the JSON returned from the server has valid structure.

  • Lacks meta-data annotations

  • Provides no mechanism to access the annotations at runtime

Dart

  • Dart is semantically different from JavaScript. The resulting Dart2JS code uses JS as more of a VM than a language. The result is that Dart2JS code can not easily interoperate with JS code. Only primitive types (such as strings, numbers, arrays, maps) can be passed between Dart and JS. Complex things such as classes can not be marshaled easily.

    • Existing JavaScript libraries can not be used from Dart in a straightforward way. Limiting reuse of prior art.


As a frequent TypeScript and Angular.js user, I see what benefits AtScript brings to the table. One thing is certain, the Angular future looks promising…

Tuesday, October 28, 2014

ASP.NET Custom Headers–X-UA-Compatible=‘IE=Edge’

If you are building a ‘modern’ web application for Internet Explorer, I would recommend to enable the following header inside your web.config:

Using this header will enable ‘Edge mode’ inside IE. It represents the highest support for modern standards available to the browser. In other words, it tells Internet Explorer to use the highest mode available to that version of IE; e.g. Internet Explorer 8 can support up to IE8 modes, IE9 can support IE9 modes and so on. Edge mode was introduced in Internet Explorer 8 and has been available in each subsequent release. Note that the features supported by edge mode are limited to those supported by the specific version of the browser rendering the content.

Remark: Starting with IE11, Edge mode is the default mode. Other document modes are deprecated and should no longer be used, except on a temporary basis. Make sure to update sites that rely on legacy features and document modes to reflect modern standards. 

Monday, October 27, 2014

Building cross-platform mobile apps in Visual Studio

Interested in building cross-platform mobile apps using Visual Studio? Microsoft made this easy thanks to the Multi-Device Hybrid Apps Visual Studio extension. This extension allows you to combine Visual Studio and Apache Cordova to easily build hybrid apps that run on iOS, Android, Windows, and Windows Phone using a single project based on HTML and JavaScript.

image

The extension is available for download here.

Remark: Be aware that the extension will download and install some additional dependencies, including

  • Joyent Node.js
  • Git CLI
  • Google Chrome
  • Apache Ant
  • Oracle Java JDK 7
  • Android SDK
  • SQLLite for Windows Runtime
  • Apple iTunes

More information can be found at http://www.visualstudio.com/en-us/explore/cordova-vs.aspx.

Friday, October 24, 2014

Internet Explorer–What’s coming next?

Do you want to know what HTML/JavaScript/CSS features will be supported in future versions of Internet Explorer? https://status.modern.ie/ brings you the answer. You see all the features that the IE team is considering to support(and you even can see the support for other browsers).

image

Thursday, October 23, 2014

ASP.NET MVC–CS0234: The type or namespace name ‘’ does not exist in the namespace ‘System.Web.Mvc’

Sometimes you have these issues that always appear randomly. You know you have seen these issues before, but you can’t remember how you fixed them Verwarde emoticon.

Today I opened up the project I was working on for the last month to see the following error:

CS0234: The type or namespace name ‘’ does not exist in the namespace ‘System.Web.Mvc’

image

I first tried all the obvious things when you have such an unexpected error:

  • Clean the solution and rebuild the project… Didn’t help
  • Restarting Visual Studio… Didn’t help
  • Delete everything from the Temporary ASP.NET Files folder… Didn’t help
  • Got another coffee at the coffee corner… Didn’t help but I felt a little bit better

Finally I noticed that I had switched between configuration modes. Inside the Debug configuration mode, I noticed that Copy Local was set to False for System.Web.MVC. When I changed Copy Local to True everything was working again.

Wasted one hour…

Tuesday, October 21, 2014

TFS Performance Tips

Last week I noticed the following blog post by Cory House; Two Quick TFS Performance Tips.

It’s a small post, but one with great value…

In his post, he shares one of the greatest performance tips ever about TFS; create a separate workspace for each Team Project. How many times I heard a developer complain that TFS was slow and cumbersome to use… And when I took a look at his Visual Studio solution I had to discover that his 5 years of developer work was all sitting in the same workspace. Ugh…

tortoise_and_hare

Monday, October 20, 2014

Announcing Microsoft Connect event

On November 12th,  Microsoft is hosting an online developer event called Connect();Connect(); will be a chance to have a conversation with developers about what’s coming next for developer tools, developer services and application platforms across Microsoft.

From the website:

Connect(); is a cloud-first, mobile-first, code-first virtual event focused on current and future Microsoft technologies for developers. Build on your current skills, unleash your creativity, and expand what's possible to deliver unprecedented innovations.”

connect-2

So if you have any questions about what’s coming next in ASP.NET, this is a great opportunity to get some answers…