| Mauro's profileTaming the JunglePhotosBlogLists | Help |
Taming the JungleThe joys and perils on being in the bleeding edge of software development technology. |
|||||||||
|
April 29 Microsoft TechEd 2010 dates and locationMy friends at Microsoft told me the next years’s TechEd, Microsoft’s primary technical conference, will take place in New Orleans, from June 7th to 11th.
This year’s Tech will take place in Los Angeles on the week of May 11th. I will not be able to attend this year but I expect to visit New Orleans next year. April 17 Automatic checking numeric rangeI was recently involved in a discussion about the lack of “ranged ints” in the C# language. A ranged int is an integer type that would only accept a smaller subrange of all possible integers, say just 1 to 100. This is a discussion dear to me be because I sort of designed “ranged ints” for C++.
It all started because I used to develop with Turbo Pascal which *had* “ranged” integer types. You could turn on a compiler option that would automatically validate the range at runtime. I used it as a debugging aid, like an “automatic assert” every time the variable was assigned to. For instance, I would have a “row” variable that must hold values between 1 and 24, so I would declare it to be of a “row type”, a ranged integer of 1 to 24. During development and testing I would get an error if it got assigned something outside of that range. The final “non-checked” version would have this option turned off and have no performance penalties.
Then I had to switch to C++ and I missed my “ranged ints”. Since C++ templates allowed not only types but constants as arguments as well, I developed my own “ranged int” classes based on templates. At debug time they would check the range. I then flipped a compiler “define” and they would behave pretty much like a normal int, semantically and performance wise. This was not a popular C++ technique, but I used it left and right, despite that it made for slower compilations and at one point the Borland C++ compiler would choke with so much template usage.
I dusted off my C++ skills and wrote such an example as a console Win32 app below – this one is pretty simple (no copy constructor, no necessary operator overloading) and it will actually coerce the value to be within the range instead of issuing a warning, but you can get the idea. Of course, you could do the same with other numeric types such as float.
I couldn’t replicate the technique with C#. Maybe if it would accept constants as generics arguments, I could have my “ranged ints” back…
Here is the sample:
#include "stdafx.h"
#define DEBUG template <int V1, int V2> class RangeInt { private: int Value; #ifdef DEBUG // Checks range and force into the range if outside // An alternative would be to throw an exception or flag the error somehow void CheckRange() { if (Value < V1) { Value = V1; } if (Value > V2) { Value = V2; } } #endif public: RangeInt() { Value = V1; } RangeInt(int N) { Value = N; #ifdef DEBUG CheckRange(); #endif } operator int() { return Value; } }; int _tmain(int argc, _TCHAR* argv[])
{ RangeInt<1, 100> MyVal; MyVal = 0; printf("%d\n", MyVal); MyVal = 1000; printf("%d\n", MyVal); return 0; } April 16 Why I am not crazy about 64 bit desktop applications64-bit computing has been around for some years now and it didn’t get a lot of traction, despite the efforts from hardware and software suppliers. I know the reason: few people really need to run 64-bit software on their desktops; even on the server side the picture is not so rosy.
From a software developer point of view, if you are not managing more than 2 GB of memory in your program, it doesn't make sense to go to 64 bits. Some people would go further and say that a 64-bit address space is only worth if you have a *single variable* that holds more than 2 GB of data by itself. This is a far cry from the jump from 16 to 32 bits. In the Intel 16-bit world it was a huge pain if you wanted to have variables holding more than 64 kb each - which any stupid program did have back then; 32-bits cured that.
If you have less than 2 GB of data in your program, the same 64-bit code is way larger and thus slower (takes more time to load from memory) and the memory operations themselves are slower. I would dare to say that there are very, very few desktop programs around that would benefit from going to a 64-bit address space.
I’ve heard people say that if you have to manage a large, multi-gigabyte file, such as a video file, a DVD image or even a PST/OST Outlook file, you could use a large variable. Yes, you could but I am not sure that there would be a benefit loading the whole thing into memory at once, even if it were virtual memory.
On the server side, where a single application is actually serving hundreds or thousands of users, there are more reasons to go to 64 bits, especially in the case of infrastructure products that will be around for several years like a database server. March 31 The Cloud Manifesto and it’s dark originThere’s some buzz going on over the Web about the so called “Could Manifesto” (http://opencloudmanifesto.org/). It’s supposedly a technical manifesto asking for companies providing “could” hosting to be open, interoperable, nice and good-smelling. Their motto is “dedicated to the belief that the cloud should be open”.
At first one would think this is just the usual naïve, hippie, Richard Stallmanesque wishful thinking.
Yeaa, right. We have at least three companies (Microsoft, Google, Amazon) spending billions of dollars to set up cloud infrastructure, both hardware and software. Cloud hosting is a challenging environment, one for which the current software and hardware infrastructure is unable to meet for several technical reasons. That’s why those companies are investing on it.
Or, according to the Manifesto these companies are supposed to do one of the following:
Both are business suicides. Now it seems that IBM – a company notable for its lack of cloud offers – is behind the manifesto: http://news.cnet.com/8301-13505_3-10206927-16.html. Shame on you, IBM. March 25 The Wonderfull World of ScorecardsSuppose you are managed under a scorecard system: you have a numeric objective (i.e. numeric) criteria and you follow it, even knowing that might leave “something to be desired” or “it might not be the absolute best for the company”.
Let me give you an example: suppose you are an executive in the financial arm of a major insurance company. Your scorecard tells you that you get big cash bonuses if you sell “XYZ” financial instrument, say insurance against default on a AAA-rated package of crappy loans, a product you might have some mixed feelings about. Anyway you sell it left and right and cash in your bonuses. What else can you do? You are just a peon on the check board. Someone high up in the hierarchy must know better and have reasons to act this way. They do, BTW – and their reasons are similar to yours: High in the Sky there’s this Godly thing called “Wall Street” that scorecards the top executives of all public company every three months and commands their bonuses, jobs and lives.
Despite all the recent turmoil in the financial industry, the Gods are doing fine and didn’t lose their ways. Treasury Secretary Tim Geithner recently said: “AIG highlights broad failures of our financial system…Compensation practices encouraged risk-taking and rewarded short-term profits.”
Alan Greespan, of all people, didn’t know that the Gods were evil – or even existed. He found “a flaw in the model I perceived was the critical function in the structure that defines how the world works”… “I made a mistake in presuming that the self-interests of organizations, specifically banks and others, were such as that that they were best capable of protecting their own shareholders and their equity in the firms.”
Besides the “short term issue”, scorecards are an attempt to transform essentially subjective things in objective ones, but many times they end up like trying to fit a circle in a square hole. One can hope that even if the score cards were not precise, there would at least be a correlation between the points and what is best for the business.
Unfortunately that’s the way for an individual to survive in this environment. In March 2006 I wrote about this: http://maurosjungle.spaces.live.com/blog/cns!F3CEB0849B03B6CC!130.entry.
Obviously a good alternative is a system where the selfish interests of the executives are aligned with the selfish interest of the owners. Currently the owners of public US companies, such as a retirement fund, see a 20+ years horizon. The executives see a three months to one year horizon. One wonders why they sink the ship for a quick buck.
In places where you have a more “oligarchical” capitalism, where companies are owned by families or small groups you don’t see them doing this sort of blunders (well you see other blunders, but that’s another story).
Recently The Economist Magazine ran an article on how the Brazilian banks were spared from the recent financial massacre (http://www.economist.com/world/americas/displaystory.cfm?story_id=13331179). They attributed it to the high interest rates in Brazil, which made the banks “neglect” other “sources of profit”, as if they were fools. Ha ha ha. This is my explanation: all the major banks are tightly controlled and don’t give too much credit to what Wall Street says, so they didn’t join the “subprime gold rush”. They are no fools at all.
|
||||||||
|
|