programming book

First-Class: Luciano Ramalho’s Fluent Python

Programming languages as feature sets, not paradigms
Luciano Ramalho

code
San Francisco, California
November 11, 2019

IN 2015, A SEMINAL BOOK on programming was released: ‘Fluent Python’1 by Luciano Ramalho2.

Many coding books can feel like remixes—familiar content presented under different chapter titles and with slightly varied code examples. However, Fluent Python wasn’t just another one of those books. It was well-written and refreshingly original. The chapters brought to light lesser-known aspects of the Python language and programming more broadly.

It was the minutiae in the book that truly solidified my admiration.

The term “first-class functions” is widely used as shorthand for “functions as first-class objects.” It’s not perfect because it seems to imply an “elite” among functions. In Python, all functions are first-class. - Chapter 5. First-Class Function

“First-class” as an adjective implies a categorization—an “elite,” as he calls it. In reality, functions are always first-class in Python. First-class means a function can be assigned to a variable, passed as an argument, and returned from another function. It doesn’t need to be executed immediately to be referenced or manipulated.

Sensitivity to language shows up throughout the book. For example, in another chapter (Chapter 18: Concurrency with Asyncio), Ramalho leads with this quote.

Concurrency is about dealing with lots of things at once. Parallelism is about doing lots of things at once. Not the same, but related. One is about structure, one is about execution. Concurrency provides a way to structure a solution to solve a problem that may (but not necessarily) be parallelizable. - Rob Pike, Co-inventor of the Go language

Ramalho’s first paragraph of that chapter paraphrases a Hungarian-born Brazilian mathematician and computer scientist named Imre Simon3: "…[he] liked to say there are two major sins in science: using different words to mean the same thing and using one word to mean different things."

So we see that great books are built on avoiding the sins of language.

A few Sundays ago, I attended the final day of a local Python conference, PyBay. This wonderful event is now in its fourth year, and I’ve attended all but one.

Ramalho gave a talk called “Beyond Paradigms” at 4pm.4 There was another talk I wanted to attend, but I couldn’t pass up the chance to see the author of such an excellent book. I sat near the front. As expected, the talk was good.

Luciano Ramalho speaking at PyBay 2019

During the question-and-answer session, a man a couple of rows behind me asked Ramalho for his thoughts on the practicality of learning new programming languages if one doesn’t have time to become an expert. The questioner cited the 10,000-hour rule, popularized by Malcolm Gladwell, as supposedly necessary to reach expertise.

Ramalho opened by saying the 10,000-hour rule isn’t accurate. I was glad he led with that. Gladwell popularized the idea without enough context, and the expert he drew from, Anders Ericsson, later pointed this out.5

Regardless of expertise, Ramalho noted that learning new languages reveals the strengths and weaknesses of the ones we know best. It sharpens our skills in our primary languages. He’s currently learning Elixir.6

Here are three more takeaways. Watch his talk7 and check out the slides8. :

  1. Read only the first 30 pages of the Gang of Four book9. Ramalho suggests there’s no need to read beyond that.

  2. Fixation on design patterns can lead us down the wrong path. Ramalho mentioned he spent years tracking down a 1996 slide by Peter Norvig, a renowned computer scientist and director of research at Google. The slide states: “In a study of the Design Patterns book, 16 of the 23 patterns have qualitatively simpler implementations in Lisp or Dylan than in C++ for at least some uses of each pattern."

  3. Learn complementary languages. Explore languages that offer different features from your favorites. If you’re fluent in Python, learning Ruby might not add much, since they share similar strengths and weaknesses. In contrast, Elixir and Go are strong complements to Python and Ruby.


  1. On Amazon: Fluent Python: Clear, Concise, and Effective Programming via local bookstores or Amazon ↩︎

  2. Luciano Ramalho profile at Thoughtworks and his two Twitter accounts:@ramalhoorg and @standupdev ↩︎

  3. Direct copy of Ramalho’s footnote: Imre Simon (1943–2009) was a pioneer of computer science in Brazil who made seminal contributions to Automata Theory and started the field of Tropical Mathematics. He was also an advocate of free software and free culture. I was fortunate to study, work, and hang out with him. ↩︎

  4. Talk description: “Java is object oriented and Haskell is functional. How about Python? Is it really OO with free-standing functions and porous encapsulation? Python has lambdas and closures, but is it functional? Are these useful questions? A better approach to learning of programming languages is to focus on features, not paradigms. This delivers practical advice for choosing patterns and understanding idioms." ↩︎

  5. Ericsson’s 2017 book - Peak: Secrets from the New Science of Expertise via local bookstores or Amazon ↩︎

  6. https://elixir-lang.org/ ↩︎

  7. PyBay 2019. If the videos are not up on Youtube yet, they will be soon. ↩︎

  8. Ramalho’s slides↩︎

  9. Design Patterns: Elements of Reusable Object-Oriented Software via local bookstores or Amazon ↩︎