Layered Design in Go: A Weapon Against Circular Dependencies

2025-04-20

This post delves into the problem of circular dependencies in Go and offers solutions. The author points out that Go's prohibition against circular package imports inherently shapes program design, promoting a layered architecture. Analyzing package import relationships allows for decomposition into layers, where higher-level packages depend on lower-level ones, preventing circularity. Several refactoring techniques for handling circular dependencies are introduced, including moving functionality, creating new packages, and using interfaces. Minimizing exported package members is stressed. This layered approach not only avoids circular dependencies but also enhances code understandability and maintainability, making each package independently useful.

Read more
Development Circular Dependencies

The Pragmatist's Guide to Functional Programming: Macro over Micro

2025-04-14

This essay argues against a purely micro-level application of functional programming principles in imperative languages. While acknowledging the benefits of functional programming, the author contends that obsessively replacing for loops with maps and reduces without addressing higher-level architectural concerns often yields minimal gains or even negative results. The true value lies in adopting macro-level principles like managing mutation, simplifying architecture, and strengthening type systems. The author advocates for a pragmatic approach, prioritizing architectural design and code quality over strict adherence to functional micro-styles, suggesting a portfolio of 80/20 solutions often surpasses a single 100/100 approach.

Read more
Development

Functional Programming: The Art of Folding the Problem Space

2025-03-21

This article explores the differences between functional programming (using Haskell as an example) and imperative programming when solving complex problems. Imperative programming can easily lead to code bloat, like drawing a straight line on paper, while functional programming is like folding the paper, cleverly "folding" the problem space, reducing dimensionality, and ultimately achieving the goal with concise code. The article uses the author's practical experience to illustrate how functional programming builds small modules and combines them to create rich ecosystems, and how to use features like monads to achieve elegant code combinations, ultimately avoiding the common code bloat and maintainability issues of imperative programming.

Read more
Development code design

Ten Bold Ideas for the Future of Programming Languages

2025-01-08

A seasoned programmer proposes ten innovative ideas for the future of programming languages, covering aspects such as function call mechanisms, capability programming, production-level features, semi-dynamic languages, persistent data stores, truly relational languages, modular monoliths, and modular linting. These ideas aren't entirely novel but rather refinements and integrations of existing concepts, aiming to improve programming efficiency and code quality. The article explores incorporating best practices like structured logging and metrics gathering into the language itself, and enhancing the performance of dynamic languages.

Read more
Development