The Linux Bloke

Who's the Biggest Geek on the Internet?

Browsing Posts in Bugs

I run a number of web sites with WordPress, and have recently upgraded many of them to WordPress 3.0.1. It seems that every time I have to upgrade WordPress that some of the many and varied plugins are simply broken.

Why is this? I mean, in this day and age of well-defined APIs, OOP, proper object factorization, unit testing, and the like, you’d think this would rarely happen, right?

But, alas, the real problem is that most WordPress plugins are simply horribly written. Period. Way too much dependence on global variables, no use of PHP’s OOP capabilities (even though WordPress definitely supports OOP), and just poor code organization all around.

So, whenever WordPress changes something, lots of plugins simply fail to work properly. It’s so prevalent it drives me mad.

Proper software design principles applies whether you are programming in C++, Ruby, Perl, Java, or PHP. We have those design principles in place for a reason. Popular applications are never static, and should never be expected to be either. That’s why we do certain things in a certain way, folks!

Of all the languages I know, I consider PHP to be the absolute worst, basically the Basic of the 21st century. Because just like Basic, PHP allows to get away with many ills. It allows you to write very sloppy code very quickly, and actually get it to work “good enough” to throw into production!!!!

But when you are talking frameworks and plugins, there is no room for being sloppy. When you are talking millions of users that must rely on your plugins, there are simply no place for taking shortcuts. You do the job right, or not at all. You adhere to the well-established, sound design principles that we have worked out over the past 30 years or so, or you go back to “school” to get a clue.

But I really fault PHP for allowing such evils in the first place. Ruby and Python strongly encourages you to do the right thing when you write code. Ruby on Rails is sweet in this regard.

In my experience (and I have 30 years of it!), it takes just as long to write good code as it does to write bad code. With bad code, you spend much more time debugging it, and “fixing” the bugs probably entails writing more sloppy code to work around the existing sloppiness. So time wise, you’re a penny wise, pound foolish.

And then comes maintainability. With poorly written code, forget it. The time it takes to maintain it blossoms exponentially over time as the underpinnings shift and evolve over time. With Open Source development, what usually happens over time is one of the following:

  1. The code is abandoned and everyone stops using it.
  2. The code is re-written from the ground up (and using proper design principles finally!!!!)
  3. The code has become critical to many applications, but no one truly wants to maintain it because it’s so horrible, so it “limps along” with the barest minimum effort applied just to keep it — somewhat — running.

All of which could’ve been avoided if the code was written properly up front. That would free developers to work on more cool stuff, giving us even more functionality, and also allow the underlying frameworks to also grow and expand without worry of breaking all the plugins and themes out there.

So get a clue you bad PHP code slingers out there! It’s not hard at all writing good code, and is actually quite enjoyable. Spend less time playing video games and more time to educate yourself. It’ll look good on your resume and improve your bottom line. And make those who use your code happier. Why? Because your code won’t call attention to itself by not working, and your name is far less likely to become an expletive.

It’s up to you. Only You can write Good Code. If not you, then who else?

Our Universe is full of ironies. But some ironies are just too hard to take.

As you may have guessed (!!!), I am an avid Linux developer and user. Though once upon a time I did develop under Windows. Yes, believe it. And on one particular case, I got to be on a first-name basis with some of the Microsoft Software Engineers to resolve issues we were having with their OLE crap — what the Holy Gods of Microsoft decided to redub as “Active-X”.

But I digress. For the past 10 years, I have been solid Linux and have defenestrated Windows for the most part. But as you know, you can never really completely eliminate Windows.  Despite your best efforts, it will always be (for now, at least) the 500 pound gorilla in any room you care to be in. The installed software base there is just staggering, and most have no Linux options.

But then that’s why projects like Wine and the many wonderful hypervisors were created. It turns out we can just about have our cookie and eat it too — almost. There are many games written for Windows that won’t do on anything but native Windows with the latest nVidia graphics card and a 7.1 surround sound system!

I’ve been working with financial software as of late, as well as some old favorite games of mine like Diablo II. My main workstation is an Intel Quad core — pretty standard these days. But my particular system is already “obsolete” as it can only handle a max of 4GB or ram — barely enough when you are running virtual machines. I do plan to upgrade my motherboard to the latest and greatest soon, and slap 16GB of ram on there — and maybe AMD’s new 6- and 8-core CPUs coming soon to a geek dealer near you.

Yes, I love Diablo II. And it works almost flawlessly under Wine on my Ubuntu setup. Some quirks that you will only notice if you have multiple monitors like I do, but I can live with that. It runs fast and furious.

But due to my machines RAM limitations, the financial software I run sometimes wants more RAM than I can devote to it via the virtual machine, so I’ve had to install Windows natively in a multi-boot setup.

Well, getting that done is a story in and of itself. For some unknown reason, Windows 7 (and Windows Vista back when I tried it) runs unbearably slow on my particular hardware, and the installation of Windows 7 took over 24 hours!!!! And it still doesn’t work!

But installing Windows 7 on a virtual machine, such as the Sun VirtualBox, running on Linux, went without a hitch, and took less than half an hour!!! Same hardware. And runs fine!!!!

But I did managed to get Windows XP x64 installed on my machine natively. It, at least, can make use of the quad-core chip and use all of the 4GB of RAM on my system. SP2 is essential with XP 64, as my sound card would not work at all with SP1.

And so I can run my financial software under Windows either natively or in a virtual machine. And Diablo II.

But to my great surprise, both performs BETTER under Linux than Windows!!! Let me explain.

The financial software I am using is eSignal. I have written a number of EFS scripts for it — and their EFS language is simply JavaScript, which is nice — and so does a lot of heavy-duty realtime calculations on the incoming market data stream. I need SPEED, and one would expect better performance if it’s running on a native OS than one running on a virtual machine, right?

Nope!!!! It actually runs better on the virtual machine! I have XP 64 with Service Pack 2 — same image — running in both modes, and it’s simply a bit more responsive overall on Linux!!!

I am totally puzzled by this, but wait! There’s more!

Recall Diablo II? I figured it would run a bit better under native Windows than it does on Wine under Linux. It would be in its happy environment, and so the few annoying quirks I see under Wine would disappear, right?

Well, the quirks disappeared, as expected. It dosen’t go nuts when my mouse happens to move over to the other monitor (it locks the mouse cursor to its screen as it should), and some of the hot-keys issues goes away.

But, it drags. Yep. On native XP 64, Diablo II is very sluggish, and can’t even do some of the video options that it has no problems with under Wine! Is that insane or what?

In fact, Windows XP 64 itself running natively seems to steadily reduce in performance if it’s been running for a while, and the audio gets really funky. Rebooting is essential.  This is less of a problem running on a hypervisor. Why is unknown.

I have tried to research some of these issues with Windows’ lack of performance on Google, but all I find are others also having the same problems but no clue as to why.

I even tried calling Microsoft MSDN Support about this, but they were less than helpful. They kept harping that I should disable or disconnect any device attached to my system that Windows isn’t using.

If I have to do that, I may as well build a new PC and only install Windows on it. But since I primarily develop under Linux, that would be less than ideal for me.

And just what’s the deal with having to disconnect devices that Windows isn’t using? Why would leaving them connected kill performance to unbearable levels? Linux doesn’t have a problem with this at all. It just ignores unknown devices! Well, duh. This is primarily a problem with Windows Vista and Windows 7. Windows XP does the right thing — ignores what it doesn’t understand as well.

And I utterly and flatly refuse to open up my chassis and yank the cables on half the hard drives just to be able to boot and use Windows 7.

You know, the differences between Linux and Windows is like the differences between Atheists and Bible Thumpers. The first (including Yours Truly) are basically very open and tolerant of other beliefs, and typically don’t go about slamming others for having a difference of opinion. The latter is rather hostile to other beliefs, really hostile to the former, and typically spew forth the “my way or Hell” attitudes.

And so you have:

Open Source :: Closed Source

Open Minded :: Closed Minded

Atheists :: Bible Thumpers

Linux :: Windows

There are other parallels too, but I’ll leave that as a fun exercise for you! Feel free, of course, to post them here!

If you are one of the few unfortunate blokes that’s pulling your hair out over random File Menu popups on OpenOffice — Word or Spreadsheet — and have been hitting your head against a brick wall trying to find the solution, I hear you.

I intially thought there was some interaction with Skype, but now I have to retract that statement. In all honesty, I have no clue what the problem is.

But I decided to just watch the “random” File Menu problem and time it. And now I am more confused than ever.

On my computer running 64-bit Ubuntu 9.10 (Karmic), I noticed that the File Menu toggles twice a second when OpenOffice has the focus. One toggle event happens precisely on the 11th second; the other toggle event happens around 35th to the 45th second. The second toggle seems to be related to when I launch OpenOffice; the first is always precisely on the 11th second.

And this is something peculiar to OpenOffice; I have not observed this problem with any other program.

And the problem did go away for a while, but came back. I have no explanation for that, either.

But the precise timing of this bug may have something to do with an internal timer within OpenOffice, but I am just guessing at this point. I strongly suspect at this point it’s completely an OpenOffice problem, i.e. no interaction with anything else.

This weirdness was observed on Ubuntu 9.10 (Karmic Koala) 64-bit, OpenOffice 3.1.1. Please drop a line here if you observe this bizarre behavior. Give your timings if you can; may lend more insight as to the nature of this problem.