mirror of
https://github.com/foo-dogsquared/wiki.git
synced 2025-01-31 04:58:21 +00:00
1 line
9.9 KiB
JSON
1 line
9.9 KiB
JSON
{"pageProps":{"metadata":{"date":"\"2020-06-09 06:21:37 +08:00\"","date_modified":"\"2021-05-04 20:52:15 +08:00\"","language":"en","source":""},"title":"The overview of a programming environment","hast":{"type":"root","children":[{"type":"element","tagName":"nav","properties":{"className":"toc"},"children":[{"type":"element","tagName":"ol","properties":{"className":"toc-level toc-level-1"},"children":[{"type":"element","tagName":"li","data":{"hookArgs":[{"type":"element","tagName":"h1","properties":{"id":"the-elements-of-programming"},"children":[{"type":"text","value":"The elements of programming"}]}]},"properties":{"className":"toc-item toc-item-h1"},"children":[{"type":"element","tagName":"a","properties":{"className":"toc-link toc-link-h1","href":"/2020-06-09-06-21-37#the-elements-of-programming"},"children":[{"type":"text","value":"The elements of programming"}]}]},{"type":"element","tagName":"li","data":{"hookArgs":[{"type":"element","tagName":"h1","properties":{"id":"expressions"},"children":[{"type":"text","value":"Expressions"}]}]},"properties":{"className":"toc-item toc-item-h1"},"children":[{"type":"element","tagName":"a","properties":{"className":"toc-link toc-link-h1","href":"/2020-06-09-06-21-37#expressions"},"children":[{"type":"text","value":"Expressions"}]}]},{"type":"element","tagName":"li","data":{"hookArgs":[{"type":"element","tagName":"h1","properties":{"id":"namespacing-and-function-composition"},"children":[{"type":"text","value":"Namespacing and function composition"}]}]},"properties":{"className":"toc-item toc-item-h1"},"children":[{"type":"element","tagName":"a","properties":{"className":"toc-link toc-link-h1","href":"/2020-06-09-06-21-37#namespacing-and-function-composition"},"children":[{"type":"text","value":"Namespacing and function composition"}]}]},{"type":"element","tagName":"li","data":{"hookArgs":[{"type":"element","tagName":"h1","properties":{"id":"conditionals"},"children":[{"type":"text","value":"Conditionals"}]}]},"properties":{"className":"toc-item toc-item-h1"},"children":[{"type":"element","tagName":"a","properties":{"className":"toc-link toc-link-h1","href":"/2020-06-09-06-21-37#conditionals"},"children":[{"type":"text","value":"Conditionals"}]}]},{"type":"element","tagName":"li","data":{"hookArgs":[{"type":"element","tagName":"h1","properties":{"id":"evaluation-model"},"children":[{"type":"text","value":"Evaluation model"}]}]},"properties":{"className":"toc-item toc-item-h1"},"children":[{"type":"element","tagName":"a","properties":{"className":"toc-link toc-link-h1","href":"/2020-06-09-06-21-37#evaluation-model"},"children":[{"type":"text","value":"Evaluation model"}]}]},{"type":"element","tagName":"li","data":{"hookArgs":[{"type":"element","tagName":"h1","properties":{"id":"related-resources"},"children":[{"type":"text","value":"Related resources"}]}]},"properties":{"className":"toc-item toc-item-h1"},"children":[{"type":"element","tagName":"a","properties":{"className":"toc-link toc-link-h1","href":"/2020-06-09-06-21-37#related-resources"},"children":[{"type":"text","value":"Related resources"}]}]}]}]},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"The study of "},{"type":"element","tagName":"a","properties":{"href":"/2020-06-03-15-21-42"},"children":[{"type":"text","value":"Computational processes"}]},{"type":"text","value":" start with the study of a programming environment.\nThe programming environment is mostly a given in programming but let's inspect and state some things (and some are obvious) about it.\n"}]},{"type":"element","tagName":"h1","properties":{"id":"the-elements-of-programming"},"children":[{"type":"text","value":"The elements of programming"}]},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"A programming language enables you to make the following:\n"}]},{"type":"element","tagName":"ul","properties":{},"children":[{"type":"element","tagName":"li","properties":{},"children":[{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"Expressions ranging from a primitive value to a complex type.\n"}]}]},{"type":"element","tagName":"li","properties":{},"children":[{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"A way to combine simple expressions into complex ones.\n"}]}]},{"type":"element","tagName":"li","properties":{},"children":[{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"A way to abstract procedures into higher-level processes.\n"}]}]}]},{"type":"element","tagName":"h1","properties":{"id":"expressions"},"children":[{"type":"text","value":"Expressions"}]},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"Expressions may be of a primitive value (e.g., "},{"type":"element","tagName":"code","properties":{"className":["inline-code"]},"children":[{"type":"text","value":"265"}]},{"type":"text","value":", "},{"type":"element","tagName":"code","properties":{"className":["inline-code"]},"children":[{"type":"text","value":"-1.0"}]},{"type":"text","value":", "},{"type":"element","tagName":"code","properties":{"className":["inline-code"]},"children":[{"type":"text","value":"'string"}]},{"type":"text","value":") or "},{"type":"element","tagName":"strong","properties":{},"children":[{"type":"text","value":"combinations"}]},{"type":"text","value":" which are composed of operators and expressions (e.g., "},{"type":"element","tagName":"code","properties":{"className":["inline-code"]},"children":[{"type":"text","value":"(+ 2 6)"}]},{"type":"text","value":", "},{"type":"element","tagName":"code","properties":{"className":["inline-code"]},"children":[{"type":"text","value":"(* 6 3)"}]},{"type":"text","value":").\nAn expression can also hold expressions referred to as a subexpression (e.g., "},{"type":"element","tagName":"code","properties":{"className":["inline-code"]},"children":[{"type":"text","value":"(+ (* 5 12) (- 54 6) 9)"}]},{"type":"text","value":").\n"}]},{"type":"element","tagName":"h1","properties":{"id":"namespacing-and-function-composition"},"children":[{"type":"text","value":"Namespacing and function composition"}]},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"A programming environment should have a way to refer to computational objects.\nThese often comes in the form of names with each referring to a value (e.g., "},{"type":"element","tagName":"code","properties":{"className":["inline-code"]},"children":[{"type":"text","value":"(define x 10)"}]},{"type":"text","value":").\n"}]},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"A programming language should also provide the way to combine simple procedures to compound procedures (e.g., "},{"type":"element","tagName":"code","properties":{"className":["inline-code"]},"children":[{"type":"text","value":"(define (square x) (* x x))"}]},{"type":"text","value":") which can be referred to by name (e.g., "},{"type":"element","tagName":"code","properties":{"className":["inline-code"]},"children":[{"type":"text","value":"(square 10)"}]},{"type":"text","value":" evaluates to "},{"type":"element","tagName":"code","properties":{"className":["inline-code"]},"children":[{"type":"text","value":"100"}]},{"type":"text","value":").\nWith that said, we can then combine compound procedures to create a procedure of higher level (e.g., "},{"type":"element","tagName":"code","properties":{"className":["inline-code"]},"children":[{"type":"text","value":"(define (sum-of-squares x y) (+ (square x) (square y)))"}]},{"type":"text","value":").\n"}]},{"type":"element","tagName":"h1","properties":{"id":"conditionals"},"children":[{"type":"text","value":"Conditionals"}]},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"With expressions, environment, and function composition, we can create simple programs.\nHowever, we cannot create functions that may test for the value (e.g., "},{"type":"element","tagName":"a","properties":{"href":"wikipedia:Piecewise functions"},"children":[{"type":"text","value":"piecewise functions"}]},{"type":"text","value":").\nFor this, a way to conditionally evaluate a value is a must for a programming language.\n"}]},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"Here's an example function of getting the absolute value of a number.\n"}]},{"type":"element","tagName":"pre","properties":{"className":["src-block"]},"children":[{"type":"element","tagName":"code","properties":{"className":["language-scheme"]},"children":[{"type":"text","value":"(define (abs x)\n (cond\n ((< x 0) (- x))\n (else x)))\n"}]}]},{"type":"element","tagName":"h1","properties":{"id":"evaluation-model"},"children":[{"type":"text","value":"Evaluation model"}]},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"Each interpreter implements a different way to evaluate expressions.\n"}]},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"One of the simplest evaluation model is the "},{"type":"element","tagName":"strong","properties":{},"children":[{"type":"text","value":"substitution model"}]},{"type":"text","value":" "},{"type":"text","value":".\nThe substitution model works by knowing the meaning of each value and substituting the value with its equivalent.\n"}]},{"type":"element","tagName":"h1","properties":{"id":"related-resources"},"children":[{"type":"text","value":"Related resources"}]},{"type":"element","tagName":"ul","properties":{},"children":[{"type":"element","tagName":"li","properties":{},"children":[{"type":"element","tagName":"p","properties":{},"children":[{"type":"element","tagName":"a","properties":{"href":"https://mitpress.mit.edu/sites/default/files/sicp/full-text/book/book-Z-H-10.html"},"children":[{"type":"element","tagName":"em","properties":{},"children":[{"type":"text","value":"Structure and interpretation of computer programs"}]},{"type":"text","value":", chapter 1"}]}]}]}]}]},"backlinks":[]},"__N_SSG":true} |