Archive for August, 2008

Problems with Python

Programming | Posted by attriel August 28th, 2008

One of the things I’m having to deal with at work lately is Python.  It’s used around the UltraSeek (nee Inktomi) search engine in use that predates me (and boy is THAT a nuisance)

And a few things I’ve learned about python so far:

  1. If I wanted to use a position-sensitive language, I’d go back to programming in FORTRAN.  whitespace should be used for making things pretty and legible, not for replacing “ugly” braces
  2. Bacchus-Nauer Form language definitions are NOT good user documentation
  3. The guy who wrote the local mods for this code was an idiot!

On the first point:  Seriously?  Whitespace structured code?  Jesus, Guido, (no, that’s not a slur, that’s the man’s name who designed python), did someone put out a hit on { and } ???  I’m scared to replace tabs with spaces, because, honestly?  I don’t know what effect that would have.  I think 1 space would===1 tab, but wtf knows.  Because back in FORTRAN we used spaces b/c those first couple columns had meaning.  I’m not versed enough in python to know all the ins and outs, but I think it’s just “whitespace”. 

Point the second, BNF.  Don’t get me wrong, I can read BNF.  I actually LIKE BNF definitions.  They’re great for the details and nuances of “what can I put here” once you’ve got the basic setups.  But for interpreting “what does this line do”?  BNF SUCKS.  Because now you have to know the answer to know where to look for the answer.

For instance.  How do I print out the contents of a variable who’s type I don’t know?  Only way to print anything that I’ve found is “write(variable)” (no EOL markers, b/c the newline character is whitespace and thus meaningful, ooooh).  I’m sure if I knew python I’d know how to write the equivalent of PHP’s print_r() or var_dump().  But because I don’t, the official docs that I found on python.org don’t help any.  Oh, and join(“,”, $array)? join(“, “, @arr)?  yeah, reading the docs, it’s supposed to be “, “.join(arr) … uh, W T F?  I have to make an string variable, assign it the conjunction, then use it to invoke join?  who joins on the conjunction?  arr.join(“, “) would be SOOOO much more logical I’m sorry.  And I still haven’t figured out how the code is doing when it calls “string.join(arr, “, “)” … because string doesn’t have a join that takes two parameters.

I’ll grant this:  Coming from Perl (language of line noise) to looking at python (language of whitespace) is kindof a long jump.  They’re kindof conflicting paradigms, honestly.  But still.  I hate python.

Grrr

Site Maintenance | Posted by attriel August 26th, 2008

Argh.  Grr.  Seriously, I WILL get back to this page eventually.  I’m still thinking that maybe DES wasn’t the best first choice, though :/