Great question.<p>I&#x27;m a huge fan of separating the business specifications from talking about the execution.<p>-------<p>Some runtimes will do this under the hood.<p>RDBMS execution plans are a good example. Plan costs are calculated using data-dependent statistics. And cache-friendliness is taken into account: in postgres, hash joins are made to fit L1 (tuples per bucket = 10) and L3 caches (work_mem default to 4MB, after which batches are introduced) [1]<p>Some JITs will also monitor performance and behavior, and try to speculatively prune unused paths.<p>But this is all letting the runtime deal with it.<p>-------<p>Execution should be treated as an orthogonal but tweakable concern. And be exposed in some way to the user.<p>Halide [2] is one very interesting approach, is letting user choose:<p>* between materialization and compute-again<p>* parallelism levels<p>* chunk sizes<p>* scheduling, etc.<p>However the storage is implied by the execution chosen. Which to me is a constraint that is automatically enforced, and not exposed.<p>-------<p>All knobs, and their consequences, should be readily available to both users and compilers.<p>To me, typed languages could, should contain <i></i>so much more<i></i> information about performance (or anything!).<p>The perfect abstraction should be the seamless integration of 4 languages:<p>* Logical business requirements (what you want done). Should be user friendly<p>* Business properties requirements (constraints like liveness, performance envelope, security, or business ones). Declarative<p>* A language to help in proofs. Think TLA+[3] or the checker framework [4].<p>* A language to express which implementations are chosen, knobs to configure, how the layout is done (array of structs, struct of arrays?). Think Halide or JAI [5].<p>Such a combination of languages should be built on extremely typed primitives; the combination of which should propagate type information, and provide hooks to provide more type information.<p>An implementation of a sum of a value over a range should make emerge information about:<p>* which business properties it offers<p>* which items will benefit from fitting in cache<p>* which parts can be stopped without lock contention<p>* different options for the memory layout coming into and out of this algorithm<p>In the internals, something as simple as a + b would look like:<p><pre><code>    @Associative
    @Commutative
    @MapsTo(Algebra.addition)
    @Inlineable
    @CanSafePointBefore
    @WillNotContend
    @NonBlocking
    @CacheSizefunction(argumentsSize + returnSize)
    @BatchingStrategies(Single,Batch.L1Size,Batch.L1Size)
    @WaitOnIOStrategy(Unscheduleable)
    @ArgumentPassing(ref,value,ArrayOfStruct,StructOfArrays)
    @ReturnPassing(ref,value,Array)
    @Properties(case unsigned: ret &gt;= a and ret &gt;= b)
    def plus(
      a @NumberType(uint16, int, IEEEfloat, double, @CustomizeableNumber)
      ,
      b @NumberType(uint16, int, IEEEfloat, double, @CustomizeableNumber)
    ) {
      return @
        a 
        + @Impl(asm_x86_add,simd_x86_add,cuda_add)
          @NumberTypeInference
        b
    }

</code></pre>
-------<p>In short: a language into which anyone can commit type information, with type information that could inform performance.<p>[1] <a href="http:&#x2F;&#x2F;patshaughnessy.net&#x2F;2016&#x2F;1&#x2F;22&#x2F;is-your-postgres-query-starved-for-memory" rel="nofollow">http:&#x2F;&#x2F;patshaughnessy.net&#x2F;2016&#x2F;1&#x2F;22&#x2F;is-your-postgres-query-s...</a><p>[2] <a href="http:&#x2F;&#x2F;halide-lang.org&#x2F;" rel="nofollow">http:&#x2F;&#x2F;halide-lang.org&#x2F;</a><p>[3] <a href="http:&#x2F;&#x2F;cseweb.ucsd.edu&#x2F;~daricket&#x2F;papers&#x2F;fm2012.pdf" rel="nofollow">http:&#x2F;&#x2F;cseweb.ucsd.edu&#x2F;~daricket&#x2F;papers&#x2F;fm2012.pdf</a><p>[4] <a href="http:&#x2F;&#x2F;types.cs.washington.edu&#x2F;checker-framework&#x2F;current&#x2F;checker-framework-manual.html" rel="nofollow">http:&#x2F;&#x2F;types.cs.washington.edu&#x2F;checker-framework&#x2F;current&#x2F;che...</a><p>[5] <a href="https:&#x2F;&#x2F;inductive.no&#x2F;jai&#x2F;" rel="nofollow">https:&#x2F;&#x2F;inductive.no&#x2F;jai&#x2F;</a>