Skip to content

Latest commit

 

History

History
110 lines (105 loc) · 3.19 KB

motivation.org

File metadata and controls

110 lines (105 loc) · 3.19 KB

Benefits

  • Minimize mental overhead when switching between languages by associating the same key binding with the same construct across many languages.
    • Here are ways of defining a new function in several languages:
      • emacs lisp
        (defun add (a b)
            (+ a b))
                    
      • clojure
        (defn add [a b]
          (+ a b))
                    
      • python
        def add(a, b):
            return a+b
                    
      • javascript
        function add ( a, b ) {
            return a+b;
        }
                    
      • shell
        function add {
            A=${1} && shift
            B=${1} && shift
            expr ${A} + ${B}
        }
                    
      • c
        int add ( int a, int b ) {
          return a+b;
        }
                    
      • go
        func add ( a, b int ) int {
        	return a+b
        }
                    
    • Here is basic printing in these languages:
      • lisp
      (format t "hello world~%")
              
      • clojure
      (printf "hello world\n")
              
      • python
      print ("hello world")
              
      • c++
      cout << "hello world" << endl;
              
      • java
      System.out.printf( "hello world\n" );
              
    • go
      fmt.Printf( "hello world\n" )
              
    • transforming a string to uppercase
      langform
      javascript“hello”.toUpperCase()
      emacs-lisp(upcase “hello”)
      CL(string-upcase “hello”)
      c++“hello”.toupper()
      python“hello”.upper()
      go“hello”.ToUpper()
    • The same goes for other standard programming language constructs like iteration, conditionals, class declarations, etc. There is a lot of variation which requires mental effort to track. In many cases the constructs are semantically equivalent between lannguages and can be mapped to a single key-binding consistently.
  • Minimize typing:

    Some constructs can be verbose.

    • c++ nested loop
      for ( int i = 0; i < A.size(); i++ ) {
          for ( int ii = 0; ii < B.size(); ii++ ) {
            cout << A[i] << ',' << B[i] << end;
          }
        }
              
    • In buttons, this frequently occurring construct and related ones can be templetized:
      • ascending for-loop
      "for ( int {0} = 0; {0} < {}; {0}++ ){(cbd)}"
              
      • descending for-loop
      "for ( int {0} = {}; {0} >= 0; {0}-- ){(cbd)}"
              
    • This allows producing most of this double loop in 5 or 6 keystrokes:
  • Avoids running out of key bindings by taking advantage of the exponential growth of trees as opposed to relying soley on a limited # of modifier combinations,
  • Minimize repetitive strain by adding diversity to the key-sequences that may prefix a command instead of repeatedly pressing the same modifier keys.