Development

This category is for all things relating to scripting or programming languages, as well as software construction, design and development.

Windows 10 has an improved Console

Windows 10 Console

It’s true, the Windows command line is making a comeback.

With Windows 10, a number of ‘experimental’ options have been added to the console host which work with both the classic cmd.exe and PowerShell. This includes features like CTRL-C and CTRL-V for copy and paste, plus new text selection hotkeys, resizing, transparency and more.

And, by the looks of Microsoft’s UserVoice forum, this looks like just the beginning:

In the dawn of time, the original Windows console was created. For millenia, geeks and developers (typically both) steeled their nerves and leveraged the console’s utility. After a (very) short time, a great lacking was noticed. And so, legions of ever intrepid command line mavens migrated to other platforms and other consoles, ‘til but a stalwart few remained. Now, today, with a small rumbling, the ancient, weary console heaves a great sigh and rises. The journey to legitimacy has begun.

WE’RE BACK!

If these kinds of features are important to you, don’t forget to give your feedback to Microsoft so that they know that the command line is still relevant in 2014.

Windows 10 Technical Preview

As a big user of software and services in the Microsoft ecosystem, finding out about the next version of Windows is always exciting. Yesterday, we got our first official look at Windows 10, and while we didn’t learn about many features which hadn’t already been leaked, we did finally get to hear Microsoft’s plan for its next generation Windows platform.

Windows 10 Product Family

The official picture above teases how this single release of Windows will feature multiple interfaces the operating system itself, scaling from the Xbox One and the large Perceptive Pixel multi-user business display, all the way down to embedded devices, phones and small tablets.

From a developer point of view, Windows 10 will support a new universal app model that spans across multiple devices. This means that an application can be written only once to run across all of these environments, end-users will only have to purchase the application once to use it everywhere. Universal apps for Windows 10 will probably be very similar to the ones announced at Build earlier this year.

Windows 10 Start Menu

New features like Task View and Snap Assistant are included in the technical preview, but the more obvious user interface changes look like they are still to come. For example, Continuum is a set of features which enable hybrid devices to switch between touch and desktop modes automatically, just by attaching or removing the keyboard.

Windows 10 Task View

Today, along with many other Windows enthusiasts, I signed up for the new Windows Insider Program. This new program is similar in concept to the Windows Phone Developer Preview, but it will also provide opportunities to provide feedback directly to the Windows team.

Trust me, I’m going to provide as much feedback as possible.

String Hashing in F#

I recently wrote a small program to convert some strings into a ‘unique enough‘ hash which could be used as a short reference.

Whenever I’m trying to come up with an idea of how to handle these kinds of functions, I tend to turn to my favourite language, F#. This allows me to do rapid prototyping in a very functional way.

Below is the prototype version of this hashing program:

open System
open System.Text
open System.Security.Cryptography

let encode (alpha:string, number:int) =

    let b = alpha.Length

    let rec enc (s:string, n:int) =
        match n with
        | x when x <= 0 -> s
        | _ -> enc (s + alpha.[n % b].ToString(), n / b)

    match number with
    | 0 -> alpha.[0].ToString()
    | _ -> enc ("", number)

let md5Int (input:string) =

    let clean (str:string) =
        str.ToLowerInvariant()
           .Trim()

    let computeHash (str:string) =
        let bytes = Encoding.Unicode.GetBytes(str)
        use crypto = new MD5CryptoServiceProvider()
        crypto.ComputeHash(bytes)

    let convert (bytes:byte[]) =
        let i = BitConverter.ToInt32(bytes, 0)
        Math.Abs(i)

    convert (computeHash (clean input))

let hash (input:string) =

    let a = "ABCDFGHJKLMNPQRSTVWXYZ0123456789"
    let i = md5Int input

    encode(a, i)

Once I have this program created, it’s very easy to use in F# Interactive like so:

> hash "Here is a test string!";;
val it : string = "1W2ALLB"
> hash "The hash is much smaller, which is great.";;
val it : string = "5DAF5T"
>

Running JAR applications on Windows without installing the Java Virtual Machine

As part of my Open University course, I’m required to use a piece of open source software called Aladin Sky Atlas. This is maintained by Centre de données astronomiques de Strasbourg.

The program itself is actually pretty cool – it’s an interactive sky atlas, which allows you to view astronomical images along with information from the SIMBAD database and other sources.

The only problem with this program is that it uses Java, something I tend to avoid whenever possible. Installing Java on my Surface Pro 2 would mean I’d have more critical patches to install than I already do, and would open me up to a whole new attack vector. It’s not something I’d want to run on a tablet computer either.

(ノಠ益ಠ)ノ “Eww, Java!”

I originally tried using Hyper-V with a virtual machine running CentOS. This is a nice clean way of having ‘nothing running’ until it’s actually needed, but it’s quite an overhead to run a whole Linux operating system just to host a single app. Especially when battery life is a concern.

When searching around for a solution, I stumbled upon a really cool project that I’d never seen before. The IKVM.NET project includes a number of components for Java & .NET interoperability, but for this task I’m mostly interested in the Java Virtual Machine implementation.

By downloading the Windows binary of IKVM.NET, I’ve been able to run the application on my Windows 8.1 machine without requiring the JVM (or any other software) to be installed at all. This is a pretty fantastic achievement.

First I put the binaries into my apps folder (similar to my Vim setup), then I set up an alias to the executable using PowerShell.

# There's usually much more than this in my profile!
$SCRIPTSPATH  =  "C:\Users\Julian\Scripts"

Set-Alias ikvm   "$SCRIPTSPATH\Apps\ikvm\ikvm.exe"
Set-Alias ikvmc  "$SCRIPTSPATH\Apps\ikvm\ikvmc.exe"

# ikvmc.exe is cool too! have a look

After creating an alias in PowerShell I can just run it whenever I need.

PS> ikvm -jar aladin.jar

Obviously you could always set up a Windows Shortcut that does a similar thing, but that’s boring. Using PowerShell really suites me, as I often run applications this way.

Aladin Sky Atlas running on Windows without Java installed

The software doesn’t exactly look pretty, but these open source projects rarely do. Sometimes it looks like text hasn’t rendered as expected, but overall I’m really impressed.

If you’re looking to run JAR applications on Windows, without the Java Virtual Machine, then have a look at The IKVM.NET – it might work for your apps too.

Will Neovim rock on Windows?

Gvim on Windows 8

I have been using Vim on Windows since I switched to 64-bit and edit.com stopped working. Originally I just used the console version inside of PowerShell or the standard command line. In the last three years I’ve been favouring Gvim as my go-to text editor for smaller scripts and utilities.

I know for a fact I’m not using everything Gvim or Vim has to offer, but I’m quite happy with the way it works. For example, I have line numbers turned off, but I can turn them on very easily using a quick :set nu.

Very powerful, very fast.

There are some things I absolutely hate though. For starters, what’s this horrible border on the inside of the window, and how can I make it disappear without hacking the whole application and recompiling it? This isn’t Windows 95.

Ugly Border

I’ve looked for some time but I haven’t found a solution. But hey, I found out that people can make it look pretty on Ubuntu (handy!)

Enter Neovim

Neovim promises to be a refactoring (and reimagining) of the Vim text editor using more modern techniques. The plan is to have the core Vim functionality moved into a new library, which will allow the interfaces to be separated out in a modular way.

The thing that got me really interested? When they mentioned Windows:

Modern GUIs written in high-level programming languages that integrate better with the operating system. We can have GUIs written using C#/WPF on Windows or Ruby/Cocoa on OS X, for example.

True they’re not saying they will write a GUI using C# & WPF, but someone can. And I like the sound of that. Of course, it’ll be open source – and I’ll be able to edit the XAML to have no borders at all, if I like.

Also, here’s hoping we get better PowerShell integration out of this too.

It could be huge.

So, will Neovim rock on Windows? I sure hope so.

It’s a great time to be a Microsoft-focused software developer

The Build 2014 conference took place in San Francisco last week, where thousands of developers and designers came together to learn all the latest information about what it means to use Microsoft development tools, and build solutions that run on Microsoft platforms.

I have over 137 GB of videos yet to watch, but I can already say that it has been one of the best Microsoft developer conferences to date.

Here are my thoughts so far, with a few links to some of my highlights.

.NET is alive and well – and becoming more open

build-2014-4

There was a general feeling that .NET developers had been left behind in recent years. A strong push to using HTML and JavaScript really got some people worried when Windows 8 was announced – but at Build 2014 the message was loud and clear. The .NET platform is alive and well.

It’s almost as if they asked .NET developers what would make them really happy, and set about doing all those things. For me, personally, I was most excited by the promise of open-sourcing even more of the framework, including the brand-new compiler platform (Roslyn) that has been years in the making.

Initiatives like .NET Native will allow applications built with C# and Visual Basic to get much closer performance to applications created with C++. Starting first with Windows Store apps, these architecture specific binaries will increase performance at runtime without losing the productivity of developing with the architecture-agnostic .NET Framework.

Roslyn and .NET Native are in preview, and won’t be completed until the next version of Visual Studio. But there have also been a wide range of updates to the ASP.NET web platform, MVC, Entity Framework and way more – most of which are either available now with Visual Studio 2013 Update 2, or can be downloaded using packages from NuGet.

You can tell Windows is under new leadership

build-2014-1

Cortana – the new assistant built into Windows Phone 8.1 – was the highlight of the show. There had been rumours of Microsoft’s answer to Siri and Google Now for quite some time, so a lot of the information had already come out. But still, it was great to see Joe Belfiore talking to her publicly for the first time, confirming what Halo fans were waiting for: yes she is called Cortana, and yes, she sounds like Cortana.

As Cortana is such a huge step for Microsoft, I’ll be going in depth on what I think over the next few weeks.

Cortana wasn’t the only addition to Windows Phone 8.1, there were hundreds of new features and tweaks to the UI that will take weeks to be documented – the new calendar is just one of these. I’ve tried it in the emulator and it’s really great. The developer preview is due this month.

As a developer, the news of Universal Apps was very welcome. This allows high amounts of code sharing between applications designed for both Windows and Windows Phone. I can’t wait to try this stuff out, especially with the new JavaScript support.

Windows 8.1 has some new features too. The much-leaked Windows 8.1 Update includes changes to how the operating system behaves with a keyboard and mouse – though these changes are only the start of the improvements that are coming.

Azure is the future, and already here

build-2014-3

Microsoft’s cloud platform has improved tremendously over the last few years and this year was no exception – in fact, there were so many new features I can’t even begin to go through them all. Some I probably won’t even use (Java? No thanks.) but I know the option is there, which will inform my decisions for cloud hosting in the future.

Scott Guthrie and his team talked at great length about new features that will improve productivity for ‘DevOps’ tasks significantly. For example, the new Azure Portal includes the ability to view statistics, create new infrastructure, build new virtual machines, deploy websites and even do code changes with Git source control – all from one UI.

I already use Azure as part for my personal projects, as well as Visual Studio online as my source code repository. I plan on using it even more in the future – so I’m pleased to see Microsoft lead in this area. And they really are leading.

It doesn’t have to be Windows & .NET

build-2014-2

Times have certainly changed, and PCs that run Windows are no longer the most popular computing devices. As a predominantly Microsoft developer, this makes me wonder about the future. This year’s Build has continued the recent trend of Microsoft supporting other platforms in new ways – plus with partnerships with like likes of Xamarin, I see no reason to even contemplate switching over to Android (the most popular platform) in the foreseeable future.

While I was hoping that there would be the announcement of a Xamarin acquisition, they didn’t disappoint. It was great to see Maguel even joining Anders on stage during the keynote. Both of these guys are very smart, and I look forward to what else the partnership can bring. Being able to develop universal apps that also target iOS and Android is not very far away at all.

Surface Pro 2: Development Workstation

Surface Pro 2

After five years of faithful service, I have finally replaced my old MacBook with a new computer. I got myself the Surface Pro 2 with 256 gigabytes of storage, and 8 gigabytes of memory.

Frankly this small computer is the fastest one I have ever owned, and performs better than my higher spec work laptop. This is especially noticeable when using Visual Studio and other development tools, but it’s also faster doing every day things like Mail and OneNote.

Development Workstation

The purpose of this computer is to be my development workstation, and to run all my x86 applications. Due to the tiny size of the tablet it will probably spend a good deal of its time attached to external devices. A full size monitor, keyboard and mouse combination will allow me to be as productive as possible at home, while still being able to take everything to other locations in even the smallest of bags.

While thicker than my original Surface RT, the Surface Pro 2 shares the same design language, and I find that it looks almost indistinguishable when I’m facing the screen itself. Picking it up it certainly feels thicker, heavier, and warmer. But it’s still a Surface, and feels extremely well made and very sturdy.

So far, I’m very impressed. I’ll be writing up some of my experiences of using the Surface Pro 2 as a development workstation as I spend more time with it.

Surface

So if this device is meant to replace my MacBook, what does it mean for my Surface RT?

Having two 10.6 inch tablets is not ideal, I know. But I’m going to continue to use the Surface RT for things like Skype, Netflix and general carrying around in my backpack until there’s a 7 or 8 inch Windows RT based tablet that catches my eye.

Windows RT devices tend to have much better battery life, and the operating system itself certainly better suited to mobile devices. For example, Connected Standby allows Windows RT to collect email and other notifications over Wi-Fi even when ‘off’. A feature that is sorely missed on Windows 8.1 Pro x64.

I’m also not convinced that the 10.6 inch screen size of the Surface RT is what I want from a Windows RT tablet anyway. The relatively large screen is great for using with the Type Cover and being productive – but I’d rather have something smaller for using mostly with touch.

Windows 8.1 on the 2008 MacBook

Windows 8.1 on 2008 MacBook

For a while now I’ve been wanting to get myself a new PC, but I haven’t found one that really captures my attention. I tried looking at Vizio, Apple and Samsung – but nothing seemed worthy of the investment. Plus I must admit I have been holding out to see if Microsoft brings an Ultrabook to the Surface family.

Most of the time I actually use my Surface RT for doing every day stuff, but there are some things that are much faster using a larger keyboard, a proper track pad and the ability to be used on the lap. I have been using my 2008 MacBook running Windows 7 for these tasks, as well as pretty much all of the development I do for my personal projects.

Last week – when trying to get the MacBook to boot from a VHD file – I managed to mess up the boot configuration, and two of the three operating systems (OSX, Windows 7 and Windows 8.1) didn’t work at all – the only one that worked didn’t really provide me any way to fix the issue.

So for the first time in what seems like forever, I actually burnt a DVD and got a copy of the Windows 8.1 Preview installed fresh on the NTFS partition. This worked much better than the Windows 8 Preview I had previously tried, and I decided to try and get things up and running properly by following a guide (slightly modified to get the new version of Boot Camp) and lots of hacking around.

To my amazement, not only did all the Apple specific drivers (the backlit keyboard, multi-touch track pad etc.) all work for the x64 version of Windows, but the operating system itself felt a lot faster than Windows 7. It also seemed the Apple’s Boot Camp software wasn’t hammering the CPU as much as it used it.

Thanks to some of the changes in Windows 8.1 – like being able to use Snap view on lower resolutions – I’m actually able to complete most of the tasks I wanted a new computer for. Sure there are a few down points:

  • No hypervisor – meaning I can’t run the Windows Phone Emulator.
  • No touch screen – yes I have tried to swipe content on the screen by mistake!
  • Not very speedy – hey it’s a 2008 machine, it’s not going to be fast.
  • Hacky configurationthe third party drivers sometimes feel like they’re held together with luck. And they are.

But these negatives aside, I’m actually able to get most of my development tasks complete on the new operating system, and I’m going to upgrade to the final version of Windows 8.1 when it comes out in the fall. This means I don’t need to buy a new computer right away, and I’m going to try to get at least another year out of this one.

Windows 8.1 on 2008 MacBook

I still hope that Microsoft will enter the Ultrabook market, and if they do I’m sure I’ll be glad that I waited. But for now I’m going to try to continue to use this 2008 MacBook as long as I can.

My hat goes off to Apple – this has definitely been the best machine I have ever owned.

Update

I no longer own this MacBook anymore as I’ve upgraded to a Surface. It’s a little difficult for me to answer further questions around running Windows on it.

Good luck!

Installing Windows RT 8.1 Preview on Surface RT in the UK

Like many Surface RT owners in the UK, I was extremely excited to install the Windows RT 8.1 Preview that was announced today. Unfortunately, the update provided doesn’t seem to support English (UK) as a language option on my Surface RT.

First I attempted to add English (US) and replace my existing language, however that did not work and I still got the error.

So, hacking away like I usually do, I decided to try forcing the installation of KB2849636 from the Command Prompt:

expand -f:* Windows8-RT-KB2849636-arm.msu .
pkgmgr Windows8-RT-KB2849636-arm.xml

After a reboot my tablet sat on ‘Preparing to configure Windows’ for a long time, and after the jump I was able to see the preview from the Windows Store.

Windows RT 8.1 on Surface RT in the UK

Unfortunately I haven’t been able to install it yet, and I’m told to try again later. It seems to sit in this state and doesn’t progress any further…

Please try again later...

Update 1

Still no joy in getting the preview installed, but there are a few other people looking into the problem.

Check this question on the Microsoft Community for more information.

Update 2

It looks more and more like there is an issue around the installation that can only be fixed by installing an English (US) operating system. I have decided to wait and see what happens. I’ve heard that Microsoft will be releasing a fix for this in July.

In my opinion, this has been extremely poorly handled by Microsoft.

Update 3

There is another question on the Microsoft Community which has some replies from the moderators:


Windows RT users

Please do not change your base language just to install the Preview. If you do this and then update to the preview version, you will permanently change your base language on these devices. This happens because we create a new restore image based on your selected 8.1 base language during install.

Also, as we noted on the download page, if you’ve installed a language pack on Windows RT, we ask you not to install Windows RT 8.1 Preview at this time. A fix will be available soon for updating through the store with a language pack installed, so please check back.

Charles [MSFT]

Goodbye, Pokéject

When Windows Phone 7 first came out, I immediately started looking to use the new development tools to create an application. Pokémon Black and White were out around the same time, so I figured creating a Pokédex-like application would be a good idea.

pokeject

Unfortunately, not much over a year later The Pokémon Company International went after a number of the Pokémon apps for iOS, Android and Windows Phone. They asked Apple, Google and Microsoft to remove the offending applications from their respective stores. My app was included*.

Eventually, The Pokémon Company International released their official Pokédex applications for both the Nintendo 3DS and iOS. (at time of writing, there is no official app for Windows.)

pokedex-ios

The Pokédex app for iOS has a different focus from my app, aiming directly at listing out all the information rather than focusing on checking off the list (though you can use it this way using tagging). This is great, as the information contained in the application far outweighs the data I managed to collect for use in Pokéject. Including some rather cool 3D models.

pokedex-3ds

Personally, I believe the 3DS version to be a lot weaker – the user interface is pretty horrible looking, and I found it a lot harder to navigate. The biggest complaint is the lack of ‘multi-tasking’ on the 3DS. I would like to be able to check off my Pokédex as I play my game. This isn’t possible when both are applications on the same machine.

I thought about reviving Pokéject as web application, going as far as porting a large amount of the source code over to ASP.NET – however I recently started using the iOS version – which contains much more data – and decided it would not be worth the time investment.

So this is the end of the Pokéject project. It’s been fun, but the official versions contain way more information, I suggest people use them moving forward.

* A recent check shows that there are still a number of Pokédex apps in the Windows Phone store, though the most popular and best presented ones were removed long ago.