Exercises in Programming Style
by Cristina Videira Lopes · first published 2014
79% recommend21% neutral
Why HN recommends it
Solves one small term-frequency problem in dozens of styles, from callbacks to shell pipelines, so readers see how the same task changes across paradigms; suited to working programmers who want to broaden their view.
Summarised by Claude from recommending comments
"Exercises in Programming Style consists of over 30 renditions of the same simple program written in various programming styles. The book illustrates the richness of human computational thought, and the teachings that have been accumulated during more than fifty years of computer programming. These teachings are scattered around, and are mostly passed to new generations of programmers by mentoring and self-teaching. The book presents this knowledge in a package that can be understood and referenced by all programming professionals and students, so that they have a more global vision of the con
Affiliate links. As an Amazon Associate I earn from qualifying purchases.







There is also the book "Exercises in Programming Style" that uses the term frequency problem to illustrate 33 different programming paradigms (including a shell solution). https://www.amazon.com/Exercises-Programming-Style-Cristina-...
on “The Yoda of Silicon Valley” ↗…Hoare The algorithmic beauty of plants by Prusinkiewicz, Lindenmayer Network Performance Analysis Using the J Programming Language by Alan Holt Relational Programming in miniKanren by William Byrd Exercises in Programming Style by Cristina Videira Lopes edit: also "SAT/SMT by example" by Dennis Yurichev
on “Ask HN: Most interesting, mildly impractical, well-written books on software?” ↗I enjoy this sort of "one example, multiple different lenses" style of discussion. It reminds me of this book... Exercises in Programming Style by Cristina Videira Lopes.
on “Syntax Design (2014)” ↗Exercises in Programming Style - Cristina Videira Lopes The same simple programming problem (term frequency) solved using 33 different programming styles. https://www.amazon.com/dp/B00L2EAVAW/ref=dp-kindle-redirect?...
on “Ask HN: What good books have you read lately?” ↗…learn the concepts of structured programming. Every language is just a notation on top of a fundamental programming construct. If you learn those instead, you'll know every language. I recommend reading Exercises in Programming Style by Cristina Lopes as a good starting point.
on “Being confidently programming language agnostic” ↗You might enjoy the book "Exercises in Programming Style (Second Edition)" by Cristina Videira Lopes. It looks at how you can compute term frequency using 40 different coding patterns, explaining the how/why of each.
on “Ask HN: Learning new coding patterns – how to start?” ↗A little known book that many might find interesting is Cristina Lopes's Exercises in Programming Style which takes a single problem and solves it in 40 different ways using Python. [0] https://www.amazon.com/Exercises-Programming-Style-Cristina-...
on “Ask HN: Programming Courses for Experienced Coders?” ↗You might want to check out Exercises in Programming Style (2nd Edition) by Cristina Videira Lopes. It's a little known book that explores different ways of solving the same problem under different constraints.
on “Think Python, 3rd Edition” ↗As the sibling says, CL can be written in most any style. Which, I think it is fair to say for any general programming language? The book Exercises in Programming Style highlights that. That said, CL feels far friendlier to the various styles than other languages, to me. Link to book on Amazon: https://www.amazon.com/dp/0367350203
on “Show HN: Using Common Lisp from Inside the Browser” ↗…StackExchange: https://codegolf.stackexchange.com/questions/188133/bentleys... (Copying from my comment the last time this was posted: https://news.ycombinator.com/item?id=26467684) There's also a nice book "Exercises in Programming Style" about just this problem.
on “Performance comparison: counting words in Python, C/C++, Awk, Rust, and more” ↗…https://www.cs.tufts.edu/~nr/cs257/archive/don-knuth/pearls-... (One of the places where McIlroy admits his criticism was "a little unfair": https://www.princeton.edu/~hos/mike/transcripts/mcilroy.htm) BTW, there's a wonderful book called “Exercises in Programming Style” (a review here: https://henrikwarne.com/2018/03/13/exercises-in-programming-...) that illustrates many different solutions to that problem (though as it happens it does not include Knuth's WEB program…
on “Problem solving with Unix commands” ↗Thanks. >(More on that here: https://news.ycombinator.com/item?id=18699718) >BTW, there's a wonderful book called “Exercises in Programming Style” (a review here: https://henrikwarne.com/2018/03/13/exercises-in-programming-...) that illustrates many different solutions to that problem (though as it happens it does not include Knuth's WEB program…
on “Problem solving with Unix commands” ↗…low- to high-level): - The Elements of Computing Systems: Building a Modern Compiler from First Principles - Operating Systems: Three Easy Pieces - Systems Performance: Enterprise and the Cloud - Exercises in Programming Style - The Little Typer - Conceptual Mathematics: A First Introduction to Categories
on “Books that changed my career as a software engineer” ↗Also interesting is that this problem is used as the example in the book "Exercises in Programming Style" by Cristina Videira Lopes. It shows this problem solved in 33 different programming styles, for example historical, function composition, data-centric etc. I have written more about it here: https://henrikwarne.com/2018/03/13/exercises-in-programming-...
on “Performance comparison: counting words in Python, Go, C++, C, Awk, Forth, Rust” ↗>Exercises in Programming Style by Cristina Videira Lopes I didn't know of this book (have been looking for something like this for a while) and hence thanks for the pointer.
on “Syntax Design (2014)” ↗