Data-Oriented Programming • Yehonathan Sharvit & James Lewis
Dec 29, 2023
auto_awesome
Yehonathan Sharvit, author of Data-Oriented programming, discusses with James Lewis the revolutionary concept of data-oriented programming, its benefits in reducing software complexity, and its flexibility across multiple programming languages. They explore topics such as handling large amounts of data, evolving interfaces, the advantages of immutability in managing changes, and breaking big problems into smaller ones for enhanced code readability and maintainability.
Data-oriented programming focuses on reducing complexity by treating data as a first-class citizen, separating code and data and promoting immutability.
Treating data as data brings advantages in flexibility, code reuse, better communication between systems, and runtime validation.
Deep dives
Data-oriented programming aims to reduce complexity of information systems
Data-oriented programming (DOP) focuses on reducing the complexity of information systems. By treating data as a first-class citizen, DOP separates code and data, allowing behavior to become stateless functions. This approach minimizes complexity, making code more manageable and reducing errors. DOP also emphasizes immutability, using persistent data structures to efficiently manage changes. Additionally, DOP promotes schema-based data validation, ensuring data integrity and providing more reliable code. By adopting these four principles, developers can create more robust and maintainable systems.
The benefits of treating data as data
Treating data as data brings several advantages to software development. First, it allows for flexibility and dynamic creation of data without unnecessary ceremony. Using general data structures like hash maps or lists, developers gain access to a wide range of functionality and libraries for data manipulation. This promotes code reuse and simplifies development by leveraging existing tools. Furthermore, treating data as data enables better communication and integration between systems by using schema languages like JSON schema. This ensures that data conforms to expected structures, facilitating error detection and providing runtime validation. Overall, treating data as a first-class citizen enhances development productivity and maintainability.
Managing data complexity with immutability
Immutability is a key principle in data-oriented programming that offers benefits in managing data complexity. By keeping data immutable, developers reduce the amount of state to manage, making code more reliable and easy to reason about. While immutability traditionally posed performance challenges, persistent data structures were introduced in 2009 to efficiently handle changes. These structures, such as HAMTs, use structural sharing to minimize memory and computational overhead when creating new versions of data. With widespread adoption across various programming languages, developers can embrace immutability without sacrificing performance or scalability.
Data validation and schema-based approach
Data-oriented programming advocates for a separation between data representation and data validation. This approach allows developers to decide when and how to validate data, ensuring its conformity to expected schemas. Using tools like JSON schema, developers can validate data in dynamic languages, enabling accurate error detection and clear feedback for invalid data. By separating data representation from validation, developers have the flexibility to work with generic data structures for more generic functions and selectively apply schema validation for specific use cases. This approach strikes a balance between flexibility and reliability, enhancing code robustness and maintainability.
DESCRIPTION Unlock the power of data-oriented programming with this groundbreaking guide ‘Data-Oriented Programming: Reduce software complexity‘, introducing a paradigm that revolutionizes software design by representing data through generic immutable structures. DOP simplifies state management, streamlines concurrency and eradicates common issues in object-oriented code, all while offering language-agnostic flexibility. In this GOTO Book Club episode, author Yehonathan Sharvit spoke to James Lewis about how you can change the way you look at programming where code is clearer, state-related bugs are history, and your applications are more robust.
This conversation-driven book is complete with code snippets and diagrams about DOP and the best part—it's not bound to a single programming language, making it adaptable to JavaScript, Ruby, Python, Clojure and traditional languages like Java or C#. Learn to design data models for business entities and implement state management systems without mutating data. Discover how to separate code from data, write data-oriented unit tests, and specify the shape of your data, all while gaining a deeper understanding of these exciting new concepts.