Showing posts with label rants. Show all posts
Showing posts with label rants. Show all posts

Thursday, March 13, 2008

Sun / Microsoft developer marketing

I just got back from the Microsoft 'Visual Studio 2008' launch event at the Hilton. I can't put my finger on it but a few things just really pissed me off about the whole thing. Maybe it's the hot weather we've been experiencing but I'm fired up.

The ASP .NET session wasn't too bad. Kudos for the Javascript debugging / code completion, but then again firebug has been around for how long? To the people in the audience that debug their Javascript in IE using alerts; you deserve the agony :)

The next session was on Team Foundation Server , in particular the source control and continuous integration features. The presenter was carrying on like Microsoft invented these things. Personally, I found it rather condescending but on looking around everyone was lapping it up. I suppose if all you know is VSS then these things might impress you. These are not bells and whistles! These are essential development practices that you already should have been using. There are already so many existing tools available, I get along just fine with cruise control and svn. I didn't see anything innovative in TFFS at all.

I cast my mind back to the Sun Java developer day I attended last year; oh so many contrasts. Firstly, the Sun event was free, the Microsoft one wasn't (but thanks for sending me work) :). The Microsoft one was full of buzzwords, marketing and testimonials, where the sun one was more developer-centric, presenting some really cool shit, like launching project matisse.

It's a real shame the Sun event was cancelled in Adelaide this year. I dearly hope this isn't indicative of a shift

Unfortunately the biggest highlight of my day wasn't attending the event; it was my taxi almost running over Ahn Do on the corner of Wakefield and Pulteney street.

Friday, September 21, 2007

Code Voyeur

I like perusing public code repositories, be they CVS/SVN/Mercurial/Git whatever. I'm not sure if this is some kind of sick code voyeurism fetish but I think it's kind of healthy in degrees. It's a good place to pick up tricks. Kind of like doing the weekly ruby quiz but looking at the code before you know what the task is and seeing how closely you think they correlate to the spec.

Scott Hanselman is also on the kick of reading other peoples code to become a better developer, could it be the path to enlightment?

It dawned upon me that at work I have rarely had the need to tread outside my projects. All this time i've been searching far and wide for great code when I had a veritable treasure trove of unread code right under my nose.

We have a VB contractor doing some work for us and I caught wind that someone asked him to do it in C# ASP.NET. Wow. Might not be so bad I thought. So I had a look in SVN and came across this:


 1     public static string Proper(string StringIn) {
 2       string Temp = StringIn;
 3       if (Temp.CompareTo(String.Empty) != 0) {
 4
 5         char[] Delimiter = { ' ' };
 6         string[] Words = Temp.Split(Delimiter);
 7         Temp = String.Empty;
 8
 9         for (int i = Words.GetLowerBound(0); i <= Words.GetUpperBound(0); i++)
10           if (Words[i].Trim().CompareTo(String.Empty) != 0)
11             Temp += Words[i].Substring(0, 1).ToUpper() +
12                     Words[i].Substring(1).ToLower() + " ";
13         return Temp;
14       }
15       else
16         return String.Empty;
17     }
18


Apart from the upper case local variable names, in-efficient string concatenation and re-inventing the wheel, the dude did alright. Absolute respect to him, he's smart, he got it working, but it is obvious that C# is not his native tongue. That is textbook VB in C#.

Here is something roughly equivalent I came up with that produces the same output (don't lambast me for not getting the current culture, "en-AU" does weird shit that "en" doesn't) :)


1     using System.Globalization;
2     public static string TitleCase(string str) {
3       return String.IsNullOrEmpty(str) ? String.Empty
4              : new CultureInfo("en").TextInfo.ToTitleCase(str.ToLower());
5     }


It's not his fault really. He was asked to code in a language he wasn't familiar with and he got by. But what he did was speak English in down-town Nairobi.

Now I don't know what my point is but just look at the API's if you are using an unfamiliar language. I'm not shit-hot with C#, give me C, Java or Ruby and I've got a fighting chance. The thing is I'd assume that .NET would provide a way to title case a string. Instead of re-inventing the wheel I did a google search and came across the TextInfo class. You think he would have twigged that if VB has StrConv there might be something vaguely similar in C#.

Moral of the story, if you're asked to code in a language you are not familiar with, knock it back or make it clear it might not look pretty. But i guess who doesn't like getting paid?

Tuesday, August 28, 2007

"Ruby off the Rails?" quid pro quo

I came across Ruby off the Rails? by Paul Turner and he issued a challenge at the end of his post, and I bit :)

Read it here (including the comments) then come back for my some-what larger response.

Begin communique:

I agree with you that Microsoft adding more and more languages to the framework is a bad idea. J# anyone? . Their ploy is to lower barrier to entry, so what you end up with is some developers using anything but C#, because, well why bother learning it if you don't have to. Have you tried proposing C#.NET to a VB developer when they can use VB.NET? I have, it's not fun. It might just be me but I question the maintainability of an application written in 7 different languages.

To answer your question:

Read the following with the caveat of using the "right tool for the right job". Obviously if you are targetting a windows desktop app, it is hard to trump WinForms. However i think .NET is licked in every other category.

  1. Portability (Mono still doesn't implement the full .NET 2.0 API)

  2. Expressiveness of language:

  3. 1    for (int i = 0; i < 5; i++) {
    2      Console.Out.Write("c# loop ");
    3    }

    vs.

    1 5.times { print "ruby loop " }

  4. Cost $$$$$$$$$$$$$$$

  5. MSDN documentation is, well crap, contrast:

  6. http://msdn2.microsoft.com/en-us/library/system.io.file(vs.85).aspx
    and
    http://java.sun.com/javase/6/docs/api/java/io/File.html

  7. Closed source / Open standard


I can safely say that you are the first Microsoft proponent that I have come across that knows the difference between open-source and open-standard :). Some people claim that .NET is open-source. No; it's a huge difference. Java is open-source: http://www.sun.com/2006-1113/feature/. Ruby is open-source: http://www.ruby-lang.org/en/LICENSE.txt. But you hit the nail on the head C# is an open standard: http://www.ecma-international.org/publications/files/ECMA-ST/Ecma-334.pdf.

This might not be a kicker for a lot of people, but it is to me. I like being able to delve into source and see what's going on and change it to suit me. This is how i found a bug in the Sun implementation of the CachedRowSet, i thought i was going insane but i was able to get in there and figure why it wasn't working and then report it. Kudos for the open-standard, but one up it and go the whole hog.

I was also working as a government employee when I discovered that bug. If the source hadn't been open I would not have been able to temporarily patch it and get on with what I was doing.

I also have to disagree about the 'purity' of keeping SQL code in SQL Server. It's fine if you have resigned yourself to paying for SQL Server subscriptions the rest of your life. But i'd like to bet on a bit of flexibility and write ANSI compliant SQL that i could quite easily drop into Postgres or any other db for that matter. Ofcourse there are extenuating circumstances (performance reasons and the like) to dabble in sql server extensions, but it is a rarity. I wish i also had the energy to go the age old 'dynamic sql vs stored procedures' argument with you too :)

Rather than bemoan the fact that is IronRuby, maybe have a look at it, who knows you might give up your C# day job :)

Wednesday, August 1, 2007

Pander to familiarity

The first step of getting out of the familiarity trap is to feel confident in sizing up what else is on offer.

A simple set of criteria as defined by Sebesta in 'Concepts of Programming Languages' includes:

  1. Readability

  2. Writability

  3. Reliability

The invisible 4th criteria I belive is Familiarity. Unfortunately, in reality I believe that familiarity takes precedence for the majority. You might argue that familiarity is a construct of readability and writability but I disagree. It may be a fuzzy line; but to me something isn't purely readable and writable just because you've twisted your mind to think that way.

For example:

1 for (int i = 0; i < 5; i++) {
2   Console.Out.Write("hi ");
3 }


That looping construct makes sense to a veritable legion of programmers (pick your printf or println statement). Is it readable and writable because you've done it a gazillion times or is it inherently simple?

Contrast that with:

1 5.times do
2   print 'hi '
3 end


If you pulled a layman off the street and showed them both I could take a guess at which one would be considered more readable.

In Steve Yegge's (in)famous next big language post his number #1 rule for the next triumphant language is 'C like syntax'. I can tell he feels oh so dirty saying that, but 'you gotta give the programmers what they want'.

Things like orthogonality, control structures and data types don't seem to rank as highly. Whatever happened to the best tool for the job? If I know there is something out there that works I don't care whether it's functional, applicative, imperative, logical, whatever. It's just a side-effect. If you have a brain in your head, you can work it out.