Trailer: Java 4ever
In genius trailer! The .NET vs Java train left the station so long ago for me. .NET’s great for somethings, for everything else, there’s Java. Probably one of the best nerdy videos for the year!
UPDATED: First video was removed
In genius trailer! The .NET vs Java train left the station so long ago for me. .NET’s great for somethings, for everything else, there’s Java. Probably one of the best nerdy videos for the year!
UPDATED: First video was removed
A little late on this one, but MSFT have released the long awaited Visual Studio 2010 release and JetBrains have also released ReSharper 5.
A full breakdown of Visual Studios are also available, not a huge fan of all these different SKUs to be honest. You can download a copy from your MSDN subscriptions now, or download the trial version (direct download), buy an upgrade from VS2008 or just download the .NET 4.0 runtime (48Mb).
I’ve spent the past 3 hours downloading from MSDN and its been crawling.
MUST.HAVE.PLINQ.FIX.
Nate Kohari (the head Ninja of Ninject) has announced the availability of Ninject 2.0 which has been a long time coming – being a complete rewrite. The sources are on github repository. Oh and checkout the new website, its got more ninja references that you can poke a ninja with!
As for .NET 4.0 compatibility, whilst not officially announced, we’ve been using Ninject 2.0 (betas) and now just moving to the final release with .NET 4.0 without issues. All documentation and material are available on the wiki however.
It seems every year life just keeps getting busier
Anyway, here’s a bit good of news, the Visual Studio 2010 Release Candidate is available for download now. You can also get one chunky ISO if that tickles your fancy.
Compared to Beta 2, its a smooth and quite enjoyable experience and I’m very much waiting for the final. The performance of this release is insanely good and finally fixes some annoying performance issues we noticed in WPF in Beta 2 (lets forget Beta 1).
Don’t forget to try some of the cooler features of .NET 4.0 too.
I’ve been porting a few products to .NET 4.0 and came across some cool new additions in .NET 4.0 which will be quite useful for developers.
String.Join("one","two","three","four","uno","dos","tres", "quatro");
Remember writing this before to copy one stream to another?
public static void CopyTo(this Stream input, Stream output)
{
byte[] buffer = new byte[2048];
while (true)
{
int read = input.Read (buffer, 0, buffer.Length);
if (read <= 0)
return;
output.Write (buffer, 0, read);
}
}
Now you don’t need to, just use the Stream.CopyTo() method.
inputStream.CopyTo(output);
Previously to detect a 64bit operating system you would either P/Invoke out and call the IsWow64Process in Kernel32, looked at the “PROCESSOR_ARCHITECTURE” environment variable or even easier (and completely managed code) way of checking the size of a Pointer.
public static bool IsWin64
{
return (IntPtr.Size == 8);
}
public static bool IsWin32
{
return (IntPtr.Size == 4);
}
Now you can simply use the Environment class that comes with two new properties.
There are simply too many to list, see the article on ScottGu‘s blog about WPF4 and VS2010/.NET 4.0.
One very important tweak are the Text Rendering improvements that TextBlock‘s now have a new TextOptions.TextFormattingMode that greatly improves the quality of text rendering.
<Window x:Class="WpfApplication1.MainWindow" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" Title="MainWindow" Height="350" Width="525"> <Grid> <StackPanel xmlns='http://schemas.microsoft.com/winfx/2006/xaml/presentation' xmlns:x='http://schemas.microsoft.com/winfx/2006/xaml'> <TextBox TextOptions.TextFormattingMode="Ideal" FontSize="11">ThushanFernando.com - Ideal</TextBox> <TextBox TextOptions.TextFormattingMode="Display" FontSize="11">ThushanFernando.com - Display</TextBox> <TextBox TextOptions.TextFormattingMode="Ideal" FontSize="16">ThushanFernando.com - Ideal</TextBox> <TextBox TextOptions.TextFormattingMode="Display" FontSize="16">ThushanFernando.com - Display</TextBox> </StackPanel> </Grid> </Window>
Here’s a pretty picture showing the difference between using Ideal and Display. The difference is noticable for text sizes below 15.
Alternatively you can place it in the Window so all child controls will render nicely.
<Window x:Class="WpfApplication1.MainWindow" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" Title="MainWindow - Display" Height="350" Width="525" TextOptions.TextFormattingMode="Display"> <Grid> <StackPanel xmlns='http://schemas.microsoft.com/winfx/2006/xaml/presentation' xmlns:x='http://schemas.microsoft.com/winfx/2006/xaml'> <TextBox FontSize="11">ThushanFernando.com</TextBox> <TextBox FontSize="16">ThushanFernando.com</TextBox> </StackPanel> </Grid> </Window>
There are LOTS more coming in .NET 4.0 that will make anyone doing .NET development today just wet their pants over, just read the article on MSDN by Justin Van Patten about Whats new in the BCL in .NET 4.0 and also posted on the BCL team blog.
Had a nasty issue with jQuery + jSON + IEx just now – still at work because of it!
This bit of code works perfectly fine on Firefox and Chrome:
function onUnitsModified() {
$.getJSON("<%=Url.Action("GetTotalUnitCount", "ProjectReaper")%>", null, function(result) {
if(result > 0)
// Do stuffs here
}
});
return true;
}
But in IE we’ve come to realise that the first hit is successful, future json requests ones are not hitting the ASP.NET MVC actions (I put a breakpoint). You could append a time stamp to get rid of this annoying caching bug, but alternatively you can use the ajaxSetup options to disable caching.
function onUnitsModified() {
$.ajaxSetup ({ cache: false});
$.getJSON("<%=Url.Action("GetTotalUnitCount", "ProjectReaper")%>", null, function(result) {
if(result > 0)
// Do stuffs here
}
});
return true;
}
Darnit! Hope someone else doesn’t waste their time trying to fix this now
Microsoft has just released VisualStudio 2010 Beta 2 to MSDN Subscribers – aka Rosario.
I’m not sure why they’re going with the ULTIMATE moniker for Visual Studio, I still prefer the VS6 style Standard, Professional, Enterprise. Meh.
Some of the more exciting things that are coming with Visual Studio 2010 are documented on MSDN or a better one would be Vikas Goyal’s post and also his .NET 4.0 coverage.. Personally the Parallel extensions are the most exciting bits for me. The new Java 7 work is concentrating heavily on concurrency and its good to see both camps pushing the boundaries.
I’ve been reading up and keeping abreast of both the .NET world and Java world this year, both have some mighty exciting advancements coming – teaser: its all about the Pentiums! I’ll try and cover some of my research into parallel work later.
One of the other areas I’ve been keen on (after hearing from the leader of our pack, Mr Wolfe) was Scala and came across a incredibly useful resource by Daniel Spiewak on looking at Scala from a Java developers perspective.
The linked article is a ’roundup’ of the many posts he’s done on the topic and covers the many facets of Scala and gives it in a Java developers perspective. Highly recommended reading if your just starting out in understanding Scala and functional programming general. I have to admit, Scala is growing on me.
F# is the key functional programming language in .NET and whilst I’ve seen them being compared quite frequently, I feel they target to different areas. From a n00bish-functional-programming perspective, it feels like Scala is all about the OO and F# is more about writing in a functional perspective. But here’s an article from 2007 that may give you a better idea or Brandon Werner‘s article comparing the functional languages.
By the same token, there’s a great introduction to F# that will cover the historical and core language.
I remember messing about 10 years ago with Delphi, VB, Java, C/C++ and thinking this is RAD, but the world seems to be morphing into the functional programming paradigm now. What better time to start musing with it?
Here’s a little cookie from the cookie jar. To quote the legendary Jon Skeet from Threading with Windows Forms:
There are two different ways of invoking a method on the UI thread, one synchronous (
Invoke) and one asynchronous (BeginInvoke). They work in much the same way – you specify a delegate and (optionally) some arguments, and a message goes on the queue for the UI thread to process. If you useInvoke, the current thread will block until the delegate has been executed. If you useBeginInvoke, the call will return immediately. If you need to get the return value of a delegate invoked asynchronously, you can useEndInvokewith theIAsyncResultreturned byBeginInvoketo wait until the delegate has completed and fetch the return value.
Here’s a simple, uncluttered version you can utilise and reuse – this example just adds a list item to the listview.
public void Add(ListViewItem item)
{
if (m_ListView.InvokeRequired)
{
m_ListView.BeginInvoke(new MethodInvoker(() => Add(item)));
}
else
{
m_ListView.Items.Add(item);
}
}
First we check whether we’re executing on the GUI thread or not (InvokeRequired), then execute a delegate thats parsed into the MethodInvoker calling itself using a lambda expression. This code is VS2008 compatible (.NET 2.0 +).
For a non lambda version:
public void Add(ListViewItem item)
{
if (m_ListView.InvokeRequired)
{
m_ListView.BeginInvoke(new MethodInvoker(delegate
{
Add(item);
}));
}
else
{
m_ListView.Items.Add(item);
}
}
The advantage of using an anonymous delegate is that by design, delegates are able to use local variables and parameters scoped in the containing method. Therefore we didn’t need to create a custom delegate with the signature to pass onto the method.
I recently took a look at the ANTS Memory Profiler 5.1 from RedGate software and posted my thoughts on it at the DeveloperFusion market place. Having toyed with several profilers in the past – DevPartner from Compuware (who’s now someone else who now owns the product) being my primary love since I first came across their .NET version wayyy back in 2002 when I was writing for Australian Developer – see ‘ASP .NET and the Web: Optimising Application Performance’ (who became International Developer who are now no longer around!).
If anyone’s serious about their software you ought to have atleast one profiler (ProfileSharp’s free!) with you to catch those nasty leaks and ANTS MP seems to be the best of the bunch right now. While your at it, take a look at NDepend to add to your arsenal.
I love the fact that I can take a few snapshots, go to the Class list and filter by ‘Disposed objects which are still in memory’ and get a quick list, then drill in to find the sources. Give it ago.