Archive

Archive for the ‘Programming’ Category

The simplicity of not having choices

April 26th, 2007
Comments Off

If there’s one thing I’ve learned over the years, is that people are lazy and good at rationalizing. Why exercise, if a single chocolate will make you fat again? Why oppose a corrupt government, if they’ll just be replaced by someone worse? Why learn something new, if it’ll be obsolete in six months?

On yet another example, James Turner has written an article on O’Reilly’s OnLamp.com titled The Virtues of Monoculture, in which he promotes the beauty of having choices absolutely taken out of your hands.

I spent last week learning in order C#, .NET and VSTO (that’s Visual Studio Toolkit for Office, if you’re not familiar with Microsoft’s alphabet soup.)

[...]

Should I use iBatis or Hibernate? XFire or AXIS? Perl, PHP or Ruby? Debian, Fedora, Ubuntu or Suse? Make the wrong decision, and you can waste a ton of time, as we found out on a recent project when we wasted a week try to make AXIS2 work for a web service project, only to find out that XFire was the right choice.

For the Microsoft Guy, no such confusion. You use ADO.NET, ASP.NET, C# and Windows. They all work, they’re all well documented from the perspective of a developer’s needs, with nary a disparaging ‘go look at the source’ blow-off.

[...]

Microsoft offers the certainty of no choices.

Before I’m singled out as some kind of anti-Microsoft freak, let me say this: I’ve worked for five years on the Microsoft .Net platform, and it’s not until recently that I’ve started dedicating an equal amount of time to open source alternatives. I think C# is a better language than Java, and that the single advantage Java has is the significantly large number of available libraries (an advantage it’s losing daily). I have a lot of respect for the work Anders Hejlsberg did on C#, and how he took the best features of both Delphi and Java and melded them into a coherent language. I’ve spent quite a few days recently figuring out the way OS X is still Unix underneath, but behaves slightly but annoyingly differently when debugging php pages or getting Redland to build.

But the fact remains: Turner’s argument is absolute bull.

Mr. Turner makes his everything works because there are no choices leap of logic on a whole week of learning a large set of technologies. How much depth could he have achieved in that time? Not a lot, I’m sure, having been there myself. Otherwise he would have learned what any experienced programmer already knows: most things don’t just work, and the .Net platform is no exception. When you’re coding at the Hello World level, every platform works beautifully – and if it doesn’t, flee immediately for the hills. The lack of choice saves you only some Googling time, and once you’re married to the platform you’ll start uncovering some of its ugly bugs (like we learned on a very large project).

The Microsoft Way does have an advantage, but it doesn’t come by means of platform tyranny: it’s the fact that it has a group dedicated to supporting developers. Most Open Source projects can’t afford to have a full support team, so you’re left with only the community – and left on their own, people sometimes act like complete asses. If anything, what the Open Source community needs to learn is that it’s not enough that your way might be better, or smarter, or faster. If you want people to adopt your software you have to support them. Pure and simple.

His conclusion is that Open Source needs less choices. We need to start some winnowing, also known as “people need to surrender their project and work for the common good”. But which people, James? Should the Ruby on Rails group have given their idea up in order to make PHP better? Should Guido van Rossum have worked on the Perl codebase instead of doing Python?

The reason why we have to encourage new projects, or at the very least be happy they spring up all over the place, is precisely because it gives us the Ruby on Rails, the Pythons, the Nutches, that our own myopic view might have not thought of because we were oh-so-happy with our first .Net week.

Ricardo Programming

Debugging php pages

April 20th, 2007
Comments Off

I like Eclipse. It’s my main Java development tool, and I use it quite extensively for php as well. Mostly I’ve been using PHPEclipse, but it’s just not stopping on breakpoints placed on web server scripts. I gave Zend’s Eclipse PHP platform a shot as well, with the same results.

At this point I’m beginning to think that it’s something with my box.

An article on Sherlock Web suggests there might be some problem with the debugger on Intel Macs, and lo and behold, that’s exactly what I’m using. Awesome. However, after much trial and error I was able to find that if I moved my files under /Library/WebServer/Documents instead of symlinking to the directory, then the debugger did recognize breakpoints properly. This lead me to believe that the symlink was confusing the path, so I just created a VirtualHost whose document root points to the exact same directory Eclipse is getting its stuff from.

No dice.

I just started trying out Zend Studio which behaves better (breakpoint-wise) but seems to have a few peculiarities, such as an inability to find include files which are referenced via relative paths, plus a rather unorthodox user interface. On the plus side, if I load the environment and then invoke the debugger via Zend’s Firefox toolbar things work as they should.

I’m pretty much done fiddling with all this crap, and will run a heterogeneous environment until I’m done with my current php project. I’m not sure if it’s a Mac issue of a PHP issue, but my next step will probably be installing everything on a CentOs server and attempting to debug from my machine.

Meanwhile, any pointers you have are welcome.

PS: I’m using Marc Liyanage’s PHP packages for Mac. If you’re thinking of using PHP, save yourself a few headaches and just go for them.

UPDATE: Blessed be Nyarlathotep! I’ve figured it out. It not only wants the files to be on an actual path – i.e., no symlinking – but for server directories to have the same structure as your folders on the Eclipse project.

I’m I making sense? Here’s a better explanation. It works with Eclipse and Zend’s PDT, but the instructions might help you with PHPEclipse as well.

Suppose you have a php project in Eclipse called MyPHPProject, with the following structure:

    MyPHPProject
        database
            some.sql
        docs
            doc1.txt
            doc2.txt
        php
            index.php
            and.php
            all.php
            your.php
            other.php
            web.php
            pages.php

You should create a virtual host called something like mytestserver, and add the name to your hosts file.

<VirtualHost 127.0.0.1:80>
    DocumentRoot "/Users/youruser/Sources/myphpproject"
    ServerName mytestserver
    <Directory "/Users/youruser/Sources/myphpproject">
        allow from all
        Options +Indexes FollowSymLinks MultiViews
    </Directory>
</VirtualHost>

Notice that I’m not linking the document root directly to the php directory – that’s what killed all this hours of figuring it out for me. You need to maintain the same structure as the project you have on Eclipse.

When you create the PHP Web Page debug instance, set the parameters as follows:

  • File / Project: myphpproject/php/index.php
  • Leave Publish files to server unchecked.
  • Uncheck Auto Generate, and set it to http://mytestserver/php/index.php

Alternatively you could define (on the same window) a server called mytestserver that has http://mytestserver as the base path and save you that last step.

Set a couple breakpoints, debug and voilá! They now work.

Ricardo Programming

Apache unable to access you sites on OS X

April 17th, 2007
Comments Off

So you’ve just turned on Apache on OS X. You access http://localhost/ and it works just fine, but http://localhost/~username gives you an ominous 403 – Forbidden error.

Do you have FileVault enabled?

I had the same problem. FileVault seems to have changed the permissions on the home directory. You’ll need to execute:


chmod 701 ~
chmod 705 ~/Sites

Bonus: If you’re wondering how this is automagically mapped, look for UserDir on /etc/httpd/httpd.conf.

Ricardo Programming

Setup subversion securely on CentOs

April 16th, 2007
Comments Off

So you have a CentOs box and want to securely set up a subversion server with Apache, but keep finding only tutorials which are either:

  1. Not for CentOs
  2. Outdated
  3. Not focused on security at all

Search no more. I just went through the process with CentOs 4.4, and here’s a walkthrough on how to do it.

Read more…

Ricardo Programming

Parallels’ absurd memory usage

April 3rd, 2007
Comments Off

I’ve reported on the past on some decent experiences with Parallels, as well as some negative ones. One of its main problems seems to be processor usage: like I had reported, Parallels uses 10% of a MacBook Pro’s Core 2 Duo processor even when it’s doing absolutely nothing – not even having a virtual machine loaded.

Now a Parallels forum member reports that he discovered Parallels creates about 50 hidden windows on his Mac, even when there’s no virtual machine running at all, and has posted a screenshot to prove it. I ran the steps he suggests, and got exactly the same result. Testing on VMWare Fusion’s beta yielded only 4 windows, only one of which was the full screen’s size.

This is just absurd. Parallels hasn’t yet replied with a timeline for fixing bugs, nor said anything about upcoming updates. They seem to be mostly absent from the forums that are the only point of discussion for these issues, and I wouldn’t be surprised if said forums are closed down fairly soon.

Stay away from Parallels. Even at beta stage, VMWare Fusion seems to be the only sensible choice.

Ricardo Programming, Science and Technology

Numenta – an approach to artificial intelligence

March 28th, 2007
Comments Off

There’s a good article on Read/WriteWeb about Numenta, a layered approach to artificial intelligence called Hierarchical Temporal Memory. From the article:

Similar to the neural networks, HTM does not have any prewired classification of the world. Instead, HTM accepts a sequence of spacio-temporal inputs and ‘learns’ the patterns in the input stream. In the diagram above, the senses digitize the signal and turn them into bitmaps (or vectors), which are then are processed by a classification system. The system then assigns the likelihood of a particular cause to each symbol. In plain english, you are shown a sequence of pictures of cats and dogs – and each picture you classify as either a cat or a dog. But just like we can’t do that when we are born, neither can HTM. In fact HTM needs to go through a training process before it can ‘learn’ to distinguish things.

Here’s the full post on Numenta. The company has also made available some Hierarchical Temporal Memory whitepapers as well as their source code (which I have yet do download myself).

Ricardo Programming, Science and Technology

Linux and Open Source on Paypal

March 27th, 2007
Comments Off

Here’s something I didn’t know: Paypal runs its servers on Linux.

PayPal runs thousands of Linux-based, single-rack-unit servers, which host the company’s Web-presentation layer, middleware and user interface. Thompson says he quickly saw the economic, operational and development advantages of open source and Linux technology. He now sees no other way to do it.

“When you’re buying lots of Big Iron, as I did in other places I’ve worked, your upgrade path is US$2 million, US$3 million at a clip. You just had to buy big chunks of stuff to scale,” he says. “Here at PayPal, our upgrade path is 10 US$1,000 no-name servers, slapped into the midtier of the platform. And we just keep scaling it that way. It’s unbelievably cost effective.”

[...]

“Rather than have a monolithic box, or an impenetrable fortress that never breaks, we just have so many [nodes] that the breakages are irrelevant,” Mengerink says. Using a proprietary operating system to build out a system with a thousand points of failure would not be an option, he says. “This distributed, highly redundant system we have is predicated on the cost model of Linux and Intel,” he adds.

The database is still Oracle running on Solaris servers, which to me shows that this is not a decision made out of zealotry but purely because of its business advantages.

Personally I’ve been thinking about buying Mac Minis for my company’s servers (oh, I hadn’t mentioned I started consulting full time again, had I?), which are cheap enough, stable and provide a base from which I can run virtualization solutions if necessary. I’ve considered other Mini-ITX solutions but they seem to be still pretty much in do-it-yourself land, and I’d rather focus on producing great software than in managing hardware.

Ricardo Programming, Science and Technology

Parallels Desktop and VMWare Fusion: the story so far

March 23rd, 2007
Comments Off

Over a month has passed since my post about my Parallels and CentOs experience, where I mentioned that it was working rather well, and I would like to comment a bit more about it.

First of, pretty much everything I said on that post still holds: Parallels is convenient and quick to set up. Unfortunately, it also has several unadvertised problems – which the company just recently recognized as bugs – that would make me think twice about paying for it now if I hadn’t already.

First off, there is processor usage. Even when the virtual instance is doing absolutely nothing, Parallels tends to consume at least 30% of processing time in my MacBook Core 2 Duo. I understand that even in those cases Parallels probably has to provide clock and other basic services, but it still seems excessive. There’s also some issue, I expect with their network drivers, that causes that processor usage when idle to jump to around 60% on a Windows virtual machine just by loading Skype. These problems are exacerbated if you don’t turn off any of their recent, much touted features, such as Coherence or USB 2.0 support. Even worse, Parallels CPU usage is high even when it doesn’t even have a virtual machine runnning. There’s no excuse for that one – it’s simply bad programming.

But these problems would be minor if Parallels support reacted properly. Unfortunately, you’ll find many customer service horror stories, which can be summed up as either Parallels doesn’t work and they aren’t fixing these serious problems or simply Parallels is ignoring us. In my own experience, I didn’t get a reply to any of my e-mailed questions until there was a big public outcry on the forums about the general lack of support, and even then they replied only to one of the issues.

I’ve also been experimenting with VMWare Fusion, and at this relatively early beta stage seems just as stable as Parallels, and processor usage with even all their debug stuff thrown in is similar (if not lower). If you’re considering a Mac virtualization solution, I’d seriously recommend you try it as well. Parallels problems are not insurmountable, but right now they’re serious enough that I can’t recommend them.

Somebody on the Parallels forum mentioned I’ve been treated better as a prospective VMWare customer than as a paying customer of Parallels. Caveat emptor.

Ricardo Programming, Science and Technology

Evil Capitalists Save The Day

March 2nd, 2007
Comments Off

Linux and the Open Source movement have often been likened to communism. Now a LWN.net article takes the time to evaluate contributions to the Linux 2.6.20 kernel, and finds that at least 68% of the code (and possibly up to 92.3%, if we assume the Unkowns are just anonymous employers) was contributed by people working directly for major corporations like Broadcom, Nokia and IBM.

Surprise! Software developers like getting paid as much as anybody else. Surprise again! Corporations do this not because of some outdated, absurd philosophy, nor to threaten the status quo, but because it makes good business sense.

Here’s the full list, plus the Slashdot discussion.

Ricardo Programming, Science and Technology

Parallels desktop and CentOs 4.4

February 12th, 2007

I started testing out Parallels desktop on my MacBook Pro yesterday. The original plan was to use it to boot from my Boot Camp partition, so that I would be able to do Windows development without having to let go of all the other things I do in MacOS. That didn’t go to well. I’ll give more details later, but for now suffice it to say I wouldn’t try it on any set up I didn’t want to wipe and start from scratch.

But then it occurred to me that I’ve been meaning to set up a CentOs 4.4 machine inside the house, just so that I emulated the set up of our production server – testing things before sending them live and all that – and that Parallels might be perfect for just that purpose. With that in mind, I proceeded to download an ISO image and go through the very straightforward process of setting it up.

Read more…

Ricardo Programming