Topics (384k) Articles (398k) Users (410) Discussions (242) Comments (383) Files (13k) New article
Functional programming emphasizes computation by evaluating and composing functions, often using immutable data and expression-based definitions. A pure function has no observable side effects and returns the same result for the same inputs, allowing substitution of equals for equals. Mapping a square function over a list illustrates a direct transformation without an externally updated accumulator. Higher-order functions accept or return functions, making patterns such as mapping and folding reusable. Functional languages differ in strictness and effect handling; the paradigm does not imply that real programs never perform input or output.
Imperative programming describes computation through commands changing program state. Assignment updates a variable, sequencing orders commands and loops repeat updates until a condition changes. To sum a list, an imperative program can maintain an accumulator and add each next element into it. Correctness can be expressed through a loop invariant: after processing a prefix, the accumulator equals that prefix's sum. State changes can be local or observable as a side effect. The paradigm concerns the description of computation, rather than requiring a particular processor architecture.
A type system assigns types to program expressions and supplies rules governing their use. A type constrains permitted operations: in our teaching programming language,
int admits integer addition, bool supplies true and false for conditions, and a function type specifies an argument type and a result type. Storage as bits alone does not explain these distinctions; the type system determines whether an expression can serve as an argument, a condition or an operand.A typing judgment says that expression has type under the assumptions in the typing context . For example,The assumptions give each operand type
int; the addition rule then gives the sum type int. Changing to type bool prevents this derivation. Our teaching programming language has distinct int and bool types and no implicit conversions between them.The conditional rule requires a Boolean condition and the same type for both branches:Thus
if true then 1 else 2 has type int, while if true then 1 else false is rejected: its branches would require and simultaneously. Even a branch that will not execute is checked by this rule. This is a rule of this particular type system; a different programming language can choose different rules. [ref]https://softwarefoundations.cis.upenn.edu/plf-current/Types.html. Software Foundations, Programming Language Foundations, Type Systems: typing relation
The useful feature is compositional reasoning: after checking the parts, a rule explains how to check the whole. The function type diagram shows this for a call. Type inference can discover the required types automatically, and type variables let one express relationships that recur across many concrete types. The result is both a practical early error detector and a small, readable derivation explaining why an expression fits its intended use.
The guarantee depends on the rules and execution model. Type safety can exclude specified failures such as adding a Boolean or calling an integer as a function. It does not by itself establish every desired runtime property or guarantee that execution terminates. A type system that permits unrestricted recursion can accept a computation that runs forever; exception handling also needs its own account of permitted outcomes.
Exception handling transfers control from an operation that signals an exceptional condition to a matching handler. A parser can signal a malformed input instead of returning an ordinary result; a surrounding handler can report or recover from that case. Propagation may unwind intervening call frames, so cleanup constructs specify what happens to resources during exit. Checked and unchecked exception rules differ by language. Catching an exception does not itself restore an invariant damaged before it was raised, and silently discarding every exception can hide a failed computation.
// Target: computer-science.bigb
Java is a class-based, statically typed programming language whose ordinary implementation compiles source into bytecode for a Java virtual machine. Its type system, exception rules and object model specify program behaviour; the virtual machine supplies execution and managed storage. Generics in Java add parameterized types checked largely at compilation, with type erasure shaping their runtime representation. The Java language, the virtual-machine specification and a particular vendor's development kit are separate layers, so an implementation detail should not be mistaken for a universal language rule.[ref]
// Target: computer-science.bigb
Object-oriented programming organizes software around objects with associated state and operations. A method call requests behaviour through an object's interface; encapsulation can hide its internal representation. In class-based systems, a software class describes common structure and behaviour, while polymorphism allows callers to use a shared interface across different implementations. For example, circle and rectangle objects can both implement an area operation using different formulas. Inheritance is one mechanism for reuse and specialization, not a guarantee of correct substitution. Some object systems use prototypes rather than classes.
// Target: computer-science.bigb
Python is a general-purpose programming language with dynamic typing, functions, software classes, exception handling and modules. It supports procedural, object-oriented programming and functional programming. Guido van Rossum developed it to combine readable high-level data types with extensibility and access to operating system facilities; he began the implementation in 1989 and released it publicly in 1991.[ref]
General Python FAQ. What is Python? and Why was Python created in the first place?
The standard-library
ast module exposes Python abstract syntax trees. For example, parsing 2 + 3 * 4 in expression mode produces an addition whose right operand is a multiplication: the tree records operator precedence, and ordinary integer arithmetic evaluates the expression to 14. The abstract syntax tree can be inspected or transformed before compilation. The tree examples here use the Python 3.14 schema, since the schema can change between language versions.[ref]Encoded instructions executed by a central processing unit. An abstract syntax tree instead describes programming language constructs and their nesting.
An interpreter executes a program's operations according to its programming language semantics. It can recursively evaluate an abstract syntax tree, or follow an instruction sequence using an execution state such as a stack and an instruction pointer. It need not repeatedly read source code characters, and it need not use an abstract syntax tree at all.
Compilation and interpretation can coexist. In CPython, Python source code is compiled into bytecode for execution by an interpreter; its bytecode is not promised to remain stable between releases.[ref]
Glossary, Python 3.14 documentation. Python 3.14 documentation; Python 3.14 glossary: bytecode and virtual machine entries; compilation, execution and release-specific bytecodes
The Python 3.14 compile function accepts text or an abstract syntax tree and can produce a code object, which eval or exec can execute.[ref]Built-in Functions, Python 3.14 documentation. Python 3.14 documentation; Python 3.14 Built-in Functions: compile, accepted source forms, code objects and execution by eval or exec
These operations make translation and execution separately accessible without requiring them to live in different applications.Just-in-time compilation gives another combination: an interactive implementation can translate a submitted program expression into machine code and then execute it immediately. The LLVM 20.1.0 tutorial demonstrates this by adding an intermediate representation module to its just-in-time compilation facility, looking up the generated function, and calling it.[ref]
4. Kaleidoscope: Adding JIT and Optimizer Support. LLVM 20.1.0 documentation; Implementing a language with LLVM, chapter 4, section 4.4: HandleTopLevelExpression, addModule, lookup and calling the generated native function
Thus calling a programming language permanently "compiled" or "interpreted" hides an implementation choice: ask which representation is translated, which is executed, and when.A compiler translates a program from one representation to another while aiming to preserve its programming language semantics. Its input might be source code or an intermediate representation; its output might be another programming language, bytecode, an intermediate representation, or machine code. Producing machine code is therefore one possible destination, rather than the definition of compilation. For example, the LLVM 20.1.0 tutorial translates an abstract syntax tree into an intermediate representation before introducing execution.[ref]
Compilation can use an abstract syntax tree for checking and transformations such as constant folding before producing machine code. These are useful possibilities, not a compulsory sequence of separate stages for every compiler. The central distinction is between translating a program and executing its operations: a compiler can translate
x*(2+3)-4 without knowing the input value of x, whereas an interpreter needs that value to produce this program expression's result.Different representations expose different questions. Source code preserves what a programmer wrote; an abstract syntax tree exposes grouping; a type system checks permitted combinations; a stack machine makes operand movement explicit. Retaining abstract syntax tree source locations across compilation helps an error message identify the original construct even after constant folding has changed its shape. A malformed
x*(2+)-4 is a programming language syntax error; an unavailable x in the valid example is instead a missing input. Locating the failing rule is more helpful than treating both as an unexplained execution failure.The meaning of constructs in a programming language, including their permitted values and execution behavior. Programming language syntax organizes constructs; a type system and execution rules give further constraints and meaning.
The rules for forming programs in a programming language. A parser checks and structures text according to these rules; an abstract syntax tree records the resulting constructs.
An abstract syntax tree is a rooted tree recording the meaningful syntactic pieces of a program and how they fit together. A program identifier such as
x, a literal value such as 2, and a node representing addition have different roles. Their arrangement answers structural questions: which program expression supplies an operand, which name is a variable assignment target, and which construct encloses another. This makes an abstract syntax tree useful to a compiler, an interpreter, and the type system that checks a program.The word "abstract" describes what is omitted. Lexical analysis first recognizes lexical tokens, such as
x, =, 2, +, 3, *, 4. A concrete parse tree can retain grammar derivation structure, including punctuation and intermediate context-free grammar categories such as expression, term and factor. An abstract syntax tree usually keeps the operation and its operands without all those grammar scaffolds. Parentheses can determine its shape without surviving as separate nodes. A parser may construct the abstract syntax tree directly; it need not first allocate a concrete parse tree.An abstract syntax tree records programming language syntax, but does not by itself supply all programming language semantics. In
a+b, the names do not reveal their current values, and + might perform addition of integers or concatenate strings. The programming language rules, name bindings, and operand types determine the meaning. In Python, successfully calling ast.parse also does not guarantee that later compilation will accept the result: parsing return 42 succeeds, but compiling that statement outside a function fails. [ref]ast — Abstract syntax trees, Python 3.14 documentation. ast.parse: parsing performs no scoping checks; the return 42 example
An abstract syntax tree is not machine code. Its nodes describe language constructs. A compiler can check and transform this structure before translating it into executable instructions; an interpreter can evaluate an appropriate tree directly. The little evaluator below demonstrates this distinction without pretending to implement an entire programming language.
Base-sixteen representation, with digit values zero through fifteen conventionally written
0 through 9 and a through f. A group of four binary digits selects one hexadecimal digit.// Destination: computer-science.bigb
A fixed-width left shift discards high bits and inserts low zeros. A logical right shift inserts high zeros; an arithmetic right shift propagates the sign bit. In Java,
<<, >>> and >> distinguish these operations. Left shift by is multiplication by modulo the word modulus.// Destination: computer-science.bigb
A word selecting specified binary positions under a bitwise operation. To extract a stored bit at position , logically shift by and combine with the mask
1. Grouping thirty-two cells into one Java integer permits a compact representation of a Conway Game of Life board.// Destination: computer-science.bigb
For equally weighted positions, the squared radius of gyration is the average squared distance from the center of mass: , where . Expanding pair differences gives , and thereforeFor a Gaussian chain or freely jointed chain with these positions and mean squared link length , each pair variance is . Summing separations yields . Counting all endpoints of links instead gives positions and the corresponding finite-size formula.
A nucleic acid is a polymer built from linked nucleotides. The two principal kinds are DNA and RNA. Each nucleotide contributes a sugar, a nucleobase, and phosphate to the chain; the nucleobase is only the letter-bearing component, not the entire nucleotide. DNA uses deoxyribose, whereas RNA uses ribose. A chain of six nucleotides is therefore not six free nucleobases placed beside one another. See NHGRI: nucleic acids.
The chemical scaffold and the variable lettering do different jobs. Covalent bonds maintain the sugar–phosphate backbone, while the order of attached nucleobases specifies the nucleic acid sequence. A phosphodiester bond links the position of one sugar to the position of the next through phosphate. These position numbers refer to carbon chemical atoms in the sugar; they define a strand's direction even when it bends or forms a circle. See Brown, Genomes, 2nd edition: the human genome.
This division is useful: the backbone supplies a connected physical record, and base pairing allows its letters to recognize partners. DNA replication copies that record, and transcription uses a DNA template to make RNA. RNA can also fold into functional shapes through base pairing within one chain; a nucleic acid sequence specifies chemical order, not a requirement for a straight shape. The beauty is that the same kind of polymer can carry a message and form a structure that acts on messages.
A monomer is a chemical substance whose molecules can undergo polymerization and contribute units to the essential structure of a polymer. A monomer molecule is the individual reactant; its incorporated monomeric unit is the portion identifiable as derived from that reactant. Incorporation can change chemical bonds and release small byproducts, so the unit in the chain need not have the complete molecular formula of the feed molecule. See IUPAC: monomer molecule and IUPAC, A brief guide to polymer terminology: monomeric units.
Three different counts answer three different questions. Monomer molecules describe the feed; monomeric units trace that feed's contributions to the product; a constitutional repeating unit describes the smallest chemical pattern repeating along a regular chain. In Nylon 6,10, two different monomers supply one interior constitutional repeating unit,Its molecular formula is . The diamine feed is , and the diacid-chloride feed is ; subtracting two gives the interior-repeat budget. For a finite linear chain made from of each reactant, there are joining connections, hence formal eliminations, rather than . One amine end and one acid-chloride end remain in that ideal unmodified chain. This is a stoichiometry check on the depicted reaction, not a claim that the washed experimental thread retains those ends. The reacting end-group chemistry is documented in Hammond, lecture 5, p. 4; the specified Nylon 6,10 reactant pair is reported in Polymer Day, nylon demonstration.
Ethene shows the reverse counting mismatch. One monomer molecule contributes a two-carbon monomeric unit to ideal linear polyethylene, without a small byproduct in that growth step. But the smallest constitutional repeating unit of its uniform backbone is just : a chain containing incorporated ethene monomeric units contains such interior one-carbon repeats. End groups are additional bookkeeping. The frequently drawn is useful for tracing the feed, although it is not the smallest constitutional repeat. The minimum-pattern definition is given in IUPAC: constitutional repeating unit; the ethene growth chemistry is described by [ref].
A segment of a freely jointed chain or Gaussian chain instead belongs to a statistical model. It can represent many chemical bonds and several constitutional repeating units; its length and the segment count are chosen to describe chain conformation at the intended scale. The three-repeats-per-segment drawing in Figure "From two liquid layers to a Nylon 6,10 thread: monomers, a constitutional repeating unit, and statistical segments" is a deliberately arbitrary coarse-graining example, not a measured Kuhn length. Always state the counting convention before substituting a segment count for a degree of polymerization. This separation lets chemistry track which chemical atoms entered the material while statistical models track how the material bends and extends.
Pinned article: Introduction to the OurBigBook Project
Welcome to the OurBigBook Project! Our goal is to create the perfect publishing platform for STEM subjects, and get university-level students to write the best free STEM tutorials ever.
Everyone is welcome to create an account and play with the site: ourbigbook.com/go/register. We belive that students themselves can write amazing tutorials, but teachers are welcome too. You can write about anything you want, it doesn't have to be STEM or even educational. Silly test content is very welcome and you won't be penalized in any way. Just keep it legal!
Intro to OurBigBook
. Source. We have two killer features:
- topics: topics group articles by different users with the same title, e.g. here is the topic for the "Fundamental Theorem of Calculus" ourbigbook.com/go/topic/fundamental-theorem-of-calculusArticles of different users are sorted by upvote within each article page. This feature is a bit like:
- a Wikipedia where each user can have their own version of each article
- a Q&A website like Stack Overflow, where multiple people can give their views on a given topic, and the best ones are sorted by upvote. Except you don't need to wait for someone to ask first, and any topic goes, no matter how narrow or broad
This feature makes it possible for readers to find better explanations of any topic created by other writers. And it allows writers to create an explanation in a place that readers might actually find it.Figure 1. Screenshot of the "Derivative" topic page. View it live at: ourbigbook.com/go/topic/derivativeVideo 2. OurBigBook Web topics demo. Source. - local editing: you can store all your personal knowledge base content locally in a plaintext markup format that can be edited locally and published either:This way you can be sure that even if OurBigBook.com were to go down one day (which we have no plans to do as it is quite cheap to host!), your content will still be perfectly readable as a static site.
- to OurBigBook.com to get awesome multi-user features like topics and likes
- as HTML files to a static website, which you can host yourself for free on many external providers like GitHub Pages, and remain in full control
Figure 2. You can publish local OurBigBook lightweight markup files to either OurBigBook.com or as a static website.Figure 3. Visual Studio Code extension installation.Figure 5. . You can also edit articles on the Web editor without installing anything locally. Video 3. Edit locally and publish demo. Source. This shows editing OurBigBook Markup and publishing it using the Visual Studio Code extension. - Infinitely deep tables of contents:
All our software is open source and hosted at: github.com/ourbigbook/ourbigbook
Further documentation can be found at: docs.ourbigbook.com
Feel free to reach our to us for any help or suggestions: docs.ourbigbook.com/#contact





