Mostrando entradas con la etiqueta programming. Mostrar todas las entradas
Mostrando entradas con la etiqueta programming. Mostrar todas las entradas

martes, 29 de julio de 2008

Great description of a programmer mesmerized by his activity.

Sorry for the long quote, but I think this ought to be one of the best descriptions of a programmer (Ethan Levin, the main character in the novel) mesmerized by his programming work:
He was running the compiler when the bug report came across his desk. The compiler, the program that translates a programmer's code into machine-readable bits —Ethan Levin had laid his code before its merciless gaze, and now he stared into his screen to see its verdit. Was he aware of the tester passing behind him? Did he take any notice of how carefully she slipped between his whiteboard and his chair, holding in her stomach so as not even to brush against him? No, of course not. Oh, all right: perhaps peripherally. Literally in his peripheral vision he might have seen her, and the thought "tester" might have formed in his brain, which would have led to the automatically accompanying idea that testers only bring news of trouble, and so why bother with whatever trouble she was bringing him now?

He was occupied by other troubles. Warning messages were scrolling up his screen, the compiler's responses, notices that this and that little thing in his code might not be legal, might not parse according to the rules, might prevent the compiler from turning his routine into an "object file," a little file full of ones and zeros, ready to be linked up with other object files to create the executable program. He wasn't getting fatal errors —no, not on this pass. There was nothing yet that caused the compiler to issue the awful message that began "Fatal error" and then, abruptly, stop. But such fatalities had already befallen him many times this morning, how many times, he'd lost track —twenty, fifty, a hundred? On each occasion, he had fixed whatever little thing wasn't legal, didn't parse, prevented his code from becoming machine-readable bits; and then he ran the compiler again.

Warning. Warning. Warning. Fatal error. Stop.

Fix the little thing in the code that wasn't legal. Run the compiler again.

Warning. Warning. Fatal error. Stop.

Fix the next little thing.

Warning. Warning.

"It'll compile this time" was the only thought Ethan Levin kept steadily in mind, over and over, on that morning of March 5, 1984. Even the phone had to go on ringing —once, twice, three times— until it reached him, three rings to get inside his window of attention so tuned to the nervous refresh rate of the screen: Warning. Warning.

"What! Are you still there?" said the voice on the phone. "You're supposed to be here!"

He sat confused for a moment. Yes, he knew the voice was Joanna's, but the words "there" and "here": What exactly did they mean? Then, all at once, his attention snapped into focus: It was Joanna, he was supposed to take her to the airport, and he was late.

"I'm leaving!", he said.

"I mean now. Are you leaving now?"

"I'm leaving, I'm leaving," he said again, but vacantly, automatically, because despite himself, his eyes had been drawn back to the screen, to the irregular pulse of the messages as they appeared: Warning. Warning.

"Hello? Are you there?"

"Yeah, yeah. I'm here," he said, jusr as the compiler suddenly displayed the message "Fatal error: MAXWINSIZE not defined," and came to a stop.

"Shit!" Ethan Levin muttered under his breath.

"Ethan! You're compiling! I know it!"

"Yeah, yeah, sorry," he said to Joanna McCarty, who, as his girlfriend of four years, knew all too well the sort of exclamations he made when he was programming and compiling. "Sorry," he repeated, but again automatically, because —though he knew better than to do this now— his mind immediately began ranging over the places where MAXWINSIZE should have been defined. On one side of his attention was Joanna, the month-long trip to India she was taking with Paul Ostrick, husband of her best friend, Marsha Ostrick, and the promise Ethan had made to take them to the airport —and be on time! he swore! But on the other was his sudden and unexpected problem of MAXWINSIZE, this branching trail of questions that led off in many directions, curious and puzzling, down which his mind involuntarily started traveling...

"It's an airplane, Ethan! It's not going to wait for a compile!"

"Shit! Yes! I'm leaving now."

"That's like now now, right? Not like a one-more-compile now?"

"Now now," he repeated, as much to himself as to Joanna. "Now now."

Still, even after he'd stood up and grabbed his jacket from the back of his chair, the face of the screen drew him back. He sat down again, reread the messages on the monitor, typed a command to the system that set it searching the entire code library for all occurrences of MAXWINSIZE. Yes, much better now. The system would tell him where the problem was. Then, tomorrow, he'd fix it.

(Ullman: pp. 17-19)

Who hasn't experienced something like this? Programming, unlike many other human activities —especially the ones we do while at work—, does have that extraordinary ability to suck you in. Viewing the code, writing it, compiling it, testing it, you lose track of time, forget whether it's daytime or nightime, and quite often even disregard basic human needs, such as eating too. The only other activity I can think of that's similar in this respect is any artistic endeavor. It shouldn't surprise us then that so many people speak of programming as an art.

jueves, 24 de julio de 2008

The bridge-building metaphor.

So much talk throughout the eons about how software development ought to be "like building bridges", and it turned out that perhaps it is far closer than we ever thought although not in the way we always intended:
Somewhere, someone's fist is pounding the table again. Why can't we build software the way we build bridges?

Well, maybe we already do.

As OSAF's programmers labored to construct their tower of code, piling bug fixes atop Python objects atop the data repository, I watched the work proceed on the new eastern span of the Bay Bridge. The project, replacing half of the 4.5-mile, double-decker bridge that several hundred thousand vehicles cross each day, was born in the 1990s and first budgeted at a little over a billion dollars. The original design called for a low-slung, unadorned causeway, but political rivalries and local pride led to the adoption of a more ambitious and unique design. The new span, a "self-anchored suspension bridge", would hang from a single tower. A web of cables would stretch down from that lone spire, underneath the roadway and back up to the tower top, in a picturesque array of gargantuan loops. It was going to be not only a beautiful bridge to look at but a conceptually daring bridge, a bootstrapped bridge —a self-referential bridge to warm Douglas Hofstadter's heart.

There was only one problem: Nothing like it had ever been built before. And nobody was eager to tackle it. When the State of California put it out to bid, the lone contractor to throw its hat in the ring came in much higher than expected.

In December 2004, California governor Arnold Scwarzenegger stepped in and suspended the project, declaring that the Bay Area region would have to should more of the ballooning cost of the project and calling for a second look at the bridge design. Never mind that work on half of the bridge, the water-hugging viaduct that would carry motorists for more than a mile on a slow climb up to the future main span, was already very far along, and every morning you could see vehicles swarming up a temporary ramp onto the new roadbed. Schwarzenegger wanted the project scaled back to a less novel and cheaper design. The governor, the state legislature, the state's transportation agency, and local governments spent months bickering and horse-trading. The transportation agency claimed that each day of delay was costing the state $400,000. Finally, in July 2005, a new compromise reaffirmed the fancier single-tower design, to be paid for with bridge toll hikes and other measures, and projected a new finish date for the bridge: 2012 —almost a quarter century after the Loma Prieta earthquake had shaken a chunk of the old bridge deck loose.

As I read about the controversy, I couldn't help thinking of all the software management manuals that used the rigorous procedures and time-tested standards of civil engineering as a cudgel to whack the fickle dreamers of the programming profession over the head. "Software development needs more discipline," they would say. "Nobody ever tried to change the design of a bridge after it was already half-built!"

(Rosenberg: pp. 346-347)

Sounds like a horror story. As a matter of fact, it doesn't sound as different from the story about the development of Chandler that Rosenberg narrates in his book: changes of heart, disputes, political controversy, worries about the final cost, delays... In other words, as soon as civil engineers try to build something that has never been done before —something truly innovative— they run into the very same problems software engineers do.

Programming is writing and its corollaries.

After so much pondering about the best possible ways to make software development more like engineering, Rosenberg finally realizes something important: programming, after all, is a lot like writing.
People write programs. That statement is worth pausing over. People write programs. Despite the field's infatuation with metaphors like architecture and bridge-building and its dabbling in alternative models from biology or physics, the act of programming today remains an act of writing -of typing character after character, word after word, line after line. Tools that let programmers create software by manipulating icons and graphic shapes on screen have a long and sometimes successful story (for a time in the 1990s, one such tool, Visual Basic, won phenomenal popularity). But these have generally served as layers of shortcuts sitting on top of the same old text-based code, and sooner or later, to fix any really hard problems, the programmer would end up elbow-deep in that code anyway.

(Rosenberg: pp. 298-299)

Why else would style become such a contentious issue among programmers? He's absolutely right. Programming is like writing, in spite of all the efforts to make it a "scientific" discipline, something reliable, akin to building a bridge. Companies have created lots of IDEs, tools that make it easier for programmers to carry on with their activities, to drag and drop. At the end of the day, the programmer is no more than a coder, that adjective that so many would-be engineers find derisive. But it's a reality, the programmer has to write the lines of code, one by one. He may be able to rely on other programmers' work, include libraries, use modules... but whatever he does, he still has to actually write the lines of code. That's precisely why quite a few programmers still prefer to use good old Emacs,vi or some other simple text editor. This wouldn't be possible if the act of programming were something very distinct from writing lines of code. It should be patently obvious. The tools currently available may help in this writing activity, just the same way the computer —and the typewriter prior to that— helped the writer of a novel, but the core of the activity remains the same: writing line after line.

Now, said all that, assumed that the core of programming is actually writing, we can also reach other conclusions. For instance, there are always different writing styles. Some of them may be considered better than others, more efficient than others, even more aesthetically pleasant than others. In other words, programming can be considered, to some extent, an art or, at the very least, a craft. To some people, this may be a mind-boggling conclusion, but I think it's clearly derived from everything we have seen before.

miércoles, 23 de julio de 2008

Alan Kay's cellular biology paradigm of software development.

Rosenberg tells us about Alan Kay's wild idea of applying cellular biology to the world of computing:
He is not suggesting, however, that anyone stop at cathedrals. There can be a real science of computing, he believes; we just haven't discovered it yet. "Someday," he says, "we're going to invent software engineering, and we'll be better off." And those discoveries and inventions will take their cues, he thinks, from cellular biology. Ultimately, he says, we need to stop writing software and learn how to grow it instead. We think our computing systems are unmanageably complex, but a biologist —who regularly deals with systems that have many orders of magnitude more moving parts— would see them differently, Kay maintains. To such an observer, "Something like a computer could not possibly be regarded as being particularly complex or large or fast. Slow, small, stupid —that's what computers are."

(Rosenberg: p. 288)

It's the same old idea also expressed by Stephen Wolfram in A New Kind of Science: complexity as something that emerges from simple programs, from simple logic. If we were able to find the smallest snippets of computation needed by the different modules that make up a larger program, all we would have to do to create new applications from that moment on is to combine and recombine these modules. Of course, the problem is how to find about those smallest snippets of computational logic. That's where we all get stuck. Otherwise, the ideas is attractive enough, without any doubt.

The Law of Leaky Abstractions and understanding the basics.

Sooner or later, software developers will have to come to the realization that theirs is hardly the only human activity that ends up creating bugs. Sure, other disciplines don't call them by that name, but that doesn't mean they are not haunted by human errors, miscalculations, the passage of time, erosion, bad materials, etc. As a matter of fact, what makes software stand out in this respect is that there is an official (and quite often publicly available) list of all these errors associated to every project. As Joel Spolsky once explained, the complexity underlying our shiny tools is prone to cause leakages:
In an essay titled The Law of Leaky Abstractions, Joel Spolsky wrote, "All non-trivial abstractions, to some degree, are leaky. Abstractions fail. Sometimes a little, sometimes a lot. There's leakage. Things go wrong." For users this means that sometimes your computer behaves in bizarre, perplexing ways, and sometimes you will want to, as Mitch Kapor said in his Software Design Manifesto, throw it out the window. For programmers it means that new tools and ideas that bundle up some bit of low-level computing complexity and package it in a new, easier-to-manipulate abstraction are great, but only until they break. Then all that hidden complexity leaks back into their work. In theory, the handy new top layer allows programmers to forget about the mess below it; in practice, the programmer still needs to understand that mess, because eventually he is going to land in it.

(Rosenberg: pp. 281-282)


We come across this sort of situation fairly often. It wouldn't be the first time my wife runs into a showstopper problem while putting together a set of web pages on iWeb. The applications does wonders as long as you don't stray too far from what it deems the regular path. As soon as you need to do something different or special (or sometimes, even if you don't), you will run into a problem. The GUI will fail to display things just the way you want them. This table or that font just doesn't look the way it should. Yes, WYSIWYG editors are cool. They allow your regular Joe to edit web pages without having a clue as to how HTML truly functions. On the other hand, as soon as something fails you need to take a look at the inside, read the actual code (and, oh, by the way, what awful job these tools do at writing the actual code underlying the whole thing!) and know what you are doing if you truly want to fix it. In other words, you still need to be familiar enough with the underlying technology that you are using. This is precisely the main problem with these tools. They start being developed as a way to provide some help, a way to automate boring mindless functions. Yet, very quickly they turn into these magic tools that will let you do whatever it is you need to do without having a clue as to what you are actually doing or how things truly work beyond all the pretty interface. That's where we run into trouble. It's like relying on speech recognition software without being able to read. As long as the program gets it right, you're OK. But as soon as it has a mistake, you will be totally lost. Actually, it's even worse: even if the program gets it right, there is no way for you to know.

Two different roles of the software programmer, according to Simonyi.

Charles Simony, the famous Hungarian-American programmer who oversaw the creation of Microsoft Office, distinguished between two separate roles of software design:
In Simonyi's view, one source of the trouble is that we expect programmers to do too much. We ask them to be experts at extracting knowledge from nonprogrammers in order to figure out what to build; then we demand that they be experts at communicating those wishes to the computer. "There are two meanings to software design," he says. "One is designing the artifact we're trying to implement. The other is the sheer software engineering to make that artifact come into being. I believe these are two separate roles -the subject matter expert and the software engineer."

(Rosenberg: pp. 278-279)

I imagine he is referring to the same sort of separation of roles we see between the architect (or the engineer) and those who lay the bricks and finally shapes the original plans in real life. If that's what he is referring to, it definitely is a true distinction. On the one hand, you have the programmer as a designer, the professional who makes the long-term decisions about the overall design of the application, the language to be used, the resources thay will be needed, etc. Then, on the other hand, you have the programmer as coder, the one who actually writes the code and implements the plans laid out by the designer. We're definitely talking about two separate roles, two different phases of the software development. However, what's not so clear to me is that they need to be done by different people too. Perhaps that should be the case, ideally. However, programming has not reached the level of reliability and abstraction that's so prevalent in other fields, such as the construction business, for instance. It's not so clear to me that we can safely divide software development teams in groups of designers and coders, the latter just implementing whatever the former lay out on paper. There is a good amount of wishful thinking in that idea, I'm afraid. As a matter of fact, it could very well be that you could end up with a worst case scenario: software designers who have little experience in the nitty-gritty business of actual programming (this is not, obviously, Charles Simonyi's case) putting together their pie-in-the-sky schemes, while programmers who have never been asked to take a bird's view of their projects continue working on spiritless line of code after line of code without having a clue how the whole thing fits together. I seriously doubt this would represent a step forward for the world of software development as we know it.

The invisibility of software.

Rosenberg speculates that the invisibility of software makes it more difficult to design it in a reliable manner as it (supposedly) happens in the physical world:
As we have seen, software sometimes feels intractable because it is invisible. Things that we can't see are difficult to imagine, and highly complex things that we can't see are very difficult to communicate . But invisibility isn't the only issue. We can't see electricity or magnetism or gravity, but we can reliably predict their behavior for most practical purposes. Yet simply getting a piece of software to behave consistently so that you can diagnose a problem often remains beyond our reach.

(Rosenberg: p. 275)

Since he discusses this in the context of GUI programming, it automatically triggered an idea in my mind: would it help if we were to build Shockwave Flash mockups? Would that make software more and visible and, at the very least, help understand the way the different GUI components interact with eachother? It may be worht a try. Obviously, I don't think it would be of any help when it comes to the internal logic of a program, but it may be of some use in the design of the graphical front-end, especially when it comes to obtaining some quick up-front input from the customers.

lunes, 21 de julio de 2008

WebDAV, peer-to-peer and the influence of hype.

Who doesn't remember the big peer-to-peer trend that happened a few years back? Napster showed up in the radar, it quickly became the next big thing and... well, it quickly went away too. Yes, it also served a purpose. Who thinks that we'd have the iTunes store today without that little experiment? Still, it's also true that peer-to-peer became fashionable, trendy, cool, the thing to do and, all of a sudden, everybody wanted to fit the framework into whichever project they were working on. According to what we can read in Dreaming in Code, that's precisely what happened to Kapor and the team behind Chandler:

If WebDAV could do it, why was it so har for Chandler? Chandler's peer-to-peer approach meant there was no central server to be what developers call, with a kind of flip reverence, "the source of truth". WebDAV's server stored the document, knew what was happening to it, and could coordinate messages about its status to multiple users. Under a decentralized peer-to-peer approach, multiple copies of a document can proliferate with no master copy to rely on, no authority to turn to.

Life is harder witout a "source of truth". For programmers as for other human beings, canonical authority can be convenient. It rescues you from having to figure out how to adjudicate dilemmas on your own. After just a few weeks at OSAF, Dusseault became convinced that the peer-to-peer road to Chandler sharing was likely to prove a dead end. The project had little to show for its efforts to date anyways. "But it was like, we're doing peer-to-peer. We have to. We said we would. We decided to."

(Rosenberg: p. 213)

WebDAV was certainly much better suited to the project they had in mind that peer-to-peer. The same could be said of the traditional client-server approach. So, what's the morale of the story? Even the best hackers make mistakes when they let themselves be influenced by hype.

An innovative feature for a PIM: stamping.

Interesting feaure:
Yin explained the latest thinking on items. Most PIM programs required users to decide up front, when they created a new item, what it was: Were you creating a new email? A calendar event? A to-do task? Chandler would instead let you sit down, start typing a note, and decide later what kind of item it was. Like the human body's undifferentiated stem cells, notes would begin life with the potential to grow in different directions. This design aimed to liberate the basic act of entering information into the program from the imprisoning silos. It also made room for Yin's proposed solution to the item mutability problem: The mechanism users would employ to specify the "kind-ness" of an item would be called stamping.

Say you had typed a note —a couple of sentences about a meeting— and then wanted to put the meeting on the calendar. You would stamp the note as an event. Chandler's detail view would add fields that let you specify a date and a time; your generic note was now an event. Later, if you wanted to invite a colleague to the meeting, you could take the same note and stamp it as an email. A "to" field and a subject line would appear in the detail view. You would fill it out and click on a "send" button.

(Rosenberg: pp. 189-190)

I don't think any other existing PIM software allows you to do that. Apparently, many of these innovative features in Chandler are actually carried from Lotus Agenda, an old piece of software that Kapor wrote back in the Lotus days. It's a pity that today's PIM software is, for the most part, quite run-of-the-mill. When it comes to doing simple things (i.e., dealing with email or taking care of our appointments on a digital calendar) they are too complex and prone to corrupt our (valuable) data. As a matter of fact, it wouldn't be the first time I try to use one of these fancy applications and always end up reverting to good old time-tested mutt. No, mutt is not cool and fancy with all its bells and whistles, but it is extremely flexible, it lets me configure it precisely the way I want it and, above all, I can trust it with my email. I won't corrupt the data as soon as the email folders are too large, forcing me to deal with an emergency crisis at the worst possible moment. So, if I am going to use one of these newflangled applications, it'd better be something different, creative, innovative. It'd better be something that seemlessly links my email to my calendar, my tasks and my contacts. Otherwise, why even bother with a new app?

Linus Torvalds on avoiding large projects.

In accordance with the principles stated in a previous post about developing in Internet time, open source projects tend to stay away from large and ambitious plans. This is not to say that they never reach the status of large projects, of course. However, it does mean that they usually start as small, little projects that try to "scratch an itch" and, given enough interest and a good amount of contributions, may grow to something as large as the Linux kernel, GNOME or KDE. These ideas were pretty well expressed by Linus Torvalds in an interview published by Linux Times June 2004 where they asked him if he had any advice for people starting large open source projects.
"Nobody should start to undertake a large project," Torvalds snapped. "You start with a small trivial project, and you should never expect it to get large. If you do, you'll just overdesign and generally think it is more important than it likely is at that stage. Or, worse, you might be scared away by the sheer size of the work you envision. So start small and think about the details. Don't think about some big picture and fancy design. If it doesn't solve some fairly immediate need, it's almost certainly overdesigned".

(Rosenberg: p. 174)

Once more, the emphasis is on a project that's small, releases quick and nimbly responds to the users' feedback. This mindset is at the very core of the open source development model. Commercial software companies may stress that their approach is quite different, refusing to treat customers as beta testers. However, this is quite disingenous. Anybody who has gone through the experience of running the first public release of any software product knows what I mean.

jueves, 17 de julio de 2008

The paradox of reusable code.

The dream of code reuse has been with us for quite sometime. It promises to speed up the time it takes to write a given project and, even more important, it also promises sturdy, well tested components that may overtime become completely free of bugs. This is what people mean when they talk about modularity. Well, as Rosenberg explains in his book, code reuse is widespread these days and it does contribute towards solving some of the problems programmers had to deal with in the past —especially, it does speed up the time to completion. However, it is not free of its own problems.
Here is one of the paradoxes of the reusable software dream that programmers keep rediscovering: There is almost always something you can pull off the shelf that will satisfy many of your needs. But usually the parts of what you need done that your off-the-shelf code won't handle are the very parts that make your new projects different, unique, innovative —and they're why you're building it in the first place.

(Rosenberg: p. 102)

This is almost by definition. A reusable component exists because a relatively high amount of people had a particular need in the past and it was written to satisfy that need. However, any project that is truly unique and innovative will have, by definition, needs that didn't exist before. It's one of those doh moments, isn't it?

However, there is another face to this paradox that's even more worrisome. What happens if a given project decides to use a particular reusable component from the get-go and later on finds the need to innovate and/or make some deep changes? Either they have to invest the time to learn the component —and we are talking about large and difficult pieces of programming here, such as Zope— or they have no other choice but to shoehorn their innovations into it. Needless to say, this leads to more bugs and, eventually, to an unmaintanable project.

miércoles, 16 de julio de 2008

Dreaming in Code.

The author tells us the story of a group of programmers who are trying to write a killer PIM app, something much better than MS Outlook and Exchange, which is overkill for most small businesses (not to talk about personal use). They are looking to build an open source peer-to-peer application that aspires to be far more flexible than anything else seen yet. But more important, the brains behind the whole operation happens to be none other than Mitch Kapor, the mythical programmer behind Lotus 1-2-3 and the name of the new application is Chandler. In any case, perhaps far more important than the particular story Rosenberg tells us about the experience of programming this particular application it's all the wonderful reflections about the history (and the job) of programming software that he shares with us.

Technical description:
Title: Dreaming in Code: Two Dozen Programmers, Three Years, 4,732 Bugs, and One Quest for Transcendent Software.
Author: Scott Rosenberg.
Publisher: Crown Publishers
Edition: New York (USA), 2007.
Pages: 400 pages, including index.
ISBN: 978-1-4000-8246-9

lunes, 14 de julio de 2008

Code: The Hidden Language of Computer Hardware and Software.

Petzold introduces us to the inner workings of computers (both in regards to hardware and software) without a need to resort to overly complex concepts for the initiated. As a matter of fact, he starts with a brief explanation of what is code and uses both Morse code and Braille to illustrate it.

The author also maintains an errata on his own website.

Technical description:
Title: Code. The Hidden Language of Computer Hardware and Software.
Author: Charles Petzold.
Publisher: Microsoft Press.
Edition: Redmond (USA), 1999.
Pages: 392 pages, including indexes.
ISBN: 0-7356-0505-X