LINQPad – More than just a LINQ editor

I stumbled across this .NET 3.5+ utility today, LINQPad. I think I’ll be putting this on every development machine I control — it’s been very handy today.

image

At first I thought it was just a live LINQ viewer/editor (which is useful on it’s own!). But, in order to support that type of functionality, it supports a wide variety of code snippets that you might want to experiment with, without the hassle of starting Visual Studio.

The syntax coloring editor (no Intellisense yet, sorry) makes editing code a decent experience. Once you’ve typed in your code snippet or LINQ statement, hit F5 to test it. The results appear in the bottom half of the application. I believe through extension methods, it adds a "Dump" method to IEnumerable objects so that they become nicely formatted in the resulting display (see the screen shot for an example).

Here was the C# code I used in the screen shot above:

Console.WriteLine("WiredPrairie");
var website = new { Href = "www.wiredprairie.us", 
    Topics="Coding,Usability,Software,Photography,Java" };

IEnumerable<string> topics = from topic in website.Topics.Split(',') 
    where topic.IndexOf("Java") == -1 select topic;
topics.Dump();

Results:

image

It’s free. Oddly, there’s no installer, or click once for the application (given it’s part of a book on C#, I would have thought a click-once installer would have made sense … but I won’t complain loudly since it’s free.)

I’m not sure what to do with this button:

image

I can’t get it to display anything … if someone figures it out, post a comment or send me a link if you don’t mind!

I looked up one of the snippet compilers I used to install, "Snippet Compiler" (here). There’s an "alpha" release for .NET 3.5. I stopped using that tool a few years ago when it started to "bloat" and do too much. It looks like a full editor now…

The Mobile Web is dead?

Geesh — one company dies and industry pundits (here for example) are declaring that the mobile web is finally dead.

What? Although my phone finally supports 3G in those areas of the country that have 3G service — I’d hardly say that my Windows Mobile 6 phone web browsing experience is anything but barely adequate. I was never bothered by AT&T EDGE speeds — mainly because the web pages rendered so poorly as to be barely useable. I don’t fault web sites for not considering my use to be a prime candidate for optimization and development. It’s a lot of work just to make a web page work on the various full-sized browsers such as IE, Firefox, and Safari. Then, they must consider the actual frequency of mobile users — near 0.1% I’m sure before deciding to create an optimized mobile web version.

Amazon has a mobile site though — and it’s perfect for my needs. Fast, simple, and renders perfectly. The other day in a local store, I did some price comparison’s with Amazon to verify that I should buy some of the stuff locally and wait to buy a few items when I got home from Amazon (I didn’t feel the need to try to buy something from Amazon while in a physical store).

I frequently use mobile versions of news (CNN, MSNBC), weather (weather.com), and Google Reader.

Why do we still need mobile then?

I hear people talking about the ideal experience that is available on the iPhone/iPod touch for browsing the web. I’m using a beta of SkyFire which attempts to emulate some of the experience of the iPhone browser on my WM6 phone. It’s not bad — but what I really don’t care for is all the zooming in and out and panning. It’s slow and sloppy. I’m disappointed when I need to use it. It’s solving a problem that we ideally shouldn’t have to deal with.

I’d be skeptical that you’d ever find a piece of PC/Mac software that emulated that zooming and panning experience on your monitor/LCD and enjoy it (imagine if your current web browser worked that way). (And no, mapping software doesn’t count!) Instead, you’d want something optimized for the computer and display. Lots of the better web designers and web sites get this and create optimized web sites for phones (I’ve seen mention of quite a few for the iPhone for example). I for one, hope they continue and don’t declare mobile web to be dead. For most applications, it’s a reasonable experience that is zero-install and "good enough." It also targets the most phones — whereas doing custom development for the various phone platforms takes time, effort, etc.

Do you have a data plan? Do you use your mobile phone’s web browser? What are your thoughts?

Can Java compete?

An interesting blog post discussing the merits of trying to simplify the Java web server runtime.

The first real issue is the overhead to develop and then start hosting java applications. It is difficult for host providers to support allowing each user the ability to run their own JVM processes in a sustained fashion. I remember the days when using PostgresSQL required you to have a dedicated server whereas you could use mysql easily by just setting up yourself for a small multi-tenant plan on a web server out there. Today Java is like PostgreSQL of those days. There is no easy way to simply set yourself up to run a small Java application in a shared tenant environment. Even if you did set yourself up chances are that you would be far less than satisfied with the performance in a multi tenant situation even though Java is actually a really really fast language.

When I had a passing fancy recently regarding Java recently — I couldn’t find a hosting provider for any price I was comfortable paying. The problem is summed up nicely above — it’s too hard to host. Java on the web — mainstream web — is never going to catch on if it can’t overcome at least this hurdle.

The only web platforms that are going to survive the long haul must adapt to the new web development model of shared hosting and inexpensive hosting, easy scaling …, simple and convenient programming; all things that the traditional Java web platforms does poorly.

Getting a Handle on it all …

Window Handles that is.

WPF Window Handles.

It’s not hard to get the HWND for a WPF Window. There’s a class that makes it easy to get access to the Win32 based HWND that hosts a WPF Window, called WindowInteropHelper.

I saw this post by Brandon and it made me think, Extension Methods to the rescue!

His solution, although neat, means that there’s an extra object that needs to be created just so that a properties value could be delay loaded. Window handles generally should be obtained and discarded anyway (as they can change), so I thought I’d go with this method to add the Handle property to every WPF Window, without needing to add either a custom class and derive everything from that, or manually add it to every class.

public static class WindowExtension
{
    public static IntPtr GetHandle(this Window w)
    {
        return new WindowInteropHelper(w).Handle;
    }
}

To use:

this.GetHandle()

Done. I don’t mind it being a method in this case as it’s not necessarily a fast operation, and it’s read-only.

What technique would you use?