Thursday, June 26, 2008

Area Man Misses the Point of MVC

Just this morning, I read about a guy who integrated some instant messaging features into an application. First of all, good on ya for using Rails. You're lightyears ahead of those idiots still using PHP. On the other hand, the ENTIRE point of MVC is a consistent stack of logic to render information back to clients. In Rails, this is achieved with ActionController scrounging up instances of Models for use by ActionView. So, instead of doing a 1980's style of dispatching, why not try this?
  1. Write a dispatcher from xmpp4r to ActionController. Get rid of that ugly while true loop.
  2. Write a proper render action. Have ActionController look for some sort of proper template, like status.chat_response.erb. msg.from could be easily DRYed out, since you'll be responding to the same person every time.
  3. Release it as a rails plugin
  4. Profit.
... Just a thought.

Wednesday, May 14, 2008

TomsTechBlog.com: Free and far too expensive

Before I get right into it, I found a serious bug in Google tonight: I searched for something, and this post came up. I don't care what I'm searching for, there's no search terms on earth that should bring this crap to light.

As for the post, it's essentially a handful of thinly veiled rants about how sad Tom is that he doesn't work at Google. I'll quote parts of the post here, with my comments in italics.

Google App Engine is essentially just a free web host. Google.com is essentially just a free search engine.

Given that, I made a quick chart comparing Google App Engine to a popular shared hosting company (for the record, I've never done business with this company). I compared Google's free service to the other company's $5.95 per month service...

Average Webhost Google
Data Transfer per Month 15,000Gb 300-310Gb (10Gb per day
Setup Free Free
Database (Open) MySQL (Proprietary) BigTable
PHP Yes No
Ruby Yes No
Python Yes Yes
Perl Yes No

As you can see, Google falls behind in every single category. So the question becomes this: is there really anyone who can't afford $6 a month?

Despite drastically missing the meaning of 'every', this comparison has some built-in assumptions that were formed with the aid of a giant bucket of fail. Do you think Google would spend centuries worth of labor of the smartest programming minds of our era building something that wasn't as good as fucking MySQL? Neither do I.

Google App Engine's ability to scale depends on how much server resources Google is willing to dedicate to the task of running these applications. Google is not going to risk slowing down their primary services for a Google App Engine application. So their ability to scale could very well be less than other companies, we just don't know.

Alright Tom, here comes the enlightenment, are you ready for this? Sitting down? GOOGLE APP ENGINE ISN'T MEANT TO BE A FREE SERVICE! Sure, it's free for the "small fish", but that's not who Google cares about. Google has some of the industry's the smartest people, and as an application developer, I'm ecstatic to be able to send them my hugely popular python web app and have them scale it to kingdom come. If this strikes you as wrong, you should go back and re-read Adam Smith.

The Google App engine may some day be worth mentioning but as of right now its nothing short of comical. Essentially Geocities 2.0. I don't know what internet you remember, but Geocities was a joke of a website where people were forced into contrived communities in order to create a free small website. Google is offering their infrastructure and expertise. Focusing on the free website aspect just enlightens the world to your myopia.

I can't imagine any serious developer signing up for this under the current circumstances. I can't imagine you commenting about serious topics.

Congratulations Tom, you utterly fail.

Monday, May 12, 2008

An angle bracket tax?

You ever hear that the lottery is an "idiot tax"? Angled brackets in the realm of programming are exactly the same thing. That's why I had to laugh out loud when I read the latest post on the Coding Horror about XML. It takes a special kind of idiot to admit that he's using XML for anything, and an even more special kind of idiot to write an entire blog post about it. This sentence struck me as especially relevant: "if it's stored in a text file and needs to be retrieved and parsed, it's probably XML.". I would word that a different way: "if it's stored in a text file and it's XML, you've got a shit career.". But that's just me; after all, all of the text stored in my /etc folder is in XML right? Oh shit, it's not? Nor are any of my application configs for that matter; I've been using YAML for five-plus years like any sane person. As for the "hot debates" over JSON and alternative formates, the crowd that has been fawning over Ruby on Rails, trend whores as they are, have already made this decision for you. Fight it all you want, but only Microsoft losers will be using XML in 2009. As a parting note, I'd like to suggest that if you're still using SOAP, you drop whatever you're doing right now and practice saying "Would you like fries with that?", you're gonna need it.

Thursday, January 24, 2008

PHP Sucks Balls.

This morning I read a rather hilarious article. It was posted on TheDailyWTF, and involved someone building a loop in a GUI that would artifically slow processing for the express purpose of being removable when the programming team needed an "accomplishment". Then, I read something even funnier. Some idiot was extolling the virtues of PHP, and suggested that he would point back to this article as his "sole defense" in future arguments. Well, for all of you who argue with this fine gentleman in the future, I'll do you a favor and win the argument for you right now. I've taken the liberty of copying the original article's (found here) points in italics, and refuted them sumarily.

Language Features

  • It's dynamically typed. This isn't a feature. It's a design decision made early on.
  • All arrays are associative (hashes) Which means that if you want to build an array, you have no easy way of guaranteeing that all indices will be numeric. Sounds like a recipe for trouble to me.
  • It's object oriented with a reflection API. Ruby, Java, and Python are object oriented. PHP is a procedural language with some stapled-on shit that they try to pass off as object orientation. Note that they still haven't implemented proper class and instance scoping, which makes objects in php just more typing, not more usable or functional.
  • It uses different operators for numeric addition (+) and string concatenation (.) This wouldn't be necessary if it had anything more than the most useless type checker in the universe.
  • It supports eval() and lambdas (somewhat) BASIC implemented eval() this well 30 years ago. Having a "dynamic" language with such a poor-performing eval() really should scare users of the langauge.
  • Can execute system commands and read from local and remote files (all one-liners) So can BASIC.
  • Supports coercing scalars into boolean decisions (means you can just do if($x) instead of if($x!=null && $x!=0 && $x!=false ... ) Coercing anything into boolean values is one of php's worst offenses, so it's a tad hilarious that this article mentions it as a "Feature". For instance, try evaluating 'if(1), if(0), if("1"), and if("0")'. See anything funny?
  • Usable in both web and command-line contexts Usable, but different. Just different enough to make a completely useless command line program.

Built-in Functionality

  • It comes with a vast array of built-in functions to do all sorts of common tasks. Here are a few off the top of my head:
    • Base 64 encoding and decoding And it lacks proper i18n support at the same time. Which would you rather have?
    • URL encoding and decoding My grandma could write a function to encode and decode URLs in about ten minutes. This is hardly worth noting.
    • HTML character encoding, decoding and tag stripping Again, I use a library my grandma wrote for this purpose.
    • SAX style XML parsing Yes. Computer languages can use SAX style parsers now. Is it really worth noting?
    • REGULAR EXPRESSIONS OMG ITS IN CAPS!!! Trivia quesiton: Can you find a language made in the last 15 years that doesn't support regular expressions?
    • Array sorting, custom sorting Sorting an array? Wow. That's tough shit. I had to get to CS 102 before I learned how to sort an array myself.
    • md5 and sha1 hashing So, they like, copied the pseudocode from wikipedia and compiled it?
  • It can natively connect to the most popular Database engines around. But it can't do so without resorting to using different functions for each database. (eg mysql_query() vs pg_query())
  • It comes prepackaged with graphics manipulation capabilities (GD) No. It knows how to access a GD installation on the same system.

Irrelevant complaints^H^H^H^H^H^H^H^H^H Just a few of the complaints this article refuses to^H^H^H^H^H CAN'T refute

Now, here are some common complaints about PHP, and why the don't matter:
  • I don't like PHP because it's not statically typed (like my beloved Java) News flash: static typing sucks - deal. Based on the logic this article demonstrates, the static vs dymanic debate is one it shouldn't touch with a ten-foot pole.
  • PHP doesn't have namespaces, so there can be naming collisions. Oh noes! Seriously, this is a theoretical objection, not a practical problem. Use a class dude - makes for a nice way to wrap your functions. This isn't theoretical in the least. See above, where querying to similar database engines use the same functions, BUT WITH DIFFERENT PREFIXES. PHP's lack of proper namespacing forces the language designers to do stupid shit like put "namespace_" in front of colliding function names, which makes the whole language even messier than it otherwise would be.
  • I hate globals Globals can save your life. Globals pierce through all the layers of code and get right to the heart of the matter. You say you don't like globals, so try to remember that the next time you grab a singleton from your static factory. Globals save the lives of programmers that don't know what the hell they're doing. Note to author: Reconsider what side of that elusive "circle" you're on.
  • PHP allows/promotes poor programming practices I call shenanigans on that one. PHP appeals to a broad audience, especially new coders, because it is ubiquitous. It's just as easy to write poor code in any other language (an Interface with exactly one Implementation anyone?) I'm not sure PHP allows it more than anything else, but it sure does market itself to the dumbest bunch of idiots that ever did type on a computer.
At least the author knows he's way behind. He's even kind enough to point out that "The curve is a circle", whatever that means. I tried to read the linked post, but it was long and sounded trite and angsty, but I interpreted it as this guy admitting that he sucks.

But! (there's always a "but", right?)

PHP does provide for the single greatest interview question every concocted. Now, when I'm interviewing candidates, the first question can be "Do you like PHP?". If they answer yes, I've just saved myself an hour.