The main lesson that Clojure teaches its developers is to embrace simplicity.
The secret sauce used by Clojure to embrace simplicity is that it treats data as a first-class citizen that is manipulated with generic functions.
In the Clojure community, we call this secret sauce: Data-Oriented programming.
The good news is that this paradigm is in fact language agnostic, meaning that it is applicable in other programming languages, both OOP and FP, both statically and dynamically typed.
In Data-Oriented programming, we follow 3 principles:
- We separate our code from our data
- We represent data with generic data structures
- We never mutate our data
What does it mean in practice for you to adhere to Data-Oriented programming?
- You write your code in stateless functions (or static methods)
- You represent your data with hash maps and vectors
- You use a library that implement efficient immutable data structures
What do you get from that?
In one word: SIMPLICITY!
In a few sentences:
- No more complex UML diagrams!
- You benefit from dozens of generic data manipulation functions
- You can visualize any part of your system, as it is just data
- You liberate your mind from concurrency-related issues.
Curious to see how it looks like in a real production system?
Start reading my book Data-Oriented programming.
Here is a 50% off discount code for you: mlsharvit2
. Valid until March 15.
The principles of Data-Oriented programming are explored in greater detail here.
Enjoy!
原文链接:Data-Oriented programming: Liberate yourself from objects
暂无评论内容