Tuesday, November 11, 2008

Yet Another Comment at C# 4.0

Yes, me too. I need to comment on this.

I was at first a little disappointed. All that buzz around the new dynamic type, and Spec# did not reach the podium...

Well, actually it did. They got the idea of implementing contracts in a language neutral manner, by rewriting the IL the compiler generated. Whoa. Now that is cool. It works with every language that targets .NET even your own DSL if you've written one. And the Pex utility that automagically finds input values that break your preconditions, kinda seems nice too...

That is an order of magnitude more useful than canadian ducks being able to Quack() and Walk() anywhere, eh!

Now, what will happen with .NET implementations of Eiffel and RemObjects Oxygene? Will they target the new Contracts framework?

Wednesday, September 10, 2008

A new start

A long time ago, I wrote a little utility to keep a historical record of all changes made to a source file. It was (and still is) called Synchrotron, and written in Delphi.

Now I've moved to a much more powerful version, always called Synchrontron, with so much more to it, and written in C#.

Maybe I should have managed to release it into production today...

Wednesday, May 14, 2008

Yet another example of Dynamic Typing abuse

In this example, they managed to break the test framework itself. You can't even be sure that your tests are actually running! That's a nice programming paradigm :-)

Wednesday, April 30, 2008

Dynamic Weenies are crazy !

I tried to understand the monkey-patch concept. I drove into that gem:

http://blog.nicksieger.com/articles/2008/03/14/monkey-patching-is-part-of-the-diy-culture

Excerpts (bold text is by my own decision) :



So, it took me a while before it occurred to me that something in my project might be overriding make_tmpname. But even after I found it, notified MenTaLguY, and he fixed it, it still left me wondering: who’s in the wrong here? Akira-san, for not making a better way to hook into make_tmpname, Rick for monkey-patching it, or MenTaLguY for changing the method arity in his rewrite? I can’t really point the blame at any of them.

There are certainly more egregious and offensive monkey-patches than this example (and I include myself in that camp). In any case though, I could live with just about any monkey-patch if I had better debugging tools. For example, it would be great if you could ask Ruby to track and retain references to all methods, including those that get replaced, along with the source locations where each was defined. Another possibility might be a before_method_added hook that could let you track method replacements as they’re about to happen (and maybe even veto method redefinitions!).


Yeah, and why not veto the veto, and allowing some other code to veto that also :-)

You can't point the blame? The blame is to consider monkey patching a valid programming practice! If you want to be able to veto method definition, or need debugging methods to track the changes, maybe there is something wrong with the concept...

Think of it: he even considers that the guy who changed a private method could be the one to blame :-)

Incredible! Everyone with common sense agrees that statefulness is evil, and these guys try to add yet more state to try to control the state. And we have to trust them to build secure software?

I'm not that much against dynamic typing, you know

By reading my posts you may think that I'm against dynamic typing. I am not. I am just (very) unconvinced by its promises. Dynamic typing is not the next big thing. It is just a brand new way of making the same old mistakes. Tenfold.

One of these mistakes it to believe that building computer programs is - or at least should be - a simple task. It is not. It requires deep understanding of the problem at hand. In turn, this requires to build an abstract model of the reality, and implement this abstraction. There is no reason that building a computer program should be significantly simpler than building a bridge. You may throw a little amount of plywood to allow you to cross the stream at the back of your house, but to build the Golden Gate Bridge, you do not simply assemble iron bars and test along the way that they still support your weight.

What I don't like is the way the dynamic typing zealots - which are probably in their very early twenties - are pushing their toy, and calling everybody else dinosaurs, afraid of change, blocked in their ivory towers.

Dynamic typing has intrinsic weaknesses. Weaknesses that computer science has tried hard to eradicate, and we the dinosaurs are now witnessing their resurgence as they are hyped as the new great leap forward. Yes we are afraid that we'll have to deal again with self-modifying code. Yes we are afraid that duck typing is yet another way of reliving the glorious days of DLL hell.

Friday, April 25, 2008

We will never agree

From another post :


In Ruby I can write this:

10.times { i puts i }

But in C# I have to write this:

for (int i = 0; i < 10; i++)
{
Console.Write (i);
}

Which do you find more beautiful? :-)



Actually, I strongly prefer the C# version. Not because it is more beautiful, but because it is more descriptive. How do I know whether "10.times" will count from 0 to 9 or from 1 to 10? Or from 412 to 421? How do I know that it will count upwards ? Or backwards? Or randomly?

And anyway...

10.Times (i => Console.Write(i) )


:-)))

Statefulness considered harmful... again :-)

Serious programmers keep telling you ... again and again. Dynamic weenies keep not wanting to hear ... again and again.

http://kurt.karmalab.org/articles/2008/04/24/monkey-patching-core-classes-bad

"the first thing that happened was that 20 completely unrelated specs broke"


---


"This, in turn, snuck into our codebase in all sorts of little unexpected places."


Having the possibility to modify any behaviour of any object at runtime (monkey patching) is the silliest idea since trying to manufacture nitroglycerin in a rollercoaster. Whether it is a core class or not is irrelevant, it is still a stupid idea. Modifying a method in a class is the same as the nice Cobol feature ALTER PARAGRAPH TO PROCEED TO.

Thank you again for these few minutes of irrepressible laugh :-)

Wednesday, April 23, 2008

Yet another silly debugging session

var RantLevel : integer;

begin
RantLevel := MaxInt;
end.

I again lost a few hours today, tracking the silliest problems of them all. A problem that is so easy to get rid of, once you stop listening to all the hype.

One of the forms (in Delphi 7) does not load. Cannot find the class implementing a component... Works on my development machine, breaks on the build server. Why? Oh why? ... Depending on the order in which your units are loaded in the EXE file, the class gets registered on time, ... or not.

Solutions to this? Soooo simple. In Java and (until recently) in C# / .Net you do not rely on dynamic retrieval of classes. Your forms are created by actual code that gets compiled when you build your application. Yes, you heard correctly: static checking by the compiler; does not find all bugs; just avoids losing hours on silly things. Now of course the hype is to remove this life saver, and replace that by XAML. Unfortunately one day or another I will no longer have the choice, and I will have to use it :-(

Don't you ever learn? As you may know, there are two main classes of bugs. The ones that are due to a bad algorithm, locally; an array index that is off by one. And there are those bugs that are due to a bad state left by some code that triggers problems in another part of the program; a variable does not get initialized, or contains a string when it should contain an integer.

The latter are an order of magnitude harder to track down. Statefulness considered harmful...

Adding statfulness adds comfortable nesting places for the nastiest bugs. Having types being dynamically changed (eg by having type definitions be executable statements like in Python) adds statefulness where there was none previously.

Saturday, April 19, 2008

Python definitely beats them all

Whoa, I tried to write some Python code today (trying that nice Google App Engine, of course.)

Guess what... After three typed lines I managed to hit the first wall of laughability. My code does not compile (oh you may want to say "parse", I don't care) and that was because...

because some "unexpected indentation".

Indeed... there were blank lines at the end of the file, and those blank lines were actually not blank, but full of spaces. How do you distinguish an empty line from a line with only spaces? The funny thing is ... you don't :-)

The sad thing is that some people still believe that Python is a valid programming language :-(

Wednesday, March 26, 2008

Too much stress, lately :-)

I don't know how I did that, but I managed to write... this piece of code :


procedure TEditTestDefSimpleForm.ClearNotesGrid;
end;
NotesGridTableView.DataController.SelectAll;
NotesGridTableView.DataController.DeleteSelection;
begin



It does not compile ...