Search code examples
language-agnosticprogramming-languageslanguage-featuresself-healing

What language features eliminate a whole class of errors?


I have often seen claims that a programming language feature eliminates a whole class of errors.

For example, I have seen claims that:

  • A strong type system eliminates the class of errors caused by using features that a type does not support.

  • Automatic memory management eliminates the class of errors relating to allocating the correct amount of memory for an object/structure.

  • Mandatory variable initialisation eliminates null pointer or null reference errors.

  • Immutable data structures eliminate the class of errors caused by not understanding the impacts of changing mutable state.

I am not trying to find out whether the claims above are true or not, but rather compile a list of claims of this type that are specific enough for me to research and evaluate myself.

What other specific features are alleged to eliminate a whole class of errors?

Is there a general principle or theory for identifying features that do this, or identifying the absence of such features?

(Note that I do not include obviously vague or subjective claims like these, whether true or not:

  • Object oriented programming improves reusability.

  • Dynamic languages are faster to program in.

  • Meaningful whitespace makes the program cleaner. )


Solution

  • Here are a few off the top of my head:

    Class                 Feature                             Example
    Type Error            Single Data Type                    awk
    Type Mismatch         Union Types                         XQuery
    Reference Error       No Variables                        sed
    Mismatched Braces     No Braces                           python
    Dangling semicolon    Significant Whitespace              python
    Buffer Overflow       No Pointer Arithmetic               Ada
    Division by Zero      Default to infinity                 lua
    Circular Reference    All values are immutable strings    tcl
    Circular Import       No Cyclical Dependencies            OCaml
    Ambiguous Type        Hindley-Milner type inference       OCaml
    Not enough args       Partial Application                 Haxe
    Import Error          Implicit Standard Library           Coldfusion
    Leaky Abstraction     No Conditional Logic                CSS
    Object Expected       Everything is an object             SmallTalk
    No such method        Reification                         SmallTalk
    Infinite Loop         No Side Effects                     DSSSL
    Deadlock              Software Transaction Memory         Clojure
    Namespace Conflict    Stack Save/Restore                  PostScript
    Invalid arguments     Stack Machine                       PostScript
    Heisenbug             Message Passing Concurrency         Erlang