Phillip Trelford's Array

POKE 36879,255

Walkie Scorchie

From the window at the office I’ve seen a series of futuristic buildings erected, first the Gherkin, then the Shard and now the Walkie Talkie:

London skyline 

The last one being recently been re-dubbed the Walkie Scorchie as it produces a supercharged solar ‘death ray’ that has burned holes in carpets, melted furniture and even the interior of a Jaguar parked nearby.

It feels almost reminiscent of the dystopian future portrayed in the cult film Idiocracy:

Idiocracy skyline

Though our current society is probably closer to the surveillance society of 1984 with the omnipresent Big Brother watching over you:

Big brother is watching you

The everyday software we work with is no less broken, or so Scott Hanselman concludes in everything's broken and nobody's upset.

Software is increasingly a world of broken windows where developers are more accustomed to working around issues than giving feedback, let alone tackling the root causes.

waiting for background operation to complete modal dialog 

Anyone else struggling with the cognitive dissonance of a modal dialog waiting for a background operation to complete?

XAML

I’ve been using XAML in it’s various guises off an on for over 5 years now. Over that time I’ve used WPF, Silverlight and Metro. It feels like little has changed in that time. It’s still probably the best thing out there for desktop app development but surely we could do better.

XML

I’m still stuck editing views in XML, the poor man’s DSL. I, like the developers I know rarely use the designer view. When we do it frequently hangs and we’re left manually killing XDescProc.exe from task manager.

Data Binding

Data binding is central to XAML. With it you can easily bind a collection to a data grid and get sorting and filtering for free. But binding comes with a high performance cost and it’s stringly typed nature means you’re left finding binding errors in the output window at runtime.

Dynamically binding a view to a model would make more sense to me if I could edit the view at runtime, but you can’t, it’s compiled in.

Value Converters

If I want to transform a model value bound to the view to a different form I have to create a class that implements the IValueConverter interface then reference it as a static resource in the resources section. It has all the elegance of C++ header files. Achieving the same thing in ASP.Net is much simpler, you can just write inline some code in the view or call a function.

INotifyPropertyChanged

There’s a plethora of libraries and frameworks dedicated to working around this design decision, from the MVVM frameworks with LINQ expressions to PostSharp and attributes. The C# 5 compiler’s CallerMemberName attribute has finally brought some sanity to the situation. But I know many developers, including myself, have wasted countless hours dealing with it and trying to think of ways of subverting it.

Just about every view model class ends up inheriting from some ViewModelBase or ObservableObject class so that it can implement INotifyPropertyChanged.

Inheritance

It is often said that object-oriented programming is well suited to graphical user interfaces. Perhaps, but I start to have doubts when I see WPF’s Button class with 9 layers of inheritance and over 160 members.

Visual Studio 2010 introduced improved intellisense with substring search on members to partially work around this, but honestly I’d prefer to see buttons be closer to having content and a clicked event than their current diaspora of responsibilities.

Null Reference Exceptions

By far the most common error I see in C# applications is Null Reference Exceptions. Hardly a day goes by where yet another null check is added to the codebase. This needs to be fixed at the language level, functional-first languages like Scala and F# show it’s possible.

HTML5 & JavaScript

HTML 5 and JavaScript are now being pushed as an alternate environment for desktop development. JavaScript has come a long way performance and libraries wise and I like the HTML 5 Canvas model. However I’m not yet convinced how well this scales to multi-window applications that need to interact between processes.

Windows 8

I get that Metro style interfaces are good for tablets and touch, but for multi-window desktop applications it feels like a non-starter.

 

I’ve seen traders use 9 displays simultaneously, running a multitude of different apps from execution platforms and news services to Excel, Outlook and instant messengers.

To me Windows 8 appears to be consumer orientated release. I’m hoping the next version will bring something for the larger customer base of business users.

Vendors

One person’s problem is another’s opportunity. Third party vendors like JetBrains are grasping the opportunity with both hands by patching flaws in Visual Studio and C# with tools like Resharper. They’re now starting to provide elastoplasts over XAML editing too. Jetbrains are not the only ones, Telerik and others are making hay selling themes and datagrids.

627 

To temporarily workaround performance issues caused by the cost of the mouse handler events in one these products we were forced to throttle the number of system mouse events bubbling through the system.

Duct tape is a good short term solution, but surely at some point we should consider building a stronger foundation.

Simplicity

I would not give a fig for the simplicity this side of complexity, but I would give my life for the simplicity on the other side of complexity. - Oliver Wendell Holmes, Jr.

XAML is huge and bloated, WPF 4.5 Unleashed is 864 pages long, yet XAML’s focus on data binding makes it feel like a one-trick pony.

I think a modern desktop UI environment needs to cover a diverse range of product scenarios. There should be a low-level core that can be easily accessed with code for high performance features all the way up to a designer view for tacking databases on to views, and it should all interoperate seamlessly.

Sections of the development community are striving to bring simplicity to our environments. Language designers like Rich Hickey (Clojure) and Don Syme (F#) are bringing us simplicity at the language level. I’d love to see these thought processes applied to UI environments too.

To tackle the root causes of problems some times you need to stop continuously patching over the cracks, step back and take time to look at the big picture. To create Clojure Rich Hickey practised Hammock driven development. I’d love to see more of this kind of thoughtful design and less Mortgage driven development.

Tackling the root causes of complexity and defects in our software is not an easy choice, it requires investment and changes to the way we do things. But not changing is a choice too.

They live out their lives in this virtual reality as they would have around the turn of the 20th and 21st centuries. The time period was chosen because it is supposedly the pinnacle of human civilization. – Agent Smith

Must Java like languages and XML be considered the pinnacle of software development for time immemorial?

5 Common C# Misconceptions

I’ve had the pleasure of working with and interviewing C# developers for over a decade now. However here’s 5 common misconceptions I continue to encounter.

1) Lists are implemented as linked lists

List<T> is actually implemented using an underlying array. The name is a little misleading with the earlier non-generic version having the less ambiguous name of ArrayList and in F# they are aliased to ResizeArray to avoid confusion. Needless to say the performance characteristics of operations on an array are somewhat different to those of a linked list.

2) var is dynamic

The var keyword is used to implicitly define a local variable that is strongly typed using type inference.There is actually no runtime difference from explicitly defining the type.

3) Dependency injection requires interfaces

Dependency injection has become common practice in C# code bases. Many seem to believe that you can only inject interfaces, often leading to interface proliferation, to the point that it can feel like you’re back in C++ land with header files. In fact most dependency injection environments support injection of abstract and even concrete classes.

4) Built-in serialization is efficient

The truth is the opposite, it is slow and verbose. If you’re looking for something efficient consider using Google Protocol Buffers with a library like protobuf-net or JSON from a third party like Service Stack.

5) C# is at the cutting edge of programming language design

C# is heavily based on the Java programming language, and has since made some incremental improvements like LINQ and more recently the async/await keywords. The reality is that all of the “new” features in C# are actually rather old, and progress has been pretty slow when compared to more recent curly brace languages like Scala and Nemerle.

Iterators introduced in C# in 2005 are merely coroutines, defined in 1963, they were first seen in the 1970s in Modula-2.

LINQ provides a library of higher order functions available as extension methods. Similar libraries have been available in functional programming languages like ML since the 70s, for example Select is equivalent to List.map and Where is equivalent to List.filter.

Finally C#’s innovative new async feature actually first appeared in F# back in 2007.

Maybe the pace will pick up when Roslyn is finally delivered, but if you want to experience a wider range of features you might want to look at Clojure, F#, Nemerle, Scala or TypeScript.

GameCraft NYC

gamecraftSkills Matter are excited to host the first ever New York GameCraft event on Friday 20th September at the DUMBO Loft! Following the phenomenal success and excitement around Dublin GameCraft, the event is now going global with a event also planned in London! GameCraft is a games jam event designed around building the gaming community. We aim to create events which allow game-makers to meet, share ideas, have fun, compete for prizes and most importantly make games. The events will be facilitated by Games experts (and enthusiasts!) Andrea Magnorsky and Phil Trelford.

 

This is a free event on the same week at the same venue as the Progressive F# Tutorials NYC, so why not come and join us for both. F# + MonoGame makes a pretty awesome combination, as does Lua + Love or Python + PyGame. Take a peek at the excellent GameCraft resources page for some great links to game engines and tools.

Check out the recent article on GameCraft in the Irish Times. I popped over to Dublin for the first event back in February 2012 and it was really well organized and great fun. I managed to knock up a simple game in under 6 hours. The London event on Saturday August 10th will be 12 hours which may be enough to create a releasable game. Currently my hope is to take a simple game concept to completion and release it on an app store on the same day!

Hope to see you there.