?

Log in

No account? Create an account

Previous Entry | Next Entry

python horror

Writing code in Python is pretty neat. Executable pseudocode! It does match how I think. (Not how everyone thinks: a friend says he's gotten so used to pattern matching a la Haskell/ML now that *that's* part of his pseudocode, and Python is deficient.) Also the interpreter is really nice, and I'm surprised Perl still doesn't have one like it.

Testing code in Python? This seems to suck. Even the most basic lexical analysis isn't done and erroneous variable references don't get caught until the code tries to run.

def dummy():
    rint(stri)

print("hello")


happily prints "hello"; referencing an unassigned variable by calling an undefined function in a function that doesn't run causes no fuss. Naive perl is no better, but strict perl

use strict;

sub dummy() {
    rint $stri;
}

print "hello\n"


generates


Global symbol "$stri" requires explicit package name at test.pl line 4.
Execution of test.pl aborted due to compilation errors.


OTOH, the undefined 'rint' causes no fuss, which surprises me.

I was coding a simple HTTP server in Python, and while it's good to try to exercise all your code paths in testing as it is, I found myself wanting to do so specifically to make sure I didn't have typos in the enumerated constants I was referencing. That should not be an issue in a production language...

See the comment count unavailable DW comments at http://mindstalk.dreamwidth.org/444715.html#comments

Profile

Phoenix
mindstalk
Damien Sullivan
Website

Latest Month

August 2017
S M T W T F S
  12345
6789101112
13141516171819
20212223242526
2728293031  

Tags

Powered by LiveJournal.com
Designed by Lilia Ahner