Category Archives: Devs (Visual Studio)

Tail Call bug Discovered in .NET 4.6

If you have begun using Visual Studio .NET 2015 you might want to hold off.  There is a serious bug that was discovered in .NET Framework 4.6 64 Bit optimizer that affects the last parameter that is placed in the tail call of functions.  This bug is simply being referred to the tail call bug (https://github.com/dotnet/coreclr/issues/1296).

To understand what this bug is you need to know a few things about tail calls and how compilers work in general.  First we will cover what a tail call is.  When you write a function in any modern language, may times you can have your return value be a return value from other function.  An example is demonstrated below:

function foo(data)
{
a(data);
    return b(data);
}

In the above example, the function foo() calls two functions, a() and b().  However the value from the function call b() is returned from foo().  This means that the call to b() is consider to be the tail call.  Your function can have multiple tail calls as demonstrated below:

function bar(data)
{
    if (a(data))
        return b(data);

    return c(data);
}

In this example, b() and c() are tail calls but a() is not.  You can read up more on tail calls here: https://en.wikipedia.org/wiki/Tail_call

The next topic to cover is code optimization.  When you compile your programs in most modern languages it will analyze your code and attempt to see if there is anything that can be substituted with a simpler set of instructions.  Please consider the following:

int a = 1 + (2 * 8);

An optimizer will see this and replace it with the following line before it creates the output assembly:

int a = 17;

As you can see that the final result of the variable a would be exactly the same but the code in the later example would execute faster.  For the case of the bug that is happening with .NET is affecting the optimization related to the last parameter of the tail call.  What is interesting about this bug is originating in the new RyuJIT which is supposed to affect 64 Bit versions of assemblies (http://blogs.msdn.com/b/dotnet/archive/2013/09/30/ryujit-the-next-generation-jit-compiler.aspx).

So now the question is what to do?

Well you can wait for this bug to be fixed.  Microsoft is working on a fix (https://github.com/dotnet/coreclr/pull/1298) but there is no word yet on when this will be released.

You can also disable the RyuJIT optimization by updating your registry: Under HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft.NETFramework add a useLegacyJit DWORD with a value of 1.  After Microsoft does release the patch for this bug you should change the value back to 0.

Source: http://nickcraver.com/blog/2015/07/27/why-you-should-wait-on-dotnet-46/

Update (7/30/2015 @ 10:18 AM EST): 

The bug has been fixed and the patch has been made but it won’t be available into the next Windows Update.  No word yet on when this will be.  Rich Lander, who works on the Microsoft Common Language Runtime team, posted this:

Could C# be the one language to rule them all?

Being a developer, it is important to continue to learn about new languages as you are being asked to create solutions for multiple platforms.  The reason why we have so many languages is because on a hardware level each CPU uses a different assembly language to run their instructions.  Due to this fact not every language is able to run on every platform.  For this to work you would need to have multiple companies that are able to understand these CPU differences to write compilers for the same language.

Java_1

For a time, the language Java (which as owned by Sun Microsystems for a time until Oracle purchased the company) was set out to solve this problem.  From 1995 through the mid 2000’s it seemed like Java was supported on almost every computer and device.  That was until the iPhone come along with its first version of iOS in 2007.  It wasn’t unusual that a new device didn’t have support for Java on the initial release but then Apple announced that they will never support languages like Java (http://www.iphonefaq.org/archives/9731).

The reason is because their terms of use do not allow developers to create apps that were written from interpreted code.   So that means you are only able to create apps that are written in a low level language like Objective-C which create compiled programs.  This was bad news for developers as there was one more language that we needed to learn.

The folks over at Google decided on using Java (although you can also use C++) to write your mobile apps for their Android operating system.  Meanwhile Microsoft relies on their .NET Framework to create Windows Mobile apps which includes the Visual Basic .NET and C# languages.

By now you see the problem.  If you wanted to write a mobile app for each of these platforms, you would need to learn three different language on three different frameworks.  Wouldn’t it be nice if someone created a new language and would allow programmers to create apps for all of these types of devices?  Well the short answer is no.

xkcd-standards

The solution to this problem has been solved for us already by the Mono group (http://www.mono-project.com/).  The Mono project was started back in 2004 as an open source project to port the .NET Framework to run on Linux and Mac.  This project was original independent from Microsoft but now it is being included in the latest version of its developer environment: Visual Studio 2015.

VS2K15_1

This is all possible because of Xamarin (http://xamarin.com/) which takes the ported version of the .NET Framework and uses it build apps that run on both Android and iOS devices.  However it isn’t perfect.  For instance, in order to create iOS apps in Visual Studio 2015 you are going to need to purchase a business account from Xamarin ($89/month) plus have access to a Mac.  This will then create the compiled programs that iOS will allow to run on its devices.

Also the version of the ADK (Android Development Kit) that is included with Visual Studio 2015 isn’t the latest version so you will need to manually go out and download and configure the latest version on your machine before you are able to create Android apps.  At any rate you will be prompted to log into Xamarin.  You can find more information about this here: https://www.visualstudio.com/en-us/features/xamarin-vs.aspx.

Not exactly plug in play, but it is still early days.  Hopefully, future versions of Visual Studio will allow developers access to a more “turn key” solution for creating mobile apps in a single programming language.

Windows 10 Universal Apps can be Submitted on July 29

I had a feeling this was the case. In fact, had I known it would be a story, I would have published this a few days ago. Microsoft will begin allowing developers to submit universal apps to the Windows 10 Store on July 29. I suppose it’s because they want to make sure there are absolutely no universal apps when Windows 10 launches.

It seemed obvious because when Microsoft released Visual Studio 2015 on Monday, they stated that developers wouldn’t even be able to work on universal apps until July 29, oddly enough, although the release candidates had and still have the capability to develop universal apps.

Continue reading Windows 10 Universal Apps can be Submitted on July 29

Microsoft Makes Visual Studio 2015 a Kept Woman

Visual Studio 2015 is now available! That is all.

Just kidding. I was right smack in the middle of installing Visual Studio 2013 Ultimate when I heard the news. When I went into my Visual Studio account to download Visual Studio 2015, I saw a disappointing message.

As it turns out, developers will not be able to develop Windows Universal apps on Visual Studio 2015 until July 29 when Windows 10 is released. If you are working on a universal app, you need to use one of the release candidates. It’s a bit odd that Microsoft doesn’t want anyone officially working on universal apps until Windows 10 is out. You would think they’d want some universal apps (other than their own) coming out of the gate.

Continue reading Microsoft Makes Visual Studio 2015 a Kept Woman

Let Microsoft See if you have a Twin

By Rich W Woods

Remember how-old.net? The web app that Microsoft created to guess your age that became a viral sensation? Well, Microsoft is looking for a second round.

This one is twinsornot.net. The idea is that you upload a selfie of yourself and someone else and Microsoft will tell you how much you look alike. As you can see, I look 24% like Justin Bieber.

Continue reading Let Microsoft See if you have a Twin

Joe Belfiore’s T-Shirt at Build Explained!

By Rich W Woods

During the Build 2015 Day One keynote, you might have noticed that Joe Belfiore was wearing an interesting keynote. He even made reference to it during the keynote, suggesting that there was something to decode in there.

The t-shirt was in binary, meaning that it was a combination of ones and zeroes that makes up the Windows logo. Kévin Gosse was the developer to decode the message. Have a look:

Continue reading Joe Belfiore’s T-Shirt at Build Explained!

Extras: The Week in Tech #1, Apple Earns and Microsoft Builds

By Rich W Woods

Extras: The Week in Tech is going to be a weekly YouTube video that recaps the week’s tech news. This is the first one. I would love to get some feedback on it, as well as feedback on the name. The name is really just something I thought up.

That being said, there was a lot that happened this week. Apple announced earnings, Google wants to buy your patents, LG announced the G4, and Microsoft had some small event where they announced a couple things <wink>. Check it out.

Continue reading Extras: The Week in Tech #1, Apple Earns and Microsoft Builds

Microsoft Releases Band SDK to Developers

By Rich W Woods

The long awaited Microsoft Band SDK is now available. There are three different SDKs, one for iOS, one for Android, and one for Windows Phone, which is just a bit disappointing, as we saw so much at Build this week about being able to develop once and port it to all three platforms.

Who knows though? I honestly can’t say for certain that one doesn’t work with the other. But I digress. Go make some apps!

Oh, and the features:

Continue reading Microsoft Releases Band SDK to Developers

Missed Microsoft Build Day One? Here’s a Recap

By Rich W Woods

Today was the first day of Microsoft’s annual developer conference, Microsoft Build and boy, was it amazing. the keynote was a whopping three hours long and it was just jam-packed with great stuff. So what did they talk about? A lot. Have a look.

Continue reading Missed Microsoft Build Day One? Here’s a Recap

Microsoft Announces Continuum Mode for Windows 10 Phones

By Rich W Woods

Today, at Microsoft Build, Microsoft’s yearly developer conference, Microsoft announced that Windows 10 for phones would have a continuum mode, effectively allowing users to plug their Windows Phones into a monitor and turning the phone into a PC.

Continuum mode is something we have already seen on tablets, allowing users to switch between a desktop and a tablet with the click of a button. This is something really cool.

Continuum on phones is not just projecting the screen. It turns the phone into a full desktop PC and since it is running universal apps, it will run the full desktop version of the universal app. Note that this new feature will require new hardware.