Thursday, December 11, 2008

Why Eclipse, as an IDE, makes me all "Hulk Smash!"

I still dislike PHP as a language. It's inelegant, clunky and baroque. However, my two biggest problems with PHP are these: the IDE and the community.

First, the IDE. IDE, for the non-technical crowd, means Integrated Development Environment. It's the tool that your web developer geeks and other computer programmers use to write those programs. It consists of an editor, a compiler, and a debugger. Generally, IDE's also group files together into one project (or some other vaguely defined term, like solution, based on your particular programming language). For MS stuff, the IDE is Visual Studio. It compiles your code, gives you neat line-by-line debugging, and a really swank editor that not only doesn't get in your way, but actually shows you such diverse things as the arguments for a method or function so that you don't have to remember them all or look them up. It has some problems, I'll grant you. The collaboration/versioning software that's designed for it really sucks (Visual Source Safe is just awful). It takes a ton of memory to run. It's not free, or even cheap. However, when it comes to rapid application development, it rocks.

PHP doesn't have an IDE of its own. Manly open source programmers use vi. Less manly ones use Emacs. If you must have an IDE, because you are a little sissy girl who can't work a compiler all on your own, then fine. I guess you can use Eclipse. The problem is that Eclipse sucks. It's written for Java, and it might be great for Java development. But for PHP, you have to get a plug-in to handle syntax comprehension and highlighting. You have to get a different plug in, which is fiddly to configure, to do debugging. You have to get yet another plug-in to handle connection to CVS for versioning and collaboration. It's slow. If you configure your project as a CVS project (and why do you have to do that ever!) you can't run the PHP debugging against it. If you want to make your project a PHP project, it can be a pain to get the CVS plug in to be happy. And it's always in your way. You have to switch "perspectives" to debug, and the default debugging perspective doesn't show variable values in the pane. You can't get any sort of WYSIWYG (What You See Is What You Get) HTML editing, because manly open source types don't need it. I spend at least as much time arguing with Eclipse as I do actually getting useful work done in a given day.

The other problem PHP has is the community. On the back of Learning PHP 5 by David Sklar, the first 2 sentences are these: "PHP has gained a following among nontechnical web designers who need to add interactive aspects to their sites. Offering a gentle learning curve, PHP is an accessible yet powerful language for creating dynamic web pages." That sums up the problem in as pretty a way as could be done. PHP was written so someone could put a little dynamic content on a personal home-page, hence the acronym. Yes, it's the most popular web application language in the world. More people use PHP than any other web language. But here's the thing, it's not the most popular language for scalable, enterprise business applications, and for good reason. But the popularity thing is what PHP really has going for it. So they can't really rebuild from the ground up like MS did when they launched ASP.Net and killed off classic ASP. Too many people would stop using PHP for their fantasy football league stat pages.

Why is the general amateur nature of the PHP community a problem? Two reasons. First, the advice you get on how to do something in PHP may be awful. Do a Google search on PHP File Upload. You'll get back all sorts of scripts to do this, but the problem is that few of them check the file type in a safe way, if they check it at all. There's no explanation for why you should check more than just the browser supplied mime type. There's just a whole bunch of "copy this and it'll work." There's more free PHP scripts on the web than there are for any other language, and 90% of them are just bad. Secondly, the casual nature of the PHP community means that there's no pressure to make PHP a better language, just an easier one. There's no incentive to do anything that will alienate all those casual users. Remember, popularity is PHP's selling point here. So doing things like fixing crap like deployment, creating a separation of logic from presentation, and namespaces, all things that you need in a large, collaborative website, are held back in favor of making sure that those fantasy football stats web pages aren't broken.

Wednesday, November 5, 2008

And so he did...

Been a while since I posted. A few thoughts on the recent election.

First, Barack Obama's election is a redemption of America's Original Sin. Our country was, paradoxically, founded on the idea that all men are equal and it that creation was fueled by the blood, sweat and tears of African American slaves. That's why you should be ecstatic regardless of political persuasion. We've tried before to eliminate the stain of slavery on our country, and we've failed. This moment shows that, even though it may take a while, we can and will finally make good on our rhetoric.

However, there has been a strong undercurrent of an attitude that, even if you're happy about Obama's victory, you think that this is a sad day in American politics. This attitude is summed up in posts like this one (culled from the comments on Wil Wheton Dot Net In Exile):

I never fight on teh Internets, but I will state my POV. Besides - look at this place - it could use little ying to all this yang!

If anything this is an indictment certainly on the GOP - both parties have swung far away from a true constitutional republic respecting freedom, property, limited government and minimal taxation.

However may the indictment stand, the GOP is FAR closer to the original American ideals than the DNC - but still much too far.

Four years of Obama could very well usher in a true conservative (i.e., classic liberal) government that is the embodiment of the true America as described in the second paragraph.

First, the founding fathers weren't paragons of perfection. They compromised on issues as important as anything we face today. Northerners bowed to the pressures of the southern representatives. The southern representatives put basic human dignity subservient to their own economic interests. Don't forget that the property that this poster so proudly cites our original constitutional republic respecting included slaves.

Secondly, there's no clear evidence that the founders were big fans of minimal taxation. The newly born republic did not represent some sort of libertarian utopia. They were rebelling against the idea of being taxed without having a say in the matter. A constitutional republic, as a form of government, doesn't have anything to say about taxation or anything like that. It's about representation of the people according to a set of written rules.

Thirdly, the idea that Obama represents some radical departure, in the political sense, from any who came before him is just wrong. American political discourse is largely homogeneous. The differences between the views that are taken seriously in America are really quite small. Politicians who step too far outside of that narrow margin are ignored. Look at Dennis Kucinich, for example. The most extreme policies that Obama has suggested are to try to find a way to use the free market to expand health care! That's not socialism. If it were, all doctors would be employees of the government, which would set the prices they may charge and even how many doctors of each specialization could graduate from med school each year.

Finally, there's nothing holy about the idea of a classically liberal economic theory. Even if there were, the founder of that economic theory, old Adam "Invisible Hand" Smith, was a fan of the rich paying more taxes. But remember, these are ideas that were promoted in response to a rapidly industrializing economic landscape in Britain. Those conditions no longer prevail. America's economy is largely based on the service sector. We're not a nation of factory workers and farm workers any more. We're a nation of merchants, programmers, writers and administrators as well as those factory and farm workers.

Wednesday, October 1, 2008

Another in my increasingly semi-regular PHP annoys me posts

So, I have been ordered to come up with a list of pros and cons for both a .Net based content management system* (CMS) implementation and a PHP based CMS implementation. Now, this makes as much sense, in terms of decision making, as trying to decide whether or not to buy a piece of software programmed in C or in (to pull something out of the air) pascal. It's irrelivant. If the software provides solutions to your problems and works with the environment you're in, buy it. Otherwise, don't. Personally, I can't see how PHP can be used to create a large-scale application, but apparently, it runs Yahoo!. Of course, that being said, it runs Yahoo!. Meh.

*For those of you who don't have to deal with the wooly IT world, I'll explain what a content management system is. Websites are display HTML. Often, the person writing code (like me) isn't the one you want writing press-releases or other content that the public will read. Otherwise, you get stuff like this blog. Lots of rants, with an excessive amount of cruelty to grammer, spelling, and rational thought. The solution is to have the programmers write something to let the non-technical folk update the content, ideally, as easily as they might use a word processor.

Thursday, September 25, 2008

PHP continues to suck...

I have a new project. I have to allow uploaded academic articles to be cataloged by author and, basically, keyword. With my years of experience doing the exact same thing for a large organization for whom that was their raison d'etre, you'd think it would be no problem. Heck, it's probably even a chance for some quick code recycling. With a deadline of December 31, I could have it knocked out in a week or so (with judicious code reuse) and look like a hero.

That's where you'd be wrong. See, I'd love to do this in ASP.Net. Like I said, I've got the code already. It's just a matter of editing the presentation layer, and writing a little bit to handle pdf uploads. But, they want it to exist in the existing design, which is going to be replaced within a year anyway. Again, no problem, I'll just use Master Pages and CSS to seamlessly change from one layout to another. Yeah. That's not what's going to happen.

It has been mandated that this will be done in PHP. Not just in PHP, but in the craptastic* content management system that already exists. This means that I have to wade through this utter dreck to figure out how to do it via the CMS that will be replaced within a year, or I have to edit the home-brewed CMS cruft and try to make that work. In any case, everything I do will be superceeded and need to be rewritten within a year. On top of that, the fact that I am supposed to do this in PHP rather than .Net suggests to me that my boss has little optimism that the IIS server will be ready by the New Year. It's that, or she wants me to practice my PHP skills. In either case, it's truly disappointing.

* Firefox recognizes "craptastic" as a word, but Blogger's spell check doesn't. Interesting.

Monday, September 22, 2008

Lich, what lich?

The grim destroyers of the undead hordes of Borgravia are down to the penultimate of foes, the Lich Queen, Lilia. They've found that her phylactry is housed in the body of an Iron Golem. They know where she is, they know where her phylactry is, they're all ready to go, right? No. The party have come up with multiple plans for this. They're convinced that they can't fight both at the same time, or even one after the other. They need a cunning plan, and they've developed several. Unfortunately, all of them require start-up capital. Therefore, the party, with their steely-eyed gaze on destroying the lich, destroying the vampire, and ending the curse that has crushed their lands, decided that now was the time to go to a city they hadn't been to, and rob them blind.

So, they sat and plotted, and gathered some intelligence. They visited Lord Meserole, spymaster of Borgavia, and asked him for intelligence about which mercantile houses and families would make good targets. They secured passage aboard a ship, and sailed to Hestia, now the primary commercial port for Borgravia. They sailed in, gathered a little local intel, and proceeded to create a plan. Dagnall would steal some of the local undead, used for various unpleasant and difficult chores on the docks and use them to start fires to cover their escape. Emerykul decided to track down one of the local clergy, and use the Ghoul Guantlet spell to transform him into a ghoul under his command, and Korr worked to secure contacts amongst the church of Suzerial and to track where the money that the merchants secured went.

Emerykul enchanted a trade bar with arcane mark, to allow him to track it later through the Locate Object spell. Dagnal went in to purchase something, and Korr hid, so that he could watch the building and follow the money if it had to leave. Fortunately, the Lightsails Mechantile Company used their offices as remote banks. A captain could get enough money to pay his sailors, but take the rest as a credit. That way, if a ship was lost, they wouldn't loose too much profit. The trade bar stayed where it was.

In the interim, the thought that they'd scope out the local opposition, in the form of the clerics of the god of death, Oberlin. With the decimation of so many of the higher level clerics in the land, this church had one of the more powerful priests of death left. The Ghoul Lord of the Shadow Lands wasn't taking any chances though. He set one of his more powerful minions, a nightwing, to guard both the high priest and his cathedral. When the characters explored the cathedral, under the guise of worshipers, they discovered the nightwing, secure in the rafters of the church. A nightwing, like all night shades, has some useful abilities against magically inclined foes. They are spell immune. Furthermore, their attacks actually drain magic from items. However, they are slightly weaker in daylight. Therefore, the plan was altered to strike at noon.

On the appointed day, they made their move. They attacked the ware house, killed the middling level guards, and stole lots of cash. 9 of the 18 skeletons that Dagnall had appropriated were destroyed in the process. They opted to grab whatever was light and obviously valuable, eschewing the priceless crates of spices. And they fled. On the way out, they ordered the skeletons to light the docks (because what heist on the waterfront is complete without burning the docks). And then, through the cloud of smoke, as they rushed to the ship, the Nightwing emerged.

Friday, September 19, 2008

Coolest thing since 3 Dead Trolls Internet Helpdesk

This is totally not safe for work, but it is also totally the coolest thing since the 3 Dead Trolls in a Baggie's Internet Helpdesk video.

The Website Is Down

Thursday, September 18, 2008

PHP: The Rusting Yugo of Languages

Once, in the dawn of time (the late 1990's) I did a lot of programming in Perl. Perl is a fun language, and if one were to compare it to a car, it would be a lot like an old Mustang. It was fast, you could tinker under the hood, and it was powerful. Sure, there were some drawbacks. The fact that it is an interpreted language, rather than a compiled one, means that generally, you can't use it for big, commercial applications. If you had to write a GUI in it, you were sunk. Overall though, Perl is a nice, if somewhat persnickety, programming language.

Around the same time, I was writing web applications in Cold Fusion. CF was originally owned by a company called Allair, then bought by Macromedia, who in turn was swallowed up by Adobe. CF is a very straight-forward web language. It beats CGI by a long bit. It has a very simple, tag-based structure. If Microsoft ASP 3.0 was the Ford Taurus of web programming, CF was, for a long time, the Saab 93. It's nicer, a bit faster, a bit safer, and almost no one used it because the other option was pretty much ubiquitous.

After that, I moved into the exciting world of .Net development. Microsoft's .Net framework is a fantastic programming environment, especially for the web. It's a compiled language, which means your web apps run faster. It separates logic from design, which means that you can have programmers writing code, and graphic artists designing pages, and not have to worry about one getting in the way of the other. It's object oriented, and I really didn't know what I was missing back in the late 90's when I didn't work in an OO environment. On the down-side, it is such a high level language that many of the basic concepts are completely obscured from you. All in all, it's like a Ferrari. It's fast and powerful, but sometimes, I do miss the days of poking around under the hood.

Then, I came to have to do some work in PHP. Lord save us from PHP. First, it's an outgrowth (like a tumor) that developed from an effort to program web pages with Perl. It's an interpreted language. Perl's motto is "There's more than one way to do it." PHP appends that with these words: "and they're all wrong." The entire language feels like a kludge. It's not typed, at all, so you constantly have to check user input to see if it's a valid type for whatever you want to do with it. That's irritating on the web, where user input can be anything. What's worse is this: "(string)"false" == (int)0." In a weakly typed language, the number 0 = the boolean logic value false. As a rule, in a weakly typed language, something is false if it is 0 characters in length (""), if it's a number equal to 0 or if it is a boolean value of false. However, in PHP, if I want to see if a user has typed anything into a text field, and they type "false" then it will say that they haven't. Parents, I advise you to name your children something like "'; drop table customers" as a first name, "false" as a middle name, with "null" as a last name.

On top of all of that, PHP requires you to write extensive amounts of Javascript to do most things. For example, let's say that you want to forward someone to a different page. You can use the "header()" function to do it, but there's a bit of a worry there. If at any point your programming produces output before your header(), you'll get an error. Therefore, your options are to write a bit of javascript to bounce people to a new page (which breaks if they've disabled javascript on their browser), or you have to use meta refresh tags (which usually work). There's nothing within the language to handle that stuff.

Finally, PHP requires you to work hard at making sure your content is end user friendly. You have a couple choices. Option one, adhere to standards. The problem here is that no browser currently on the market follows the standard, so this, while technically correct, will never work properly. Second, write to a specific browser. You're going to get better results for that browser, but you've just bent the rest of your customer base. Lastly, try to detect what browser someone is using, and serve appropriately written HTML/javascript/css. You're sunk. First, browser's don't always identify as themselves. Opera can be set to ID as whatever you want. Secondly, as the recent issues with new CSS needing to be written for the new version of IE so as to avoid breaking the work arounds people put in place for old IE illustrates, you're always going to be rewriting your pages. That's just no good. In short, PHP is the rusting Yugo of programming languages. It's always about to fall apart, you're always working to hold it together, and you never know when that unexpected bump in the road is going to make your transmission fly across three lanes of on-coming traffic.

For more, see here: I'm sorry, but PHP sucks!