Data-Oriented Programming and Elixir

So I start to read Data-Oriented Programming and I realized that phoenix, elixir and erlang are implemented in a way that we develop using this a lot of concepts of this paradigm without knowing about and this is beautiful, really, I’m so amazed.

what do you think of this paradigm?

1 Like

Data is the king, code is the army of servants. Took me a while to understand it but once I did my entire view on programming has changed and I became better at my job.

Everything, code included, should be modeled after the data.

7 Likes

Nice quote I will take with me for life

I’d phase it differently: Data is the gold, code is the army of miners. Data is of paramount importance but it does not have free will.

2 Likes

Sure. My main point is that the programmers at large are over-focusing on programming languages and usually for the wrong reasons e.g. syntax. I was one of them a lifetime ago and I still facepalm hard at least twice a month when remembering it.

Programming languages are important – Elixir is the living proof (good luck finding Erlang’s BEAM VM runtime anywhere else!). But the true effort and energy must be invested in properly modelling and understanding the data our code must work with. This also includes parallelism which is where good runtime and/or compile-time support is paramount.

Constantly reinventing wheels is a nice way to secure your job but there comes the day you’d rather slash your own wrists than do it.

Prediction: one of the future programming innovations will be the invention of a (more or less) universal data description format. Or if it’s not a prediction, it’s a very desirable outcome.

1 Like

When reading Design Elixir Systems with OTP, I found a similar point:

If you want to write beautiful code, you need to design the right data structures first.

I totally agree with that. Good software should be built in layers:

  • data
  • functions
  • modules
  • business boundaries

Data is at the bottom, and it’s the most important. It’s only natural to do data-oriented programming. :wink:

please share examples

love those quotes.

For me, most important: the language has to be immutable (have some respect for the data-gold).
Pure functions with well designed data structures are the best way to good code. (correct and understandable code!)

But: immuntability makes it even more importand to think about the data structures …

There was a discussion last year concerning nested data structure traversal.
There were lots of interesting solutions in different languages here: https://github.com/josevalim/nested-data-structure-traversal - Sadly the repo is gone. Does anyone know about the whereabouts?

Anyway: All the solutions without mutability were very hard to understand, while its very easy if you change the datastructure: https://elixirforum.com/t/picking-up-fp-coming-from-oop-split-thread/33187/99

Thats ambitious. I’d rather say: dont shy away from changing the data structures into sth easier to handle (and then - most of the time - better grasping the problem at hand). So refactoring includes refactoring data-structures.

1 Like

There’s a nice post on Clojureverse with the principles that Yehonathan Sharvit made