Solving “accidents” and “essences” of programming with better languages

Note: this post was written in January 2007, but it has stood the test of time.

The programmer, like the poet, works only slightly removed from pure thought-stuff. He builds castles in the air, from air, creating by exertion of the imagination.

Few media of creation are so flexible, so easy to polish and rework, so readily capable of realizing grand conceptual structures. Yet the program construct, unlike the poet’s words, is real in the sense that it moves and works, producing visible outputs separate from the construct itself. It prints results, draws pictures, produces sounds, moves arms. The magic of myth and legend has come true in our time. One types the correct incantation on a keyboard, and a display screen comes to life, showing things that never were nor could be.

… The computer resembles the magic of legend in this respect, too. If one character, one pause, of the incantation is not strictly in proper form, the magic doesn’t work. Human beings are not accustomed to being perfect, and few areas of human activity demand it. Adjusting to the requirement for perfection is, I think, the most difficult part of learning to program.

Frederick Brooks, author of the The Mythical Man-Month, distinguished between two problems in software development: the accidental problems and the essential ones. You can read Brooks’ watershed article on this topic, “No Silver Bullet”, freely available online in HTML or PDF, or as part of his book.

Those in the industry like to argue that we have made huge leaps in terms of the “accidental” problems in recent years. Programmer productivity is better with the help of better software revision systems, but more importantly there are RAD tools, like user interface builders and powerful IDEs, like Eclipse and Visual Studio. Do I think we’re headed in the right direction?

In a sense. I think those tools are useful, but only because I think all we can do is shrink the accidental problem as small as possible, and then do our best to tackle the essential. The major win in terms of the accidental and even the essential is high-level programming, and I mean really high level, like Python.

Why is this important? Well, Brooks once talked about how PL/I was a great software engineering language because the statements written to the compiler are “pretty close” to the “thought stuff” the programmer is working with in his head. But PL/I is nowhere near there (neither is C++, or even Java or C#). However, Python heads in that direction.

In my head, unless I really am immersed in C code all the time, I don’t think of things like types, memory management, or, God, pointer arithmetic. When we solve problems, we solve it in something computer scientists have used for years: pseudocode. Pseudocode is nothing more than code that expresses an algorithm or approach without worrying about the gory details of the underlying hardware.

Python isn’t quite pseudocode, but it’s closer than anything else I’ve seen. And that’s a huge help to productivity not just from the point of view of the single developer, but, I’d argue, also from the point of view of a team of developers. Code readability is hugely important in team environments. C and Perl can be very unreadable, which makes them ill-suited to team development. Java and C++ are better, but even they suffer from some readability problems, where the actual solutions can be masked by “best practices” and strange ways of exploiting constructs of the language. Python can be hacked too, but it tends not to be, and it tends to have very high readability.

But what about the tools mentioned above (Eclipse & Visual Studio)? I often wondered about all the *nix programmers (including many of my past Computer Science professors) who still load up terminal with vim or emacs for their programming needs. Wouldn’t they benefit from the latest and greatest in IntelliSense, Refactoring, CallTips, SaneOnlineDocumentation, and any other CamelCase ideas I can think of for a development environment?

Well, most *nix users would say that stuff is unnecessary–and in many senses, they are right. The essential problem remains, no matter how fancy your IDE.

A lot of *nix developers shrink their accidental problem on a “as-needed” basis, by coding scripts or plugins or configurations for their highly-extensible text editors. Or incorporating tooling that is freely available online in the wider F/OSS community.

But nowadays, productivity is starting to be a concern even in the F/OSS world, where users have traditionally stuck with the old “mortar and pestle,” or, should I say, “gcc and gdb”.

But Python offers a nice, alternative path, I think. The accidental problem is worth shrinking. But I think it can be done simply by one major refocus:

(1) make the language usable, not the tool. IMO, this is already done with a high-level language like Python.

…and…

(2) create source code analyzing tools that integrate with development environments to make the language-bearer more productive.

You can see enormous success in (2) with the Eclipse IDE project for Java programmers. My main problem: Eclipse’s focus is on a language that isn’t very usable, that is, Java. Java is certainly better than C, but still, it has significant problems that stop it from connecting me (the programmer) with my problem-solving ideas — that is, the “thought-stuff” of programming, as Brooks called it, above.

At my new job, I work with Java eight hours a day, but my code just doesn’t read and work like my Python code, which is much closer to the underlying algorithms and approaches. Java certainly pushed forward OOP on the masses of computer programmers, but it did so without incorporating other non-OOP concepts, whether from the dynamic language, scripting language, or functional language traditions. One simple example: having Lists and Hashes as built-in types, with tons of syntactic sugar, for crying out loud! Most problems break down to List and Hash problems, after all.

What’s more, programmers have learned that OOP, per se, is no panacea. I’ve seen many convoluted OOP designs that I wish were written functionally, or even just procedurally, and which might have been more performant (and more comprehensible) if they had been written in a non-OOP style.

As the Python community says, “Practicality beats purity”. The “legacy” OOP software engineering community thinks that there will be a silver bullet (OOP! AOP! XP! MDE!). But: I think just getting programmers closer to the “thought-stuff” — via high-level languages like Python, and lightweight tooling around the editor and the command line — will be an effort with better rewards.


Update from the future in June 2020, 13 years later: I was right. I’ve incorporated all my years of experience writing professional Python into The Elements of Python Style, which you can read online. If you’re still stuck in a programming language like Java, C#, or C++ which is far away from the “essential”, you’re well advised to check out my Idiomatic Python Resources compendium. I personally can’t believe just how successful Python has become in the intervening 13 years. Its massive success surprised all of us, the early champions and fans, included. And I don’t personally miss my RAD tools one bit. I only ever open an IDE when working with Java code, specifically, IntelliJ. But for every other language, vim and the “UNIX IDE” suffices. Plus, with projects like VS Code, Onivim 2, Language Server Protocol (aka langserver, LSP), and Jupyter, you can “have your cake and eat it, too”. Also: Brooks was right. Despite the tooling improvements (most notably, cloud computing), the essential problem of programming remains.

Free and DRM-Free E-Books

I got a Nokia 770 for Christmas, to replace my aging and dying Palm V. I’ll probably write more about the 770 and the Palm V later, but suffice it to say that I got the Palm V when it came out, approximately 10 years ago, and have used it ever since. My main uses for it were AvantGo and Vindigo, although in the past I did get other uses out of it as well. I plan to keep the Palm around mainly for the Vindigo features, which I haven’t seen done better anywhere else. (No book on the planet has as much information about NYC as my 8MB Palm V with Vindigo loaded on it.)

I basically got the 770 because of all the great stuff I heard on Teleread and other sites about its use as a portable e-book reader. Indeed, that has been the most pleasant experience on the device. With the Evince PDF viewer and with FBReader (an Open Source ebook reader for a lot of different formats, including HTML, Plucker, and zTxt), I am able to read a ton of stuff while I’m in my commute, and all on a beautiful 800×480 screen that fits in the palm of my hand. (Yes, finally I get to read with serif, anti-aliased fonts!)

I have been overwhelmed with how many free e-books you can find online, thanks in part to efforts by groups like Creative Commons. Here are some good ones:

Feel free to post more in comments!

The Three-Way Division of Web Development Labor

There is a great article posted by a developer of the open source FreeMarker project on a proposed “third” role for web development teams — something between a backend application developer and a frontend web designer.

Check it out.

I have to say, so much of this article rang true for me. I just finished a web application in which we had four developers but two main rules: backend developer and frontend designer/developer. Due to the type of project it was (and the skillsets of the people involved), backend work was done by 3 of the 4 team members, and frontend work was done by a sole designer.

The issues we had were that:

  • The backend developers could only make guarantees about what kind of object to pass to the view. But often, in order to get access to other “global” objects, the frontend designer would have to hack controller code as well. (Luckily, data services were tiered off out of the controllers, so at least the designer didn’t have to muck about with SQL.)
  • The designer hated the idea of pushing some logic “back” into application code. So, though we as backend developers proposed a layer for configuring things like which menus to display on each page, etc., the frontend designer preferred to engage in the copy-paste-modify antipattern instead, so that it could just “get done.” I can see why: it’s a pain to context switch from JSPs, HTML and CSS to Java POJOs that then will have to be checked using JSTL anyway!

If, early on, we had decided to use FreeMarker instead of JSTL, perhaps the frontend designer could have had access to more powerful macros, and wouldn’t have done the copy/pasting. But I think overall, the two tiers are too few; I agree that you need someone to sit in between and think about how to cleanly integrate backend logic and frontend design.

Linux Desktop Talk at NYU

I gave another talk for CANYU and the emerging open source clubs at NYU about Linux on the desktop. Here is the synopsis:

LINUX AND FREE/OPEN SOURCE SOFTWARE

The State of the F/OSS World Update
with talk/demo by Andrew Montalenti

December 5, 2006 @ 7pm
Room 813, Warren Weaver Hall

Open source software is now mainstream. Whether it’s the nearly ubiquitous Mozilla Firefox browser, the Azureus peer-to-peer client, the Eclipse IDE, or the Linux kernel, almost everything in the computer world has been touched by free / open source software developers collaborating across the globe.

Judging by the state of the community, this movement doesn’t seem to be losing steam. With Microsoft Windows Vista around the corner offering a potentially bloated and hardware-requirements-heavy experience, desktop Linux operating systems are taking aim at the big giant, with big support around Ubuntu, Fedora (Redhat), and SuSE (Novell), among others.

So, what’s next for the free / open source world? That’s what this talk is meant to help you find out. After explaining a bit of the history of free and open source software, and the history of recent community and corporate efforts to make it widely available, this talk will show off some of the new, cool technologies coming out of the open source community, such as 3D desktop effects, productivity tools, enhanced multimedia support, better support for laptops, and a full suite of industry-grade development tools. The talk will also discuss some of the legal and intellectual property issues facing the open source community, with a particular focus on the recent news coming from the Novell / Microsoft deal and Sun’s decision to open source Java.

Who is this talk meant for? Anyone who hasn’t tried out Linux on their desktop, or anyone who is at least mildly interested in the current and future state of the computer industry. Free / Open Source software has completely rocked the industry, changing every aspect of it from top to bottom, and this wave is only growing bigger every day. NYU students interested in copyright issues surrounding open source may also find this talk valuable.

In any event, this won’t be a boring lecture — it’s meant to be interactive and fun!

The speaker will be bringing free CDs of Ubuntu Linux, a community-driven desktop Linux operating system which you can install on almost any home PC! Come for the free CDs, stay for the revolution.

It went very well, with about 10 people in the audience. You can download the slides in OpenOffice or PDF. Admittedly, the slides aren’t as cool without the live demo of Beryl I did at the talk itself. Yay 3D desktop effects.

Taming spam with spamassassin and evolution

I’ve found the anti-spam support on Linux to be pretty poor overall. Considering how common this problem is and how ingenious OSS guys usually are, I’m a bit surprised.

I am trying to use Evolution with SpamAssassin, and finding horrible slowness and bugs in the bayes_* databases to be the norm.

If you are attempting this setup, I recommend the following hacks:

  1. Do not use bayesian autolearning in spam assassin, as this is a broken way to update your spam filters.
  2. Instead, create a JUNK and HAM directory in Evolution, and move your junk mails and ham mails there.
  3. If you have already tagged mails as Junk using Evo’s “Mark as Junk” feature, you need to hack these mails out of that folder and move them into a regular Evolution folder. “Mark as Junk” is really not moving mail anywhere, but just “tagging” it, and then the Junk folder is like a vfolder which searches for all mail tagged as junk. This is cool, but sucks if you want to run sa-learn on your mbox in order to train spamassassin. The way to get around it is to create a mail filter in Evo which says: “if mail is marked as junk, then mark it as not junk AND move it it to folder named JUNK.” Then you apply the filter to your Junk directory and Evo will copy them out. (Note: if you try to merely “copy” the mail messages to another folder, they will simply not move — again, Junk is a “tag” in evo, not a location).
  4. Now from the shell, go to .evolution/mail/local and find your mbox for your mail. You can use sa-learn –spam –progress –mbox to learn it as a spam, and change –spam to –ham for ham.

This is much better than using the built-in Evo stuff. Do this every few weeks until you don’t have to anymore.

The Flight of Computer Science majors

I read this response to an article at eWeek on Bill Gates’ views about Computer Science research, graduates, spending, and company strategies.

I think it’s pretty clear that despite the disagreements I have with Mr. Gates over a subject known as “business ethics” (if such a subject truly exists!), he does seem to be a genuinely patriotic guy who loves technology. I mean, what good is it for more Americans to get into CS, if other countries are diving in and filling whatever knowledge gap may exist? Can’t Bill just hire those workers, and what’s more, for less money per hour?

Well, I think Mr. Gates really wants innovation in computer software to remain “America’s Great Industry.”

I was very intrigued by this response to the article:

Everyone knows that Open Source is taking over the software development industry. And according to the Open Source philosophy; developers should be enslaved, source code should be free. No, no, that’s not politically correct, let me try again. Developers should give their work away because code needs to be free (as in speech) and the needs of the code is more important than the needs of the people who create it. Well, that doesn’t sound quite right either but in any case, it doesn’t really matter to me because my kids won’t be studying computer science.

This is a very interesting post. True, it will be seen as a troll by some, since open source philosophy definitely doesn’t say anything about programmer enslavement. But his point is real and felt in the industry. That is, if you aren’t selling software, how are software developers to make money from it?

I think the response to this was best-articulated by Eric Raymond, when he pointed out that of programmers, only about 1-2% make their cash from off-the-shelf software sales. Instead, most make their money from “in-house” or “custom” software solutions. In other words, the majority of developers aren’t working on the Adobe Photoshop team, they’re working on Acme Inc.’s payroll or issue tracking system.

I kind of love this sort of propaganda, though. Because it is all good news for me.

When I first decided to do CS, I considered the possible effect of outsourcing and other factors on my employment possibilities. I thought, what if there are no jobs when I get out of college? But I stuck with it.

Well, it turns out, everyone had a hunch similar to mine, but they were more wooed by it than I was. So everyone fled CS. And now I’m the only one left. (An exaggeration, but you get what I mean — my computer science classes are nearly empty, whereas they were packed during registration only a few years ago).

It turns out, firms are hiring more than ever before. Why? Because the dotcom bubble is over, and green-eyed imposters are getting flushed out of the industry. But the demand is still there. Software is pervasive. Everyone needs software development done. There simply isn’t anything under the sun that can’t benefit from a little software developer finesse.

You can’t have all this work done in India and China because, it turns out, people want software developers to work with customers (big surprise). They want applications which meet their sensibilities, and they want them changes when the environment changes.

I liked that Mr. Gates said the #1 thing he’s looking for is project management IT types. Funny, it’s the #1 thing I’m looking for, too. Software developers are a dime a dozen. Find me a software developer who doesn’t get nervous when you ask him a tough question, or ask him to write, in plain English, a high-level overview of the system you’re asking him to create, and you’ve got yourself someone who’s valuable.

Changing the tools you use

Mark Shuttleworth has written a nice little blog post about the tools we learn through life and how we discard old tools and learn new ones.

I personally find this to be very true in my life.

When I was in high school, I prided myself (from the point of view of “tools”) as knowing graphic design (Photoshop/Illustrator), web development, and print/page layout. Handy tools to know for (1) making money and (2) working on a high school newspaper. The only real programming languages I knew back then were Actionscript (for Flash), JavaScript, and (eegads) Perl. Then I got to college and armed myself with algorithms, data structures, and systems, and started picking up Java and C on my own. Now I consider myself well-versed in those, and this past summer learned Python and used that on a lot of different projects. Then this semester I got interested in C++ and used that a lot. Nowadays, when I look at problems, I look at them in terms of my tools. Text parsing problem? Wow, Python’s re (regular expressions) module could handle that pretty easily. Big engineering project? Wow, using templates and OO features in C++ may lead to a nice design. Database-driven web application? Well, Java/JSP may fit you nicely. (I know, I know, what am I doing not knowing Ruby on Rails!)

I think Mark’s onto something. Changing toolsets often is definitely useful. Even though I couldn’t write full programs for you in Perl nowadays, what I do know about it (its limitations, capabilities) is definitely good enough to see when it may be the best choice for the job.

As for academic tools — very true. A lot of techniques I learned in e.g. Discrete Math, Linear Algebra were in one ear and out the other. Alas, I think the main point is to learn them once and then be able to Wikipedia them later, when needed 😉

That said, stuff I learned in my algorithms and data structures and operating systems courses have stayed with me. I think some of that stuff is just essential.

Calculus Made Easy

I am taking “remedial” Calculus II alongside Numerical Computing this semester. My Calc course is “remedial” in that I haven’t seen any Math over the reals for about 4 years (took Discrete Math and Linear Algebra, which both focus on integers) and this semester I am overloading on real numbers (and even complex numbers) just when I had forgotten they even existed 🙂

That said, after spending some time in the humanities (where writing quality is high) and much time in Computer Science (where literacy is defined as being able to read code), coming back to traditional math textbooks has been quite a culture shock. They are so horribly written, it really blows my mind.

So, in response to my horrible Calculus II textbook (published at NYU only for NYU classes, this book features minimal explanation and the maximum amount of notation), I have been using it only for the homework problems and using instead James Stewart’s excellent book, Calculus: Early Transcendentals for rigorous proofs of concepts (because Stewart really does present them nicely), and the lighter but infinitely more illuminating Calculus Made Easy, by Silvanus Thompson.

A somewhat controversial book, Calculus Made Easy chooses to skip the notation-laden explanations of Calculus concepts provided by typical textbooks, and opts instead of a clear, textual elucidation of core concepts in the context of their applications. The philosophy of the book is well-described by this excerpt from the Epilogue.

I think this is wonderful writing, however damning it may be:

It may be confidently assumed that when this tractate Calculus Made Easy falls into the hands of the professional mathematicians, they will (if not too lazy) rise up as one man, and damn it as being a thoroughly bad book. Of that there can be, from their point of view, no possible manner of doubt whatever. It commits several most grievous and deplorable errors.

First, it shows how ridiculously easy most of the operations of the calculus really are.

Secondly, it gives away so many trade secrets. By showing you that what one fool can do, other fools can do also, it lets you see that these mathematical swells, who pride themselves on having mastered such an awfully difficult subject as the calculus, have no such great reason to be puffed up. They like you to think how terribly difficult it is, and don’t want that superstition to be rudely dissipated.

Thirdly, among the dreadful things they will say about “So Easy” is this: that there is an utter failure on the part of the author to demonstrate with rigid and satisfactory completeness the validity of sundry methods which he has presented in simple fashion, and has even dared to use in solving problems! But why should he not? You don’t forbid the use of a watch to every person who does not know how to make one? You don’t object to the musician playing on a violin that he has not himself constructed. You don’t teach the rules of syntax to children until they have already become fluent in the use of speech. It would be equally absurd to require general rigid demonstrations to be expounded to beginners of the calculus.

One thing will the professed mathematicians say about this thoroughly bad and vicious book: that the reason why it is so easy is because the author has left out all the things that are really difficult. And the ghastly fact about this accusation is that — it is true! That is, indeed, why the book has been written — written for the legion of innocents who have hitherto been deterred from acquiring elements of the calculus by the stupid way in which its teaching is almost always presented.

I should note that my Calculus professor is actually quite good, and provides very nice explanations of complex topics, usually beginning with an elucidation of the general idea, and then going on to the formalities. But our assigned textbook is not nearly as clear, and many professors I’ve had in the past have lived entirely inside their constructed notational apparatus.

This reminds me of an old joke I heard awhile back:

A math professor begins his lecture by writing on the blackboard. He only pauses for brief moments of notational explanation, but continues writing and writing, one symbol after the other, for thirty minutes on end. He fills up six blackboards full of derivation, algebraic manipulation, and what have you. At the end, he smiles and draws the open box, indicating the completion of the proof. “Is that clear?” the professor asks. Blank stares all around.

At that point, the professor stops himself. “Oh, no, I believe I’ve made a mistake.” He then looks at the six boards of writing, and begins pointing at certain sections while nodding his head, clearly doing calculations internally. He then paces back and forth across the front of the classroom, with his head bent down and his fist to his chin. For five full minutes, he paces and nods, thinking about the proof just presented.

Then he stops pacing, looks at the students, and says, “Ah, yes, yes. It’s clear.”

Here’s an interesting read, by the way. Came as especially relevant to me, as I “rediscover” math for math’s sake.

Using C++ instead of GObject/C

There’s a great post on why to use C++ instead of GObject/C over at BMP CodeBlog, the blog for developers of beep media player (my preferred MP3 player on Linux). I have to agree with most of what the author says. Using GObject/C is quite cumbersome, I’m almost surprised so many GTK+ developers do it. Especially considering the fact that C++ doesn’t incur overhead unless it has to, nicely expressed here:

The ultimate feature is that all of these are optional. We incur no overhead when we do not use a language feature (with the exception of… exceptions). In fact, cxx_conversion is currently in perfectly valid C++ and uses none of the features or C++ libraries mentioned above yet. The C++ language follows the philosophy of ‘pay for you use’ (better rephrased as ‘don’t pay for what you don’t use’). As it is right now, cxx_conversion is no less (or more) CPU or memory efficient than its C original.

GTKMM keeps getting more and more mature, so now that I’m finally learning C++ properly, I think moving over to GTKMM will be quite nice for a future project that needs a cross-platform UI.