* Judging programming language designs ** Flon's axiom: can write bad programs in any language ---------------- "There does not now, nor will there ever, exist a programming language in which it is the least bit hard to write bad programs." ---------------- ** The paradox of judgement ------------- all languages Turing-complete (Turing tarpit, Church equivalence) all constructs can be abused so how can one formally compare languages, evaluate them, make judgements? ------------- *** MacLennan's principles of language design **** expressiveness ---------------- abstraction, automation, inf. hiding, allowing expression of security, structure or readability, meta-linguistic abstraction ------------- **** efficiency --------------------- programming time, compile-time, run-time, object file size, run-time space, localized costs, portability --------------------- **** aesthetics --------------------- simplicity, syntactic consistency, orthogonality, regularity, zero-one-infinity, terseness or syntactic abstraction --------------------- **** Problem: how to formalize expressiveness and aesthetics? * Felleisen's paper: On the expressive power of Programming Languages ** An example: compare Scheme without assignment (set!) vs. Scheme with set! *** Is there a difference? ---------------- ; with set! (let (... (TransManager (let ((TransCounter 0)) (lambda (TransType) (if (counter? TransType) TransCounter (begin (set! TransCounter (add1 TransCounter)) BODY))))) ...) ... (TransManager t1) ...) ; without set! (let (... (MakeTransManager (lambda (n) (let ((TransCounter (add1 n))) (lambda (TransType) (if (counter? TransType) TransCounter BODY))))) (TransManager (MakeTransManager 0)) ...) ... (let ((TransManager (MakeTransManager (TransManager 'count)))) (TransManager t1) ...)) ---------------- *** the Turing Tarpit *** How to avoid the Turing Tarpit? **** alternative way around turing tarpit: non-turing-complete languages **** Felleisen's key idea: compare using *homomorpic translation* ** What logicians mean by "expressive power" *** Formal models of logics **** Conservative extension **** Definitional extension (syntactic sugar) *** Formal Theory of Programming Language Expressiveness **** Languages, conservative extension and restriction ***** Formal programming language, L ***** distinguish programs based on whether they terminate or not ***** Conservative extension and restriction **** Expressibility (definitional extension, syntactic sugar) ***** Homomorphic translation into L' ***** Expressible Programming Constructs *** Describing expressibility using observational equivalence **** contexts (definition 3.4) **** operational approximation **** operational equivalence **** theorem 3.6, proving constructs expressible **** theorem 3.8, proving constructs not expressible *** Example application ------------------- ;TTS version of Figure 2 Semantics Gamma = configurations = closed terms I = identity function on terms T = set of values (v) O = eval_Lambda = the constant function that returns "true" ;note below that v must be a lambda abstraction (value) (\_n x . e) e' ==> e[x/e'] (\_v x . e) v ==> e[x/v] e0 ==> e0' ____________________ (e0 e1) ==> (e0' e1) e1 ==> e1' ______________________________________ ((\_v x . e0) e1) ==> (\_v x . e0) e1' -------------------