Programming is a way to express ourselves, is a form of art if you do it with style and do it properly. The source code is a literature. However, the programming language determines the genre, you can write heroic poems in C or ASM, zen koans in Lisp/Clojure, contemporary farout stories in Haskell or write the next Game of Thrones in Elixir. However, with Java whatever you do, the result will be some romantic wordy crap with boring sceneries. Tableau is about Zen: be expressive, pithy and beautiful.
But how can we generate tableau extracts in this Zen way?
First of all we must chose a programming language. It should be clean, short and and functional. Each and every characters must have a meaning. It should be functional as functional languages are designed to work with data more efficiently. Since in essence everything in functional languages are data it become very easy to handle and manipulate data. The same set of functions used to manipulate data structures work the same on all data structures, so you can transform data from one structure to another and still apply the same functions. We can consider D, F#, Haskell, Clojure, Erlang or Elixir. Erlang and Elixir are overkill for simple extract creation, D is not clean enough, F# is too microsoft and Haskell generally sucks in IO with its idiomatic monads.
So lets use Clojure.
Lets see an example how it generates and extract:
Again, every character, every closure make sense. table-definition defines the structure of the extract. You do not need to create new object instances just to call setter methods to pass the stuff to an another object. Just define the table without any unnecessary characters, that’s it. The test-data function follows a different functional pattern. repeatedly takes a function and executes it infinity time in a lazy way. Theoretically it returns a vector with infinity number of elements, however, it will calculate the values for the elements on their first read value operation.
The “main” function is clean and easy to read as well. The with-extract closure ensures that the TDE file will be closed when the execute will go out of scope. The threading macro ( -> ) instructs the compiler to take the result from the previous command and push it as the first argument for the next function in scope. table tries to open a table, return it’s definition if exists or create if not. add-rows takes 10 rows from test data. Again, test-data is an infinite sequence, but we “take” only 10 from that never ending sequence.
No objects, no lengthy parameter passing and return code mungling and no variables at all. This immutable world with short form expressions are the nirvana, source of programmers’ peace.
- Tableau Extensions Addons Introduction: Synchronized Scrollbars - December 2, 2019
- Tableau External Services API: Adding Haskell Expressions as Calculations - November 20, 2019
- Scaling out Tableau Extracts – Building a distributed, multi-node MPP Hyper Cluster - August 11, 2019