March 11th, 2011

Liveblogging "Programming and Minimalism: Lessons from Orwell and the Clash"

I'm at SxSW Interactive, attending Jonathan Dahl's talk, "Programming and Minimalism: Lessons from Orwell and the Clash." Thought I'd share the wealth with a little liveblogging action.

The twitter hashtag is #minimalistprogramming

Dahl is cofounder of Zencoder, which offers video encoding as a service, helpful for integrating video directly into your site without embedding a branded video player such as YouTube or Vimeo or Viddler. Another approach, just FYI, is to use the white label service available with Viddler Business to Business accounts. That gives you a player that doesn't mention Viddler. We've used this successfully at P'unk Avenue. But if you really want your own customized Flash player without the work of transcoding a zillion uploaded video formats Zencoder is likely a good choice.

Getting ready to start. Tweeting out the liveblog. I'll be updating this post regularly.

Jon Dahl getting underway

Still working at Zencoder, "video encoding as a cloud service"

They are hiring "awesome engineers, a designer and an evangelist"

Question: "what is programming?"

Is coding typing curly brackets? Is math writing down numbers on paper?

Coding is a process. "Doing shit"

"Defining complex processes in a really precise way."

Comparison to engineering. "The job for a programmer is to find the rules and instructions that make something happen." iPhone slide. Super Mario slide.

"An engineer builds a noun, a programmer builds a verb. The engineer designs something but they don't build it. Someone implements the idea of the engineer. As programmers we sort of have that, the compiler executes the instructions. But it's effectively instant and free"

"If an aviation engineer could tweak the design and instantly test it out, that would be more like programming"

Plug for "the pragmatic programmer" and a view of programming as craftsmanship.

Craftsmen often work in small teams, like programmers Craftsmen focus on good habits and practices Constructing a team and process that can do good work Also focuses on developing their own good work habits

Third analogy: "writing." Nice old school typewriter slide

The engineer approaches a problem directly (think of memcached). The craftsman thinks about creating an environment in which a problem can be solved (think pair programming or test driven development).

The composer and the programmer write characters in an editor but that is not a finished work. The finished work is a running application / a live performance.

Wittgenstein slide. "Most problems caused by lack of precision in specifying the issue. Confusion in thinking follows ambiguity in language"

Later he realized that the only problem with the imprecision of language is a lack of recognition that it is imprecise.

"Fire!" What does that mean? Depends on context.

"Whether we like it or not, every time we code, we're coding with a particular style."

"What is good programming?"

Let's start with music. Consider this: "simple and interesting." A simple and interesting form that people build on. Eventually, if too much is built on top of it, it'll wind up tedious and boring.

What's the next stage? "start over, but keep the best parts."

Happened twice in the history of music. Bach wrote in the baroque (ornamented, complex) style.

[Listening to a bit of Bach]

"What's the next step? Someone throws a lot of it away and you get the classical tradition, starting with Haydn and Mozart. A move towards simplicity from the baroque era. In classical music you can often pick out a tune, in baroque not so much." [Listening to Mozart]

Sure enough Beethoven repeated the building-on process, building classical music into something more complex. Mahler continued in that tradition and he went out of his way to make everything bigger and badder (including doubling the size of the orchestra, chorus, etc. in a new arrangement of Beethoven's Ninth).

A cycle of simplicity and complexity. "At the core of a lot of beauty"

The extremes are no good. [Played sample of a boring sine wave and something "too complex–" a white noise sample]

Reactions: Steven Reich and Philip Glass write in a new style, minimalism. [Listening to samples... some of these I like, others not all that much]

"The cycle continued with rock music. The Beatles early on wrote catchy simple popular music. Easy to understand, easy to listen to. Later on they wrote more complex music. Led Zeppelin elaborated the form with the double guitar. Spinal Tap builds on this tradition..." [Chuckle]

"The first time I gave this talk I made the mistake of badmouthing Rush, I won't do that here, suffice to say their music is more complicated. 20 minute rock operas about Ayn Rand. A departure from the simplicity of early rock music"

The next revolutionary discarding of complexity came with punk rock. [God Save the Queen, by the Sex Pistols]

[And The Clash, as promised]

A good tweet summarizing the talk so far:

.bbpBox46304839646445570 {background:url(http://a0.twimg.com/profile_background_images/192749093/Pudzisz-Twitter_Bacground.png) #ffffff;padding:20px;} p.bbpTweet{background:#fff;padding:10px 12px 10px 12px;margin:0;min-height:48px;color:#000;font-size:18px !important;line-height:22px;-moz-border-radius:5px;-webkit-border-radius:5px} p.bbpTweet span.metadata{display:block;width:100%;clear:both;margin-top:8px;padding-top:12px;height:40px;border-top:1px solid #fff;border-top:1px solid #e6e6e6} p.bbpTweet span.metadata span.author{line-height:19px} p.bbpTweet span.metadata span.author img{float:left;margin:0 7px 0 0px;width:38px;height:38px} p.bbpTweet a:hover{text-decoration:underline}p.bbpTweet span.timestamp{font-size:12px;display:block}

#minimalistprogramming #sxsw Something too simple or too complex is not interesting, but if it operates between the two, you get beauty.less than a minute ago via Twitter for AndroidNatalia Pudzisz
pudzisz



Now he's talking about the "USA Patriot Act!"

"What was this legislation about? Whether we loved the USA? The title obscures thinking about the real content. Had it been called the expanded surveillance act we could have had a rational discussion about it"

A historical example of a long paragraph of propaganda which translates to "20 million dead in Stalin's purges is cool with me."

So what's the payoff here? Ah! An example of a horrible paragraph about Milton and Shelley that is "not only imcomprehensible, but prone to bugs," as found by George Orwell, who offers up solutions for better writing/coding:

Never use an unfamiliar metaphor Never use a long word where a short one will do If it's possible to cut a word, do Never use the passive voice where you can use the active Never use a jargon word if there is an everyday equivalent Break any of these rules before yous ay anything "outright barbarous"

"Bad writing = bad thinking = totalitarianism"

"So how does this relate to programming? What makes good style?

* Minimalism. We're defining complex processes as it is, avoid adding more complexity in our style of expression * Clear, direct writing enables clear thinking about the problems we're facing

A few specifics

* Clever code is bad code

A Ruby example
  def me?(user=@user)
    returning(user == current_user) do |me|
      yield if me && block_given?
    end
  end
"This 'returning' method is a k combinator. It's a perfectly valid structure but it's not usual in Ruby or even in the core library. It's the wrong thing to use here. The programmer used it because they wanted to try something out and it looked clever.

Try:
yield if user == current_user
* Any code that isn't doing something is harming your project. * Accept constraints. If the system you're working on makes an approach simple, take it. * If something isn't local business logic it should be in a library.

view -> controller -> model

"You don't want too much logic in your views so you move it to the controller, but you don't want a lot there so you move that off to the model. Who does MVC programming? How huge do your model classes get?" The winner was about 4,000 lines. (The longest in Apostrophe is about 1600 lines)

"Create libraries. Reuse code. Use what is already available. Don't reimplement search, etc."

* Don't over-abstract

Shows a Ruby one-liner to comma-separate a list. Then shows an extracted method for it. Is this really worthwhile?

* Always active clean up your code. Constantly.

"Code does not stay the same over time. Untouched software degrades over time"

"If you are not actively improving your code it is degrading"

"Track code debt in an issue tracker. Pick one thing to improve every week"

* Apply these rules wisely. In some circumstance all of these rules are inappropriate

* Remember that simple code is beautiful

* Break hard problems down

Reminder to break things down, code from top down, etc. This is programming 101 but I suppose a lot of people missed the memo (:

"Consume." Look at other programmers' good code. Pair program with better coders than ourselves.

Also: good poetry, music, prose

"Study." Many good books on programming, read them

"Produce." You don't become a good poet (just) by reading poetry. You become a good poet by writing for years and years and throwing it away (so true cf. my first zillion poems)

"Make it better"

minimal, clear, direct, effective, beautiful

Write beautiful code!

And that's it. Simple but worthwhile

Q&A has been meatier in a lot of ways because the serious coders in the audience are bringing up specifics

Q. "Do you refactor at work?" A. "Yes. We do code review, not as much as we should, some pair programming, like real time code review"

Q. "What's the most beautiful code you've ever seen?" A. "Let me think about it, it's a good question"

"Ideally every piece of code that's not a whitespace change gets reviewed. Emailing diffs can be enough"

"If you don't understand the way software works you might think pair programming and test driven development are a waste of time." You get to keep the tests, for one thing.

"Pick a appropriate languages for problems, but bear in mind a higher level language is easier to understand"

"New languages that improve elegance?" "CoffeeScript" He agrees CoffeeScript is excellent

[CoffeeScript introduces a Ruby-like brevity to JavaScript. Interesting stuff]
Check out another article
March 8th, 2011
Invader Zim Party
By