MessiandNeymar

  • Subscribe to our RSS feed.
  • Twitter
  • StumbleUpon
  • Reddit
  • Facebook
  • Digg

Thursday, March 1, 2012

I love style guides

Posted on 3:27 PM by Unknown

Style guides have a long and distinguished past. Classic examples include Strunk & White's The Elements of Style, and The Chicago Manual of Style (can't resist that chance to mention my Alma Mater...).

When programming languages started to become moderately sophisticated, style guides soon followed; Ben Schneiderman's The Elements of Fortran Style was one of the first (it's reached its 40th birthday!), followed 5 years later by Brian Kernighan's The Elements of Programming Style.

I wasn't ever a Fortran programmer (though I was once a PL/1 programmer), but I read both those books cover to cover, several times.

Anyway, I'm a junkie for style guides in general, and for programming language style guides in particular. Nowadays they are a dime a dozen, but I still perk up when I hear of a new one and I go check it out.

So I was intrigued to see, recently, that the engineering team at Twitter had shared their Scala programming guide: Effective Scala. I haven't had a chance to program in Scala, but it's a very interesting language and I got a better feel for the language by reading through the Twitter style guide.

While highly effective, Scala is also a large language, and our experiences have taught us to practice great care in its application. What are its pitfalls? Which features do we embrace, which do we eschew? When do we employ “purely functional style”, and when do we avoid it? In other words: what have we found to be an effective use of the language? This guide attempts to distill our experience into short essays, providing a set of best practices. Our use of Scala is mainly for creating high volume services that form distributed systems — and our advice is thus biased — but most of the advice herein should translate naturally to other domains.

I like the fact that the Twitter team recognize that programs are written to be read by human beings:

Scala provides many tools that enable succinct expression. Less typing is less reading, and less reading is often faster reading, and thus brevity enhances clarity. However brevity is a blunt tool that can also deliver the opposite effect: After correctness, think always of the reader.

You can never tell what will pop up when you read programming texts; there is always something new to learn, and it may be hiding around the next corner. In this case, I stumbled upon The Cake Pattern, which was a programming pattern I hadn't heard of before.

The neat thing is that we can here switch between different implementations of the services (if we had defined an interface trait and multiple implementations). But even more interestingly, we can create multiple “worlds” or “environments” by simply composing the traits in different combinations.
It's a nifty technique, though I haven't yet figured out why it's called "The Cake Pattern". I guess I'll go read the paper.

Thank you, Twitter engineering team, for sharing your style guide, it was most interesting!

Email ThisBlogThis!Share to XShare to FacebookShare to Pinterest
Posted in | No comments
Newer Post Older Post Home

0 comments:

Post a Comment

Subscribe to: Post Comments (Atom)

Popular Posts

  • Shelter
    I meant to post this as part of my article on Watership Down , but then totally forgot: Shelter In Shelter you experience the wild as a moth...
  • Parbuckling
    The enormous project to right and remove the remains of the Costa Concordia is now well underway. There's some nice reporting on the NP...
  • The Legend of 1900: a very short review
    Fifteen years late, we stumbled across The Legend of 1900 . I suspect that 1900 is the sort of movie that many people despise, and a few peo...
  • A Very Short Review of The Hangman's Daughter
    By way of the quite-nice Kindle Owners Lending Library , I recently read Oliver Potzsch's The Hangman's Daughter . At least part of ...
  • Jones v Anand
    If you think grandmaster chess is boring, with lots of positional strategic maneuvering, you owe it to yourself to play through the game bet...
  • A Glorious Defeat: a very short review
    Somewhat unexpectedly, Timothy Henderson's A Glorious Defeat: Mexico and Its War with the United States found its way to my nightstand....
  • Unbroken: a very short review
    Laura Hillenbrand's Seabiscuit: Three Men and a Racehorse was a massive worldwide hit, and became a movie hit as well. It took her seve...
  • One Day: a very short review
    I'm about two years late (typical), but I finally got around to David Nicholls's One Day . The book's concept is to tell a story...
  • Rim fire winding down
    I hadn't been over to Inciweb's Rim Fire status page in a while, so I dropped in to see how the progress goes. This is the long, sl...
  • XCOM Enemy Unknown
    I don't have much time to play video games, so I tend to go many months between games, looking for just the right one. I've been pla...

Blog Archive

  • ►  2013 (165)
    • ►  September (14)
    • ►  August (19)
    • ►  July (16)
    • ►  June (17)
    • ►  May (17)
    • ►  April (18)
    • ►  March (24)
    • ►  February (19)
    • ►  January (21)
  • ▼  2012 (335)
    • ►  December (23)
    • ►  November (30)
    • ►  October (33)
    • ►  September (34)
    • ►  August (29)
    • ►  July (39)
    • ►  June (27)
    • ►  May (48)
    • ►  April (32)
    • ▼  March (30)
      • 30 days has September, April, June, and November ...
      • Online reviews
      • I don't know what the game will be like ...
      • Every day you get in your life is precious
      • Last year, it took a full hour!
      • Bill Slawski's Top Ten SEO Patents list
      • Cliff Click's deep dive into Constant Propagation ...
      • A great example of the power of generators
      • I have no idea what it will be like to play ...
      • I'm really enjoying Dan Boneh's online cryptograph...
      • BATS IPO Algorithmic Snafu?
      • The complicated task of trying NOT to keep up with...
      • It's not just a game...
      • Internet scale, administrations, and operations
      • Followup, followup, followup
      • Perfectly named for your career
      • rands on hacking
      • Mapping the past
      • Mark your calendars!
      • The Google I/O 2012 website is live
      • Software in the courts
      • Great gaming post
      • Link dumping, March 2012 edition
      • Are some algorithms simply too hard to implement c...
      • The Stanford online cryptography class is up and r...
      • A fine use of the web
      • RSA 2012 has come and gone
      • How will the field of software analysis emerge?
      • Satan's Trifecta
      • I love style guides
    • ►  February (10)
Powered by Blogger.

About Me

Unknown
View my complete profile