Ping
Monday, May 12th, 2008Yes I’m still here.
As I wrote last time my new laptop arrived, I still think it’s a great laptop but not as great as it would explain blogging inactivity for more than a month.
Many thing happened in the meantime, firefox is becoming emacs so emacs should better get the next firefox first, jeff the obvious has something new going on, subversion is considered a dead patient (at least where I hang around when I’m online).
Of course not everybody shares my observations. I heard others are more worried about missing potatoes for the next month than JVM’s balls of steal. Ah yeah, there was also a guy who asked me why I use emacs as its not installed anywhere. He got used writing in vi and it’s on all boxes and wherever he sshs into he finds a familiar environment. Heh, I demonstrated tramp and laughed is his face.
However, that doesn’t explain what I’ve been doing.
Well… I’ve been busy. Not just busy as usual, really busy. I guess the underlying problem is my new strategy how tasks should be handled. You know, I adopted the maybe greatest philosophy ever and converted myself into a lazy evaluation person.
That means, I’m doing nothing for a long time until something should be actually delivered and then, and just then I start focusing on the tasks.
The huge advantage is that you just spend time doing what is really necessary and have more time for other things.
The downside however is the work-explosion you cannot predict before no matter how hard you try. Nobody can. Thus when you finally started you just pray you don’t run out of resources.
One thing I was doing was dealing with was the .NET XmlSerializer.
And I tell you, that’s a piece of crap. Normal people like you and me tend to introduce interfaces, abstract base classes and many other things to keep things somehow modular so they can be kept in the context in our heads.
But exactly those abstractions cannot be serialized. As soon as the serializer discovers that the type of your property is an interface it will throw an exception back to you and tells you to change your design because it’s too complicated to serialize.
One way to solve the serialization problems is to duplicate all problem-properties and map them all to object properties but that’s exactly what you wanted to avoid in the first place.
The second approach is to tag the base class (if there is any) with XmlInclude tags for all existing inherited classes. But as you normally don’t have the control over your base class or just can’t update it whenever you add new extended implementation you cannot make use of it anyway.
The third approach is to use the IXmlSerializable interface. By implementing it, you can override the way how your class is converted into an Xml document and deal with interfaces and base classes on your own. Wohooo!
However, after five classes I noticed that it is a pretty tedious job to implement the same similar logic all over the place. So I implemented a somehow generic solution which scans with reflection over the properties of a type and if it finds something with an interface or inherited class it stores further type hints as attributes so it can convert it back later.
Of course I chose the latest option and in my base classes I can now write
public class Car { IEnginge Engine{get;set;} IList<IFoo> Foo{ get;} BaseDescriptor Desc{ get{ return new ExtendendDescriptor()} } WriteXml( XmlWriter writer ) { Serializer.WriteXml( this, writer ); } ReadXml( XmlReader reader ) { Serializer.ReadXml( this, reader ); } }
And all kinds of interfaces, generics, lists and dictionaries can be serialized with the implementation in Serializer. Mishto!
Though it’s not a very elegant solution neither those 2xml conversions. Actually I still don’t get the hype around that text format. Obviously it’s great (and even the first time) that your application achieves standard compliance and interoperability by just choosing the right library and not everybody is busy implementing their own buggy text parser but still… for logical representations it’s not the right thing in my opinion. The only really cool thing I found are XPath queries but that’s already it.
However, the main part of the time I spent with all my vapor projects and I somehow doubt that any of them will be finished until summer. Obviously that’s very normal with vapor projects just I made the mistake to actually talk about them and mentioned release dates.
But seriously guys, you actually think I have time for that? I mean, do I look like?
And it is not just the actual coding itself, using immature languages will bring you enough trouble anyway and when you don’t have time to fix the main libraries of that language, don’t want to monkey patch everything or don’t have the time to write new bindings every second hour then you just have yet another unfinished project in your repository.
Yes obviously I should have used something more proven but limitations get just discovered above a certain project-size anyway. When the developed program suddenly gets incredible slow or shows (at least in the eyes of the naive programmers like I am) strange behavior. Though at least you start getting a feeling which things might be problematic when faced with a new language and may explore their limits right in the beginning and don’t run into huge problems because of some half-baked implementations you are depending on at a later stage.
Ah where was I… right, problems with static languages. Did you notice that everybody started to ditch their old fat static language and went over to the dynamic camp? Oh and I’m not just talking about far away from here somewhere in the interwebs. It seems to be happening right down the street at the next corner. Who knows where this will lead us to?
It ends up into a maintenance hell with many different languages and their incompatible flavors as a result of constant forking and a too dynamic development path? Where it’s faster to rewrite the program for every new feature and where the non technical java-is-great managers won and don’t want to hear about the introduction of yet another language and framework?
Or we get a truly great environment with easy interoperability and robustness which attracts even more dynamic kids to jump in.
Today’s situation with the current languages seem do match the first option more thus the ongoing adoption of dynamic idea let us hope for a shift to the second one in near future. As soon as it would get widely accepted there would be yet another division in our industry. It will be way harder to hide missing knowledge or unwillingness to contribute behind strategyBridgeAdapter patterns or endless abstractions over abstractions. What the blubs will do is another question but there will be enough things left to do anyway.
Moreover, there would be finally a supporting type system which wouldn’t just put obstacles in our ways.
Time will show. Anyway, I wish our application would have been written in a dynamic language like lisp. Instead of converting some parts of the program into an xml file and then parse it back, the saved data could be lisp code on its own which could be loaded straight into the application without tedious parsing.
What a great world that would be.

If you attended the classes, you know about those problems in the first place and can code around those critical parts with appropriate methods. But if you have no idea about scheduling, threading, memory management, I/O stuff and security, to just name a few, there will be certainly a moment where the program is unexplainable slow or runs into strange
Thats when your computer science knowledge from some dark place deep in your head comes into. Because after the operating system course you can pass by the limitations of your framework and operating system, because you know what you are actually doing and what you cause deep down in your framework or operating system. Otherwise you don’t even have the slightest chance to fix, not even to detect those kind of problems. This ability differs you also from the outsource-endangered species “code monkey”.
That’s okay with me. These days you should consider yourself lucky when they even find time to talk to you. However, will I hang around there for I don’t know how many hours? God no, of course not! I can do plenty of other things than sitting in the garage: Go shopping, have dinner, work a few hours, meet somebody, etc.
On Windows for example there are the overlapped I/O operations. You pass a special structure which contains an event while calling your long during operation. If the system decides it should not execute it synchronously, the method returns immediately and you are free doing other things while your request gets executed by the operating system. After running out of stuff you could compute and prepare, you actively wait for your first call to end and will be woken up when the system completed your request and presents you the results from the first call.
Not really hard, isn’t it? Just I almost never see it in other’s code. They prefer letting their software wait instead of doing something more useful. Nobody would ever wait for hours in a garage because its obvious to anybody how inefficient that would be. In our software world though, it is not considered that silly anymore. Most of the I/O operations I saw in projects were done synchronously. As if our software was fast and we would have enough time anyway.

However, it did not ship with Vista and I don’t know what happened to it. I guess it’s imploded under it’s own weight. Maybe it was too slow, to buggy or whatever.
The only guy who is not so happy about that and responds with mailbox size limits is the one who has to maintain all those things. He has to do that because all mails get stored in a gigantic file and when that file exceeds the 16GB storage limit he has a problem. (If he wants more he needs an expensive update, has to hack the registry etc.) Why not providing a unix like mail spool with a single file for every user? Another example of how you create problem by storing everything in the same place.
His next reply was “Ey, look mate: You can press here and here, and then magically everything gets reordered. It’s so fancy!”.
We all like it, don’t we? Those bloated and fat enterprise programming environments with their sweet features they provide. You don’t have to think about algorithms anymore because “I can debug them later anyway” and you don’t think about performance issues because “My performance tool will highlight the bad statements”. Soon you don’t even think about design anymore because “I can update my software architecture in that other UML tool”
me”. Anyway, you could do it: Your imaginary friends were waiting to help you with all your coding issues, weren’t they?
Basically, you can divide the different ways in which you structure your code into four paradigm. That is Procedural, Functional, Logical and Object Oriented. There also others (e.g. Aspect Oriented) but I will ignore them for today.
All those problems occurred because a common resource was accessed incorrectly. As soon as you start using those shared resources (that does not have to be the all-time-evil singleton, also class attributes may bring you into troubles) you need think about how you initialize them and in which order. Which values may be null? Where do I verify all my data? What happens on concurrent calls, do they mess everything up? What will happen when I throw an exception, do I reinitialize properly?
It does not depend on that other method DoEvil() which sets the class attribute google you use to a state you never thought of before, it’s more like math: The Square root of four will return two also when you calculated exp(4) thousand times before. Those functions do not share data between each other thus wont affect each other. Because everything runs at it’s own, the compiler has also the possibility to optimize and split your program over several threads and CPUs automatically. Of course, no shared data means no need for synchronization mechanism which will let the program run truly faster because no synchronization information have to be passed between the CPUs.