<?xml version='1.0' encoding='utf-8' ?>

<rss version='2.0' xmlns:lj='http://www.livejournal.org/rss/lj/1.0/' xmlns:atom10='http://www.w3.org/2005/Atom'>
<channel>
  <title>Tang&apos;s DW</title>
  <link>https://tangaroa.dreamwidth.org/</link>
  <description>Tang&apos;s DW - Dreamwidth Studios</description>
  <lastBuildDate>Tue, 04 Jul 2017 08:14:21 GMT</lastBuildDate>
  <generator>LiveJournal / Dreamwidth Studios</generator>
  <lj:journal>tangaroa</lj:journal>
  <lj:journaltype>personal</lj:journaltype>
<item>
  <guid isPermaLink='true'>https://tangaroa.dreamwidth.org/123671.html</guid>
  <pubDate>Tue, 04 Jul 2017 08:14:21 GMT</pubDate>
  <title>Elvish, a new Unix shell</title>
  <link>https://tangaroa.dreamwidth.org/123671.html</link>
  <description>&lt;p&gt;Via lobste.rs, &lt;a href=&quot;https://elvish.io/&quot;&gt;the Elvish shell&lt;/a&gt;: 

&lt;blockquote&gt;Pipelines in Elvish can carry structured data, not just text. You can stream lists, maps and even functions through the pipeline.&lt;/blockquote&gt;

&lt;p&gt;Not too long ago I was thinking that shells should bring in high level language features and pipes should be matched with data types. It sounds promising.&lt;/p&gt;&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;img src=&quot;https://www.dreamwidth.org/tools/commentcount?user=tangaroa&amp;ditemid=123671&quot; width=&quot;30&quot; height=&quot;12&quot; alt=&quot;comment count unavailable&quot; style=&quot;vertical-align: middle;&quot;/&gt; comments</description>
  <comments>https://tangaroa.dreamwidth.org/123671.html</comments>
  <category>computers</category>
  <category>unix</category>
  <category>programming</category>
  <lj:security>public</lj:security>
  <lj:reply-count>0</lj:reply-count>
</item>
<item>
  <guid isPermaLink='true'>https://tangaroa.dreamwidth.org/123248.html</guid>
  <pubDate>Thu, 08 Jun 2017 22:34:23 GMT</pubDate>
  <title>Optimizable Malleability, and other thoughts</title>
  <link>https://tangaroa.dreamwidth.org/123248.html</link>
  <description>&lt;h3&gt;Optimizable Malleability&lt;/h3&gt;

&lt;p&gt;The life of a productive environment may look like: 

&lt;ol&gt;
&lt;li&gt;High malleability - you can do almost anything, with few restrictions.
&lt;li&gt;Exploration - certain workflows are found to be better than others.
&lt;li&gt;Optimization - simplified interfaces increase productivity while leaving out lesser-used features.
&lt;li&gt;Stagnation - The existence of a standard way of doing things discourages the development of alternative ideas.
&lt;li&gt;Replacement - Somebody invests a new system that replaces the entire old system.
&lt;/li&gt;&lt;/li&gt;&lt;/li&gt;&lt;/li&gt;&lt;/li&gt;&lt;/ol&gt;

&lt;p&gt;Examples of malleable systems and optimized systems:

&lt;ul&gt;
&lt;li&gt;Assembly language lets you do anything, leading to goto spaghetti. C gives you formal looping and function call patterns along with a subset of assembly&apos;s features. Higher level languages have additional formal implementations of common programming patterns and lack some of C&apos;s features to prevent entire categories of bugs. Driver writers and OS programmers still need the lower-level features, but 90% of programming can be done without them.

&lt;li&gt;Text files allow you to store data in any format. Every Unix tool invented its own text file format. INI, CSV, JSON, and XML are types of text files that are optimized toward storing certain types of information.

&lt;li&gt;Tail call recursion is an optimizable subset of recursion.

&lt;li&gt;Excel lets you freely place data without structure. Access requires you to define the structure first. 

&lt;li&gt;Static typing versus dynamic typing. A language could be dynamic by default with optional static typing and optional type constraints. In this case the optimized system (static typing) came first and the malleable system came later.

&lt;/li&gt;&lt;/li&gt;&lt;/li&gt;&lt;/li&gt;&lt;/li&gt;&lt;/ul&gt;

&lt;p&gt;Stagnated systems and their replacements: 

&lt;ul&gt;
&lt;li&gt;Why aren&apos;t webforums based on Usenet/NNTP? The environment of HTML+SQL allowed for the development of alternatives at a lower cost.

&lt;li&gt;Why don&apos;t new languages use object files? The burden of compatibility is not worth it.

&lt;li&gt;Why aren&apos;t most programs made of shell scripts? Fewer features, security concerns, etc.
&lt;/li&gt;&lt;/li&gt;&lt;/li&gt;&lt;/ul&gt;

&lt;hr /&gt;

&lt;h3&gt;Reconsidering the notion of a &quot;program&quot;&lt;/h3&gt;

&lt;p&gt;Let us view the entire operating environment as a set of mechanisms for directing input to a function. 

&lt;p&gt;Consider the command line shell.

&lt;ul&gt;
&lt;li&gt;The user provides the program with &lt;em&gt;representations of&lt;/em&gt; the function&apos;s arguments. The arguments are not passed directly, but you provide a string that represents the argument. Code inside the program converts the string to a filename or URL, parses the data, and provides that as the argument to the function. 
&lt;li&gt;The program provides standard input and output methods, using pipes
&lt;li&gt;The program may allow the user to set the initial state of the program, using switches
&lt;/li&gt;&lt;/li&gt;&lt;/li&gt;&lt;/ul&gt;

&lt;p&gt;We could say that a program is a wrapper that sets state, has the standard input and output, and provides access to the desired function(s). Let us consider a future operating environment that separates these tasks.

&lt;ul&gt;
&lt;li&gt;The future system could automate the generation of wrapper code.
&lt;li&gt;The future system may use dynamic type casting, late binding, just-in-time compilation, etc to rewrite part of the program based on the user&apos;s input.
&lt;li&gt;The future system might allow the caller to directly set global variables / class members by name, doing away with the need to parse switches. 
&lt;li&gt;Inputs and outputs may be something other than raw byte streams. The pipes may have a class type. The system may provide a standard iterator for a given type and handle casting automatically. The standard Unix tools may be rewritten to work on interfaces. 
&lt;/li&gt;&lt;/li&gt;&lt;/li&gt;&lt;/li&gt;&lt;/ul&gt;

&lt;hr /&gt;

&lt;h3&gt;Incomplete classes and comprehensive dynamic typing&lt;/h3&gt; 

&lt;p&gt;Consider the evolution of classes.

&lt;ul&gt;
&lt;li&gt;1970s - C -  A &lt;tt&gt;struct&lt;/tt&gt; is, basically, a way to arrange data 
&lt;li&gt;1980s - C++ - A &lt;tt&gt;class&lt;/tt&gt; is, basically, a way to arrange functions around the data they operate on 
&lt;li&gt;1990s - C#/Java - An &lt;tt&gt;interface&lt;/tt&gt; is, basically, a definition for a set of functions that we will expect any given type to implement.
&lt;/li&gt;&lt;/li&gt;&lt;/li&gt;&lt;/ul&gt;

&lt;p&gt;The struct, class, and interface are all key/value pairs. 


&lt;p&gt;Consider the function: 

&lt;pre&gt;sub doStuff(x){ return x + 1 }&lt;/pre&gt;

&lt;p&gt;In the &quot;message passing&quot; concept we might consider &lt;tt&gt;x:Dynamic&lt;/tt&gt; and expect the runtime to check whether the given x has a ._plus() method at call time. (A more complex system could check for this when the object to be passed as x is known.) In the &quot;interface&quot; concept we might check that x implements the INumeric interface which includes a ._plus() function. &quot;INumeric&quot; is a way of saying that a dynamic type will implement a standard set of methods, what C# calls a contract. 

&lt;p&gt;An interface might be seen as an incomplete data type. An incomplete data type might be seen as a type of filter. A data type filter could describe the partially resolved value of a dynamic type, or could be used to implement very strict typing. 

&lt;pre&gt;
interface IPercent:UInt8 {
  _value = 0..100 // Value is between 0 and 100 inclusive 
} 

interface asdf {
  foo:String and len = 0..8 // .foo will be a string whose length is &amp;gt; 8
  
  // let&apos;s propose something outrageous... 
  baz: fnord(_) between &amp;(&quot;camel&quot;), dronf(&quot;llama&quot;) and &amp; &amp;gt; 3 
  // * we will have a .baz member
  // * the namespace will also include functions fnord() and dronf()
  // * the result of fnord(baz) has a comparator that puts its result
  // between the results of fnord(&quot;camel&quot;) and dronf(&quot;llama&quot;),
  // * and the value of fnord(baz) will be greater than 3
  // * or else the program throws a type mismatch exception,
  // preferably at compile time 
} 
&lt;/pre&gt;

&lt;p&gt;This would be of little use to a programmer, but might be useful to a compiler, runtime, or IDE. 

&lt;pre&gt;
// as written by the programmer
function doSomething(futz): 

// as interpreted internally 
function doSomething(futz:{
  foo:String = &quot;foo&quot; // string with a known value 
  bar():Int // an undefined function that returns int
  } 
)
&lt;/pre&gt;


&lt;p&gt;The same sort of filter or incomplete class can also be used as a search object. 

&lt;pre&gt;
interface SalariesOver30000:Employee { 
  salary:Numeric &amp;gt;30000   
}

select SalariesOver30000 from Employees // pseudo-sql
&lt;/pre&gt;

&lt;hr /&gt;
&lt;h3&gt;Function constraints&lt;/h3&gt;

&lt;p&gt;A compiler could theoretically determine that it is impossible for a function to do certain things: 

&lt;ul&gt;
&lt;li&gt;a given function may not modify its inputs 
&lt;li&gt;the function may not make any asynchronous calls 
&lt;li&gt;the function may not open any additional inputs or outputs
&lt;li&gt;the function&apos;s inputs may have values known at compile time or runtime
&lt;/li&gt;&lt;/li&gt;&lt;/li&gt;&lt;/li&gt;&lt;/ul&gt;

&lt;p&gt;A compiler could potentially use this information to optimize the function, possibly running it at compile time if enough information is known.

&lt;hr /&gt;


&lt;p&gt;My TODO list for language design is to look into:

&lt;ul&gt;
&lt;li&gt;intermediate languages
&lt;li&gt;continuation-passing-style (CPS) interpreters 
&lt;li&gt;A-normal form (ANF) representations 
&lt;li&gt;static single assignment (SSA) representations
&lt;li&gt;Haskell&apos;s universal machine and Higher Order Abstract Syntax
&lt;li&gt;read: &lt;a href=&quot;https://wingolog.org/archives/2011/07/12/static-single-assignment-for-functional-programmers&quot;&gt;static single assignment for functional programmers&lt;/a&gt;
&lt;li&gt;&lt;a href=&quot;http://www.antlr.org/&quot;&gt;ANTLR&lt;/a&gt;
&lt;/li&gt;&lt;/li&gt;&lt;/li&gt;&lt;/li&gt;&lt;/li&gt;&lt;/li&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/p&gt;&lt;/p&gt;&lt;/p&gt;&lt;/p&gt;&lt;/p&gt;&lt;/p&gt;&lt;/p&gt;&lt;/p&gt;&lt;/p&gt;&lt;/p&gt;&lt;/p&gt;&lt;/p&gt;&lt;/p&gt;&lt;/p&gt;&lt;/p&gt;&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;img src=&quot;https://www.dreamwidth.org/tools/commentcount?user=tangaroa&amp;ditemid=123248&quot; width=&quot;30&quot; height=&quot;12&quot; alt=&quot;comment count unavailable&quot; style=&quot;vertical-align: middle;&quot;/&gt; comments</description>
  <comments>https://tangaroa.dreamwidth.org/123248.html</comments>
  <category>computers</category>
  <category>programming</category>
  <lj:security>public</lj:security>
  <lj:reply-count>0</lj:reply-count>
</item>
<item>
  <guid isPermaLink='true'>https://tangaroa.dreamwidth.org/122941.html</guid>
  <pubDate>Mon, 06 Feb 2017 15:47:41 GMT</pubDate>
  <title>A lesson in meaningful variable naming</title>
  <link>https://tangaroa.dreamwidth.org/122941.html</link>
  <description>&lt;p&gt;A variable representing a link to a website might be called &lt;tt&gt;$url&lt;/tt&gt; or &lt;tt&gt;$link&lt;/tt&gt; or &lt;tt&gt;$site&lt;/tt&gt;. 
Take &lt;a href=&quot;http://tangaroa.dreamwidth.org/122537.html&quot;&gt;this project&lt;/a&gt; I&apos;m working on. At one point in the code the variable might be called &lt;tt&gt;$url&lt;/tt&gt;. 
At another point it is &lt;tt&gt;$link&lt;/tt&gt;. Further on, it is &lt;tt&gt;$site&lt;/tt&gt;. I want to reach back across time 
to my younger self and &lt;s&gt;slap him the face and scream at him and&lt;/s&gt; impart a lesson on the value of 
maintaining a consistent naming convention.

&lt;p&gt;So let&apos;s say &lt;tt&gt;$site&lt;/tt&gt; represents a link to a website except when it doesn&apos;t because I am also
using &lt;tt&gt;$site&lt;/tt&gt; as a unique key to represent a website in the general sense that &quot;this website contains
web pages&quot;. For this purpose I send &lt;tt&gt;$site&lt;/tt&gt; through a filter that strips out the protocol and
leading &lt;tt&gt;www.&lt;/tt&gt; and the ending &lt;tt&gt;index.html&lt;/tt&gt; if it exists. This means that &lt;tt&gt;$site&lt;/tt&gt; 
is not the same thing that it used to be. So &lt;tt&gt;$site&lt;/tt&gt; and &lt;tt&gt;$link&lt;/tt&gt; actually are two different
things with two different meanings. They should be two different variables. 

&lt;p&gt;I fixed a few bugs just by noticing that the meaning of these variables was not consistent. 

&lt;hr /&gt;

&lt;p&gt;In the same program I have two variables &lt;tt&gt;$sites_visited&lt;/tt&gt; and
&lt;tt&gt;$destination_count&lt;/tt&gt; that seem to have a similar purpose.

&lt;p&gt;&lt;tt&gt;$sites_visited&lt;/tt&gt; is: 
&lt;ul&gt;
&lt;li&gt;set to 1 when &lt;tt&gt;process_site()&lt;/tt&gt; is run
&lt;li&gt;checked when recursing into new sites 
&lt;li&gt;was sent to &lt;tt&gt;process_site_results()&lt;/tt&gt; in an earlier version, but this is commented out
&lt;/li&gt;&lt;/li&gt;&lt;/li&gt;&lt;/ul&gt;

&lt;p&gt;&lt;tt&gt;$destination_count&lt;/tt&gt; is: 
&lt;ul&gt;
&lt;li&gt;increased by 1 when &lt;tt&gt;process_site()&lt;/tt&gt; is run (this is a bug) 
&lt;li&gt;increased by 1 when a site&apos;s list of links is finalized
&lt;li&gt;used by &lt;tt&gt;process_site_results()&lt;/tt&gt; to determine whether the site should be included in output.
&lt;/li&gt;&lt;/li&gt;&lt;/li&gt;&lt;/ul&gt;

&lt;p&gt;So both of them are set to &lt;tt&gt;true&lt;/tt&gt; when a site is processed and were intended to be used to tell if a site is worth processing. However, they mean different things. 

&lt;ul&gt;
&lt;li&gt;&lt;tt&gt;$sites_visited&lt;/tt&gt; is &lt;tt&gt;true&lt;/tt&gt; when a site has been fetched and processed. 
&lt;li&gt;&lt;tt&gt;$destination_count&lt;/tt&gt; counts the number of times a site has been linked from
another site. It is nonzero (&lt;tt&gt;true&lt;/tt&gt;) before the site is fetched or processed. 
&lt;/li&gt;&lt;/li&gt;&lt;/ul&gt;

&lt;p&gt;So they remain two different variables because they account for different concepts.&lt;/p&gt;&lt;/p&gt;&lt;/p&gt;&lt;/p&gt;&lt;/p&gt;&lt;/p&gt;&lt;/p&gt;&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;img src=&quot;https://www.dreamwidth.org/tools/commentcount?user=tangaroa&amp;ditemid=122941&quot; width=&quot;30&quot; height=&quot;12&quot; alt=&quot;comment count unavailable&quot; style=&quot;vertical-align: middle;&quot;/&gt; comments</description>
  <comments>https://tangaroa.dreamwidth.org/122941.html</comments>
  <category>programming</category>
  <lj:security>public</lj:security>
  <lj:reply-count>0</lj:reply-count>
</item>
<item>
  <guid isPermaLink='true'>https://tangaroa.dreamwidth.org/122862.html</guid>
  <pubDate>Sun, 05 Feb 2017 19:26:47 GMT</pubDate>
  <title>Quick thoughts on multiple inheritance</title>
  <link>https://tangaroa.dreamwidth.org/122862.html</link>
  <description>&lt;h4&gt;Has-A pattern:&lt;/h4&gt;

&lt;pre&gt;
class MyClass { 
 FooType foo;
 BarType bar;
}&lt;/pre&gt;

&lt;ul&gt;
&lt;li&gt;each MyClass allocates space for a FooType and a BarType.
&lt;li&gt;&lt;tt&gt;foo&lt;/tt&gt; and &lt;tt&gt;bar&lt;/tt&gt; establish their own namespaces.
&lt;/li&gt;&lt;/li&gt;&lt;/ul&gt;

&lt;h4&gt;Inheritance:&lt;/h4&gt;

&lt;pre&gt;class MyClass extends FooType, BarType { }&lt;/pre&gt;

&lt;ul&gt;
&lt;li&gt;each MyClass allocates space for a FooType and a BarType.
&lt;li&gt;The namespaces for FooType and BarType are incorporated into the MyClass namespace.
&lt;/li&gt;&lt;/li&gt;&lt;/ul&gt;

&lt;p&gt;So what&apos;s the problem? Something in FooType or BarType might overlap. 

&lt;h4&gt;General outline of a solution:&lt;/h4&gt;

&lt;ul&gt;&lt;li&gt;All namespace conflicts must be resolved by the programmer.&lt;/li&gt;&lt;/ul&gt;

&lt;h4&gt;Considering specific examples:&lt;/h4&gt;

&lt;p&gt;1. Both FooType and BarType have a .x property? 
&lt;ul&gt;
&lt;li&gt;Solution 1: Forced upcasting. All attempts to access MyClass.x must be upcasted 
to the parent. All parent methods work on their own .x property.
&lt;/li&gt;&lt;/ul&gt;
&lt;p&gt;2. Both FooType and BarType have a .fooMethod()? 
&lt;ul&gt;
&lt;li&gt;Solution 1: Forced upcasting. The compiler should warn if the programmer fails 
to resolve the conflict, and throw an error if the programmer tries to run 
MyClass.fooMethod() without overriding it. This can cause problems (see case 4). 
&lt;/li&gt;&lt;/ul&gt;

&lt;p&gt;3. MyClass has its own .x property? 
&lt;ul&gt;
&lt;li&gt;Solution 1: Override parent access methods. If the property is interface-compatible 
with the parent&apos;s .x property, the FooType/BarType methods will run on MyClass.x
instead of their own .x properties. If the property is not interface-compatible 
with the parent&apos;s .x, the compiler should throw an error and refuse to compile. 
PROBLEM: FooType and BarType may intend for their .x property to mean different
incompatible things or to hold separate pieces of information. Sharing the same
piece of data will introduce bugs.
&lt;li&gt;Solution 2: Do not override parent access methods. Parents continue to operate
on their own .x properties. 
&lt;/li&gt;&lt;/li&gt;&lt;/ul&gt;
&lt;p&gt;4. MyClass has its own .fooMethod()? Theoretically, this should override the
FooType/BarType methods. However, it introduces a double-call problem. 
&lt;ul&gt;
&lt;li&gt;Solution 1: Override parent methods. This introduces a double-call problem.
If both parents have a method called every second that calls their own fooMethod(),
this causes the overridden fooMethod() to be called twice per second instead of 
once per second.
&lt;li&gt;Solution 2: Do not override parent methods. Parent calls to fooMethod() will
call the parent version of fooMethod().
&lt;/li&gt;&lt;/li&gt;&lt;/ul&gt;


&lt;h4&gt;Conclusions&lt;/h4&gt;

&lt;p&gt;More thought needs to go into this.

&lt;ul&gt;
&lt;li&gt;Multiple inheritance is fine until you have a namespace collision, and then you&apos;re in trouble.
&lt;li&gt;If you have the parent classes share data when both have a .x property, then you have the problems that each might treat .x as a different conceptual thing and that conflicting actions on the same .x may introduce race conditions that do not exist when each class uses its own data.
&lt;li&gt;If you do not have the parent classes share data, then you have multiple copies of what might be the same conceptual thing, updates to one do not affect the other, and the state of &quot;.x&quot; is unclear.
&lt;li&gt;If the child class .x overrides the property for both parent classes, then you risk the parent methods modifying the data in ways you did not intend.
&lt;li&gt;If the child&apos;s .foo() overrides the method for both parent classes, then you might get a double-call problem when methods in both parent classes call their overridden .foo() method.
&lt;li&gt;If the child&apos;s .foo() does not override the parent method, then you lose the ability to extend the parent class by having its .foo() method do something different.
&lt;li&gt;The programmer may want to resolve namespace collisions in a different way for different properties and methods in the same class.
&lt;/li&gt;&lt;/li&gt;&lt;/li&gt;&lt;/li&gt;&lt;/li&gt;&lt;/li&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/p&gt;&lt;/p&gt;&lt;/p&gt;&lt;/p&gt;&lt;/p&gt;&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;img src=&quot;https://www.dreamwidth.org/tools/commentcount?user=tangaroa&amp;ditemid=122862&quot; width=&quot;30&quot; height=&quot;12&quot; alt=&quot;comment count unavailable&quot; style=&quot;vertical-align: middle;&quot;/&gt; comments</description>
  <comments>https://tangaroa.dreamwidth.org/122862.html</comments>
  <category>computers</category>
  <category>programming</category>
  <lj:security>public</lj:security>
  <lj:reply-count>0</lj:reply-count>
</item>
<item>
  <guid isPermaLink='true'>https://tangaroa.dreamwidth.org/122537.html</guid>
  <pubDate>Tue, 31 Jan 2017 02:00:07 GMT</pubDate>
  <title>Revisiting a pet project</title>
  <link>https://tangaroa.dreamwidth.org/122537.html</link>
  <description>&lt;p&gt;Gee, I &lt;em&gt;think&lt;/em&gt; this software of mine is close to ready for release. I just need to brush it up a &lt;em&gt;little&lt;/em&gt;.

&lt;blockquote&gt;
&lt;p&gt;... (create a todo list ... it&apos;s half a dozen things)

&lt;p&gt;... (open the file, and there&apos;s a list of another half dozen things to do) 

&lt;p&gt;... (there are several known bugs that have no discernable cause)

&lt;p&gt;... (none of the functions are documented and I cannot tell what one of them is supposed to return)

&lt;p&gt;... (making it run well will require repeatedly rerunning it and massaging input data files) 

&lt;p&gt;... (it produces no output when given the same input that had produced good results the last time I had worked on it)

&lt;p&gt;... (the file is still named test.pl) 
&lt;/p&gt;&lt;/p&gt;&lt;/p&gt;&lt;/p&gt;&lt;/p&gt;&lt;/p&gt;&lt;/p&gt;&lt;/blockquote&gt;

&lt;p&gt;This might take more time than I had thought.&lt;/p&gt;&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;img src=&quot;https://www.dreamwidth.org/tools/commentcount?user=tangaroa&amp;ditemid=122537&quot; width=&quot;30&quot; height=&quot;12&quot; alt=&quot;comment count unavailable&quot; style=&quot;vertical-align: middle;&quot;/&gt; comments</description>
  <comments>https://tangaroa.dreamwidth.org/122537.html</comments>
  <category>programming</category>
  <category>webcomics</category>
  <lj:security>public</lj:security>
  <lj:reply-count>0</lj:reply-count>
</item>
<item>
  <guid isPermaLink='true'>https://tangaroa.dreamwidth.org/119940.html</guid>
  <pubDate>Fri, 09 Dec 2016 15:28:31 GMT</pubDate>
  <title>Building high level code from low level code</title>
  <link>https://tangaroa.dreamwidth.org/119940.html</link>
  <description>&lt;p&gt;Consider that a class in c++ or java defines both an implementation and an interface.
&lt;p&gt;Consider the similarities in these three examples:

&lt;pre&gt;
// Example 1 
interface IFoo {
 // interface
 doStuff();

 // implementation not defined
}
&lt;/pre&gt;

&lt;pre&gt;
// Example 2
class Foo {

 // implementation
 int x;
 string y;

 //interface
 doStuff(){...}
}
&lt;/pre&gt;


&lt;pre&gt;
// Example 3
// implementation 
struct foo {
 int x;
 string y;
}

void foo_doStuff(); // interface
&lt;/pre&gt;

&lt;p&gt;An ordinary compiler might be expected to convert lower-level code to a low-level implementation 
immediately upon reading it. The programmer has defined exactly how the code is to be implemented, and there is no apparent need for higher level considerations. 

&lt;p&gt;A hypothetical high-level compiler might first convert as much low level code as possible into
a higher-level intermediary language.

&lt;ul&gt;
&lt;li&gt;&lt;tt&gt;class Foo&lt;/tt&gt; is automatically built from &lt;tt&gt;struct foo&lt;/tt&gt; and is automatically populated 
by the foo_() functions that operate on a struct foo.
&lt;li&gt;&lt;tt&gt;interface IFoo&lt;/tt&gt; is automatically built from the internal representation of &lt;tt&gt;class Foo&lt;/tt&gt;
&lt;li&gt;This high level representation is saved to an object file and can be accessed by any programming
language that can load libraries.
&lt;/li&gt;&lt;/li&gt;&lt;/li&gt;&lt;/ul&gt;

&lt;p&gt;Additional thoughts:  

&lt;ul&gt;
&lt;li&gt;An autodoc tool can produce documentation from the resulting high-level objects, especially if the
high level object includes comments or links back to the original source code.
&lt;li&gt;An IPC mechanism can send the object definition to the receiving side if the receiving side does not have the structure defined. 
&lt;li&gt;The compiler can detect classes that are binary-compatible with one another and allow them 
to be casted without harm. 
&lt;/li&gt;&lt;/li&gt;&lt;/li&gt;&lt;/ul&gt;

&lt;hr /&gt;

&lt;p&gt;Also, it should be possible for a sufficiently smart compiler to recognize that some for-loops are examples of an iteration. These can be interpreted upwards to a high-level description of an iteration like &lt;tt&gt;foreach x in myArray{...}&lt;/tt&gt; for which the developer has provided a low-level implementation &lt;tt&gt;for (i=0; i&amp;lt;length; i++){...} &lt;/tt&gt;

&lt;p&gt;I cannot think of any benefit to doing this, but it could potentially be done.&lt;/p&gt;&lt;/p&gt;&lt;/p&gt;&lt;/p&gt;&lt;/p&gt;&lt;/p&gt;&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;img src=&quot;https://www.dreamwidth.org/tools/commentcount?user=tangaroa&amp;ditemid=119940&quot; width=&quot;30&quot; height=&quot;12&quot; alt=&quot;comment count unavailable&quot; style=&quot;vertical-align: middle;&quot;/&gt; comments</description>
  <comments>https://tangaroa.dreamwidth.org/119940.html</comments>
  <category>programming</category>
  <category>computers</category>
  <lj:security>public</lj:security>
  <lj:reply-count>0</lj:reply-count>
</item>
<item>
  <guid isPermaLink='true'>https://tangaroa.dreamwidth.org/116233.html</guid>
  <pubDate>Sun, 07 Aug 2016 21:19:09 GMT</pubDate>
  <title>DWARF Overpopulation</title>
  <link>https://tangaroa.dreamwidth.org/116233.html</link>
  <description>&lt;p&gt;A new preview release of &lt;a href=&quot;https://swift.org/download/&quot;&gt;Swift 3&lt;/a&gt; is out this month. I tried compiling it with debugging flags turned on, left my computer running, and came back several hours later to a failed build.

&lt;blockquote&gt;
FAILED: lib/libLTO.so &lt;br /&gt;
(...cut giant parameter list...) &lt;br /&gt;
clang-3.7: error: unable to execute command: Killed &lt;br /&gt;
clang-3.7: error: linker command failed due to signal (use -v to see invocation)
&lt;/blockquote&gt;


&lt;p&gt;Huh. I tried it again while browsing the web in the background. A few hours later, my system started swapping like crazy. KDE froze for minutes at a time. 
&lt;tt&gt;top&lt;/tt&gt; showed several &lt;tt&gt;ld&lt;/tt&gt; processes each using over 1GB of memory. 
I think it died when one of them hit the 32-bit limit at 2GB. 

&lt;p&gt;So, WTF? Let&apos;s check out the sizes of some of these libraries.&lt;/p&gt;

&lt;blockquote&gt;
&lt;pre&gt;
560968756 Aug  6 19:22 libclangSema.a
620546286 Aug  6 19:49 libclangStaticAnalyzerCheckers.a
660270964 Aug  6 19:19 libLTO.so
&lt;/pre&gt;
&lt;/blockquote&gt;

&lt;p&gt;And let&apos;s see what&apos;s in some of these archives.
&lt;blockquote&gt;
&lt;pre&gt;
~/swift/src/build/Ninja-DebugAssert/llvm-freebsd-x86_64/lib% ar -tv libclangStaticAnalyzerCheckers.a
rw-r--r--       0/0        164312 Dec 31 16:00 1969 AllocationDiagnostics.cpp.o
rw-r--r--       0/0       7163456 Dec 31 16:00 1969 AnalyzerStatsChecker.cpp.o
rw-r--r--       0/0       7142344 Dec 31 16:00 1969 ArrayBoundChecker.cpp.o
rw-r--r--       0/0       7290936 Dec 31 16:00 1969 ArrayBoundCheckerV2.cpp.o
rw-r--r--       0/0       9251672 Dec 31 16:00 1969 BasicObjCFoundationChecks.cpp.o
rw-r--r--       0/0       7271432 Dec 31 16:00 1969 BoolAssignmentChecker.cpp.o
rw-r--r--       0/0       7159208 Dec 31 16:00 1969 BuiltinFunctionChecker.cpp.o
...
&lt;/pre&gt;
&lt;/blockquote&gt;

&lt;p&gt;There are many object files in the 7MB range. It adds up. Looking at one of them with &lt;tt&gt;elfdump&lt;/tt&gt;, nearly all of the space is used by DWARF debugging info.  

&lt;blockquote&gt;
&lt;pre&gt;
entry: 730
        sh_name: .debug_str
        sh_type: SHT_PROGBITS
        sh_flags: 
        sh_addr: 0
        sh_offset: 26152
        sh_size: 3267448
        sh_link: 0
        sh_info: 0
        sh_addralign: 1
        sh_entsize: 1
entry: 734
        sh_name: .debug_info
        sh_type: SHT_PROGBITS
        sh_flags: 
        sh_addr: 0
        sh_offset: 3296469
        sh_size: 1252146
        sh_link: 0
        sh_info: 0
        sh_addralign: 1
        sh_entsize: 0

entry: 735
        sh_name: .rela.debug_info
        sh_type: SHT_RELA
        sh_flags: 
        sh_addr: 0
        sh_offset: 5007208
        sh_size: 2054928
        sh_link: 748
        sh_info: 734
        sh_addralign: 8
        sh_entsize: 24
&lt;/pre&gt;        
&lt;/blockquote&gt;
        

&lt;p&gt;How big are the original source code files?

&lt;blockquote&gt;4944&lt;/blockquote&gt;

&lt;p&gt;So &lt;em&gt;that&lt;/em&gt; gets turned into 7MB when debugging flags are turned on, and it all goes over 2GB when multiplied by the many files in a large package. This causes the build to fail.&lt;/p&gt;&lt;/p&gt;&lt;/p&gt;&lt;/p&gt;&lt;/p&gt;&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;img src=&quot;https://www.dreamwidth.org/tools/commentcount?user=tangaroa&amp;ditemid=116233&quot; width=&quot;30&quot; height=&quot;12&quot; alt=&quot;comment count unavailable&quot; style=&quot;vertical-align: middle;&quot;/&gt; comments</description>
  <comments>https://tangaroa.dreamwidth.org/116233.html</comments>
  <category>programming</category>
  <category>computers</category>
  <category>freebsd</category>
  <category>swift</category>
  <lj:security>public</lj:security>
  <lj:reply-count>0</lj:reply-count>
</item>
<item>
  <guid isPermaLink='true'>https://tangaroa.dreamwidth.org/115709.html</guid>
  <pubDate>Sun, 31 Jul 2016 18:58:49 GMT</pubDate>
  <title>Scrap Dump</title>
  <link>https://tangaroa.dreamwidth.org/115709.html</link>
  <description>&lt;p&gt;pattern for resolution of an abstraction to a meaningful value 

&lt;p&gt;A = an abstract something 

&lt;pre&gt;
function f(A) {
  if(A == &quot;FOO&quot;)
    return FOO
  if (A == &quot;BAR&quot;)
    return BAR 
  if (A matches /[A-Za-z0-9]+/)
    return TOKEN_ALNUM
  if (A has method &quot;next&quot;)
    return I_SEQUENCE
  if ( not (A contains meat) )
    return VEGETARIAN

  return DEFAULT 
}&lt;/pre&gt;

&lt;p&gt;This can be generalized to a function taking input: 
&lt;pre&gt;   f(A, DEFAULT, array of [f_comparator -&amp;gt; f_resolver])&lt;/pre&gt;
&lt;br /&gt;where the comparator function runs a comparison or pattern match on A, and the resolver function takes A and produces an output. 


&lt;p&gt;Possible error conditions: 
&lt;ul&gt;
&lt;li&gt;All comparators fail. Solution: force caller to provide a DEFAULT value, have the caller handle it. 
&lt;li&gt;Multiple comparators match. Possible solutions: 
&lt;ol&gt;
&lt;li&gt;Use the first matching comparator.
&lt;li&gt;Give different values to comparators. Use the comparator with the highest matching score. 
&lt;li&gt;(combination of 1 and 2) Sort the comparator-&amp;gt;resolver pairs by comparator value before passing them in.
&lt;li&gt;Throw an exception (nooooooo!)
&lt;li&gt;[Edit Aug 2] Perform ALL of the matching operations. Assume the function is a decorator. 
&lt;li&gt;[Edit Aug 2] Perform all of the matching operations and return a set of results. Assume the function returns results, plural, rather than one result.
&lt;/li&gt;&lt;/li&gt;&lt;/li&gt;&lt;/li&gt;&lt;/li&gt;&lt;/li&gt;&lt;/ol&gt;
&lt;/li&gt;&lt;/li&gt;&lt;/ul&gt;

&lt;p&gt;Possible optimizations:

&lt;ul&gt;
&lt;li&gt;Inline the function calls.
&lt;/li&gt;&lt;/ul&gt;

&lt;p&gt;These are not particularly new ideas. All of this has to be well tread ground.

&lt;hr /&gt;

&lt;p&gt;[Edit Aug 2] Thoughts on &quot;inline the function calls&quot;

&lt;p&gt;The comparator functions may be very simple and easily optimizable in theory. My preference is to write code to pass them in as a set and then let the compiler somehow produce code that has the simple comparison functions inlined as in the original example. This might be possible in theory if the functions are defined at compile time. The optimizer would need to be smart enough to unroll the loop and examine its contents and understand them.

&lt;p&gt;If the functions are defined at run time, the optimizer would need to be part of the run time environment. It seems that what I want is the ability to arbitrarily optimize away function calls at runtime.&lt;/p&gt;&lt;/p&gt;&lt;/p&gt;&lt;/p&gt;&lt;/p&gt;&lt;/p&gt;&lt;/p&gt;&lt;/p&gt;&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;img src=&quot;https://www.dreamwidth.org/tools/commentcount?user=tangaroa&amp;ditemid=115709&quot; width=&quot;30&quot; height=&quot;12&quot; alt=&quot;comment count unavailable&quot; style=&quot;vertical-align: middle;&quot;/&gt; comments</description>
  <comments>https://tangaroa.dreamwidth.org/115709.html</comments>
  <category>programming</category>
  <category>computers</category>
  <lj:security>public</lj:security>
  <lj:reply-count>0</lj:reply-count>
</item>
<item>
  <guid isPermaLink='true'>https://tangaroa.dreamwidth.org/109081.html</guid>
  <pubDate>Sun, 20 Mar 2016 20:46:53 GMT</pubDate>
  <title>Installing Haxe on FreeBSD</title>
  <link>https://tangaroa.dreamwidth.org/109081.html</link>
  <description>&lt;span class=&quot;cut-wrapper&quot;&gt;&lt;span style=&quot;display: none;&quot; id=&quot;span-cuttag___1&quot; class=&quot;cuttag&quot;&gt;&lt;/span&gt;&lt;b class=&quot;cut-open&quot;&gt;(&amp;nbsp;&lt;/b&gt;&lt;b class=&quot;cut-text&quot;&gt;&lt;a href=&quot;https://tangaroa.dreamwidth.org/109081.html#cutid1&quot;&gt;cut for length&lt;/a&gt;&lt;/b&gt;&lt;b class=&quot;cut-close&quot;&gt;&amp;nbsp;)&lt;/b&gt;&lt;/span&gt;&lt;div style=&quot;display: none;&quot; id=&quot;div-cuttag___1&quot; aria-live=&quot;assertive&quot;&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;&lt;img src=&quot;https://www.dreamwidth.org/tools/commentcount?user=tangaroa&amp;ditemid=109081&quot; width=&quot;30&quot; height=&quot;12&quot; alt=&quot;comment count unavailable&quot; style=&quot;vertical-align: middle;&quot;/&gt; comments</description>
  <comments>https://tangaroa.dreamwidth.org/109081.html</comments>
  <category>computers</category>
  <category>freebsd</category>
  <category>programming</category>
  <category>haxe</category>
  <lj:security>public</lj:security>
  <lj:reply-count>0</lj:reply-count>
</item>
<item>
  <guid isPermaLink='true'>https://tangaroa.dreamwidth.org/107584.html</guid>
  <pubDate>Wed, 13 Jan 2016 17:19:40 GMT</pubDate>
  <title>Scrap dump: Thoughts on startup systems</title>
  <link>https://tangaroa.dreamwidth.org/107584.html</link>
  <description>&lt;h3&gt;PC-BSD needs a better startup system&lt;/h3&gt;

&lt;p&gt;It&apos;s 2015 and we still haven&apos;t fixed init systems yet. 
&lt;ul&gt;
&lt;li&gt;Problem: Duplication of code in the scripts. For example, every script contains code that checks to make sure the script is not disabled. This is best handled by the caller.
&lt;li&gt;Problem: Startup scripts are disabled by looking for the name of a magic word in the startup script and manually adding it to a global config file. This is clunky and there has to be a better way. 
&lt;li&gt;Problem: Startup waits 30s for wireless to not connect when booting my laptop away from home. I can ^C but shouldn&apos;t have to. 
&lt;/li&gt;&lt;/li&gt;&lt;/li&gt;&lt;/ul&gt;

&lt;p&gt;Goal: allow a parallel system startup 

&lt;span class=&quot;cut-wrapper&quot;&gt;&lt;span style=&quot;display: none;&quot; id=&quot;span-cuttag___1&quot; class=&quot;cuttag&quot;&gt;&lt;/span&gt;&lt;b class=&quot;cut-open&quot;&gt;(&amp;nbsp;&lt;/b&gt;&lt;b class=&quot;cut-text&quot;&gt;&lt;a href=&quot;https://tangaroa.dreamwidth.org/107584.html#cutid1&quot;&gt;Read more...&lt;/a&gt;&lt;/b&gt;&lt;b class=&quot;cut-close&quot;&gt;&amp;nbsp;)&lt;/b&gt;&lt;/span&gt;&lt;div style=&quot;display: none;&quot; id=&quot;div-cuttag___1&quot; aria-live=&quot;assertive&quot;&gt;&lt;/div&gt;&lt;/p&gt;&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;img src=&quot;https://www.dreamwidth.org/tools/commentcount?user=tangaroa&amp;ditemid=107584&quot; width=&quot;30&quot; height=&quot;12&quot; alt=&quot;comment count unavailable&quot; style=&quot;vertical-align: middle;&quot;/&gt; comments</description>
  <comments>https://tangaroa.dreamwidth.org/107584.html</comments>
  <category>programming</category>
  <category>freebsd</category>
  <category>computers</category>
  <category>linux</category>
  <lj:security>public</lj:security>
  <lj:reply-count>0</lj:reply-count>
</item>
<item>
  <guid isPermaLink='true'>https://tangaroa.dreamwidth.org/107392.html</guid>
  <pubDate>Wed, 13 Jan 2016 17:03:53 GMT</pubDate>
  <title>Scrap dump: notes on programming languages</title>
  <link>https://tangaroa.dreamwidth.org/107392.html</link>
  <description>&lt;ul&gt;
&lt;li&gt;Any operation may take operands (parameters, arguments). Example: function foo($arg1, $arg2, $arg3)
&lt;li&gt;Any operands may have attributes. Example: f(long int $arg1, fancy blue dishwasher $arg2)
&lt;li&gt;The reader (compiler or interpreter) takes operation + operands and produces instructions that will have the desired effect. This can be done at runtime or at compile time. 
&lt;/li&gt;&lt;/li&gt;&lt;/li&gt;&lt;/ul&gt;

&lt;p&gt;Operations, operands, and attributes might be seen respectively as Verbs, Nouns, and Adjectives.

&lt;p&gt;The question of what instructions are to run depends upon the attributes
of the operands. For the simplest example, the code &quot;2 + x&quot; will produce 
different instructions depending upon the attributes of x.

&lt;blockquote&gt;&lt;pre&gt;
small int x = 42
return 2 + x // add ax, 2

long int x = 42
return 2 + x // add eax, 2

float x = 42.0
return 2 + x // fadd(42.0) ; adds to st0
&lt;/pre&gt;&lt;/blockquote&gt;

&lt;p&gt;At some point the system determines &quot;x is an int, use integer add&quot; 
or &quot;x is a float, use floating point add&quot;. The process of compilation
can be described as the resolution of high-level code to lower-level
implementation. This may involve translation through intermediary
languages.

&lt;p&gt;An interpreted high-level language will make these determinations at
run time. A compiler may make the process more efficient by stripping out 
all of these determinations at compile time. At the most extreme of efficiency
the reader may determine that the code will always produce the same
result (42+2 = 44) and insert the resulting value rather than the
code to produce it.

&lt;h4&gt;Optimization vs. reuse&lt;/h4&gt;

&lt;p&gt;A downside of such optimizations is that it becomes 
impossible to modify the behavior of a program at runtime if the
behavior-determining code is optimized out. Correspondingly, an
advantage to keeping code unoptimized is that the program may be 
modified by a wrapper that changes the resolution of a function call. 

&lt;p&gt;A system could provide the best of both worlds by using an object format 
that stores both the optimized version and a high-level interpretation, and
recompiling on the fly when directed to change part of the program. To allow 
the recompilation of one subroutine at a time, instead of rebuilding the 
whole program, the metadata may include a catalogue of entry points.&lt;/p&gt;&lt;/p&gt;&lt;/p&gt;&lt;/p&gt;&lt;/p&gt;&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;img src=&quot;https://www.dreamwidth.org/tools/commentcount?user=tangaroa&amp;ditemid=107392&quot; width=&quot;30&quot; height=&quot;12&quot; alt=&quot;comment count unavailable&quot; style=&quot;vertical-align: middle;&quot;/&gt; comments</description>
  <comments>https://tangaroa.dreamwidth.org/107392.html</comments>
  <category>algorithms</category>
  <category>computers</category>
  <category>programming</category>
  <lj:security>public</lj:security>
  <lj:reply-count>0</lj:reply-count>
</item>
<item>
  <guid isPermaLink='true'>https://tangaroa.dreamwidth.org/106519.html</guid>
  <pubDate>Fri, 08 Jan 2016 17:48:42 GMT</pubDate>
  <title>Golang makes easy things difficult</title>
  <link>https://tangaroa.dreamwidth.org/106519.html</link>
  <description>&lt;p&gt;Go claims to have strings. That would be a nice feature except that most of the core library functions operate on byte arrays and you need to make an explicit cast every time you move from strings to byte arrays and back.

&lt;p&gt;Do you want to interpret a boolean as an int?  &lt;a href=&quot;http://stackoverflow.com/questions/8393933/is-there-a-way-to-convert-integers-to-bools-in-go-or-vice-versa&quot;&gt;Fuck you.&lt;/a&gt;


&lt;p&gt;It is difficult to define complex types such as sets of function references. The syntax that works in a parameter definition produces a syntax error when I try to cast an array. By the way, you need to cast your arrays when you define them because the compiler cannot determine that information from the array&apos;s contents. 

&lt;p&gt;Error handling is... different. For example, if you wanted to write to a file in any other language you would do something like this: 

&lt;blockquote&gt;&lt;pre&gt;
status = fopen(&quot;foo.txt&quot;, &quot;w&quot;)
&lt;/pre&gt;&lt;/blockquote&gt;

&lt;p&gt;or: 

&lt;blockquote&gt;&lt;pre&gt;
try {
 fopen(&quot;foo.txt&quot;, &quot;w&quot;)
} catch e {
...
}
&lt;/pre&gt;&lt;/blockquote&gt;

&lt;p&gt;In Golang you need to do something like this: 

&lt;blockquote&gt;&lt;pre&gt;
var writer *bufio.Writer 
f1, err1 := os.Open(&quot;foo.txt&quot;)
if(err1 != nil){
	return writer, err1
}
tmp2, err2 := io.Writer(f1)
if(err2 ! nil){
	return writer, err2
}

return bufio.Writer(tmp2)
&lt;/pre&gt;&lt;/blockquote&gt;

&lt;p&gt;... so you end up with long repeating branches in a function that would be a few lines in any other language.

&lt;p&gt;Do you want to close the file, allow other subprocesses to work on it, and reopen it later for reading? &lt;a href=&quot;http://stackoverflow.com/questions/13512634/how-can-i-close-bufio-reader-writer-in-golang&quot;&gt;Fuck you.&lt;/a&gt; 

&lt;p&gt;Have I mentioned that I don&apos;t like golang&apos;s error handling pattern? &lt;a href=&quot;http://codepad.org/SnEYRoVa&quot;&gt;I don&apos;t like golang&apos;s error handling pattern.&lt;/a&gt;

&lt;p&gt;Go gets one thing right and that is its goroutines. Parallelization of a function should be as easy as putting the word &quot;go&quot; in front of the function. Other languages should pick up on this.&lt;/p&gt;&lt;/p&gt;&lt;/p&gt;&lt;/p&gt;&lt;/p&gt;&lt;/p&gt;&lt;/p&gt;&lt;/p&gt;&lt;/p&gt;&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;img src=&quot;https://www.dreamwidth.org/tools/commentcount?user=tangaroa&amp;ditemid=106519&quot; width=&quot;30&quot; height=&quot;12&quot; alt=&quot;comment count unavailable&quot; style=&quot;vertical-align: middle;&quot;/&gt; comments</description>
  <comments>https://tangaroa.dreamwidth.org/106519.html</comments>
  <category>golang</category>
  <category>go</category>
  <category>programming</category>
  <category>computers</category>
  <lj:security>public</lj:security>
  <lj:reply-count>0</lj:reply-count>
</item>
<item>
  <guid isPermaLink='true'>https://tangaroa.dreamwidth.org/105987.html</guid>
  <pubDate>Sun, 29 Nov 2015 20:47:34 GMT</pubDate>
  <title>Sorting</title>
  <link>https://tangaroa.dreamwidth.org/105987.html</link>
  <description>&lt;h3&gt;Streamable sorting&lt;/h3&gt;

&lt;p&gt;A streamable sorting algorithm is one that has an intermediary state in which the entire set may not yet be sorted, but it can be guaranteed that some number of items at the head are sorted. For example, the bubble sort will bring the optimal item to the head of the set before the rest of the set is sorted. The sorted elements at the head may be dispatched while the sorting algorithm continues to run on the remainder of the list.

&lt;p&gt;The use case is to pipe data to a different operation in a multi-stage process so that the entire process will be completed more quickly than if the process had waited for the set to be sorted. This could be in shell scripting or any I/O bound transfer of data. Another use case is in a user-facing interface where the appearance of doing something is more important than total runtime.

&lt;h4&gt;Speed considerations&lt;/h4&gt;
&lt;p&gt;A strong argument against use of a streamable sorting algorithm is that non-streamable algorithms are so much faster than the bubble sort that the process is likely to complete sooner if one chooses the better algorithm and waits for it to complete. 

&lt;p&gt;Made-up example:

&lt;ol&gt;
&lt;li&gt;Algorithm A will sort in 10 seconds and can start transfering after 4 seconds because it knows that the head is optimal.
&lt;li&gt;Algorithm B will sort in 5 seconds, but I/O cannot begin transfer until all items are sorted.
&lt;/li&gt;&lt;/li&gt;&lt;/ol&gt;

&lt;p&gt;The slower algorithm will get the data across sooner if certain conditions are true:

&lt;ol&gt;
&lt;li&gt;Transfer time is slower than the sort time of the faster algorithm. 
&lt;li&gt;The transfer process will not interfere with the sorting process. On modern multi-cpu systems this should not be a problem. 
&lt;li&gt;The fraction of time when transfer may begin (say, at 40% of sort time) is lower than the speed of the comparable nonstreamable algorithm compared to the nonstreamable one (say, algorithm B finishes sorting in 50% of the time of the streamable algorithm). Note that this will depend heavily on the set size due to the performance differences in sorting algorithms.
&lt;/li&gt;&lt;/li&gt;&lt;/li&gt;&lt;/ol&gt;

&lt;p&gt;Variables:
&lt;ul&gt;
&lt;li&gt;Tx = (Time to transfer X objects)
&lt;li&gt;At = (start of transfer for algorithm A)
&lt;li&gt;Bt = (start of transfer for algorithm B)
&lt;/li&gt;&lt;/li&gt;&lt;/li&gt;&lt;/ul&gt;

&lt;p&gt;When transfer time is slower than the sorting time of either sort algorithm, the overall process is bound by when the transfer begins. The streamable algorithm will be faster when it begins transfer before the non-streamable algorithm would finish and begin transfer.

&lt;p&gt;When transfer time is faster than the slower streamable sorting algorithm, the streamable algorithm is bound by its own slowness. The process will be faster than a non-streamable algorithm only if transfer time remains slow enough for (Tx + Bt) to be greater than the time needed for the streamable algorithm to 
finish sorting. 

&lt;hr /&gt;
&lt;h3&gt;Dividing sort time across sender and receiver&lt;/h3&gt;

&lt;p&gt;Imagine the following: 

&lt;ul&gt;
&lt;li&gt;We need to sort and transfer data between two systems that both need to minimize CPU use.
&lt;li&gt;We have a sorting algorithm that divides the set into chunks and sorts the chunks over multiple passes.
&lt;li&gt;We can predict the number of passes needed by the algorithm from the set size. 
&lt;/li&gt;&lt;/li&gt;&lt;/li&gt;&lt;/ul&gt;

&lt;p&gt;Assuming that it is still the 1990s when these limits would matter (this is more of an intellectual exercise than a serious proposal), we can divide the effort of sorting between client and server. The sender runs half of the expected number of passes and sends the data partially-sorted. The receiver finishes sorting the half-sorted data as the data is received and inserts the items coming down the pipe where they best fit.&lt;/p&gt;&lt;/p&gt;&lt;/p&gt;&lt;/p&gt;&lt;/p&gt;&lt;/p&gt;&lt;/p&gt;&lt;/p&gt;&lt;/p&gt;&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;img src=&quot;https://www.dreamwidth.org/tools/commentcount?user=tangaroa&amp;ditemid=105987&quot; width=&quot;30&quot; height=&quot;12&quot; alt=&quot;comment count unavailable&quot; style=&quot;vertical-align: middle;&quot;/&gt; comments</description>
  <comments>https://tangaroa.dreamwidth.org/105987.html</comments>
  <category>algorithms</category>
  <category>computers</category>
  <category>programming</category>
  <lj:security>public</lj:security>
  <lj:reply-count>0</lj:reply-count>
</item>
<item>
  <guid isPermaLink='true'>https://tangaroa.dreamwidth.org/105956.html</guid>
  <pubDate>Sun, 29 Nov 2015 19:09:01 GMT</pubDate>
  <title>Brief thoughts on metadata</title>
  <link>https://tangaroa.dreamwidth.org/105956.html</link>
  <description>&lt;p&gt;Let us say that we have a data object and we want to manage metadata about the object. There are multiple ways of handling this.
&lt;span class=&quot;cut-wrapper&quot;&gt;&lt;span style=&quot;display: none;&quot; id=&quot;span-cuttag___1&quot; class=&quot;cuttag&quot;&gt;&lt;/span&gt;&lt;b class=&quot;cut-open&quot;&gt;(&amp;nbsp;&lt;/b&gt;&lt;b class=&quot;cut-text&quot;&gt;&lt;a href=&quot;https://tangaroa.dreamwidth.org/105956.html#cutid1&quot;&gt;Read more...&lt;/a&gt;&lt;/b&gt;&lt;b class=&quot;cut-close&quot;&gt;&amp;nbsp;)&lt;/b&gt;&lt;/span&gt;&lt;div style=&quot;display: none;&quot; id=&quot;div-cuttag___1&quot; aria-live=&quot;assertive&quot;&gt;&lt;/div&gt;&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;img src=&quot;https://www.dreamwidth.org/tools/commentcount?user=tangaroa&amp;ditemid=105956&quot; width=&quot;30&quot; height=&quot;12&quot; alt=&quot;comment count unavailable&quot; style=&quot;vertical-align: middle;&quot;/&gt; comments</description>
  <comments>https://tangaroa.dreamwidth.org/105956.html</comments>
  <category>computers</category>
  <category>programming</category>
  <lj:security>public</lj:security>
  <lj:reply-count>0</lj:reply-count>
</item>
<item>
  <guid isPermaLink='true'>https://tangaroa.dreamwidth.org/105697.html</guid>
  <pubDate>Wed, 25 Nov 2015 00:55:53 GMT</pubDate>
  <title>Strings should be interfaces</title>
  <link>https://tangaroa.dreamwidth.org/105697.html</link>
  <description>&lt;p&gt;Proposed: &lt;strong&gt;The basic data types of a programming language should be interfaces&lt;/strong&gt;, the standard library should work on interfaces, and the low-level data types should be implementations of the basic interface.

&lt;p&gt;The php devs spent years trying to convert their default string type from ascii to unicode before giving up. Golang shits a brick if you try to convert between a string and a []byte without an explicit cast. Consider instead that every function were written to operate on a &lt;tt&gt;string&lt;/tt&gt; &lt;em&gt;interface&lt;/em&gt; rather than a string data type, and we let the compiler and optimizer figure out what to do with whatever is passed into the function. []byte can implement the string interface. The programmer can send the standard string functions data in any charset (korean, japanese, whatever) and it will just work because a string of any charset will implement the string interface. 

&lt;p&gt;Another use case: You read some numbers as an integer. It could be a bigint or a small int. You don&apos;t care until you need to store it again. Performance and storage do not matter, you just need some math or a comparison to work. You write your code to work on an &quot;int&quot; interface and let the compiler figure out how to implement it.&lt;/p&gt;&lt;/p&gt;&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;img src=&quot;https://www.dreamwidth.org/tools/commentcount?user=tangaroa&amp;ditemid=105697&quot; width=&quot;30&quot; height=&quot;12&quot; alt=&quot;comment count unavailable&quot; style=&quot;vertical-align: middle;&quot;/&gt; comments</description>
  <comments>https://tangaroa.dreamwidth.org/105697.html</comments>
  <category>programming</category>
  <category>computers</category>
  <lj:security>public</lj:security>
  <lj:reply-count>0</lj:reply-count>
</item>
<item>
  <guid isPermaLink='true'>https://tangaroa.dreamwidth.org/104837.html</guid>
  <pubDate>Thu, 19 Nov 2015 18:50:06 GMT</pubDate>
  <title>Scrap dump: Nim notes</title>
  <link>https://tangaroa.dreamwidth.org/104837.html</link>
  <description>&lt;p&gt;I was experimenting with Nim &lt;a href=&quot;https://tangaroa.dreamwidth.org/91984.html&quot;&gt;earlier this year&lt;/a&gt;.

&lt;p&gt;Useful links:
&lt;ul&gt;
&lt;li&gt;&lt;a href=&quot;http://nim-lang.org/manual.html&quot;&gt;Nim manual&lt;/a&gt; 
&lt;li&gt;&lt;a href=&quot;http://nim-lang.org/tut1.html&quot;&gt;Nim tutorial&lt;/a&gt;
&lt;li&gt;&lt;a href=&quot;http://nim-lang.org/tut2.html&quot;&gt;Num tutorial (part 2 - OOP, exceptions and macros)&lt;/a&gt;
&lt;/li&gt;&lt;/li&gt;&lt;/li&gt;&lt;/ul&gt;

&lt;span class=&quot;cut-wrapper&quot;&gt;&lt;span style=&quot;display: none;&quot; id=&quot;span-cuttag___1&quot; class=&quot;cuttag&quot;&gt;&lt;/span&gt;&lt;b class=&quot;cut-open&quot;&gt;(&amp;nbsp;&lt;/b&gt;&lt;b class=&quot;cut-text&quot;&gt;&lt;a href=&quot;https://tangaroa.dreamwidth.org/104837.html#cutid1&quot;&gt;Scrap notes&lt;/a&gt;&lt;/b&gt;&lt;b class=&quot;cut-close&quot;&gt;&amp;nbsp;)&lt;/b&gt;&lt;/span&gt;&lt;div style=&quot;display: none;&quot; id=&quot;div-cuttag___1&quot; aria-live=&quot;assertive&quot;&gt;&lt;/div&gt;&lt;/p&gt;&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;img src=&quot;https://www.dreamwidth.org/tools/commentcount?user=tangaroa&amp;ditemid=104837&quot; width=&quot;30&quot; height=&quot;12&quot; alt=&quot;comment count unavailable&quot; style=&quot;vertical-align: middle;&quot;/&gt; comments</description>
  <comments>https://tangaroa.dreamwidth.org/104837.html</comments>
  <category>nim</category>
  <category>programming</category>
  <category>computers</category>
  <lj:security>public</lj:security>
  <lj:reply-count>0</lj:reply-count>
</item>
<item>
  <guid isPermaLink='true'>https://tangaroa.dreamwidth.org/104295.html</guid>
  <pubDate>Wed, 11 Nov 2015 16:03:46 GMT</pubDate>
  <title>Computing has gotten abstract. So should operating environments.</title>
  <link>https://tangaroa.dreamwidth.org/104295.html</link>
  <description>&lt;h3&gt;Layers of abstraction&lt;/h3&gt;
&lt;p&gt;At the hardware layer we have native bytecode created from amd64 through a translator. We operate on registers, have to keep track of what data is in what register, and if the data has any meaning there is no way for the computer to know about it.

&lt;p&gt;At the low level of abstraction we operate on bytes and sets of bytes. OS, POSIX, and standard library interfaces are written in C. One might consider high level assembler with strings and matrices to be at this level. There are multiple data definition formats to define how data is laid out in memory: C header files, SQL data definitions, a custom format for each language.

&lt;p&gt;At the intermediate level of abstraction we define classes to associate the data structures with the methods that work on the data. We have templates, interfaces, abstracts, generics to allow code reuse.

&lt;p&gt;At higher levels everything is abstract. We create anonymous objects on the fly and tell the computer to run operations on members that we hope will have been defined by runtime.

&lt;h4&gt;Method abstraction&lt;/h4&gt;

&lt;p&gt;There are similar layers of abstraction for methods, functions, subroutines. At the hardware layer a method is just a series of instructions that you jump to. Low-level programming allows you to describe the inputs and outputs: this function takes a byte pointer and returns a byte pointer. At the intermediate level of abstraction you can define a template function that allows the same code to be reused on different data types. At higher levels of abstraction all functions do that by default. 

&lt;h3&gt;Abstracting operating environments&lt;/h3&gt;

&lt;p&gt;We have had all of these advances in abstraction in the programming area but our shells are still stuck in the early 1990s. Programs are written to read bytes or lines at a time. Streams of characters are passed between programs with no information about what the characters mean. Each program in the sequence must re-parse the stream.

&lt;p&gt;Consider this sequence.

&lt;pre&gt;sh$ ls -l | bar &amp;gt; baz&lt;/pre&gt;

&lt;p&gt;Presently this outputs a chunk of text, and the &lt;tt&gt;bar&lt;/tt&gt; program needs to know what to do with the text. Imagine instead that ls -l generates a table or recordset of files and their attributes, and what it outputs is context-dependent.

&lt;ul&gt;
&lt;li&gt;If the receiver is a text terminal, the shell uses a formatter provided with ls to generate a text table compatible with today&apos;s ls -l.
&lt;li&gt;If the receiver is a hypertext terminal running in a windowed environment, the shell uses a formatter to send the data and metadata to the terminal in a given standard format that the terminal will use to produce an interactive display of files. 
&lt;li&gt;If the receiver is a .csv file, the shell automatically uses the standard table-to-CSV converter from the operating system&apos;s libcsv.
&lt;li&gt;If the receiver is a program that requests input of a given class, the shell attempts to present the input as that class.
&lt;/li&gt;&lt;/li&gt;&lt;/li&gt;&lt;/li&gt;&lt;/ul&gt;

&lt;p&gt;In a high-level shell design, 
&lt;ul&gt;
&lt;li&gt;Programs are written to read more abstract sequences of objects. The implementation of the reader is chosen at runtime. Programs will have metadata exposing their expected input types. 
&lt;li&gt;Programs may pass both data and metadata. There will likely be a standard for a data+metadata format, and all standard readers will automatically recognize it.
&lt;li&gt;Programs may pass pre-parsed chunks of data to skip the step of parsing by subsequent programs. This may be as simple as copying a chunk of memory from one program to another on the same computer. The high level program code will be the same whether the receiving program runs on the same computer (memory copy) or sends the data over the network. 
&lt;/li&gt;&lt;/li&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/p&gt;&lt;/p&gt;&lt;/p&gt;&lt;/p&gt;&lt;/p&gt;&lt;/p&gt;&lt;/p&gt;&lt;/p&gt;&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;img src=&quot;https://www.dreamwidth.org/tools/commentcount?user=tangaroa&amp;ditemid=104295&quot; width=&quot;30&quot; height=&quot;12&quot; alt=&quot;comment count unavailable&quot; style=&quot;vertical-align: middle;&quot;/&gt; comments</description>
  <comments>https://tangaroa.dreamwidth.org/104295.html</comments>
  <category>linux</category>
  <category>computers</category>
  <category>programming</category>
  <lj:security>public</lj:security>
  <lj:reply-count>0</lj:reply-count>
</item>
<item>
  <guid isPermaLink='true'>https://tangaroa.dreamwidth.org/99815.html</guid>
  <pubDate>Tue, 30 Jun 2015 00:38:24 GMT</pubDate>
  <title>And now some bad news from SCOTUS</title>
  <link>https://tangaroa.dreamwidth.org/99815.html</link>
  <description>&lt;a href=&quot;https://soylentnews.org/article.pl?sid=15/06/29/1754205&quot;&gt;The Supreme Court let stand the Google v. Oracle decision finding APIs to be copyrightable&lt;/a&gt; (&lt;a href=&quot;https://tangaroa.dreamwidth.org/78295.html&quot;&gt;mentioned earlier&lt;/a&gt;). They did not make a decision but chose not to hear it on the advice of Solicitor General Donald Verrilli who affirmed the appeals court ruling.&lt;br /&gt;&lt;br /&gt;&lt;img src=&quot;https://www.dreamwidth.org/tools/commentcount?user=tangaroa&amp;ditemid=99815&quot; width=&quot;30&quot; height=&quot;12&quot; alt=&quot;comment count unavailable&quot; style=&quot;vertical-align: middle;&quot;/&gt; comments</description>
  <comments>https://tangaroa.dreamwidth.org/99815.html</comments>
  <category>politics/us</category>
  <category>computers</category>
  <category>programming</category>
  <category>law</category>
  <category>politics</category>
  <lj:security>public</lj:security>
  <lj:reply-count>0</lj:reply-count>
</item>
<item>
  <guid isPermaLink='true'>https://tangaroa.dreamwidth.org/91984.html</guid>
  <pubDate>Sun, 04 Jan 2015 19:04:49 GMT</pubDate>
  <title>Nim</title>
  <link>https://tangaroa.dreamwidth.org/91984.html</link>
  <description>&lt;p&gt;&lt;a href=&quot;http://nim-lang.org/&quot;&gt;Nim&lt;/a&gt; (formerly Nimrod) looks like an interesting language. Via &lt;a href=&quot;https://lobste.rs/&quot;&gt;lobsters&lt;/a&gt;. Some links: 


&lt;ul&gt;
&lt;li&gt;&lt;a href=&quot;http://www.drdobbs.com/open-source/nimrod-a-new-systems-programming-languag/240165321&quot;&gt;Review by 	Andreas Rumpf in Dr. Dobbs&lt;/a&gt;
&lt;li&gt;&lt;a href=&quot;http://ziotom78.blogspot.com/2014/01/experiments-with-nimrod.html&quot;&gt;Review by Maurizio Tomasi&lt;/a&gt;
&lt;li&gt;&lt;a href=&quot;http://hookrace.net/blog/what-is-special-about-nim/&quot;&gt;Review by Dennis Felsing&lt;/a&gt;
&lt;/li&gt;&lt;/li&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;img src=&quot;https://www.dreamwidth.org/tools/commentcount?user=tangaroa&amp;ditemid=91984&quot; width=&quot;30&quot; height=&quot;12&quot; alt=&quot;comment count unavailable&quot; style=&quot;vertical-align: middle;&quot;/&gt; comments</description>
  <comments>https://tangaroa.dreamwidth.org/91984.html</comments>
  <category>nim</category>
  <category>computers</category>
  <category>programming</category>
  <lj:security>public</lj:security>
  <lj:reply-count>0</lj:reply-count>
</item>
<item>
  <guid isPermaLink='true'>https://tangaroa.dreamwidth.org/83297.html</guid>
  <pubDate>Fri, 06 Jun 2014 05:37:51 GMT</pubDate>
  <title>scrap dump</title>
  <link>https://tangaroa.dreamwidth.org/83297.html</link>
  <description>&lt;p&gt;I had intentions to write a blog post declaring 2011 as the Year of the Hacker but never got around to it. We had LulzSec, J3ster, and Web Ninjas. We had Stuxnet. We had Iran hacking certificate agencies. We had the iPhone &quot;Towson&quot; hack. We had noobs getting arrested for using LOIC from home. We had a virus hit control computers for the CIA&apos;s drones.

&lt;hr /&gt;

&lt;p&gt;The benefit of modern Javascript+HTML is that you can do anything with it. The drawback of making Javascript+HTML a Turing-complete environment is that you can do anything with it. 

&lt;hr /&gt;

&lt;p&gt;I was studying Android programming a few &lt;s&gt;months&lt;/s&gt; years ago, and they made this recommendation: &quot;Don&apos;t call the UI-construction code directly! Use XML for your interfaces!&quot; 

&lt;p&gt;The Android XML format is so painful to look at that I thought it worth my time to design my own alternate domain-specific language rather than use the one they gave me. (I never finished it)

&lt;hr /&gt;

&lt;p&gt;The old practice of web development

&lt;blockquote&gt;&lt;pre&gt;
&amp;lt;HTML&amp;gt;
&amp;lt;HEAD&amp;gt;
&amp;lt;TITLE&amp;gt;My Webpage&amp;lt;/TITLE&amp;gt;
&lt;/pre&gt;&lt;/blockquote&gt;


&lt;p&gt;The new practice of web development&lt;/p&gt;

&lt;blockquote&gt;&lt;pre&gt;
var node_html = document.createElement(&quot;HTML&quot;);
var node_html_head = document.createElement(&quot;HEAD&quot;);
var node_html_head_title = document.createElement(&quot;TITLE&quot;);
node_html_head_title.innerHTML =&quot;My Webpage&quot; 
&lt;/pre&gt;&lt;/blockquote&gt;

&lt;hr /&gt;

&lt;p&gt;Android and the Web seem to be going in opposite directions there.

&lt;hr /&gt;

&lt;p&gt;I propose a new baseball statistic that weights and combines multiple different types of failure. Call it Derps Per Perp.

&lt;p&gt;For pitchers:

&lt;ul&gt;
&lt;li&gt;any appearance including:
 &lt;ul&gt;
 &lt;li&gt;an inning surrendering four or more runs, OR
 &lt;li&gt;any appearance of under one inning that is not the final appearance of that inning.
&lt;/li&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/li&gt;
&lt;li&gt;Balks 
&lt;li&gt;Hit batters 
&lt;/li&gt;&lt;/li&gt;&lt;/ul&gt;

&lt;p&gt;for batters:

&lt;ul&gt;
&lt;li&gt;Hitting into double and triple plays
&lt;li&gt;Fielding errors
&lt;/li&gt;&lt;/li&gt;&lt;/ul&gt;

&lt;p&gt;Divide batter stats by factors related to at-bats 
&lt;p&gt;Divide pitcher stats by factors related to innings pitched

&lt;p&gt;Statistics for the AL might need to be adjusted due to pitchers not hitting and designated hitters not fielding.&lt;/p&gt;&lt;/p&gt;&lt;/p&gt;&lt;/p&gt;&lt;/p&gt;&lt;/p&gt;&lt;/p&gt;&lt;/p&gt;&lt;/p&gt;&lt;/p&gt;&lt;/p&gt;&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;img src=&quot;https://www.dreamwidth.org/tools/commentcount?user=tangaroa&amp;ditemid=83297&quot; width=&quot;30&quot; height=&quot;12&quot; alt=&quot;comment count unavailable&quot; style=&quot;vertical-align: middle;&quot;/&gt; comments</description>
  <comments>https://tangaroa.dreamwidth.org/83297.html</comments>
  <category>sports</category>
  <category>programming</category>
  <category>security</category>
  <category>computers</category>
  <lj:security>public</lj:security>
  <lj:reply-count>0</lj:reply-count>
</item>
<item>
  <guid isPermaLink='true'>https://tangaroa.dreamwidth.org/79000.html</guid>
  <pubDate>Wed, 14 May 2014 16:47:17 GMT</pubDate>
  <title>Nifty link of the nonce</title>
  <link>https://tangaroa.dreamwidth.org/79000.html</link>
  <description>&lt;p&gt;&lt;a href=&quot;https://jakevdp.github.io/blog/2014/05/09/why-python-is-slow/&quot;&gt;&quot;Why Python Is Slow&quot;&lt;/a&gt; is a quick read on Python&apos;s dynamic typing. I had not known that it was possible to change the value of an integer constant in Python.&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;img src=&quot;https://www.dreamwidth.org/tools/commentcount?user=tangaroa&amp;ditemid=79000&quot; width=&quot;30&quot; height=&quot;12&quot; alt=&quot;comment count unavailable&quot; style=&quot;vertical-align: middle;&quot;/&gt; comments</description>
  <comments>https://tangaroa.dreamwidth.org/79000.html</comments>
  <category>python</category>
  <category>programming</category>
  <category>computers</category>
  <lj:security>public</lj:security>
  <lj:reply-count>0</lj:reply-count>
</item>
<item>
  <guid isPermaLink='true'>https://tangaroa.dreamwidth.org/78295.html</guid>
  <pubDate>Mon, 12 May 2014 15:55:47 GMT</pubDate>
  <title>US court outlaws software compatibility</title>
  <link>https://tangaroa.dreamwidth.org/78295.html</link>
  <description>&lt;a href=&quot;http://www.theregister.co.uk/2014/05/09/oracle_vs_google_appeal/&quot;&gt;The US Court of Appeals for the Federal Circuit has granted copyright protection to APIs and the layout of files on a filesystem.&lt;/a&gt; This makes it legally impossible to write a homebrew replacement for a software library in the United States. &lt;a href=&quot;http://regmedia.co.uk/2014/05/09/oracle_google_appeal_opinion.pdf&quot;&gt;The decision&lt;/a&gt;, by Kathleen O&apos;Malley with S. Jay Plager and Richard Taranto concurring, gives the example of the name &quot;java.lang.Math.max&quot; being a copyrighted work on the grounds that someone trying to implement a replacement math library could have used the name &quot;Math.maximum&quot; or &quot;Arith.larger&quot;. Until overturned by an en banc rehearing or the Supreme Court, this decision outlaws Wine, Samba, Mono, Blackdown, probably half of GNU, and certainly Linux and the BSDs, not to mention OSX.&lt;br /&gt;&lt;br /&gt;&lt;img src=&quot;https://www.dreamwidth.org/tools/commentcount?user=tangaroa&amp;ditemid=78295&quot; width=&quot;30&quot; height=&quot;12&quot; alt=&quot;comment count unavailable&quot; style=&quot;vertical-align: middle;&quot;/&gt; comments</description>
  <comments>https://tangaroa.dreamwidth.org/78295.html</comments>
  <category>politics</category>
  <category>law</category>
  <category>programming</category>
  <category>computers</category>
  <category>politics/us</category>
  <lj:security>public</lj:security>
  <lj:reply-count>0</lj:reply-count>
</item>
<item>
  <guid isPermaLink='true'>https://tangaroa.dreamwidth.org/72161.html</guid>
  <pubDate>Wed, 09 Apr 2014 03:43:49 GMT</pubDate>
  <title>Proprietary Value Decomposition</title>
  <link>https://tangaroa.dreamwidth.org/72161.html</link>
  <description>&lt;p&gt;Math has a concept called &lt;a href=&quot;https://en.wikipedia.org/wiki/Singular_value_decomposition&quot;&gt;singular value decomposition&lt;/a&gt;. The short version is that you put in one matrix and get three out. This apparently being a well known concept in engineering, it is implemented in the data analysis language &lt;a href=&quot;http://www.exelisvis.com/docs/SVDC.html&quot;&gt;IDL&lt;/a&gt; and in the &lt;a href=&quot;http://docs.scipy.org/doc/numpy/reference/generated/numpy.linalg.svd.html&quot;&gt;NumPY&lt;/a&gt; library for Python, and you can probably guess where this is going. The singular value decomposition functions in IDL and NumPy produce different matrices for the same input matrix.

&lt;ul&gt;
&lt;li&gt;All three output matrices have their columns swapped.
&lt;li&gt;One of the columns in the &apos;u&apos; matrix is the negative of the matching column in the other language. 
&lt;li&gt;One of the rows in the &apos;v&apos; matrix is the negative of the matching row in the other language. 
&lt;/li&gt;&lt;/li&gt;&lt;/li&gt;&lt;/ul&gt;

&lt;p&gt;I&apos;ve only tested one chunk of data, so I do not know if the pattern will hold for different input matrices.&lt;/p&gt;&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;img src=&quot;https://www.dreamwidth.org/tools/commentcount?user=tangaroa&amp;ditemid=72161&quot; width=&quot;30&quot; height=&quot;12&quot; alt=&quot;comment count unavailable&quot; style=&quot;vertical-align: middle;&quot;/&gt; comments</description>
  <comments>https://tangaroa.dreamwidth.org/72161.html</comments>
  <category>python</category>
  <category>numpy</category>
  <category>programming</category>
  <category>idl</category>
  <category>computers</category>
  <lj:security>public</lj:security>
  <lj:reply-count>0</lj:reply-count>
</item>
<item>
  <guid isPermaLink='true'>https://tangaroa.dreamwidth.org/69279.html</guid>
  <pubDate>Sun, 23 Mar 2014 13:44:38 GMT</pubDate>
  <title>Obscure bug of the nonce</title>
  <link>https://tangaroa.dreamwidth.org/69279.html</link>
  <description>Python easy_install on Windows sometimes fails with a UnicodeDecodeError:

&lt;blockquote&gt;
UnicodeDecodeError: &apos;ascii&apos; codec can&apos;t decode byte 0xc3 in position 6034: ordinal not in range(128)
&lt;/blockquote&gt;

&lt;a href=&quot;http://stackoverflow.com/questions/19536068/mitmproxy-installation-by-the-python-setuptools-easy-install-got-error-decoding&quot;&gt;The solution is to comment out the &lt;code&gt;config = config.decode(&apos;ascii&apos;)&lt;/code&gt; line in Lib/site-packages/setuptools/easy_install.py&lt;/a&gt;.

&lt;hr /&gt;

&lt;p&gt;Here&apos;s an even more fun one: 

&lt;blockquote&gt;&lt;pre&gt;
  File &quot;geopts.py&quot;, line 128, in xp2str
    s = etree.tostring(resultset[0], method=&quot;text&quot;)
  File &quot;lxml.etree.pyx&quot;, line 3165, in lxml.etree.tostring (src\lxml\lxml.etree.
c:69399)

exceptions.TypeError: Type &apos;_ElementStringResult&apos; cannot be serialized.
&lt;/pre&gt;&lt;/blockquote&gt;

&lt;p&gt;This says that the XML library&apos;s own tostring() function cannot convert one of its own string types to a string. What&apos;s especially brilliant about this is that &lt;a href=&quot;http://lxml.de/2.1/api/lxml.etree._ElementStringResult-class.html&quot;&gt;_ElementStringResult inherits from the native string class&lt;/a&gt;. 

&lt;p&gt;Here is a hacky attempt to manage the problem:

&lt;blockquote&gt;&lt;pre&gt;
r = resultset[0]
if isinstance(r, etree._ElementStringResult):
    s = r
else:
    s = etree.tostring(r, method=&quot;text&quot;)

&lt;/pre&gt;&lt;/blockquote&gt;&lt;/p&gt;&lt;/p&gt;&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;img src=&quot;https://www.dreamwidth.org/tools/commentcount?user=tangaroa&amp;ditemid=69279&quot; width=&quot;30&quot; height=&quot;12&quot; alt=&quot;comment count unavailable&quot; style=&quot;vertical-align: middle;&quot;/&gt; comments</description>
  <comments>https://tangaroa.dreamwidth.org/69279.html</comments>
  <category>xml</category>
  <category>python</category>
  <category>i18n</category>
  <category>programming</category>
  <category>computers</category>
  <category>debugging</category>
  <lj:security>public</lj:security>
  <lj:reply-count>0</lj:reply-count>
</item>
<item>
  <guid isPermaLink='true'>https://tangaroa.dreamwidth.org/68866.html</guid>
  <pubDate>Sat, 22 Mar 2014 05:44:06 GMT</pubDate>
  <title>Hack</title>
  <link>https://tangaroa.dreamwidth.org/68866.html</link>
  <description>&lt;a href=&quot;http://docs.hhvm.com/manual/en/hacklangref.php&quot;&gt;The Hack language adds several missing features to PHP&lt;/a&gt;, most notably static typing. It was developed by Facebook for their HipHop VM. Via &lt;a href=&quot;http://soylentnews.org/article.pl?sid=14/03/21/1847254&quot;&gt;soy&lt;/a&gt;.&lt;br /&gt;&lt;br /&gt;&lt;img src=&quot;https://www.dreamwidth.org/tools/commentcount?user=tangaroa&amp;ditemid=68866&quot; width=&quot;30&quot; height=&quot;12&quot; alt=&quot;comment count unavailable&quot; style=&quot;vertical-align: middle;&quot;/&gt; comments</description>
  <comments>https://tangaroa.dreamwidth.org/68866.html</comments>
  <category>facebook</category>
  <category>computers</category>
  <category>programming</category>
  <category>php</category>
  <category>hhvm</category>
  <category>hack</category>
  <lj:security>public</lj:security>
  <lj:reply-count>0</lj:reply-count>
</item>
</channel>
</rss>
