Search This Blog

Thursday, August 9, 2012

Some Things You Need to Watch Out For in WinRT

We all know that Windows 8 is coming out in October. We also know that developers are hard at work trying to ready their apps for Windows 8 when it is finally released. However, if you're new to WinRT or have a big amount of experience coding using C++ or one of the .Net languages like C#, there are some things you have to watch out for.

For your primitive data types, WinRT supports 99.9% of the primitive types supported in the .Net Framework languages. The only ones it doesn't support are 8-bit signed integers. I will also add that Javascript limits a Number to only 53 bits, so be careful when dealing with large numbers.

Compared to C++ which allows mutable strings, the .Net languages consider strings to be immutable. WinRT has taken the route of strings being immutable (even in C++), and the use of NULL or (nullptr) with strings is now frowned upon. Any string which is set to NULL is treated as an empty string (with 0 characters).

In the fight between pass by reference and pass by value, WinRT only passes interfaces as references. All other types are passed by value. This means that you should be careful when passing objects. Structs are allowed, but structs can only hold information of semantic value (such as strings, numbers, and other structs). Pointers inside a struct are not supported. If you are programming using Javascript, please note that Structs are not directly supported. In this case, if you want a struct in javascript, you will have to create a Class which just holds values, mimicking the functionality of a struct.

In Data Structures, we have a big change. Arrays normally are reference types, pointing to a "group" of same-type values (or objects) as part of one big memory chunk. In WinRT, arrays are now value types. I am not sure how the memory management actually works yet (whether it's still one big chunk for the group or not).

For events, you handle them the same way that you normally do in your language of choice (for example, in C#, you add event listeners using += and remove event listeners using -=, so you still continue this practice when developing WinRT programs).

For method overloading, WinRT changes how this works. Normally in method overloading, you can either use a different number of parameters for each declaration of a function, different types of parameters for each declaration of a function (for example, the function displayMessageOnScreen(string message) and displayMessageOnScreen(char[] message)), or a combination of the two approaches. In WinRT, method overloading is determined by the number of parameters, so something like the example I gave above would throw an error in WinRT.

As far as Collections go, many of the collection types found in .Net have a couterpart in WinRT. As far as specific changes go, the WinRT Vector type resembles arrays and the array syntax is used to consume them and the WinRT Map type is a key/value pair collection, and is projected as Dictionary in .NET languages.

Regarding asynchronous functions, all functions taking more than 50 milliseconds to complete is deemed an "async method.

For information, please see http://channel9.msdn.com/events/BUILD/BUILD2011/PLAT-876T. I hope this is helpful to you in some way, shape, or form when developing WinRT programs.

If you have any thoughts or comments of your own about this, feel free to share them via the comment box below or e-mail me at catholictechgeek@gmail.com.You can also find me on twitter (twitter username is @rctechgeek). Feel free to subscribe to my rss feed too. I am now on Tumblr now as well (link to Tumblr is http://www.tumblr.com/blog/catholictechgeek), so please follow me on Tumblr too.

If you're feeling thirsty while using the computer or can't quite stay awake while using one, drink  (or give someone you care about) some tasty Mystic Monk Coffee (use this link or click on the picture below to access the store and purchase). Trust me, it's good coffee (in most instances, much better than Starbucks coffee) and you won't regret buying some (just keep it away from your computer keyboard or laptop/tablet). For the summer, they are also offering Iced Coffee as well. If you like tea more than coffee, they also offer tea. Using the link (or picture below) to buy the coffee (or tea) helps the monks out and helps me with college expenses as well.









Feel free to try out my apps for Windows Phone: Mobile Media Manager, a media player app I made which has some features which (I feel) are missing from the system Zune player, and BSA Eagle Tracker, an app that boy scouts can use to track their progress to Eagle Scout (when the scout handbook isn't always handy). The update for the paid version of Mobile Media Manager is out, but my last submission update for the free version in Microsoft Apphub certification failed, so release of the update to the free version will be a few days (< 7). BSA Eagle Tracker is also getting a bug fix for an obscure bug I noticed recently.

BSA Eagle Tracker download: http://bit.ly/Mm1Upo
Mobile Media Manager (paid version) download: http://bit.ly/y3rf6V
Mobile Media Manager (free version) download: http://bit.ly/xGCsWE

No comments:

Post a Comment

ShareThis