Computer Science theory definitions

✍️Theory
concepts
definition
stub
  • Singleton

    • Restrict the instantiation of a class to one “single” instance (see the wiki article)
    • This is useful when exactly one object is needed to coordinate actions across the system.
  • debounce:

    • it limits the rate at which a function can fire
    • In redux-saga is non-blocking.
  • idempotent: When applying a function multiple times, the state won’t change after applying it the first time.

    • A function we can retry several times until it works! Yeah!
  • idiomatic: Idiomatic in the context of programming can usually be defined as “the most natural way to express something in a language”
  • imperative vs. declarative

    See the article which compares imperative vs. declarative

literal vs statement vs expression

literals

Representing a value within source code.

  • "foo" (a string)
  • true (a boolean)

Not literals:

  • std::cout (an identifier - refer to a value in memory)
  • foo = 0; (a statement)
  • 1+2 (an expression)

Taken from this SO answer.

Statement vs. Expression

  • Statements are everything that can make up a line (or several lines) of Python code. Note that expressions are statements as well.
  • Expressions can be reduced to some kind of “value”

Taken from this excellent answer concerning python.

Examples

Expressions

Something that evaluates to a value.

  • 3 + 5
  • function() {} because every function will return something. With no return specified, a function expression will return undefined.
  • yield* is an expression, not a statement — so it evaluates to a value.
  • In the haskell article I read the following line:

    Haskell’s if is an expression that must return a value, and not a statement.

Statements

JavaScript

  • if/else clause and switch/case
  • return
  • import and export
  • with

See this article from Axel Rauschmayer for more details.

Compiled vs. transpiled

High level languages to machine code

Discuss on TwitterImprove this article: Edit on GitHub

Discussion


Explain Programming

André Kovac builds products, creates software, teaches coding, communicates science and speaks at events.