Recently, I wrote a blog post about Python Quality, that got some comments and spurred an offline discussion with David Beazley. (As a side note, he has written one of the best Python books ever in "Essential Python Reference".) One of the things he brought to my attention was an excellent presentation by Robert Martin at RailsConf 09, entitled "What Killed Smalltalk Could Kill Ruby, Too".
You can watch the full presentation here, and I highly recommend that you watch it, perhaps even right now, you can always come back to my blog post. I was nodding my head the whole time, and thoroughly enjoyed the both the message, and the great public speaking by Robert Martin.
The author's main conclusions about how to save Ruby, are directly transferable to "saving" Python. The key word, if there is one, is professionalism. According to Robert, "Professionalism: The disciplined wielding of power". When there is professionalism, these three areas are being addressed:
1. Discipline: specifically in test driven development.
2. Humility: The us versus them attitude.
3. Acceptance of solving the dirty problems.
First, let's dive into his point about Discipline. Ultimately writing quality code, with tests comes down to a "being lazy" problem, or an ignorance problem. If it is an ignorance problem, which is quite prevalent when a language's community grows quickly, then it may be as simple as dealing with, as Jeff Atwood refers, "The Non-Programming Programmer". You can expect 199 out of 200 people applying for a job might be NPP, but there are some ways to deal with that in an effective hiring process (I have a another blog post I am writing that talks about my take on the technical hiring process).
If it is a being lazy, then that is inexcusable. Of course, in general, as a programmer it is good to be lazy, but the right kind of lazy. Robert brings up this analogy, "It is the discipline of the doctor who washes his hands when he leaves one patient and goes to the next". My take on that is if you are employed as a professional Python software developer, then not writing tests is lazy, unprofessional, and unacceptable…period.
He goes on to say some things that other people like Titus and Grig have been saying for a long, long time, I think their faces have actually turned blue a few times too. To avoid making their faces Avatar blue, I will quote Robert this time, "If that batch of tests can be run at a click of a button, how afraid are you to clean up a mess that you found somebody left in the code….Nothing makes a system more flexible then a suite of tests……If you have a terrific design, but not tests, you will still be afraid(to fix bad code)."
Tests are important, and easy ways to run the tests are important. My preferred workflow at this point, is to have Hudson run unit tests, functional tests, test coverage analysis, and code metrics. I have all of this wrapped into a custom test runner I wrote in anger one day, that counts bad metrics as a failure, as well as unit test failure.
The next thing he brings up was humility. This is a very interesting point, and I will directly quote him: "There was an arrogance in the smalltalk community that told them they were better…it was a powerful language and they knew they could work miracles….Our tools are so good, our language is so good, we don't have to follow the rules."
I love this point. Getting past the obvious first stopping point, which is according to the Dunning-Kruger effect, the dumb guys are the most confident, and the smart guys are the most insecure, there are some other interesting things to consider. Writing understandable code is very hard work, and an act of humility and, ultimately, skill. Robert mentioned that Ward Cunnigham's idea of "clean code", was that it was obvious what a function did. This isn't as easy as it sounds. In fact, this is a lot of hard work, even with a language as beautiful, and elegant as Python.
What I see too often in some Python code is trickery, arrogance, and needless complication. For example, useless multiple inheritance, nesting classes inside of functions, "pure" functional programming dogma, or tricks for the sake of tricks. Sometimes these things are warranted, but having the restraint to understand, as Robert puts it, "Powerful tools kill quickly, and in surprising ways, and we are going to be careful.... " Often in a failed or troubled Python project, you will see a lot of code where someone was making a mess by trying to be cute. In a successful project, you will observe where immense effort went into making code that is obvious and understandable.
In addition, arrogance can also come in other forms, such as dogmatic adherence to a library or framework. There are many different libraries and frameworks in Python, one size doesn't fit all, and often it is a matter of saying "It depends…". This is why I wish recruiters were a bit smarter about putting vanilla framework buzzwords in their job postings, because it often encourages the arrogant Python programmer to apply. And in addition, when I ask the companies technical questions, that buzzword framework was used, but is often now a hybrid solution, or has been replaced by something not as buzzword friendly.
Finally, he mentioned acceptance of solving the dirty problems. This is a really interesting, and valid thought. In particular, he mentioned schemas. Having worked on some truly awful schemas, I concur. Any library or framework that expects a greenfield is going to have some big problems in the enterprise. They may be very successful on a new project at an enterprise, but that is why it is important to have diversity in libraries and frameworks and to keep our humility in check. For example, SQLAlchemy, with SQLSoup is a really powerful way to tap right into a scary legacy database and be productive from day one, but it isn't red hot buzz worthy, and is not in all of the San Francisco startup job postings.
In conclusion, Python is a scalable (even for gigantic projects), elegant, powerful, and productive language, but like any powerful tool, it depends on the skill and professionalism of its operators. In the wrong hands, unprofessional developers could use Python to bankrupt a company, just look at the film industry, they are a poster child for unprofessional Python development. I wonder how much money it would take to make a film if the software didn't suck so much and constantly need to be fixed by scores of people working overtime. Hopefully the people at the very top who count the beans will pay attention to the fact that professionalism is the key to profitability with Python.
This is Noah Gift's Coding Blog. I only talk about coding and technical stuff here, including Artificial Intelligence when I can.
Subscribe to:
Post Comments (Atom)

17 comments:
I'm not a python guy but I like the post; the professionalism "should" carry over to any facet of software.
I am curious about the bit you mention on the movies,
"I wonder how much money it would take to make a film if the software didn't suck so much and constantly need to be fixed by scores of people working overtime."
Can you elaborate? I'm not a movie-software guy either :)
Great post. I see these points being abused mainly by the ruby community at large much more so than python. However, I think these points are valid for any software eng. project. We barely write test for our app in java (not my doing), and it kicks us in the ass. The same goes for dogmatic adherence to a framework, previous devs did this with hibernate and Flex, and it cost us ample amounts of time fixing legacy code that was purely written because it was the prescribed way to fix the problem and also the most inefficient way.
BTW, Which software in the film industry are you referring to?
Great post. I think these points are valid for any software eng. project. I have seen java devs not write tests and it kicks them in the ass later. The same goes for dogmatic adherence to a framework. There was some hibernate/spring code that was written purely because it was the prescribed way to fix the problem with the framework (the end result was we went back to JDBCTemplate instead of relying on some horrendous ORM generated SQL).
BTW, Which software in the film industry are you referring to?
Good article! Just curious about this statement:
...just look at the film industry, they are a poster child for unprofessional Python development..
Can you expand on this or give some examples?
@Chris Carter,@ryan.fairchild@Valds,
In the film industry there is a fundamental lack of understanding about software quality and how truly expensive it is. What happens is a lot of people who can't really program, often called Technical Directors, write bad code without tests.
This "temporary" code, turns into production code, which then turns into catastrophic failure. In turn this often triggers emergency fire fighting which costs studios a lot of money in down time and overtime.
In addition, even some of the more software development oriented departments don't care about software quality. It is a rampant problem in film, and one of the reasons I am switching industries :)
@Noah Gift - That just doesn't happen in film...That happens everywhere :)
@Valds: I agree, I have worked in several industries as a software developer. This difference is in other industries the lack of quality is by accident. In film, it is by design.
Sorry it is tough to elaborate without another huge blog post, which I may do on that topic soon.
This reminds me of how a smart kid can often end up in trouble in college; up until then the kid was always smart enough to breeze by through high school without much work, still getting good grades. Then things actually start getting hard and being smart isn't enough, you have to be smart and also work hard and show real dedication.
Languages at the cutting edge (be it Python or Ruby or I'm sure Smalltalk and Lisp at other times) give this false sense of success: a younger programmer can easily outperform their other young peers, but in fact they are all performing rather poorly (at least in terms of quality) but it can be hard to tell the difference between performing best and performing well.
@ian bicking
Wow, Ian that is a great analogy, plus, I am ashamed to admit, this is how my first two years of college were.
This is a lot of what is going on I suspect too. What I learned in college, fortunately, was as smart as I thought I was, I had to work, hard....period. The same goes for using a powerful language, sure it is "smarter", but you won't get anywhere without hard work. In fact the "dumb" guys will dance circles around you if your lazy.
I have to add that dedication and professionalism has to be taught, or at least shown.
I had the chance to open my eyes and grab a great opportunity to learn from a great Python developer when everybody else thought this person was 'just another dev at the office'.
If you do not have that kind of guidance, at least for even a little while, then I have to say it is really really hard for someone to be as professional as we expect.
There is a contractor that works for me a few hours per week and he was avoiding writing tests like the plague.
This was my 2 cents on his future professionalism:
"If you do not write tests I will not answer ANY questions about Python or code at all. Show me your tests and show them passing. Then we can talk."
Nice post.
I think professionalism is the discipline to define and follow a set of policies which direct your process. It's also knowing when to break from discipline and still deliver a quality product.
However, I don't find the lack of professionalism coming from "lazy" people so to speak (everyone is lazy as far as I'm concerned). I think there are a great many developers out there who are pretty good at what they do and are just ignorant. They're the people who learned how to build websites and apps from tutorials and books. After building a few of their own, they went out and got a job. The thing is, their employer is the one to blame: all too often the employer doesn't care how the work is done as long as they get their website. This green developer just has to get it done even if they work hours and hours of overtime and end up producing a horrible monstrosity. As long as a paycheque lands in their hands, they have no reason to evaluate their processes and find the real discipline required to be a professional. The companies are encouraging these "lazy" developers by hiring them in the first place.
FWIW I strongly prefer the term "craftsmanship" to "professionalism" for this general idea. This isn't about being polite, or respectful, or even attentive; it actually involves the deliberate learning of the craft.
I was going to say that you can be an antisocial slob and still know your craft, even though you might not be professional. But... when I think of those people I don't think they are usually very good at their craft either. It also requires a respect for your coworkers, and a process that simply includes the programmer. You can be quirky or unpresentable or terrible at sales and still be good, but you can't be antisocial and you have to care what other people think and you have to respect other people's time and effort and contributions.
FWIW, I've been programming in the film industry for 10+ years now, and I have to say that Noah is pretty much right (disclaimer--we work together). I think the main reason software quality is at best an afterthought in this industry is that software is not the product. The product is images.
Software is what artists use to make the images. To make things worse, each film project is separately budgeted and managed by producers, with very little input from the technical side. Larger studios have a CTO and an IT/software development team, but even with that, the industry rewards "miracle workers" that produce quick solutions (often in just appearance), and ignores or even punishes "slow and steady" people/methodologies. There are few filters or couterbalancing mechanisms for bad code.
The consequences are almost always the same: software infrastructure gets way too complex, and becomes progressively more difficult and expensive to maintain. Yet, the productions just absorb the costs, while appearing to control costs by capping the number of IT personnel no matter how big the productions scale. As it happens there are many other factors that drive up film production costs and software badness is usually dwarfed by these other factors, so there is little incentive to promote best practices for software quality.
That being said, I think other industries are just as susceptible to ensuring bad quality software for similar or different reasons.
There is more to say about programming in this industry that I'll leave for a future post (like, software disasters that were actually made worse or even caused by rigid adherence to misapplied best practices).
@ian
I agree with the word "craftsmanship", as a possible substitute, although I think professionalism and craftsmanship can be slightly different.
In fact, this is going to be a part of another blog post I am doing next about employment interviewing processes for Python developers.
With all due respect, I strongly disagree with the word "craftmanship" as a possible substitute for "professionalism". They project very different qualities. Both can be extremely valuable, but professionalism emphasizes discipline while craftsmanship emphasizes perfectionism and individuality. Another way to put it: Professionalism emphasizes software-as-engineering while craftsmanship emphasizes software-as-an-art.
I would go so far as to say that the most vehement proponents of professionalism (particularly those who would push TDD "come hell or high water") are software engineers (or at least have engineering leanings), and are working hard to fight the placement of craftsmanship at the top of the value ladder.
Most programmers are, by nature, craftsmen (I include myself in that group). Languages like Smalltalk, Ruby, and Python are very seductive for craftsmen. I think the point of Robert Martin's RubyConf talk was that Smalltalk succumbed to a craftsmanship culture, and lacked sufficient professionalism. Ruby (and to an extent Python) flirt dangerously with the same path, and he is exhorting us not to let it happen.
Can we see some of this Python trickery? Part of why I like Python so well is that it seems to be trickery-resistant and mostly tamper-proof. I hope to learn something about this that I can use to horrify and astonish my friends!
@writeonly: I'm only beginning to Python programming coming from a Java background for 8 years. I should say there are many 'pitfalls' or 'gotchas' of Python that may be suprising for the newcomers. But when I've completed my first draft Python program, a viewshed analysis plugin for QGis, I saw that these gotchas almost never catch you in a real sense and the programming is a delightful breeze.
I've tried to write my opinions in 'Just What is Python?'. Search for 'pitfalls' and there is a link for them.
On the post's subject, I have to say professionalism is inherently lacking in the industry. Part of the reason is that we, software developers, see the end product as the only deliverable and try to put all our professionalism, craftmanship, and smartness in there, in the final product, never caring about the process it is created.
During my work in the past as a ISO9001 QMS consultant, I've learned to appreciate the value of processes over final products. Products are just part of the 'System Engineering' processes. Testing, documenting, management etc. are the other parts and should be given equal if not more importance.
Post a Comment