elfs: (Default)
[personal profile] elfs
I've figured out why I'm not a world-famous open-source programmer. It's simple, really; I don't have many itches to scratch. Most of the software I have with me pretty much does what I need it to do.

I write software when my aesthetic sensibility is offended. And I have much to be offended about this week. I've been deep inside the guts of FireWatir this week, the web application testing framework written in Ruby, and I have come to the conclusion that the FireWatir programmers have at best a passing familiarity with Ruby and Javascript.

I even showed the FireWatir code that offended me to a co-worker, a programmer of phenomenal youth and skill (I'm the one with age & treachery), and he agreed that the code was offensive. Six hundred lines of the same three lines repeated over and over, each with eight lines of comments above it. Those three lines defined subclasses of Element, for individual HTML components like divs, spans, and paragraphs.

I replaced the whole mess with one four-line function, a one-line list of names, and a one-line call to generate classobjects from the function for each name on the list. My list is more complete than theirs.

In another example, their code builds this humungous raw chunk of javascript, which it then uploads to the JSSH JVM, executes, takes the return value, and then... does nothing. The variables defined and described live for the duration of the test, even though they're never re-used. The builder does this component by component, intermingling ruby and javascript in a mangled heapin' mess of unreadability.

I wrote the lookup function in pure javascript, using a BSD-licensed function findElementsBySelector. When the program starts talking to the JSSH JVM, it uploads and instantiates a single new object, _firewater, which has a reference cache and a collection of functions, including the selector function. All of that huge, ugly ruby/javascript now devolves to this:

oblist = self.command('_whiskey.locate("%s", "%s");' % (selector, self.element_object()))


(Oh, that's another thing; the idiom 'send this, then read the response' is everywhere in this damned code. You'd think after the third time they'd have boiled it down to a single command. And my command function is smart enough to append the semicolon if you forget!)

See? I'm offended. It must be fixed.

Date: 2008-08-28 04:10 pm (UTC)
From: [identity profile] antonia-tiger.livejournal.com
I make no claim to be a programmer.

I've done a few tricky things with MS-DOS batch files, written some very simple utilities with Turbo Pascal to work with such stuff.

But even I know that there are better ways of handling repetition than those clowns used. It's the same with art: you don't have to be able to paint the picture to recognise ugly.

Date: 2008-08-28 04:20 pm (UTC)
From: [identity profile] elfs.livejournal.com
There's an adage in programming: "Never program at the limit of your cleverness. Experience has taught us that you have to be smarter to understand what's going wrong with a program than you had to be to write it in the first place. If you're writing code at the limit of your cleverness you are not smart enough to fix it when it breaks."

These guys are clearly at the limit of their cleverness.

Date: 2008-08-28 04:53 pm (UTC)
ext_3294: Tux (Default)
From: [identity profile] technoshaman.livejournal.com
gyaaaaaah!!! I'm explicitly NOT a dev (though I do enjoy porting), but jeez, I've heard language on the bus that wasn't that offensive!

Please. Scratch away, kind sir, this stuff needs *fixing*.

Date: 2008-08-28 05:04 pm (UTC)
From: [identity profile] elfs.livejournal.com
The thing that bugs me most is that Ruby, far more than Python, is touted as a super-duper metaprogramming language. This is clearly a metaprogramming problem (I'm writing programs in python that know about DOM datastructures and Javascript; I'm writing programs about programs, the very definition of metaprogramming) and yet there's not a shred of metaprogramming wisdom in all this code. WTF?

Date: 2008-08-28 05:08 pm (UTC)
ext_3294: Tux (Default)
From: [identity profile] technoshaman.livejournal.com
You can write crap code in any language. You can write great code in FORTRAN or Z-80 assembler. Somebody threw something together the hard way and chucked it out there. But it's open source, so you can fix it! FTW!

Date: 2008-08-28 10:03 pm (UTC)
From: [identity profile] norikos-author.livejournal.com
Whoever wrote this wasn't a Ruby programmer, clearly. If I had to guess, either they picked Ruby because they wanted to learn it (doubtful, given what you described), or they picked it because of the hype.

I tend to be skeptical of criticisms such as the latter, but in this case, it sounds like it's justified. Hell, I'm putting more effort into avoiding duplications in my _tests_ than that! (And Ruby makes it easy to do, too, even though many of these tests are perl-written-in-ruby from when I first started learning it)

Date: 2008-08-28 06:17 pm (UTC)
From: [identity profile] funos.livejournal.com
They hadn't learned the rule of ruthlessly eliminating copy-and-paste. If I have to repeat something, I reduce it to a single token using a macro or a function. Longer to write, but infinitely faster to understand, debug, and maintain later.

Date: 2008-08-29 05:06 am (UTC)
From: [identity profile] gromm.livejournal.com
Ugh. I can program my way out of a wet paper bag (usually in sh, perl, or more recently, PHP) but only just barely, and *I* know that much. The least he could do would be to overload an operator and/or build a function that was called repeatedly. Programming is meant to remove and automate repetition, not add more.

Date: 2008-08-29 07:07 am (UTC)
From: [identity profile] zonereyrie.livejournal.com
You can submit the fixes back to the program, yes?

Profile

elfs: (Default)
Elf Sternberg

December 2025

S M T W T F S
 12345 6
78910111213
14151617181920
21222324252627
28293031   

Most Popular Tags

Style Credit

Expand Cut Tags

No cut tags
Page generated Dec. 30th, 2025 09:38 am
Powered by Dreamwidth Studios