Thursday, December 22, 2005

Confessions of a Language Bigot

I'm so ashamed. It all started when I was a poor boy and awfully abused...

Ok, well, that's not quite true, at least the second sentence. :-)

Back in 1995, I was exposed to Python for the first time and pretty annoyed by it. Unlike most people significant whitespace was a positive, since it was pointed out curly braces are redundant with whitespace. So I was already specifying my intent once, why would I need to repeat myself. DRY and all that. Ok, I buy that argument.

But really, C had served me quite well for many years, I was quite experienced with it and I could do everything I needed. Sure developing GUIs was kinda painful, but come on, what's really better.

Well, we had to develop over 280 C APIs to implement the highly repetitive, but fairly regular RTCA DO-219. So this guy wrote Python code that generated the C APIs. I had to review the Python code. I wasn't really happy about it.

Ok, there were a few things which I reluctantly had to admit were half decent. I still managed to avoid actually using Python for the duration of my stint at ARINC which lasted until 2000. In the meantime, I learned C++ and used it increasingly. It was fine, better than C in some ways, worse in others. But since it was mostly C-ish, it was okay, I didn't really have let go of the basic syntax. No matter how bad something is, most people prefer a known bad versus an unknown.

In 2000, I wasn't able to achieve the things I wanted at ARINC, so I followed that guy above to a dot bomb in DC. There was this new-fangled technology I'd heard so much about called Java. It was gonna fix all the worlds problems and there would never need to be any other programming language. It would be perfect. It would do everything but give me a blowjob if I believed the hype. (Or maybe I just missed something.)

I was quite eager to learn Java. I wanted to believe the hype. I really wanted to learn just one more language and be done with it. I had already learned BASIC, machine code, Pascal, assembly, C, shell scripting, make, C++ and others I forgot (like Prolog). I can be pretty lazy, but that's the ideal programmer, right? I even have some, um "colorful," constructive lazy solutions lurking in my closet. So if I learned just one more language, I could stop wasting my time learning a language and actually solve problems.

I already mentioned I was working at a dot bomb, so you can imagine what the business was like. OTOH, I had a lot of fun. The first week was great, I had to learn Java and Javascript and create a working web page to submit auction data. Oh, did I mention I didn't know HTML at this point either. It was great to be overwhelmed. The second week slowed down and I jumped into some awful code. It happened to be written in Java, but I can't really blame Java, ugly is ugly straight through. I've since seen even worse Java code that was Pascal, ported to C++ and then ported again to Java.

I learned a lot about Java in the next 9 months--completely lived Java. At the end of the 9 months, I was completely disgusted. The "company" was a joke and the Java hype was about as accurate as saying the Earth is flat. It had a few marginal improvements over C++, but in the hands of well qualified people it seemed to do more harm than good. We mostly used Java 1.1, with a little 1.2 at the end.

I quit the dot bomb and decided to take some time off. I figured that since I had already taken the plunge to learn a new language, I better learn one that could teach me more than Java had. Actually, I learned to ignore the hype, so it wasn't a complete waste. I figured I might as well learn Python finally. It had a few things that really made it much easier than C. Like when I needed to do something like:

    for x in range(100):
        print x,
        for y in range(100):
            print y,
        print

I don't remember the exact code. There was more formatting, but this sort of stuff is much easier in Python (or any scripting language) than in Java or C++.

I wasn't about to work for someone else again after the dot bomb experience. Eric and me had already decided to start our own business. We were both contractors for ARINC, so it was easy to go back to being contractors/consultants. This time we were going to work together rather than as individual hired guns. He was already consulting on a short term gig and I was going to take a break.

The stock market was still doing well and I decided it was fun to watch it. I started a project to pull down stock quotes and track portfolios. I had already decided I was going to really give Python a shot (5 years of hostility was long enough). It seemed like a good match to do the portfolio app in Python.

I think I got about 2 weeks of Python programming and learned some nice features of Python. It wasn't great, but it was usable. And GUI programming in any scripting language beats Motif. Hell, what doesn't beat Motif programming?

Stupid ARINC decides they have a lot of money to spend and we needed to hurry up and get the business up and running. Dammit, I didn't even get a real month of vacation between jobs before I gotta start again! Well, what are you gonna do when they are practically throwing money at you. It's a good problem to have.

So after about 4 weeks of moderate Python use, I decide to write the new product we were contracted to write in Python. This wasn't quite as risky as it sounds. Eric had a bunch of Python experience, so he was my backup. It was only a 3-4 month contract. How much could possibly go wrong?

Heh, don't answer that question!

Actually, the project went very smooth. We hit all the deadlines which was really good since it was a fixed price, fixed schedule contract. There weren't any big gotchas. I learned a lot about Python and really learned its strengths. I was quite impressed.

Towards the end of the contract, I was demoing the system to the customer. I did some simple action like dragging a plane being deiced at one gate to another gate and the whole app crashed! !@#$% (blush). Sorry about that... It really wasn't that big of a deal, just major embarrassment and my own disappointment that I had screwed up. It still wasn't final delivery and everything else went very well.

I later determined the problem was I had moved some code between modules and forgot to copy the import. Based on my enormous embarrassment, I pretty much vowed at that point to fix the problem. If there wasn't a solution, I would create one. Well, there wasn't a solution. I had read what Guido wrote about compiling Python, etc. I didn't care if I could only find the one bug that made the app crash, I was going to write a program to find that problem. Did I mention, not only am I lazy, but I'm also stubborn. I really didn't think you could find many bugs in Python programs. Boy was I wrong.

There have been many other less embarrassing moments that most people don't know about. I suppose it's time for me to come clean about those moments too. People made various requests for adding warnings to pychecker. I often commented to myself or privately to others how stupid that mistake was and it will only find problems in one persons code. I mean, really, who forgets to add the parenthesis when calling a method as in file.close (as opposed to file.close()). And damn if there weren't too many times to count I saw that message come out from my own code!

I spent the next 4 years or so (2001-2005) annoyed at the Java letdown. But I had my Python, I was very happy with it. I still did a lot of work in C and C++. They annoyed me from time to time, but they were still my old friends. I really liked Python and became a developer at the end of 2001 (I think). I got really involved with Python and the Python Software Foundation.

My 5 year cycle hit and it was time for me to move on again. Somehow I wound up at Google. Sometimes I still try to figure out how I got there, but mostly I'm just having a good time and learning tons. Google uses many languages, but primarily they are C++, Java, and Python. There's lot of code in all those languages. There's lots of experts in all those languages. There's lots of bigots emphatically declaring the One True Language. (I'm not implying the experts are the bigots.)

I used to say I don't like Java. I find that isn't even accurate anymore. Java has it's strengths and weaknesses. No different than Python, C, C++, Ruby or any other language that's ever been created. Different strengths and different weaknesses, but every one of them is flawed. Some flaws run deep, others are shallow. There's no shortage of people spouting how some idiosyncrasy is hugely important in the language they don't approve of, while the idiosyncrasies in their own pet language are of no importance.

Languages are just tools. Like all tools, have various intended purposes. Use the best tool for the job. In order to determine which tool to use, it's up to you to base your opinion on prejudice and innuendo. Or to base your opinion on how well a language solves a specific problem.

IMO, the hype that surrounds Ruby (particularly) Rails is overblown. So what? It helps Python in many ways. The more attention one P language gets, helps promote all the P languages. Puby is definitely a P language as long as you read it in Cyrillic. ;-)

All languages annoy me at this point. I wish they were all perfect, but none of them are. I just recently realized one reason I like Python better than Java and C++. I can change Python, I can't change the proprietary/closed languages. This obviously applies to all open source languages.

I've looked at Ruby a couple of times. I've never found it to be much better than Python. I find it to be different in many small ways. That doesn't make it better or worse, just different. People are different, some people will prefer one vs. another. That's ok.

We (the language developers) need to learn more from each other. We could all benefit by working together. I wish we had community run conferences like PyCon that catered only to the language developers. Wouldn't it be great if Perl, PHP, Python, and Ruby (and any other language) developers got together to share war stories, learn about things that worked and things that didn't. I'm not talking about a love-fest. I want to learn from other smart people doing similar things. I don't want to make their mistakes. I want to learn vicariously. I'm sure I won't agree with all their decisions, but if I could understand why they made the trade-offs they did, I can make a better decision.

I fully intend to learn Rails. I have a little experiment I hope to continue. I have been documenting what it takes to setup the same web app up and running and how long it takes. I only went through setting up the databases (Postgres and MySQL) and Rails so far. Hopefully there will be more later in 2006.

One final, unrelated thought. Maybe we should really work to get the syntax for dropping explicit self. I think Guido wants to keep it explicity in the signature. Though I recall either a do statement that allowed not specifying the object (self generally). There's also the seemingly general agreement that .attr (ie, leading dot) should reference self. Maybe we should push for these in 2.5. There is now a critical mass of Python developers with enough time to make this happen.

It's late I wrote way too much. If you read this far, I'm sure it says a lot about you. I'm not sure what, but it must say something! Now I need to do more listening, since that's what this world needs more.