miller/doc/originality.html

291 lines
13 KiB
HTML

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html lang="en">
<!-- PAGE GENERATED FROM template.html and content-for-originality.html BY poki. -->
<!-- PLEASE MAKE CHANGES THERE AND THEN RE-RUN poki. -->
<head>
<meta http-equiv="Content-type" content="text/html;charset=UTF-8"/>
<meta name="description" content="Miller documentation"/>
<meta name="viewport" content="width=device-width, initial-scale=1.0"/> <!-- mobile-friendly -->
<meta name="keywords"
content="John Kerl, Kerl, Miller, miller, mlr, OLAP, data analysis software, regression, correlation, variance, data tools, " />
<title> How original is Miller? </title>
<link rel="stylesheet" type="text/css" href="css/miller.css"/>
<link rel="stylesheet" type="text/css" href="css/poki-callbacks.css"/>
</head>
<!-- ================================================================ -->
<script type="text/javascript">
var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");
document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));
</script>
<script type="text/javascript">
try {
var pageTracker = _gat._getTracker("UA-15651652-1");
pageTracker._trackPageview();
} catch(err) {}
</script>
<!-- ================================================================ -->
<script type="text/javascript">
function toggle_div(div) {
if (div != null) {
if (div.id.startsWith("section_toggle_")) {
var state = div.style.display;
if (state == "block") {
div.style.display = "none";
} else {
div.style.display = "block";
}
}
}
}
function expand_div(div) {
if (div != null) {
if (div.id.startsWith("section_toggle_")) {
div.style.display = "block";
}
}
}
function collapse_div(div) {
if (div != null) {
if (div.id.startsWith("section_toggle_")) {
div.style.display = "none";
}
}
}
function toggle_by_name(divName) {
toggle_div(document.getElementById(divName));
}
function expand_by_name(divName) {
expand_div(document.getElementById(divName));
}
function collapse_by_name(divName) {
collapse_div(document.getElementById(divName));
}
function expand_all() {
var divs = document.getElementsByTagName("div");
for(var i = 0; i < divs.length; i++) {
expand_div(divs[i]);
}
}
function collapse_all() {
var divs = document.getElementsByTagName("div");
for(var i = 0; i < divs.length; i++){
collapse_div(divs[i]);
}
}
</script>
<!--
The background image is from a screenshot of a Google search for "data analysis
tools", lightened and sepia-toned. Over this was placed a Mac Terminal app with
very light-grey font and translucent background, in which a few statistical
Miller commands were run with pretty-print-tabular output format.
<body background="pix/sepia-overlay.jpg">
-->
<body bgcolor="#ffffff">
<!-- ================================================================ -->
<table width="100%">
<tr>
<!-- navbar -->
<td width="15%">
<!--
<img src="pix/mlr.jpg" />
<img style="border-width:1px; color:black;" src="pix/mlr.jpg" />
-->
<div class="pokinav">
<center><titleinbody>Miller</titleinbody></center>
<!-- PAGE LIST GENERATED FROM template.html BY poki -->
<br/><b>Overview:</b>
<br/>&bull;&nbsp;<a href="index.html">About Miller</a>
<br/>&bull;&nbsp;<a href="10-min.html">Miller in 10 minutes</a>
<br/>&bull;&nbsp;<a href="file-formats.html">File formats</a>
<br/>&bull;&nbsp;<a href="feature-comparison.html">Miller features in the context of the Unix toolkit</a>
<br/>&bull;&nbsp;<a href="record-heterogeneity.html">Record-heterogeneity</a>
<br/>&bull;&nbsp;<a href="internationalization.html">Internationalization</a>
<br/><b>Using Miller:</b>
<br/>&bull;&nbsp;<a href="faq.html">FAQ</a>
<br/>&bull;&nbsp;<a href="data-sharing.html">Sharing data with other languages</a>
<br/>&bull;&nbsp;<a href="cookbook.html">Cookbook part 1</a>
<br/>&bull;&nbsp;<a href="cookbook2.html">Cookbook part 2</a>
<br/>&bull;&nbsp;<a href="cookbook3.html">Cookbook part 3</a>
<br/>&bull;&nbsp;<a href="data-examples.html">Data-diving examples</a>
<br/>&bull;&nbsp;<a href="manpage.html">Manpage</a>
<br/>&bull;&nbsp;<a href="reference.html">Reference</a>
<br/>&bull;&nbsp;<a href="reference-verbs.html">Reference: Verbs</a>
<br/>&bull;&nbsp;<a href="reference-dsl.html">Reference: DSL</a>
<br/>&bull;&nbsp;<a href="release-docs.html">Documents by release</a>
<br/>&bull;&nbsp;<a href="build.html">Installation, portability, dependencies, and testing</a>
<br/><b>Background:</b>
<br/>&bull;&nbsp;<a href="why.html">Why?</a>
<br/>&bull;&nbsp;<a href="whyc.html">Why C?</a>
<br/>&bull;&nbsp;<a href="etymology.html">Why call it Miller?</a>
<br/>&bull;&nbsp;<a href="originality.html"><b>How original is Miller?</b></a>
<br/>&bull;&nbsp;<a href="performance.html">Performance</a>
<br/><b>Repository:</b>
<br/>&bull;&nbsp;<a href="to-do.html">Things to do</a>
<br/>&bull;&nbsp;<a href="contact.html">Contact information</a>
<br/>&bull;&nbsp;<a href="https://github.com/johnkerl/miller">GitHub repo</a>
<br/> <br/> <br/> <br/> <br/> <br/> <br/> <br/> <br/> <br/> <br/> <br/>
<br/> <br/> <br/> <br/> <br/> <br/> <br/> <br/> <br/> <br/> <br/> <br/>
<br/> <br/> <br/> <br/> <br/> <br/>
</div>
</td>
<!-- page body -->
<td>
<!--
This is a visually gorgeous feature (here & in the CSS): it allows for
independent scroll of the nav and body panels. In particular the nav
stays on-screen as you scroll the body.
However, two problems:
(1) In Firefox & Chrome both I get janky end-of-body scrolls: there is
more content but I can't scroll down to it unless I repeatedly retry the
scrolldown. Which is weird.
(2) Worse, only the first page renders in PDF (again, Firefox & Chrome).
For now I'm disabling this separate-scroll feature. A frontender, I am
not ... maybe someday I'll find a config which gets *all* the features
I want; for now, it's a tradeoff.
-->
<!-- Implementation details: one bit is right here:
div style="overflow-y:scroll;height:1500px"
and the other bit is in css/poki-callbacks.css:
.pokinav {
display: inline-block;
background: #e8d9bc;
border: 1;
box-shadow: 0px 0px 3px 3px #C9C9C9;
margin: 10px;
padding-top: 10px;
padding-bottom: 10px;
padding-left: 10px;
padding-right: 10px;
overflow-y: scroll; < - - - - - - here
height: 1500px;
}
-->
<div>
<center> <titleinbody> How original is Miller? </titleinbody> </center>
<p/>
<!-- BODY COPIED FROM content-for-originality.html BY poki -->
<p/> It isn&rsquo;t. Miller is one of many, many participants in the
online-analytical-processing culture. Other key participants include
<tt>awk</tt>, SQL, spreadsheets, etc. etc. etc. Far from being an original
concept, Miller explicitly strives to imitate several existing tools:
<p/>
<boldmaroon>Unix toolkit</boldmaroon>: Intentional similarities as described in
<a href="feature-comparison.html">Miller features in the context of the Unix toolkit</a>.
<p/>Recipes abound for command-line data analysis using the Unix toolkit. Here are just a couple of my favorites:
<ul>
<li/> <a href="http://en.wikibooks.org/wiki/Ad_Hoc_Data_Analysis_From_The_Unix_Command_Line">http://en.wikibooks.org/wiki/Ad_Hoc_Data_Analysis_From_The_Unix_Command_Line</a>
<li/> <a href="http://www.gregreda.com/2013/07/15/unix-commands-for-data-science">http://www.gregreda.com/2013/07/15/unix-commands-for-data-science</a>
<li/> <a href="https://github.com/dbohdan/structured-text-tools">https://github.com/dbohdan/structured-text-tools</a>
</ul>
<p/> <boldmaroon>RecordStream</boldmaroon>: Miller owes particular inspiration
to <a href="https://github.com/benbernard/RecordStream">RecordStream</a>. The
key difference is that RecordStream is a Perl-based tool for manipulating JSON
(including requiring it to separately manipulate other formats such as CSV into
and out of JSON), while Miller is fast C which handles its formats natively.
The similarities include the <tt>sort</tt>, <tt>stats1</tt> (analog of
RecordStream&rsquo;s <tt>collate</tt>), and <tt>delta</tt> operations, as well
as <tt>filter</tt> and <tt>put</tt>, and pretty-print formatting.
<p/> <boldmaroon>stats_m</boldmaroon>: A third source of lineage is my Python
<a href="https://github.com/johnkerl/scripts-math/tree/master/stats">stats_m</a>
module. This includes simple single-pass algorithms which form Miller&rsquo;s
<tt>stats1</tt> and <tt>stats2</tt> subcommands.
<p/> <boldmaroon>SQL</boldmaroon>: Fourthly, Miller&rsquo;s <tt>group-by</tt> command
name is from SQL, as is the term <tt>aggregate</tt>.
<p/> <boldmaroon>Added value</boldmaroon>:
Miller&rsquo;s added values include:
<ul>
<li> Name-indexing, compared to the Unix toolkit&rsquo;s positional indexing.
<li> Raw speed, compared to <tt>awk</tt>, RecordStream, <tt>stats_m</tt>, or various other kinds of Python/Ruby/etc. scripts one can easily create.
<li> Compact keystroking for many common tasks, with a decent amount of flexibility.
<li> Ability to handle text files on the Unix pipe, without need for creating database tables, compared to SQL databases.
<li> Various file formats, and on-the-fly format conversion.
</ul>
<p/><boldmaroon>jq</boldmaroon>: Miller does for name-indexed text what
<a href="http://stedolan.github.io/jq/">jq</a> does for JSON. If you&rsquo;re
not already familiar with <tt>jq</tt>, please <a href="http://stedolan.github.io/jq/">check it out!</a>.
<p/><boldmaroon>What about similar tools?</boldmaroon>
Here&rsquo;s a comprehensive list:
<a href="https://github.com/dbohdan/structured-text-tools">https://github.com/dbohdan/structured-text-tools</a>.
It doesn&rsquo;t mention <a href="https://github.com/turicas/rows">rows</a> so here&rsquo;s a plug for that as well.
As it turns out, I learned about most of these after writing Miller.
<p/><boldmaroon>What about DOTADIW?</boldmaroon> One of the key points of the
<a href="http://en.wikipedia.org/wiki/Unix_philosophy">Unix philosophy</a> is
that a tool should do one thing and do it well. Hence <tt>sort</tt> and
<tt>cut</tt> do just one thing. Why does Miller put <tt>awk</tt>-like
processing, a few SQL-like operations, and statistical reduction all into one
tool (see also <a href="reference.html">Reference</a>)? This is a fair
question. First note that many standard tools, such as <tt>awk</tt> and
<tt>perl</tt>, do quite a few things &mdash; as does <tt>jq</tt>. But I could
have pushed for putting format awareness and name-indexing options into
<tt>cut</tt>, <tt>awk</tt>, and so on (so you could do <tt>cut -f
hostname,uptime</tt> or <tt>awk '{sum += $x*$y}END{print sum}'</tt>). Patching
<tt>cut</tt>, <tt>sort</tt>, etc. on multiple operating systems is a
non-starter in terms of uptake. Moreover, it makes sense for me to have Miller
be a tool which collects together format-aware record-stream processing into
one place, with good reuse of Miller-internal library code for its various
features.
<p/><boldmaroon>Why not use Perl/Python/Ruby etc.?</boldmaroon> Maybe you
should. With those tools you&rsquo;ll get far more expressive power, and
sufficiently quick turnaround time for small-to-medium-sized data. Using
Miller you&rsquo;ll get something less than a complete programming language,
but which is fast, with moderate amounts of flexibility and much less
keystroking.
<p/>When I was first developing Miller I made a survey of several languages.
Using low-level implementation languages like C, Go, Rust, and Nim, I&rsquo;d
need to create my own domain-specific language (DSL) which would always be less
featured than a full programming language, but I&rsquo;d get better
performance. Using high-level interpreted languages such as Perl/Python/Ruby
I&rsquo;d get the language&rsquo;s <tt>eval</tt> for free and I wouldn&rsquo;t
need a DSL; Miller would have mainly been a set of format-specific I/O hooks.
If I&rsquo;d gotten good enough performance from the latter I&rsquo;d have done
it without question and Miller would be far more flexible. But C won the
performance criteria by a landslide so we have Miller in C with a custom DSL.
<p/> <boldmaroon>No, really, why one more command-line data-manipulation
tool?</boldmaroon> I wrote Miller because I was frustrated with tools like
<tt>grep</tt>, <tt>sed</tt>, and so on being <i>line-aware</i> without being
<i>format-aware</i>. The single most poignant example I can think of is seeing
people grep data lines out of their CSV files and sadly losing their header
lines. While some lighter-than-SQL processing is very nice to have, at core I
wanted the format-awareness of <a
href="https://github.com/benbernard/RecordStream">RecordStream</a> combined
with the raw speed of the Unix toolkit. Miller does precisely that.
</div>
</td>
</table>
</body>
</html>