Are Googlers Too Smart For Their Own Good?
theodp writes "If you're a mere mortal, don't be surprised if your first reaction to Google Storage for Developers is 'WTF?!' Offering the kind of 'user-friendly' API one might expect from a bunch of computer science Ph.D.s, Google Storage even manages to overcomplicate the simple act of copying files. Which raises the question: Are Googlers with 'world-class programming skills' capable of producing straightforward, simple-to-use programming interfaces for ordinary humans?"
Things become much more complicated then first impression when you try to really explain something. For example I went to a football game with a group of Chinese grad students and they asked me how a team can score points. I thought to myself this is easy, and began to explain the rules.
1. Touchdowns are worth 7 points... err they are worth 6 points technically
2. After a touchdown the scoring team can decide to kick the ball through the uprights for 1 point
Or
3. The scoring team can decide to run another regular play and if they enter the end-zone again on that 1 play they get 2 points.
4. Fields goals are 3 points and are scored when the team on offense can kick the ball through the uprights.
5. The defense can score points if they can tackle an offensive player in the end-zone while they are holding the football. The defensive team then gets 2 points and gets the ball kicked to them on the following play instead of the normal system where the scoring team kicks the ball to the other team.
6. If the defense can steal the ball and run into the end-zone they are facing then it is a touchdown and rule 2 and 3 apply.
By the end of this discussion they were more confused then when we started. So when you say how hard can it be to explain how to store a file questions like.
1. How to delete?
2. How to rename?
3. How to create folders or other organizational structures?
4. How to move items between organizational structures?
5. How to copy an item already in storage?
6. How to download multiple files?
7. Can security be set or changed?
8. Oh yeah and how to I upload a file in the first place?
The more precision you apply to a discussion the more complicated they tend to get. Just like a touchdown is 7 points is easier to understand, upload a file is easy too.
It isn't slashdot that has become non-nerdy, it's that being a nerd has become "cool", very unlike it was when slashdot started. These days, anybody who knows that you make your computer stop by clicking "start" thinks (s)he's a nerd, even if they couldn't copy a file without a GUI, let alone have ever heard of Linux or BSD or any other non-Microsoft OS (which these days actually have GUIs).
In the old days, a submission like this most likely wouldn't have been posted, but now we have the firehose, where every nerd wannabe can vote a story up. There are still very good, technical stories here (there was one a couple of days ago about mathematics) -- you just have to ignore the ones like this one voted up by the wannabes. That said, I haven't looked at Google's APIs.
God, I never thought I'd see the day when we would be considered cool! Just laugh smugly and enjoy being cool instead of being a wannabe.
That said, sometimes I say stupid things here (probably a lot this week, I've had the flu and it's affected my mental faculties).
Free Martian Whores!
It's not about being too difficult. It's about being way too overcomplicated.
Let's look at the code.
config = boto.config
okay here. We need config.
bucket_name = "dogs"
remote dir. So they made a half-assed directories system. Can't be nested, data can't be outside them. Piss-poor but let's say "okay" here.
name = "poodle.jpg"
dir_name = "pets"
so far so good.
src_uri = boto.storage_uri(bucket_name + "/" + name, "gs")
dst_uri = boto.storage_uri(dir_name, "file")
seems logical if slightly redundant. So we need some objects instead of plaintext names...
dst_key_name = dst_uri.object_name + os.sep + src_uri.object_name ...wtf... oh, we are trying to create a local filename... that's some convoluted way to do it.
new_dst_uri = dst_uri.clone_replace_name(dst_key_name)
err... so our local disk file needs to be placed at... "pets/dogs/poodle.jpg". Now that's some way to get there!
dst_key = new_dst_uri.new_key()
oh, that was just the NAME of the new key... so we need the actual "key"... again, what for?
src_key = src_uri.get_key()
again, if we have the URI object, why do we need some "key" object? Isn't the dedicated URI object good enough?
tmp = tempfile.TemporaryFile() ...can't we read directly from a file instead of creating temporary one? So the "uri" of a file is not good enough, the "key" of a file is not good enough, we need a "tempfile" object extra?
src_key.get_file(tmp)
tmp.seek(0)
dst_key.set_contents_from_file(tmp)
I recommend a reading about a hammer factory factory factory. This one doesn't overdo factories, just abstraction layers. I can spot four: filename (string), URI, key, file handle within the key. WHO needs that???
45 5F E1 04 22 CA 29 C4 93 3F 95 05 2B 79 2A B2