Not a typical post on this blog, but I think you may all enjoy this one
. Last week I went to a small town that had their annual flower festival. (Well it aint named that way, but loosely translated).
What they do every year is create huge cars, I call them cars but they are pushed by people, in a specific theme. This year the theme was the world cultures. These cars are then completely covered with flowers and pushed around the town for everybody to see. (Starts to sound a little like crazy people, but trust me it’s fun)
Every year the various neighborhoods enter in this competition to try and win first place. This year that meant thirteen cars took part. It’s a huge party, lots of cafeteria open and dozens of market stands.
The only downside I found this year was that it was way to crowded. Guess that’s a good thing for the organizers of the festival.
The only way to get the feel is to visit I guess, even so I’ll include some pictures to give you a general feeling of what it’s like.
Pictures of the various cars
First of this post is not going to tell you not to use PHP, on the contrary I like using it! But what I will try to get across is the fact that PHP still has a long way to go before I will consider it a powerful web development tool.
Time to get started. Let me first start with explaining why I think you should use PHP, even though it is far from perfect.
With all of these plus points why do I still find PHP to be in its infancy. Ok I guess it’s time to tell you why I don’t really like programming in PHP. To get my point across even better I think it’s best to make a similar list as the one above.
Like I stated before I don’t hate PHP, in fact I use it quite often for web development. But I find it difficult to call it anything but a scripting language at this time. Maybe with version 6 it will become a ‘real’ programming language. Until that time I favour Java with JSP above PHP.
If you keep track of this blog somewhat you may have read ‘Netbeans and its quirks‘ I ranted about problems I faced while developing in netbeans. Since I found out the reasons for some of the problems I thought it would be nice to keep you all informed.
My first problem was with an out of memory exception I kept getting when working a full day on websites. After a lot of research and some luck I found out this is related to the way Tomcat deploys web applications. Phew that was a mouth full. To keep a long story short when you run your web project Tomcat redeploys the application in its ‘virtual’ environment. Thank god! I’d hate to do this manually every time.
But the problem with this is that Tomcat or Java doesn’t release singleton classes that are in the web application, that’s my conclusion anyway. Which means that over time the JRE runs out of memory to work with. Especially with the applications I designed, which used singletons to store tons of information for fast data retrieval. You can prevent this somewhat by stopping and starting Tomcat manually in Netbeans.
Oh and as soon as you have the out of memory exception the only way to get Netbeans and Tomcat to work again is killing all java processes. Don’t know exactly why, but just stopping and starting Tomcat doesn’t seem to work once you have the problem?
The second problem I faced was that Netbeans sometimes stops repainting its interface. Well I can add another problem that is related, the auto-complete is annoyingly slow sometimes. Turns out this has to do with my laptop having a speed step CPU. If Netbeans doesn’t get enough CPU power it refuses to work. Maybe the developers found this acceptable, but I’ve seen desktops with a 3Ghz CPU were the Netbeans started flickering during the repaint.
So do I think you should avoid Netbeans for these problems. No I don’t think so. Yeah it’s annoying when Netbeans starts slowing down (a lot sometimes, but then again I develop 8hrs without restart). But it’s got so many features to like. Top of the list is the fact that it’s free! So head over to Netbeans.org and try it out.
I’ve started to continue some C++ programming, well actually tried to continue (but more about that later on). Earlier this year I made the decision to switch from Visual Studio 2003 to 2005. This should have been the right choice as it makes significant improvements in debugging and code editing.
And I must admit on the surface it looks perfect, and during editing I find little problems in creating code. But I am using Visual Assist to improve my programming speed. When I started debugging the hate started. My first attempt resolved in Visual Studio disappearing from the screen and the memory! I couldn’t figure out what happened. The entire Visual Studio shut down, without notice or warning. All I did was hover over a variable to see the value.
Hoping that was the only problem I continued to debug, only finding more problems. And not even in my own code, well not all of them. Some times the debugger just stopped working and the application I was debugging was terminated.
The only good thing in debugging with Visual Studio was when I finally completed my debugging session. No I don’t hate Microsoft, but could they at least release a software package that works!
No I admit I haven’t updated my system in ages, so I checked to see if there were any updates for Visual Studio. Big surprise, there weren’t any! I really hope that I don’t need to do a lot of debugging work in Visual Studio 2005. It’s gonna make me go crazy.
Ever wondered why your static variable could have a different value assigned to it. If you are a developer in C++ and have ever used static member variables then you have run into this problem.
Well I ran into this problem quite some times. I had a static variable, which must be both declared and defined. So I did both in the header file, I know this is not a good practice but the class did not have a source file. This class was used in a lot of different source files.
I noticed a strange behaviour. Expecting the contents of the variable to be the same, it was a logging singleton, I got repeated errors that the file being written to was not open. Which made no sense to me as I did open the file and it appeared to work properly. And the log did contain the info I wrote during initialization.
So I put a favorite break point in every function using the singleton. Then came my surprise to see that the value of the pointer to the class, my static member variable, kept changing. I mean a static variable is supposed to mean that only one value can exist at one time.
On with some more debugging, this time a break point on the memory address of the static variable. Unfortunately that is the only way to figure out if it is being changed runtime. As expected I only hit it during initialization and the pointer never changed afterwards.
More mystery, how can something that does not appear to change still be different! I hadn’t got a clue as to what was going on. So I left this for a few weeks figuring a new day would somehow bring me new ideas.
And it somehow did. I was talking with another C++ developer some time later about this issue. He also had the same problem with singleton classes, specifically in templates. After a lot of debugging he found out that the pre-compiler literally copies all data from the headers a source file includes into that source file.
So if my gathering.cpp included the log.h then the declaration of the static variable would also be copied. Which means every single source file had a different declaration for the static singleton. This left my logging completely useless as every source file would have a different instance, not really the point of a singleton class!
Fixing the problem was a lot easier though. Just add a source file for the logging class with the declaration of the static variable. And after some thorough testing and debugging it worked. No more mysterious changing singletons for me!