# syntax styles # subtopics %scm link-files "computer/guides/syntax-styles/*.html" # keywords and identifiers there appear to be two opposing design paradigms: one favoring ornamented complexity, the other favoring functional minimalism. this dichotomy may reflect deeper psychological or cultural dispositions. ## enrichment-oriented this style favors special characters, combinations of special characters, and abbreviations. examples include: apl, mathematical notation, haskell. such systems seek expressive power through layered meanings, much like mathematical notation or apl, which rely on compact symbols. they feature a dense symbolic vocabulary and require a tediously acquired, shared understanding of esoteric symbols. these systems often use ornate and highly contextualized forms. ## simplification-oriented this style prioritizes words from natural language, and alphanumeric characters. examples include: coffeescript, scheme, ruby. these systems employ minimalist, uniform notation, or attempt to approximate spoken language. they seek accessibility and clarity, aiming to reduce the cognitive load on users. this approach often favors streamlined and universal formats. ## in other fields the same tendencies appear in other domains. in writing, enrichment-oriented authors often favor elaborate typographic conventions, using multiple distinct quotation and apostrophe marks, along with serif typefaces. simplification-oriented writers may restrict themselves to only ' and " for quotations and apostrophes. in more extreme cases, they may write entirely in lowercase, prioritizing content and meaning over form and ornament. # nesting ## keyword-delimited example (vbscript) ~~~ if 3 = x then msgbox "test" end if for each a in list: msgbox a: next ~~~ benefit: quick to type ## brace-delimited * uses multiple bracket types * the operator name is outside the brackets, operator(arguments, ...) example (c) ~~~ if (3 == x) { printf("test"); } for (int i = 1; i < array.size; i += 1) { printf("%u", array.data[index]); } ~~~ ## s-expression * the operator being part of the list unifies code and data through a single regular syntactic form for all compound expressions example (scheme) ~~~ (if (= 3 x) (display "test")) (for-each display mylist) ~~~ ## indentation sensitive example (coffeescript) ~~~ if 3 is x console.log "test" list.forEach (a) -> console.log a ~~~ benefit: code written by different authors looks more uniform, as there are fewer structural elements, such as spaces or brackets, that can be freely positioned. # operator placement ## prefix + 1 2 3 4 ## infix 1 + 2 + 3 + 4 ## suffix 1 2 3 4 + # structural composition ## clausal * program consists of rules (horn clauses), with optional unification and backtracking * structure is flat; "nesting" arises through goals and subgoals example (prolog) ~~~ likes(mary, food). likes(john, wine). friend(x, y) :- likes(x, z), likes(y, z). ~~~ benefit: emphasizes declarative knowledge, not control flow ## concatenative * structure arises via implicit stack and postfix composition * nesting is avoided entirely; control flow expressed through combinators example (forth/joy-like) ~~~ 3 4 + 5 * : square dup * ; list map square ~~~ benefit: minimal syntax, easy composition, no explicit variables