I’ve gotten a fair bit of response to my list of minor complaints with Python. Many of those have been quite helpful, and I’ve learned some good tricks that have definitely made things easier on me. Thank you.

I’ve also gotten a lot of “you need help with switching to dynamic language” responses, however, and those frankly are pissing me off.

To be clear: I’ve been using dynamic languages for more years than I can count with my shoes on. I switched to Python BECAUSE it is a dynamic language, I knew what that meant, and that is what I wanted. The vast majority of the work I do for a living — and have done for a living for a decade now — has been in languages like Perl, PHP, Ruby, JavaScript, and an assortment of other very-much-not-static languages. My issues regarding the type system with Python are not “it uses dynamic typing,” but that it does not offer any optional facility to help with type checking when I do actually need it, which is something that quite a few other dynamic languages manage to offer just fine, thank you.

Let’s take the duck typing example that some dynamic language designers love to use as “proof” that dynamic typing is so awesome in all cases ever. Sure, “if it walks like a duck and quacks like a duck, I’d call it a duck.” That’s fine and dandy. But how the hell do you actually find out of if it quacks like a duck before you try to make it quack? Well, you just try it and then watch exceptions start flying when you try to tell a toaster to quack, apparently. Fun.

I don’t want rigid typing everywhere. I don’t need rigid typing everywhere. I do have some code that simply isn’t going to work if you pass a string, or a number, or None, or a list,
I think the problem here is that there are very, very few languages that have any kind of support for type checking based on arbitrary constraints instead of on rigid types. Java makes you use interfaces. Python just makes you hope and pray. Where the hell is the middle line?

C++0x has a pretty neat feature called Concepts. A Concept is a list of constraints for a type. For example, you might have a Duck Concept that requires that the type have a walk method and a quack method. You can then state that a generic method (which is C++’s way of doing sorta-dynamic typing) parameter must adhere to a particular Concept (or multiple Concepts). So — just like Python — you can pass ANY type you want to such a method without having to inherit from any base class; you never have to tell C++ that the type adheres to the Duck protocol. The language does the Concept tests and figures it out for you. That’s damn handy.

Imagine if in Python you could define a small set of Concepts for your module, or use built-in ones. You can say that method foo takes a “mutable container.” You could pass in a hash, a list, or an object that behaves like a container, just like you already can. If you pass in a string, an int, None, or something else, you get a nice, clear exception that tells you right up front that you passed in the wrong type (and what the right type is) instead of getting some cryptic message about attempting an array operation on some value passed to an inner function called by another function that was called by the actual public API function you originally called in the module. Oh, that would be ever so nice. And, of course, it would be optional.

I mentioned Boo before, and I think it has the right idea for variables. It’s a statically typed language that offers optional dynamic facilities. The static typing stays out of your face so you don’t have to type out huge type specifiers all over the place over and over again. Plus it has a Python-like syntax. If it wasn’t for the political troubles Mono faces with getting into various distributions, I’d probably be using that instead of Boo already.

The general idea with Boo is that, once you define a variable, that variable’s type is also static. So the following code would fail:

foo = 42
foo = “answer”

Once you declare var as an int (implicitly), var is statically typed to int. Seriously, most of the time this just isn’t an issue, because very little code is going to change a variable’s type in a single block. There are exceptions, sure, but they’re pretty darn rare in comparison.

Boo also has a duck typing facility, which allows you to declare a variable as duck (it would have been a little less goofy to call it “mixed” or “var” or something, IMO), which then allows that variable to behave just like you’d expect of any other dynamic language. You can even set Boo to use duck typing by default for variables instead of using type inference, if you so wish.

ECMAScript 4 has the opposite, in which a variable is dynamic by default but can be optionally constrained. (Without type inference, unfortunately.) So you can do:

var foo = “banjo”; // duck typing
var foo as int = 64; // static typing

So, the Python apologists can see that there are plenty of options for dynamic languages to offer static type checking facilities for those cases where it’s just plain useful, while still allowing dynamic behavior elsewhere. To put down my issues with Python purely as “problems adjusting to using a dynamic language” are bunk. Wanting the language to help me enforce the rules I know my software needs is not in any way at odds with dynamic typing. To hear Python folks say that wanting any kind of type checking is “not the Python way” is just as silly to my ears as hearing the PHP folks say that having named function parameters is “not the PHP way.” Yeah. Old versions of the language didn’t have it as the language simply hadn’t matured enough yet, so now you will decide to continue to not have the feature in perpetuity due to some indefinable criteria about “the way” code should be written in the language. If I have to hack around a language’s feature set in order to save myself time or make my code more maintainable, the proper response is not to stammer out apologies or sling accusations about me “doin’ it rong.”

That out of the way, I am again thankful for the help I’ve received. It’s been years since I’ve last used Python for anything substantial and trying to relearn some of the Python peculiarities or the new features that didn’t exist all those years ago has been slower going than I’d have hoped. Thank you!

Forewarning: It’s been years since I last used Python, so I’m very much a “Python n00b” right now. I’m well aware that some of these complaints might entirely just me being an idiot. I would appreciate any comments pointing out said idiocy so I can stop being needlessly annoyed.

Having decided to write Source MUD in Python, I’ve come up with a list of things I find pretty annoying about the language. In no particular order:

  1. Horrendous Documentation

    The Python online manual is just atrocious. The modules are not very well documented, there are far too few examples, and functions don’t actually declare their intended parameters or behavior all too often. Trying to find the proper function to get a job done is hard, and trying to figure out how a particular function is used is even harder. Classes in the standard library are a nightmare to figure out.

    I particularly love the parts of the documentation that include verbiage such as “I can’t be bothered right now to describe…”

  2. Files as Modules

    The Python module system makes organizing code hard. Let’s say I have a dozen or so classes that are all grouped together. I have two choices: I either put them all into one file (e.g. module), or each class goes into a sub-module which somewhat bloats all the code that uses those classes (since I have to type out app.module.submodule.Class instad of app.module.Class).

    Contrast this to Java, which forces one class per file. In that setup, the directories are the module names, and the individual files just mirror the class names. So I can split up a large set of classes into a single module without having unnecessary sub-modules.

    I don’t particularly care for Java’s setup, either, but I find it infinitely better than Python’s. I’d personally prefer something like C++’s, where I the programmer get to explicitly declare modules/namespaces and can freely organize my code however I like.

    This one is really getting on my nerves. The few “too clever” tricks I’ve tried to work around it sadly don’t work. I’m pretty much ready to give up and just start putting all my code into singular huge multi-thousand line files so I don’t have to use stupidly.long.module.names.for.everything.

  3. Classes Are Weak

    Python classes act a lot more like JavaScript’s prototypes, except that they’re not as flexible. I can’t, for example, declare a set of class member variables and default values in the class definition (including documentation). No, instead I have to make a constructor and set all the class members explicitly from that.

    The really annoying part about that is that I can’t make my classes actually mean anything. Since you can just set any member on any class, or freely add or remove methods on any class, and the language can’t do a damn thing to check for simple mistakes (assigning to a misspelled class member name), my code feels really fragile.

    If a variable is set in a class, that actually defines a class variable, not a member. This works out fine for numbers, booleans, and strings, but not so well for hashes, arrays, objects.

    The Python gurus recommend unit testing to make sure code is solid. That’s great. If I wanted to write dozens of lines of boilerplate code in order to make sure stuff worked, I’d have stuck with C++. I want to write less code and be confident in the belief that that code is correct and error free.

    I might be better off with Boo for this particular complaint. I may just end up switching.

    I think to be honest what bothers me most is that the Python way of doing this is not self documenting. I can’t just look at a class and see, at the top, a list of all class members and their default values. I have to look at the __init__ method, which is a bit less clear cut. It moves all the member definitions to the same indentation level as regular method bodies, which makes them stand out less. It also means that member definitions have to have all the extra boilerplate, like the self. in front of the member name. it mixes the member definitions up with any actual initialization logic that __init__ requires. It’s just messy, and makes a class harder to read and understand.

  4. Declarator Inconsistency

    The Python declarator feature is pretty cool. Unfortunately, it’s pointlessly inconsistent. If you want a declarator that has no parameters, you define a simple function. If you want a declarator that takes parameters, however, you must define a function that returns another function. The side effect of this inconsistency is that you end up with two different syntaxes for actually using declarators in the case that you want to call one without any parameters.

    # declarator that takes no parameters
    def dec1(func):
      return func
    
    # declarator that CAN take parameters, but doesn't require them
    def dec2(param=None):
      def actual(func):
        return func
    
    # correct
    @dec1
    def func(): pass
    
    # correct
    @dec2()
    def func(): pass
    
    # correct
    @dec2(param='Test')
    def func(): pass
    
    # incorrect
    @dec1()
    def func(): pass
    
    # incorrect
    @dec2
    def func(): pass
    

    There’s no good reason for that. Both types of declarator should just work the same way.

  5. Variables Aren’t Declared

    I’m not all that interested in static typing of variables (although there are plenty of cases where it’s damn handy). What I am interested in is the need to declare that a variable exists before it can be used.

    Python already kicks up an error when you try to access a variable that hasn’t been defined yet (at runtime, unfortunately), but it will happily let you accidentally create a new variable instead of assigned to the one you intended.

    It’s a really minor complaint, and one that I’m sure a lot of people will disagree about, but I’d really prefer it if I had to declare every variable with a simple “var name = foo” syntax. Likewise, a “const name = foo” would be equally nice.

  6. Unstructured Docstrings

    Alright, sure, I could just decide to do this myself. I do just find it irritating that docstrings don’t enforce any kind of structure, though. It’s really very similar to the idea of Python’s code block structuring requiring indentation: you get better code if you require the code to be well structured. In languages like JavaScript, C, PHP, or Java, it’s not at all uncommon to see novice (or not-so-novice) developers write code with seemingly random indentation. I don’t have a clue how they manage to do that, but they do.

    The same goes with Python’s docstrings. Since they don’t require any kind of special format, they are all too often just worthless bits of text. About as worthless as most code comments (which I’m just as guilty of). I mean, you have to appreciate the silliness of things like:

    def getResults():
      """ Gets the results. """
      return ...
    
    # test if foo is valid
    if foo:
      ...
    

    Really glad that code is documented! It helps so much in understanding what is going on.

    So, I’m sitting here staring at my (quite useless) docstrings, and wondering what I should do with them. Unlike Java, which just uses special comments to document stuff, there isn’t even a standard package for generating good documentation. There’s pydoc, but I can’t for the life of me figure out what the use of that thing is. I think that’s what the official Python documentation is generated with, and you already know my thoughts on that crap.

    I don’t need anything particularly fancy. The bare bones javadoc syntax would be all I really need. Just a way to add a useful description of a function or class, and a way to list out what each parameter is for and what the return value should represent. And a tool to take that and turn it into something pretty to slap up on a website or in README for new developers on the project.

  7. I have a few other complaints, but as those all are being tackled already for Python 3000, I’m not going to bring them up here. No sense complaining about things that are already being fixed,.

License plate tag renewal fee: $54

Late license plate tag renewal fee: $108

Ticket for having expired tags on my plate in East Lansing: $130

Total savings if I hadn’t been a moron and forgotten to renew my tags: $184

Ability to set reminders in Evolution for next year’s renewal date: priceless.

Spent some hours making these. I hope they’re actually legal. :/ The halberd (looks far more like a german poleax, oops) is constructed with 1″ diameter rattan, a styrofoam kickboard, the usual tan pipe insulation, some thinner dark tan (not black) pipe insulation I found, and strapping tape.

The halberd’s head is a bit bigger than I intended. I cut the styrofoam without taking into consideration the width of the padding (I used the light tan stuff for the blade’s edge, and the head spike and butt spike), so the blade came out a bit more gargantuan than I wanted it.

The dark tan padding used on the haft kinda has me worried - it’s not the rubbery black stuff that breaks down uber quick - it’s the exact same material as the light tan padding - but it’s only about 5/8ths as thick. I actually like that fact, but it may not be up to the standards of the game I’m heading to this weekend. Guess I’ll have to find out. It seems to hold up all right and is just about as cushy as the thicker stuff, but I imagine I’ll have to repad it sooner. Granted, the light tan stuff can last well over a year if you aren’t hitting like a retard and store your weapons somewhere acceptable.

The sword is a little atypical in construction too. The hilt is attached a little differently than most, as it’s a single length of padding with a hole cut through the middle edge-wise, and the PVC slide through that. It’s then secured with a healthy amount of strapping tape, similar to how all the bits are attached on the halberd. The blade was then covered completely in the dark tan padding, and then another strip of the dark tan was cut in half and doubled up on the blade edges. This gives the sword a slightly nice shape, although it’s giant and bloated compared to a real sword. The thrusting tip then has some extra light tan padding to give it a slight taper and extra cushion. The pommel is the regular light tan padding construction, albeit attached with strapping tape instead of just duct tape.

I have complete confidence that the sword is safe. The blade edges are actually even cushier than normal boffer swords since the dark tan stuff doubled up is a bit thicker than the light tan padding.

The last year and a half at the old apartment has watched me get really out of shape. One of the niceties of the new apartment is that I am on a concrete slab, so I can actually get my workout equipment here. Unfortunately, I’m not sure my 500 lbs. treadmill can be moved down the stairs and through the doorways realistically. However, the main office does have a gym.

I just tried doing my first set of situps (my new couch gives me something to prop my feet under), and I managed to barely do 44 before my knees and back gave out. 44. Pathetic. I tried to do pushups, and managed to get through 3 before my arms gave out. That’s really pathetic. I only hope that my performance is degraded a bit due to my current severe cold, and that once it’s shaken off I’ll be at least relatively close to what I used to be able to do.

The current plan is to get the Bowflex in my bedroom after I figure out what to do with the piles of books, and then give thought to getting the treadmill in here. If that doesn’t work out, I’ll start using the one at the gym, although I’ll need to figure out what to do about music in that case. I’m also not particularly fond of walking to the office in gym clothes in this weather, so I’d really prefer to get my treadmill in here.

I seriously need to get back in shape. For the first time in 4 years I’ve actually gained weight, and my waist size increased. Most of my super sexy muscles are all but gone, too, so I need to work those back into shape.

I’m in turn going to have to increase my protein intake. The whole “going organic” thing makes that slightly more difficult, as getting my hands on affordable all organic beef is not particularly easy, and I’m not a huge fan of most other sources of protein. (Peanut butter is an exception, but as I said in my last post, I need to seriously cut back my peanut butter consumption, not increase it.)

I’d like to be in “not embarrassed to go to the beach” shape by July. Hopefully between my more reserved diet and working out again, I can get there by then. I don’t have a ton of time, but I’ve once already lost more than twice this amount of weight in less than half the time I have until July, so I’m confident I can do it again.

I’ve never been much of a health nut, but there are a few things I’ve tried to pay attention to. I avoid drinking soda as much as possible, especially anything with corn syrup in it. I buy organic meat (no steroids), and preferably buy the stuff raised the old-fashioned way and not on a large industrialized farm. I drink soymilk instead of regular milk, especially since the doctor recommended that one to me. I eat organic oatmeal. Other than the occasional splurging on fresh organic fruit or a trip to Zingerman’s, that’s about the extend of my organic buying.

A friend who is very big into the organic food and local farming lifestyle has kind of given me a bit more motivation to try harder. After my last shopping spree, I’ve managed to convert about 1/3 of my diet to all organic products without really raising my grocery bill much. I still have a ways to go.

The biggest problem I’m noticing is a lack of pre-made or semi-made foods that are all organic. For example, I can get the ingredients to make some kick-ass pasta sauce (along with all organic wheat pasta) easily enough, but finding a bottle of already made sauce is another thing altogether. I’m lazy. I don’t really know how to cook, and even if I did, I don’t think it would be something I’d do more than once or twice a week. Especially not in this stupid apartment with the neglectful landlord who won’t get rid of the ant problem that makes my kitchen close to unusable.

So, most of the organic food I’ve bought is stuff I can eat with little to no cooking or preparation. That mostly comes down to snacks and light meals, but not the kind of stuff I can really live off. I’d love to see a bigger variety in organic cheeses (the only ones I can find are generally whole wheels that cost a fortune), pre-made sauces and side-dishes, and so on. I’d also like to see a bigger variety in organic and whole-wheat pasta; I can’t find farfelle organic pasta for the life of me, for example.

Assuming I could find such products, I could get my diet up to at least 3/4 organic foods, with the rest of my diet being from restaurants (and several of my favorite restaurants are all organic).

My last major sin in terms of food consumption would then be that I drink bottled water. A lot of bottled water. About 150% to 200% of what the average person goes through. I don’t know why, but my body needs more water than most people. I sweat heavily even in cold weather. My father is the same way. Also, I just can’t freaking stand tap water. I mean, to the point that drinking it actually makes me gag a little. It might be that I was raised on nasty well water and I’ve been conditioned to hate tap water, but I swear even the filtered city water I have now is pretty gross. Now, I don’t believe that bottled water is bad for me (it isn’t), or even that drinking that water is bad for the environment (it isn’t), but the huge number of plastic bottles I go through is enormous. We don’t have recycling collection around here, and even if we did, it’s generally shown that recycling creates more waste due to the energy recycling and collection requires than just throwing the stuff out. I’ve tried a few alternatives to drinking bottled water, including the reusable water jugs that stores like Meijer has, but that water tastes almost as bad as tap water (that’s probably all it is). I wonder what other alternatives are available given that I just will not drink tap water?

My cupboards currently contain a few foods I bought earlier this month that, once consumed, I’ll replace with organics. I’ve got a jar of peanut butter (which, honestly, I need to cut out of my diet - that stuff is going to be the death of me), some farfelle, Kraft Macaroni and Cheese, and some jars of Kroger brand strawberry preserves. Everything else is organic, a lot of stuff is whole-wheat (I haven’t eaten white bread in more years than I can count, except for the occasional baguette), and a few things are possibly even locally grown (most of it isn’t, though).

I’ve also started taking some “all natural” vitamin supplements, as it’s been pointed out to me that my general diet sucks and I’m probably missing all sorts of crap my body needs, which combined with my lack of working out for the last year and half has led to some severely deteriorated health. I’m sick for the second time in less than a month, for example.

Laura also gave me some recipes for some very easy to prepare dishes I might try out once the fucking ant problem is solved. (This might have to result in me threatening legal action for landlord negligence due to failure to correct unsanitary living conditions. Fun.)

More photos of the 20th Annual Custom Bike Show in Birch Run, MI.

Facebook album

Dad’s public Picasa gallery

The show was sponsored by Bubba’s Tri-City Cycles, and the four beautiful models we took way too many pictures of are employees of M/C Leather Works.

We won first place in our class (Manufactured Custom) at the 20th Annual Custom Bike Show in Birch Run, MI. Pretty cool.

Some of the models there agreed to pose on our bike for us, so here’s a picture of the gorgeous Jackie from Leather Works posing on our green Big Bear Choppers Sled Pro custom bike:

Jackie on our Bike
(click for a bigger copy)

So I just got my first real hair cut in 11 years.

Me with short hair

Yeah, it’s all short now. The picture’s lighting sucks, as my apartment’s lighting sucks. What my apartment lacks in lighting it more than makes up for with pharaoh ants (I think, hard to identify a bug that size with eyes like mine and no magnifying glass).

The short hair is kinda throwing me for a loop. I don’t have a ponytail to play with while I think anymore. :(

I’m moving to my new apartment tomorrow, on New Year’s Eve. Fun fun.

Helped my very-soon-to-be ex-roommate buy the various necesseties he’ll need, like dishware and such, since I own pretty much everything in the apartment now. Also picked up some more objects d’art for the new apartment, since I’m going to have an awful lot of wall space to make interesting.