<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Robin Alexander Dorstijn</title>
    <description>The latest articles on DEV Community by Robin Alexander Dorstijn (@drvanon).</description>
    <link>https://dev.to/drvanon</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F278606%2F9a1e22ca-5aa4-488a-9e4a-bcb097552b22.jpeg</url>
      <title>DEV Community: Robin Alexander Dorstijn</title>
      <link>https://dev.to/drvanon</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/drvanon"/>
    <language>en</language>
    <item>
      <title>On Data and Objects</title>
      <dc:creator>Robin Alexander Dorstijn</dc:creator>
      <pubDate>Sun, 21 Aug 2022 17:41:28 +0000</pubDate>
      <link>https://dev.to/drvanon/on-data-and-objects-4p62</link>
      <guid>https://dev.to/drvanon/on-data-and-objects-4p62</guid>
      <description>&lt;p&gt;At my employer there is a functionally unlimited book budget, which I have been making good use of. Which is why lately I have been thinking a lot about meta-programming. You know what I am talking about, paradigms, programming styles, data structures as philosophical constructs represented in the real world with series of 1s and 0s. Computer science stuff. &lt;/p&gt;

&lt;h2&gt;
  
  
  Why I am confused
&lt;/h2&gt;

&lt;p&gt;One of my main sources of confusion is the &lt;a href="https://www.tedinski.com/"&gt;tedinski&lt;/a&gt; blog. It is really cool, but only armed with a physics degree, this stuff goes way over my head most of the time. More practical for me is the book &lt;a href="https://www.manning.com/books/data-oriented-programming"&gt;"Data oriented programming" by Yehonathan Sharvit&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Tedinski in particular tries to describe the &lt;a href="https://www.tedinski.com/2018/01/23/data-objects-and-being-railroaded-into-misdesign.html"&gt;difference between objects and data&lt;/a&gt;, but he stops short of actually defining the difference. Sharvit simply assumes the difference to be understood. This inspired some meditation on my part that is materializing as this post.&lt;/p&gt;

&lt;h2&gt;
  
  
  My (hypo)thesis
&lt;/h2&gt;

&lt;p&gt;Thinking about this, I formed a hypothesis for a good definition of data and objects. Through writing this post I feel like I have come to feel rather pleased with my understanding and would consider it if not correct at least meritorious. My definition for objects and data are as follows:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Data is a collection of queryable facts. An object is a collection of executable behaviors. &lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;For facts I had a clear understanding: &lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;A queryable fact is a independent statement that can be derived from a machine state that is assumed to be truthful.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;With queryable I refer to the fact that with my machine I am able to retrieve particular aspects about the data in any order, so that I can pass it on to subprocesses that can perform actions based upon this data.&lt;/p&gt;

&lt;h2&gt;
  
  
  Describing behavior
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Prolog and graph databases
&lt;/h3&gt;

&lt;p&gt;What remained unclear to myself was my understanding of behavior. I felt like I lacked a clear definition for it. I also did not have the ability to point out in code what exactly was "data" and what was "objects". &lt;/p&gt;

&lt;p&gt;This brings me to prolog. Now heads up, I am as clueless about prolog as the next guy. I am completely incapable of writing anything useful in that language, but the ideas it presents are useful to me, especially since it works with symbols that are extremely close to my definition of data. &lt;/p&gt;

&lt;p&gt;In the book &lt;a href="https://www.oreilly.com/library/view/designing-data-intensive-applications/9781491903063/"&gt;designing data intensive applications&lt;/a&gt; Martin Kleppmann introduces the core concept of graph databases using prolog. The core idea is as follows: in prolog we can define relations as follows:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight prolog"&gt;&lt;code&gt;&lt;span class="cm"&gt;/*&lt;/span&gt;&lt;span class="err"&gt; Contents of relation.pl &lt;/span&gt;&lt;span class="cm"&gt;*/&lt;/span&gt;
&lt;span class="ss"&gt;relation&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="ss"&gt;a&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="ss"&gt;b&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;
&lt;span class="ss"&gt;relation&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="ss"&gt;b&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="ss"&gt;c&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;
&lt;span class="ss"&gt;related&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;X&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nv"&gt;Y&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;:-&lt;/span&gt; &lt;span class="ss"&gt;relation&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;X&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nv"&gt;Z&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt; &lt;span class="ss"&gt;relation&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;Z&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nv"&gt;Y&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In the prolog command line we can then ask if these facts are true:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight prolog"&gt;&lt;code&gt;&lt;span class="p"&gt;|&lt;/span&gt; &lt;span class="o"&gt;?-&lt;/span&gt; &lt;span class="ss"&gt;relation&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="ss"&gt;a&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="ss"&gt;b&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;
&lt;span class="ss"&gt;yes&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;and if &lt;code&gt;a&lt;/code&gt; and &lt;code&gt;c&lt;/code&gt; are related:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight prolog"&gt;&lt;code&gt;&lt;span class="p"&gt;|&lt;/span&gt; &lt;span class="o"&gt;?-&lt;/span&gt; &lt;span class="ss"&gt;related&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="ss"&gt;a&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="ss"&gt;c&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;
&lt;span class="ss"&gt;true&lt;/span&gt; 
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;or if &lt;code&gt;d&lt;/code&gt; and &lt;code&gt;e&lt;/code&gt; are related&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight prolog"&gt;&lt;code&gt;&lt;span class="p"&gt;|&lt;/span&gt; &lt;span class="o"&gt;?-&lt;/span&gt; &lt;span class="ss"&gt;related&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="ss"&gt;d&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="ss"&gt;e&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;
&lt;span class="ss"&gt;no&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;With this we can create edges that describe data. For example if we want to state: john has a job as programmer, lives in Illinois and a Illinois is in the USA. We can represent that as follows in prolog.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight prolog"&gt;&lt;code&gt;&lt;span class="cm"&gt;/*&lt;/span&gt;&lt;span class="err"&gt; Contents of edges.pl &lt;/span&gt;&lt;span class="cm"&gt;*/&lt;/span&gt;
&lt;span class="ss"&gt;edge&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="ss"&gt;john&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="ss"&gt;job&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="ss"&gt;programmer&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;
&lt;span class="ss"&gt;edge&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="ss"&gt;john&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="ss"&gt;in&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="ss"&gt;il&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;
&lt;span class="ss"&gt;edge&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="ss"&gt;il&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="ss"&gt;in&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="ss"&gt;usa&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;
&lt;span class="ss"&gt;in&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;X&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nv"&gt;Y&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;:-&lt;/span&gt; &lt;span class="ss"&gt;edge&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;X&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="ss"&gt;in&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nv"&gt;Y&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;
&lt;span class="ss"&gt;in&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;X&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nv"&gt;Y&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;:-&lt;/span&gt; &lt;span class="ss"&gt;in&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;X&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nv"&gt;Z&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt; &lt;span class="ss"&gt;in&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;Z&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nv"&gt;Y&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The latter two lines are rules, these state that &lt;code&gt;in(a, b)&lt;/code&gt; is true if the fact &lt;code&gt;edge(a, in, b)&lt;/code&gt; exists or if &lt;code&gt;a&lt;/code&gt; recursively is in &lt;code&gt;b&lt;/code&gt;. I personally think this is beautiful. Rules like this allows you to write rather complex queries with relative ease. Take for example the query "Which people have jobs as programmers in the united states?". This can be expressed rather easily with the following prolog query.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight prolog"&gt;&lt;code&gt;&lt;span class="nv"&gt;GNU&lt;/span&gt; &lt;span class="nv"&gt;Prolog&lt;/span&gt; &lt;span class="mf"&gt;1.5&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="m"&gt;0&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="m"&gt;64&lt;/span&gt; &lt;span class="ss"&gt;bits&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="nv"&gt;Compiled&lt;/span&gt; &lt;span class="nv"&gt;Apr&lt;/span&gt; &lt;span class="m"&gt;23&lt;/span&gt; &lt;span class="m"&gt;2022&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="m"&gt;09&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt;&lt;span class="m"&gt;20&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt;&lt;span class="m"&gt;55&lt;/span&gt; &lt;span class="ss"&gt;with&lt;/span&gt; &lt;span class="ss"&gt;gcc&lt;/span&gt;
&lt;span class="nv"&gt;Copyright&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;C&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="m"&gt;1999&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="m"&gt;2022&lt;/span&gt; &lt;span class="nv"&gt;Daniel&lt;/span&gt; &lt;span class="nv"&gt;Diaz&lt;/span&gt;

&lt;span class="p"&gt;|&lt;/span&gt; &lt;span class="o"&gt;?-&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="ss"&gt;edges&lt;/span&gt;&lt;span class="p"&gt;].&lt;/span&gt; &lt;span class="cm"&gt;/*&lt;/span&gt;&lt;span class="err"&gt; Load facts in edges.pl &lt;/span&gt;&lt;span class="cm"&gt;*/&lt;/span&gt;
&lt;span class="ss"&gt;compiling&lt;/span&gt; &lt;span class="ss"&gt;edges&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="ss"&gt;pl&lt;/span&gt; &lt;span class="ss"&gt;for&lt;/span&gt; &lt;span class="ss"&gt;byte&lt;/span&gt; &lt;span class="ss"&gt;code&lt;/span&gt;&lt;span class="p"&gt;...&lt;/span&gt;
&lt;span class="ss"&gt;edges&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="ss"&gt;pl&lt;/span&gt; &lt;span class="ss"&gt;compiled&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="m"&gt;6&lt;/span&gt; &lt;span class="ss"&gt;lines&lt;/span&gt; &lt;span class="ss"&gt;read&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt; &lt;span class="m"&gt;985&lt;/span&gt; &lt;span class="ss"&gt;bytes&lt;/span&gt; &lt;span class="ss"&gt;written&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="m"&gt;6&lt;/span&gt; &lt;span class="ss"&gt;ms&lt;/span&gt;

&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="m"&gt;1&lt;/span&gt; &lt;span class="ss"&gt;ms&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="ss"&gt;yes&lt;/span&gt;
&lt;span class="p"&gt;|&lt;/span&gt; &lt;span class="o"&gt;?-&lt;/span&gt; &lt;span class="ss"&gt;in&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;X&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="ss"&gt;usa&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt; &lt;span class="ss"&gt;edge&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;X&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="ss"&gt;job&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="ss"&gt;programmer&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;

&lt;span class="nv"&gt;X&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="ss"&gt;john&lt;/span&gt; &lt;span class="o"&gt;?&lt;/span&gt; 

&lt;span class="ss"&gt;yes&lt;/span&gt; 
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;And with that we have created a very basic graph database. Neat.&lt;/p&gt;

&lt;h3&gt;
  
  
  Prolog syntax as the archetype data/behavior language
&lt;/h3&gt;

&lt;p&gt;Summarizing the above I would describe prolog in the following way: there are &lt;em&gt;querys&lt;/em&gt; that prolog evaluates using &lt;em&gt;facts&lt;/em&gt; and &lt;em&gt;rules&lt;/em&gt; to answer what conditions would make the query true. I would like to fit this to my definition of data and objects as I presented at the beginning of the article. Directly from my definition it follows directly that prolog facts are data. With rules and queries the considerations are more complicated. &lt;/p&gt;

&lt;p&gt;Rules are facts in that "a fact &lt;code&gt;in(X, Y)&lt;/code&gt; can be generated from the facts &lt;code&gt;in(X, Y)&lt;/code&gt; and &lt;code&gt;in (Y, Z)&lt;/code&gt;", but it feels unfair to call it data. You could argue that when writing this to a file, in the context of the operating system this is data. The query "what is the current state of the file &lt;code&gt;edges.pl&lt;/code&gt;?" has a factual answer, which can be retrieved by the machine that is my computer. However in the context of prolog, I would argue that it is not data, since it is not independent. This statement can only generate new facts in the presence of other facts. &lt;/p&gt;

&lt;p&gt;I would rather call the symbol "rule" &lt;em&gt;behavior&lt;/em&gt;, since it describes how the system behaves. This in turn would make rule symbols objects. Trying to generalize this, I would say that behaviors have no meaning without data. If we take this to be true, then also every statement in a programming language that is meaningful on its own, must be data. &lt;/p&gt;

&lt;h2&gt;
  
  
  Applying the theory: rust
&lt;/h2&gt;

&lt;p&gt;This makes sense to me when I look at &lt;a href="https://www.rust-lang.org/"&gt;rust&lt;/a&gt;. Rust is a relatively new language that has really challenged a lot of my understanding of programming in excellent way. I have even written some productive code in it already. &lt;/p&gt;

&lt;p&gt;In rust you can define structs. Structs in rust are very similar to structs in C or C++. Here is some syntax, which I find very self explanatory.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight rust"&gt;&lt;code&gt;&lt;span class="k"&gt;struct&lt;/span&gt; &lt;span class="n"&gt;Person&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
   &lt;span class="n"&gt;name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;String&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
   &lt;span class="n"&gt;job&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;String&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
   &lt;span class="n"&gt;location&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nb"&gt;f64&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nb"&gt;f64&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;One of the sources of confusion for me is how the word object is used colloquially. Namely, often I see instantiated structs referred to as "objects". Let's look at instantiation in rust.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight rust"&gt;&lt;code&gt;&lt;span class="k"&gt;let&lt;/span&gt; &lt;span class="n"&gt;john&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;Person&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="n"&gt;name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;"John"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="n"&gt;job&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;"Programmer"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="n"&gt;location&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mf"&gt;41.8793343&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="mf"&gt;87.6289326&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Previously I would say that "the variable &lt;code&gt;john&lt;/code&gt; holds a &lt;code&gt;Person&lt;/code&gt; object." However in a discussion of objects and data I would rather say "the variable &lt;code&gt;john&lt;/code&gt; holds &lt;code&gt;Person&lt;/code&gt; data". &lt;/p&gt;

&lt;p&gt;Rust does allows for the definition of behaviors on structs however. It does so through &lt;code&gt;impl&lt;/code&gt; blocks. Let me show an example.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight rust"&gt;&lt;code&gt;&lt;span class="k"&gt;impl&lt;/span&gt; &lt;span class="n"&gt;Person&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="k"&gt;fn&lt;/span&gt; &lt;span class="nf"&gt;greet&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="o"&gt;&amp;amp;&lt;/span&gt;&lt;span class="k"&gt;self&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nd"&gt;println!&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"Hello, I am {}."&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="k"&gt;self&lt;/span&gt;&lt;span class="py"&gt;.name&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This would imply that now I can make john greet his new friends.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight rust"&gt;&lt;code&gt;&lt;span class="n"&gt;john&lt;/span&gt;&lt;span class="nf"&gt;.greet&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;However now it would be much harder to describe the contents of the &lt;code&gt;john&lt;/code&gt; variable. Is it an object or is it data? I would say that &lt;code&gt;john&lt;/code&gt; is now a &lt;em&gt;stateful&lt;/em&gt; object, or that the object that in &lt;code&gt;john&lt;/code&gt; has encapsulated person data, especially since rust makes fields private by default.&lt;/p&gt;

&lt;h2&gt;
  
  
  Resolving a confusion
&lt;/h2&gt;

&lt;p&gt;This would also explain why json like dictionary structures are referred to as data by Sharvit. Though technically when loading a json file, you create dictionary and list &lt;em&gt;objects&lt;/em&gt;, which even have methods, really this structure is much more like data, since it presents a number of queryable facts. Which also explains why libraries like &lt;a href="https://lodash.com/"&gt;lodash&lt;/a&gt; (and all of its offspring in other languages) do not extend (or subclass) the map/array/number classes, but instead define a set of functions that take those as generic structures as arguments.&lt;/p&gt;

&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;I feel like this could be the start of an exploration of a more rigorous definition of data, objects and queries. With these definitions in hand, it would be simpler to explore data oriented programming principles, as well as deep diving into topics like immutability. Definitions have purpose and their quality often is defined by the rigor with which they are stated.&lt;/p&gt;

</description>
      <category>programming</category>
      <category>computerscience</category>
      <category>rust</category>
      <category>dataorientedprogramming</category>
    </item>
  </channel>
</rss>
