Bookmark and Share

State of the Decompiler

Shortly after I joined Telerik at the beginning of 2011, one of my favorite free tools was yanked from the marketplace. It was unimaginable that it would disappear leaving the .NET community without a free decompiler. It wasn’t as simple as it no longer being support either: it had a time bomb. This meant that you would either pay up or no longer have access to the software.

Around this time, we recently added a decompilation engine to Telerik JustCode and decided to turn it into a standalone product (see: Two Tools, One Engine). This wasn’t public knowledge at the time, and we had originally slated it to be released to the public later in the year. But the opportunity was there, and we knew we had to give the community a free decompiler before there were no other options. We did just that, launching the beta of JustDecompile for the Q1 2011 release cycle.

I had a few thoughts on the ramifications of this for the community, and it panned out as I predicted: the decompiler ecosystem is healthy. I’ve compared products and know what’s good and bad about each. JustDecompile had the most professional interface, but there were few decompilation scenarios we needed to improve.

Visiting the Team

In October of 2011, I flew out to Sofia for DevReach and to finally meet the development teams for Just products in person. Each of the Just teams had their own personalities and plenty of it! It took a couple of days to meet the JustDecompile team as they were located in a separate building on the campus. I met the team leader, Tsviatko, and was amazed he was coding rather than holding Thermopylae against invaders (he reminded me of Leonidas from the movie, 300). The team was rather tight-knit, and they had the garage start-up feel to them.

just-a-team

Supposedly, they all have beards and look like warriors now.

Since I had their attention, I asked about the quality of code being generated from JustDecompile. I then learned about the new engine they were building. The team had discovered the libraries everyone was using in their decompilers made accuracy difficult, and they decided the best course of action would be to build a better core engine. The short release cycle required new features, and people certainly were requesting them. The team was split between these two activities for a while.

The new engine is finally here with the Q1 2012 release, and it’s inside both JustCode and JustDecompile. This vastly improves the code outputted from JustDecompile, and puts it over the top among free .NET decompilers. In addition, there were a number of features users requested for JustDecompile that required the new engine to be in place. I can safely say there will be amazing features coming in the near future.

The State

The state of the decompiler: it’s free and getting better! The competition amongst the free decompilers is encouraging innovation, and we all benefit. This is a definite improvement on the mood of last year, which was doom and gloom. I understand why people were upset, but it was the best thing that could have happened. Telerik promises that JustDecompile will be free forever, and there’s no time bomb anywhere in the product.

This would never have happened without the events of last year. Certainly, Telerik would have released JustDecompile, but then it would have been competing against a very established product. The open source community would have never have worked so diligently on alternatives, and they would be seen as novelty with which to experiment. Basically, the vast majority of people would be using the same ole product with the same ole features. When change happens, innovation occurs.

Awesome T-Shirt

To celebrate the official release of JustDecompile, Telerik is giving away this awesome, limited edition t-shirt. But, there’s only 50 available (it comes in a Deco pack with other cool swag). To get one, you simply need to install the latest version of JustDecompile between now and February 29th. Five winners will be randomly drawn each day starting on February 20th to February 29th.

JDTshirt

I don’t even have one of these... I’m jealous!

Conclusion

I know my words will be greeted with some degree of skepticism: I do work for the company whose product I say is best. However, JustDecompile is free, so there’s no downside to testing that claim yourself. If you’re looking for a specific feature, it now has a “suggest feature” button. Another feature you should be aware of is the full text search: just press ctrl+f. Otherwise, have fun exploring assemblies and the features of the best, free decompiler out there!

Bookmark and Share

Upcoming Telerik Webinars

The Telerik Q1 2012 release is upon us, and we will be showing you all the goodies in webinar week: February 20th – February 22nd.

Here’s the schedule with all times listed in Eastern Time (UTC–5).

Webinar Schedule

 

I will be doing “What’s New in Tools for Better Code,” which covers Telerik’s Just line of products: JustCode, JustMock, JustTrace, and JustDecompile. I had to change the abstract some after it was initially published, so here’s what you can look forward to:

What’s New in Tools for Better Code – JustCode, JustMock, JustTrace, JustDecompile

We have many exciting features to introduce for Just products in 2012 Q1. JustCode gains LINQ conversions, enhancements to the test runner, and support for QUnit and Jasmine. JustTrace makes it easier to find memory hogs with the Largest Memory Retainers view. JustMock gets a codeActivity workflow activity for Team Build. Finally, JustDecompile is officially out of beta!

Come attend my session: it’s going to be a blast! Plus, I’m going to give away a Telerik Ultimate Collection (value: $1999) to one lucky attendee following the completion of the webinar!

Bookmark and Share

Programming Language Rankings

RedMonk has released a ranking of programming languages based on their popularity on StackOverflow and GitHub. The buzz seems to be focused on Java, which is surprising since C# left it in the dust on features. C# is still beating it in most places, but Java and a few other top tier languages have it edged out on GitHub projects. I assume this is because many C# projects are hosted on CodePlex.

One interesting outlier is Rust. It appears to be popular for creating OSS projects, but there isn't a correlation with people asking questions on StackOverflow.

Here’s an example of the Rust programming language:

use std;
import std::io;

fn main() {
    for i in [1, 2, 3] {
        io::println(#fmt("hello %d\n", i));
    }

I found it odd that there are so many projects written in a language whose compiler was released less than a month ago, so I started digging into the data and found that the numbers are misleading. GitHub reports a project as Rust if a file in the project has the extension ‘.rc’. The issue is that many projects use that same extension from build scripts to resource files. Even ColdFusion on Wheels is included in the list of Rust projects. Therefore, its popularity on GitHub as the 23rd most used language is plain wrong.

The outlier on the other side of the graph is Delphi. The contrast here isn't as stark as Rust: there are plenty of OSS Delphi projects. But, it seems that people ask more questions than is justified. My interpretation is that people are coding in Delphi for business, not pleasure. Although Embarcadero has made many improvements to the language, they seem to have difficulty getting people to switch from 2002’s Delphi 7. This may be due to the number of Delphi projects in maintenance or conversion mode.

I consider C# to still be in the dominant position. RedMonk explicitly ignored C# in their commentary on Java’s recent growth. To quote the article: “the Java user group grew members faster than every other tracked programming language excepting C#.”

Bookmark and Share

C# Needs Seqs

In the age of LINQ, we oftentimes use IEnumerable<T> over an array or List<T>. The namespace System.Linq adds extensions on this interface that allows for immutable operations on any set of values, and the query operations of LINQ make your code much cleaner.

For example, this is how I would filter a list of numbers before LINQ:

var even = new List<int>();
foreach (int i in nums)
{
    if (i % 2 == 0)
    {
        even.Add(i);
    }
}

With LINQ, this is simplified to the following:

var even = nums.Where(i => i % 2 == 0);

Prefer IEnumerable<T>

A best practice when programming is to code to an interface, not an implementation. Many people use the return type List<T> when the expected usage of the returning variable is to simply iterate it. Some people try to “program to an interface” by putting an I in front of List<T>, but this is fallacious since the purpose of IList<T> is to allow indexed access to it’s elements. That’s where IEnumerable<T> comes in, as that particular interface is meant to allow iteration over its elements. This should be your default interface if you wish to avoid unintended side effects.

Here is an example of an unintended side effect, using the even number example from above.

public static IList<int> EvenNumbers(this IList<int> nums)
{
    for (int i = nums.Count; i >= 0; i--)
    {
        if (i % 2 != 0)
        {
            nums.Remove(i);
        }
    }

    return nums;
}

Unbeknownst to the caller, the original list is being modified. This violates command-query separation, and creates an unintended side effect by modifying the original list. There are a couple of other issues as well: it won’t work on other expected types, such as collections that don’t implement IList<int>, and it will fail on arrays or other read-only types implementing IList<int>.

This can be made more flexible and less error prone by writing it for IEnumberable<int> rather than IList<int>:

public static IEnumerable<int> EvenNumbers(this IEnumerable<int> nums)
{
    foreach (var i in nums)
    {
        if (i % 2 == 0)
        {
            yield return i;
        }
    }
}

This changes the structure of the method in a few ways: it’s lazy and it returns an immutable type. This is due to the compiler generated “enumerator,” which is the C# term for what everyone else calls the iterator pattern. In many situations, this is correct. Of course, it is possible that your system expects the side effects. I would recommend refactoring to use the immutable form unless there is a compelling reason otherwise; the mutable form is more prone to bugs (the consequence of unintended side effects). One thing to keep in mind is this: when returning an IEnumerable<T>, prefer use of the yield keyword. This practice will help you avoid those unintentional side effects.

The Case for Seqs

The one issue I might have with this is the terminology: IEnumerable<T>. Certainly, that’s what you’re working with in .NET, but the name is rather long and it requires some explanation to new .NET developers. What I would like to see in C#, and I feel C# needs it to change the mindset of many developers, is a new keyword: seq.

IEnumerable<T> simply represents a sequence of items. It can even be an infinite sequence!

public static IEnumerable<T> Repeat<T>(this T obj)
{
    while (true)
    {
        yield return obj;
    }
}

Imagine instead of writing IEnumerable<T> everywhere, you simply used seq<T>.

public static seq<int> EvenNumbers(this seq<int> nums)
{
    foreach(var i in nums)
    {
        if (i % 2 == 0)
        {
            yield return i;
        }
    }
}

Besides being more concise, I feel this would solidify System.Collections.Generic.IEnumerable<T> as a privileged member of the C# ecosystem; similar to how System.String is with the string keyword.

The Primary Issue

My suggestion would be easy to implement, but the C# team is rightfully reluctant to add keywords. I’ve seen code break between versions due to their introduction, and you can be sure some people will experience the same issue with async in C# 5. Since most of these issues can be corrected with a simple find/replace, I feel the cost is negligible.

One way to alleviate some of the pain is to make seq only a keyword when using a generic parameter. This may not be practical for a couple of reasons: it is natural to map the non-generic seq keyword to the non-generic IEnumerable interface, and it would be inconsistent with other keywords. It would prevent breakage, but I prefer a pure language.

What Do You Think?

I will be attending the 2012 MVP Summit in a few short weeks, and I would like to take this feedback to Microsoft. One thing people may not realize is that Microsoft listens to the community. I support adding the seq keyword, do you?

KodefuGuru.GetInfo()

Chris Eargle
LinkedIn Twitter Technorati Facebook

Chris Eargle
Telerik Developer Evangelist, C# MVP

JustCode

Telerik .NET Ninja

 

INETA Community Speakers Program

 

MVP - Visual C#

 

Friend of RedGate

World Map

Month List

Disclaimer

The opinions expressed herein are my own personal opinions and do not represent my employer's view in any way.

© Copyright 2010
Disclaimer: The opinions expressed herein are my own personal opinions and do not represent my employer’s view in any way.