November 16, 2011

Pretty command line / console output on Unix in Python and Go Lang

Posted in Software at 02:17 by graham

There are lots of easy ways to improve the output of your command line scripts, without going full curses, such as single-line output, using bold text and colors, and even measuring the screen width and height.

The examples are in Python, with a summary example in Go (golang) at the end.

Single line with \r (carriage return)

Instead of printing a \n (which most ‘print’ methods do by default), print a \r. That sends the cursor back to the beginning of the current line (carriage return), without dropping down to a new line (line feed).

import time, sys
total = 10
for i in range(total):
    sys.stdout.write('%d / %d\r' % (i, total))
print('Done     ')

Read the rest of this entry »

November 3, 2011

On why hackers don't work on large teams

Posted in Society, Software at 01:05 by graham

We’ve know for over 35 years that “adding manpower to a late software project makes it later”. Amazon has it’s two-pizza team heuristic: “If a project team can eat more than two pizzas, it’s too large”. The excellent Code Complete has a detailed explanation of how communication costs increase with team size. Yet we still need reminding.

Dhanji R. Prasanna has an excellent retrospective on his time on the Google Wave team. He sums up the problem with big teams very well:

And this is the essential broader point–as a programmer you must have a series of wins, every single day. It is the Deus Ex Machina of hacker success. It is what makes you eager for the next feature, and the next after that. And a large team is poison to small wins. The nature of large teams is such that even when you do have wins, they come after long, tiresome and disproportionately many hurdles. And this takes all the wind out of them.

For me, that’s really the crux of it. As a programmer, it kills you to not get stuff done. Large teams necessarily involve more communication, more complexity, and less getting stuff done. Large teams are a programmers equivalent of retirement.

November 2, 2011

Machiavelli on Occupy Wall Street

Posted in Society at 23:25 by graham

Reading Machiavelli’s The Prince, his advice seems just as relevant today. In On the civil principate he writes:

In every city there are two different humours, one rising from the people’s desire not to be ordered and commanded by the nobles, and the other from the desire of the nobles to command and oppress the people.

You cannot satisfy the nobles honestly and without harming others, but you certainly can satisfy the people. In fact, the aim of the common people is more honest that that of the nobles, since the nobles want to oppress others, while the people simply want not to be oppressed.

The Prince must always live among the same people, but he can do very well without a particular set of noblemen.

Substitute nobles with the 1%, and substitute Prince with President, and you get the advice he would probably give today.