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 ...

Tuesday, November 6, 2007

More wasted time today

This week, I spent (read: wasted) a lot of time.

  1. Some database did not have a foreign key constraint, and a user removed some data that was referenced elsewhere.
  2. Some customer managed to call a function, passing an object that had just the appropriate method names, but was definitely not the appropriate object.
  3. I needed to map object properties to fields in a CSV file. By name.

Why? Again because the constraints are not at the right place. When you remove data from a database, some other place that relies on that data to be present will fail. It will fail much after the original cause. And that's where you lose all your time, trying to get back in time from the error message to the actual event.

Dynamic typing is like doing that all the time. You do not get an error message when you call a method with the inappropriate arguments. It may be some totally unrelated piece of code that fails.

Now, you might say, my database was not very well tested. That is true, it's entirely my fault that the integrity constraint was not there. Or was it? The constraint can be removed at any time, by anyone. I do not have a guarantee that my constraint is still there in production code. Welcome to dynamic programming!

Not for me, thank you.

Saturday, September 29, 2007

Silliest pro dynamic typing argument to date

According to this paper (see in particular section 2.3) race conditions in multithreaded programs occur because of static typing. Dynamically typed systems are a cure for this, of course :-)

Section 2.2, we learn that having your method either handle exception RMIException, or statically declare it in its throws clause, leads to an abstraction leak. Does he realize that RMIException derives from RuntimeException, and as such does not need to be listed in the throws clause?

This, and many other hilarious fallacies (mainly if you tell the compiler that class A implements interface B, then you should be allowed to code only the part of B that you care to implement kind of stuff) makes for a good laugh.

By Grabthar's hammer, do dynamic weenies have any clue what they are talking about?

Unfortunately, this nonsense seems to emanate from a guy having some position (janitor apparently) in a known university, and presented in the standard format for academic papers, and so will be touted by Rubyist as academic proof of soundness for their beloved concepts.