| 個人檔案Taming the Jungle相片部落格清單 | 說明 |
|
10月23日 Restoring Visual Studio 2010 Beta 2 back to normal lifeSometimes Visual Studio 2010 Beta 2 starts behaving badly. For me, Intellisense disappeared, but some people report other issues such as lack of response of Team Explorer.
For those and other ailments, the solution is to reset the Visual studio environment by typing this at the command line:
devenv /resetsettings
Of course, you must navigate to VS 2010 installation folder, which in my case is
"C:\Program Files\Microsoft Visual Studio 10.0\Common7\IDE\"
You can find this and other related tips at this blog entry: http://blogs.microsoft.co.il/blogs/shair/archive/2008/09/03/reset-the-visual-studio-environment.aspx.
10月21日 Lots of news for Microsoft developersBesides the wide availability of Windows Seven, this week brought several news for Microsoft developers:
Windows 7 is here! Tonight at midnight (maybe I should say tomorrow, I don’t know) Microsoft starts selling retail copies of Windows Seven with events all over the world. Actually this is no big deal for me. I’ve been using pre-release versions Windows Seven since the end of last year and loving it. Even the final version is no big news; as a MSDN subscriber I have that for almost two months now. Windows Seven is what Windows Vista should have been. To be frank, I never liked Vista – you will not find a word I wrote praising it. I not alone in my dislike of Vista, check what Bill Gates said: http://gizmodo.com/342920/holy-crap-did-bill-gates-just-say-windows-sucks On the other hand, Windows Seven is simply great. Windows Seven installed quickly and flawlessly in all the computers I tested, both as clean installs and as upgrade from Vista. It’s fast, stable and uses fewer resources than Vista. UAC – those “security” dialog boxes that come from time to time are much rarer due to some now obvious optimizations so I now leave it turned on. For instance, UAC does not come up if called from the OS itself, like Control Panel applets. Everything that you can think of is better and faster. Details, something I consider very important in everything I uses are very well thought, which points to a mature and well tested product. As a matter of fact, Windows Seven Beta 2 was already way better than Vista. Aside from the upgrade price, I can’t see a reason why one shouldn’t get rid of Vista and start using Windows Seven now. Compared to XP, it does use a more resources, but nothing that any three year old computer could not handle. Thanks to Vista, a notorious resource hog, we have quite powerful computers now. If you are still using XP, I think it’s time to upgrade the technology. 10月20日 VS 2010 almost readyYesterday Microsoft released for its MSDN subscribers Visual Studio 2010 and. NET Framework 4.0 Beta 2.
Under Microsoft's liturgy, Beta 2 is a complete and usable product, but only with stability and performance issues. It also includes a "go-live" license. That means the software is supported and can be put into production under some restrictions.
Supposedly it coexists peacefully with Visual Studio 2008, which led me to install it on my real machine (not virtual) Windows Seven.
Among the many new features, I think the greatest thing is the excellent support for WPF and Silverlight. You can now develop within Visual Studio without the need for another tool such as Expression Blend. In fact, the interface of Visual Studio was entirely rewritten in WPF.
I installed, used it a little and liked it what I saw.
Other features include:
The final release was announced for March 22, 2010. The availability of the final version can occur just before or a bit after it, depending on the final stages of development.
9月14日 NET for iPhone (sort of)Novell has extended its Mono project (a .NET clone) to the iPhone platform.
I didn’t test it but it looks promising. I’d rather use C# and at least part of the .NET Framework than going back to C/C++ and have to learn a whole new programming model. Actually, the iPhone uses Objective C, which is not even quite C++. Also interesting is the note that the project is *not* Open Source, but a commercial venture. Check at http://monotouch.net/. 7月28日 Linus Tovald on Microsoft’s contribution to LinuxMicrosoft recently contributed some 20k lines of code to Linux, so it can work better under Microsoft’s virtualization technologies (http://www.microsoft.com/presspass/features/2009/Jul09/07-20LinuxQA.mspx). Not only that: the code is being released under a GPL license, something that Microsoft has been demonizing for years.
The move surprised not only the Microsoft camp but the Linux/Open Source camp as well (http://www.linux-watch.com/news/NS6567014545.html). Many in the Linux camp complained – of course - usually along the lines that the move was “selfish” or that it’s “too little”. This is one such comment: http://tech.blorge.com/Structure:%20/2009/07/21/how-microsoft-made-open-source-selfish/. Now no less a person than Linus Torvalds himself, the creator of Linux and its moral voice, said some interesting things in an interview to Linux magazine (http://www.linux-mag.com/cache/7439/1.html): “I’m a big believer in “technology over politics”. I don’t care who it comes from, as long as there are solid reasons for the code, and as long as we don’t have to worry about licensing etc issues. There are ‘extremists’ in the free software world, but that’s one major reason why I don’t call what I do ‘free software’ any more. I don’t want to be associated with the people for whom it’s about exclusion and hatred. I agree that it’s driven by selfish reasons, but that’s how all open source code gets written! We all “scratch our own itches”. It’s why I started Linux, it’s why I started git, and it’s why I am still involved. It’s the reason for everybody to end up in open source, to some degree.” So it seems that the “jihadists” at both sides are being put at bay and we will have an “ecosystem” where both proprietary and pen source software co-exists with less political colors. Maybe Bill Gates got this one wrong and IBM policy of “embracing and cashing in” was the right one all along. 7月17日 Why 32 bits instead of 64?To the astonishment of my friends, some very technically capable, I’ve voiced my opinion over and over that writing 64-bits applications has many disadvantages and few advantage and that currently few apps beyond database servers and the OS itself should be ported to 64 bits at all (http://maurosjungle.spaces.live.com/blog/cns!F3CEB0849B03B6CC!650.entry).
Now the development team of no less a product than Visual Studio itself voiced pretty much the same opinion. Here are some quotes: “First, from a performance perspective the pointers get larger, so data structures get larger, and the processor cache stays the same size. That basically results in a raw speed hit” “So, the only way you’re going to see serious benefits is if you have scenarios that simply will not fit into 4G at all. But, in Visual Studio anyway, when we don’t fit into 4G of memory I have never once found myself thinking “wow, System X needs more address space” I always think “wow, System X needs to go on a diet.” They also touch the all-important issue of using your limited resources on things that really deliver value to the users instead of joining a marketing hype. Kudos to the Visual Studio team. Read the full article at http://blogs.msdn.com/ricom/archive/2009/06/10/visual-studio-why-is-there-no-64-bit-version.aspx. 4月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. 4月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; } 4月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. 3月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. 3月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. 3月10日 The Scourge of Multi-Threading and its mitigationMulti-threading was promoted by IBM in the days of OS/2 2.0 as a way to differentiate it from the far more successful Windows 3.11. OS/2 had it; Windows only got it with Windows 95. Multi-threading was promoted as a way to never let the user looking at an hourglass cursor again.
Never mind that:
I do believe Mankind would have been better served had we took the coroutine path back then. But IBM marketing folks decided it was not to be. In fact the whole industry fell in love with this multi-threading thing.
Hopefully, very few programs *really* needed multi-threading. Things like web browsers, web servers, database servers and application servers did need (and used) it. Your average “Joe programmer” didn’t need to bother – and the few who did bother are to this day trying to figure out what hit them. So the damage was limited.
Forward to 2008. We now have CPUs with two, four and more cores and counting. If they are in a server, the cores are already being heavily used by the highly multi-threaded server software. However, if they sit in a workstation, chances are that the multiple cores are not really being used much. The reason is that most of the time workstations do nothing but wait for user input. When they do run some heavy load, like printing a large report, chances are this program was not developed with multiple cores in mind and run no faster that they would have run in a single core CPU. In order to take advantage of the multiple cores, some clever multi-threading programming is in order. Much clever than the average Joe programmer is capable of, unfortunately.
In order to address this problem, Microsoft is coming up with some new clever “parallel extensions” for .NET Framework 4.0. Those extensions include several ways to extract parallelism from the average program with minimum additional complexity. They also include better debugger support, parallel LINQ query and much more.
You can check this links to know more about parallel extensions in .NET 4.0: http://msdn.microsoft.com/en-us/magazine/cc817396.aspx, http://msdn.microsoft.com/en-us/magazine/cc163340.aspx.
Note that we are not talking about “multi-threading”, but “running parallel”. Although similar, the two things are not quite the same. 1月27日 Coding Standards & ToolsI’ve have always used very strict coding standards, similar to what Steve McConnell preaches at his classic book, “Code Complete”. The main problem with those standards is that they require some manual labor to continuously review the code, which makes them somewhat difficult and expensive to enforce with a large team. Not that I don’t think you shouldn’t enforce them – I’ve always did it in the projects that I managed directly. But as a consultant it is always a hard sell, for the need of continued reviewing. I’ve applauded Microsoft when they added “Code Analysis Tools” (a.k.a. FxCop) to Visual Studio 2005. Those tools would automatically verify several good coding practices. That was certainly a step in the right direction, but it didn’t check several things I deem important such as the complexity of the code inside methods, to name just one. Anyway, Microsoft is definitely moving in the right direction along this path. With Visual Studio 2008 they brought in more options in the “Code Analysis Tool”, one of my favorites being checking for try/catch statements that don’t specify the type of the exception being caught. In Visual Studio 2010, Microsoft also included a tool that allows you to see dependencies in your code (“what calls what”), as I blogged about before (http://maurosjungle.spaces.live.com/blog/cns!F3CEB0849B03B6CC!539.entry). Despite all that, I always felt that something was missing and still toyed with the idea of writing a tool myself (as if I had the time…). Not anymore. Last week I found out a tool that is really a dream come true: NDepend (http://www.ndepend.com/). First, it has a comprehensive and visual set of tools that allows you to see “what calls what”. Then it spits out a very detailed report, along the same “party line” that I myself always preached and then some. But the best part is that, after analyzing your code, it sets up a database and implements a SQL-like query language that really allows you to do your own queries, in case their own are not good enough! (well, they never are – everybody has his/her own quirks). For instance, this query checks if the size of the instance is too big: WARN IF Count > 0 IN SELECT TOP 10 TYPES WHERE SizeOfInst > 64 ORDER BY SizeOfInst DESC Last but not the least: it’s a small (7MB) download, it occupies 17MB after unpacked and it doesn’t need to be installed, which in my opinion speaks volumes about its own quality. They could have written an .msi installer but it seems that they didn’t on purpose to send a silent message to their audience. You see, it’s like a Ferrari, it does not come with an automatic transmission. If you really want an automatic transmission, well, then you don’t belong. Go buy a Mustang. It’s an amazing tool, I just scratched the surface. BTW, some features like the query engine are only available in the “Pro” version, the free demo doesn’t have them. 1月12日 Windows 7 First impressionsI’ve been using the Windows 7 build 7000 public beta for a few days and I am quite happy so far. It recognized *all* the hardware in my Satellite A205-S5825, a 1-year old computer, including things like the touchpad that gave trouble to both Vista and Windows 2008.
Although the computer runs x64, I installed the 32-bit version so as to compare it better with the other 32-bit OSs I run in the same machine. I replaced the copy of Vista I had there and left Windows 2008 Enterprise Server.
After the installation the OS selection menu didn’t show up any longer so I could not boot Windows 2008. I then run VistabootPro, a utility I used to recover from a similar situation after I wanted to make Vista coexist with XP. Not only it didn’t work, it made all OSes disappear, including the fresh copy of Windows 7. I then booted from the Windows 7 DVD and selected the “recover” option. It did find both OSes and set up a boot menu with both options.
Windows 7 seems to be everything Microsoft promised with Vista but failed to deliver: it boots fast, uses much less resources than Vista, UAC is much less intrusive so I can live with it turned on. The OS seems to be more responsive, for instance I no longer see a long leg after I open Windows Explorer. Although it’s a beta, it already looks better than the first retail version of Vista. It looks like Microsoft got it right this time. 1月8日 Windows 7 beta availableMicrosoft released yesterday to its beta testers (at http://connect.microsoft.com) a new version of Windows 7. I am already downloading the multi-gigabyte package.
This is a much-anticipated version because of a recently non-official leaked version that got good “reviews” on the Web, “unofficial” and official such as this one at CNET: http://news.cnet.com/8301-1001_3-10134184-92.html. 12月18日 At Last a (very) good Cross-Reference tool for .NETOk, I am old. I started programming professionally with Applesoft BASIC on Apple II in the early 1980s. At that time there were many “cross-reference tools” that would go through your code and find what function each function called – a “call graph” and display it as a list of function and the ones it called.
Software was small but even then the cross-reference tools (there were many!) were useful in order to see the impact of changes, help reorganize the code (we call it “refactor” nowadays), find bugs and so on.
Now I am managing a large health care application that was developed along the years by people that professional courtesy forces me to call “not very careful”. As it is now, there are very few DLLs (including a huge one) and it seems that each method calls every other one, without any layering and any order.
I desperately need to break down the code in sensible layers so I can recode parts of it and plug in new functionality with ease. I desperately need a modern version of my old Applesoft “cross-reference” tools. Of course, a modern version would know about assemblies, classes and would display the “call graph” graphically. I spent many hours on the Web and didn’t quite find anything satisfactory. The closest I got was something called “Total “.NET XRef”, but it didn’t work with .NET 2.0 and it lacked a graphical output. I even entertained the idea of writing such a tool myself – after all, AFAIK the information is all there on the assemblies and can be pulled in by reflection.
Now my prayers were answered: Microsoft came up with such a tool for Visual Studio 2010. It is no longer called “cross reference”, it is called the “Architecture Explorer” - marketing people in action, you see.
Anyway, this "Architecture Eplorer" is reason enough to upgrade to VS 2010 when it is available. Actually, I it’s reason enough to download the 8 GB CTP, put up with the slow speed of the Virtual Machine and keep using it till the cows come home – or Microsoft launches the final version.
Take a look below at XPS file it generated. Inside VS 2010 you can drill down at each module, see classes and methods. This thing is simply Glorious. Hail to the people at Microsoft that came up with this.
10月13日 Silverlight 2 is hereMicrosoft announced today that its new browser client platform, named Silverlight, will be available for download tomorrow, Oct 14th at http://www.microsoft.com/silverlight/.
Silverlight is a kind of “.NET Light” that runs under many Internet browser (IE, Firefox, Safari) and operating systems (Windows, MacOS and Linux). It is very attractive to Microsoft shops because it uses the same languages, class library and development environment as the “full .NET”.
Silverlight is a direct competitor to Adobe Flash. Compared with Flash, Silverlight has a much more robust and feature rich development environment. The one thing that Silverlight lacks when compared to Flash is 3-D graphics, but that can be included by the applications themselves. Also, Microsoft can extend Silverlight at will in the future and include support to different APIs, I believe it’s just a question of getting customer feedback.
I hope .NET finally delivers the promise of “Smart Client” applications made by Bill Gates during PDC 2001 but never quite delivered by .NET 1.X or even ClickOnce. Smart Client applications are meant to deliver the ease of deployment of browser applications with the rich user experience of Windows apps.
Compared with ClickOnce, Silverlight has some clear advantages:
It’s not as powerful as the full blown .NET Framework but I expect it to have the right balance of power and simplicity. Given that it was developed under the leadership of Scott Guthrie, of ASP.NET fame, I have a very good feeling. 9月24日 Windows will be shown for the first time during the PDCMicrosoft will for the first time publicly the next version of its flagship operating System, Windows 7, during the Professional Developer’s Conference to take place in Los Angeles during the last week of October.
See more at http://www.microsoftpdc.com. 9月23日 Preparing for PDC 2008PDC (Professional Developer’s Conference) is the premier Microsoft’s event for developers. The exciting thing about PDC is that, contrary to TechEd, it does not happen every year. It only happens when Microsoft “has something new to say”. Because of that, its contents are somewhat foggy; the real news is “saved” for the event itself.
In no PDC was this most striking than PDC 2000 in Orlando. In the agenda you could see that there were only “general sessions” and absolutely no abstracts were published beforehand. Even then Microsoft managed to attract about four thousand curious developers to see what used to be called the “New Generation Windows Services”, now known as “.NET”. You can check at http://www.microsoftpdc.com/.
This year there are abstracts published, but the main focus – as far as I can tell – will be “Extending the Platform to the Cloud”. From a developer point of view it seems it’s a new set of APIs to stuff over the Internet in deeper ways that it’s now easily possible. There’s video about the strategy at http://channel9.msdn.com/posts/Dan/Countdown-to-PDC-2008-This-is-the-Software--Services-PDC-Plus-a-Hard-Drive-Chock-Full-oBits-is-a-PDC/.
And BTW, I just got the wind that there will be so many things delivered that they will give away a 160GB USB hard disk to each participant with the contents in!
I will be there. |
|
|