It seems a little crazy to think about an application as just a reflection of the data, but I believe it is actually true. I've been building front-end browser applications for a long time, but it wasn't until I started getting into Clojure and ClojureScript (which was pretty recently) that the lightbulb went off for me.
What Are Components Really?
What Do You Mean By "Data"?
You might laugh at that question, but data is a pretty overloaded word. Sure, your application has data, but it has variables, functions, algorithms, and all kinds of other crazy things so where do you draw the line between data and not data? Can you point at something and tell if it's data? Well, I'm going to give you my definition of data. To me, the "data" of your application is all about the literals, and when I say literals it basically boils down to two things: strings and numbers. Sure, some languages (like C) only have characters (not string data type), and languages like Java have many different types for various use cases for numbers (Integer, Float, BigInteger, Ratio, etc.). However, in my mind these all roll up into strings and numbers, the two ways to really convey an underlying value. The only other thing I consider data besides the literal are collections. In an actual real-world application we often have collections of these literals (or collections of other collections, but if you keep digging you'll eventually hit some literals). Collections have slightly different features and names in different programming languages, but they are often called things like: Array, Vector, Hash Map, List, etc.
So that's what data is, according to Jim. Literals and collections. That's it! This is why when talking about Clojure people often say the phrase, "code is data". In Clojure, everything is an expression, even function calls. The syntax to write an expression is just a list collection containing the function you want to be invoked along with the arguments you pass to it. In Java you don't put every statement inside of an array, do you? No, that doesn't even make sense... But in Clojure you do. In Clojure, all the actual code is contained in list collections, and collections are data. Therefore, in Clojure the code is data. Ok then, let's move along!
Tying the View to the Data
The Data Should Be In One Place
The posts on this site are written and maintained by Jim Lynch. About Jim...