Misconceptions

Here are a couple of misconceptions. Many more to come...

Misconception Count Does Not Imply Language Difficulty

The is no connection between the number of misconceptions listed here and the difficulty of the corresponding programming language. The effort we spent on collecting misconceptions is very different for different languages. It would be inappropriate to reason about the quality of languages based on the number of misconceptions in this collection.

Java
DRAFT
AbstractClassMustImplementAbstractMethod
An abstract class must implement all abstract methods defined in its superclass
Java
DRAFT
AbstractClassNoImplementation
An abstract class cannot contain implemented methods
JavaScript
DRAFT
AccessingInexistentPropertyError
Accessing a non existent property on an object produces an error
Java
AddMemberAtRuntime
Set of class members can change at runtime
AllClassesHaveDefaultConstructor
All classes automatically get a no-argument constructor
AnyClassException
Any class can be an exception class
Java
ArithmeticPlusPrecedes
Addition has higher precedence than string concatenation
Java
DRAFT
ArrayAccessWithParentheses
Parenthesis are used to access an element in an array
ArrayAllocationWithoutNew
Arrays are created without the new keyword
ArrayBracketCountIsLength
The number of brackets in an array type or an array initializer corresponds to the length of the array
ArrayElementTypeRepeats
The type of a multi-dimensional array is written as T[] T[] T[]
Java
DRAFT
ArrayElementsUntyped
Elements of arrays are untyped
Java
ArrayHasLengthMethod
To get the length of an array, one needs to call its length method
ArrayInitializerContentsInBrackets
Array initializers list the elements in square brackets
Java
DRAFT
ArrayLengthCannotBeZero
An array cannot have a length of 0 elements
ArrayLengthPartOfType
The length of an array is part of its type
Java
ArrayListIsArray
ArrayLists are arrays
ArrayRankIsLength
Array rank and array length are the same thing
ArrayRankNotPartOfType
The rank of an array is not part of its type
Java
ArraysGrow
Arrays can grow dynamically
JavaScript
DRAFT
ArrowFunctionNoImpliedReturn
Even when an arrow function consists just of an expression, the return keyword must be explicitly written
JavaScript
DRAFT
ArrowFunctionRequiresFunctionKeyword
Arrow functions also require the keyword 'function'
Java
AssignCompares
= compares two values
Python
AssignCompares
= compares two values
Java
AssignmentCopiesObject
Assignment copies the object
JavaScript
AssignmentCopiesObject
Assignment copies the object
Python
AssignmentCopiesObject
Assignment copies the object
Java
AssignmentNotExpression
An assignment a=b is not an expression
Java
DRAFT
BaseCaseNotNeeded
Recursive computations do not necessarily need a base case
Scratch
DRAFT
BaseCaseNotNeeded
Recursive computations do not necessarily need a base case
BaseCaseSelfRecursive
The base case of a structural recursion consists of a recursive self-call
BoxedNull
Passing null to a wrapper class constructor creates an object representing the absence of a value
Java
CallNotStaticallyChecked
A method invocation on a reference of a type that does not have that method won't compile
CallOnPrimitive
One can invoke a method on primitive values
CallRequiresVariable
One needs a variable to invoke a method
CallWithoutFrame
A method invocation does not necessarily allocate a stack frame
JavaScript
DRAFT
CallbackParametersInCaller
Parameters of a callback function may be written as parameters of the caller function
CallerFrameContainsCalleeFormal
Stack frame of caller includes variables for callee's formal parameters
Python
CannotChainAttributeToObjectInstantiation
Method calls, and attribute accesses in general, cannot be chained to a constructor invocation.
Java
CannotChainMemberAccesses
Member accesses cannot be chained together
Java
CannotChainMemberToConstructor
Method calls or field accesses cannot be chained to a constructor invocation
CatchAlwaysExecutes
Catch blocks always get executed
CatchProvidesOptions
Only the necessary part of a catch block executes
Java
DRAFT
ChainedMethodsNotCalledFromOutside
Chained methods are all called on the object at the beginning of the chain
Java
CharNotNumeric
Char is not a numeric type
JavaScript
DRAFT
CharType
A single character is of type char
JavaScript
ClassDefinesType
The type of an object is equivalent to the type defined by its class definition
Scratch
DRAFT
CompareBooleanToConstant
To test whether an expression evaluates to true or false, one must compare it to a constant
Python
ComparisonWithBoolLiteral
To test whether an expression is True or False, one must compare it to True or to False
Java
ComparisonWithBooleanLiteral
To test whether an expression is true or false, one must compare it to true or to false
CompositeExpressionsUntyped
Expressions that consist of multiple parts have no type
ConcreteClassMustOverride
A concrete class needs to implement all methods declared in its abstract superclasses
ConcreteClassOnlyImplementClassAbstract
A concrete class only needs to implement those abstract methods it inherits from abstract superclasses
ConcreteClassOnlyImplementDirectAbstract
A concrete class only needs to implement abstract methods declared in its direct supertypes
ConcreteClassOnlyImplementInterfaceAbstract
A concrete class only needs to implement those abstract methods it inherits from interfaces
ConditionOneOutEdge
A condition node in a control-flow graph can have a single outgoing edge
Java
ConditionalIsSequence
If-else is equivalent to sequence of two ifs
Python
ConditionalIsSequence
If-else is equivalent to sequence of two ifs
Scratch
DRAFT
ConditionalIsSequence
If-then-else block is equivalent to sequence of two if-then blocks
JavaScript
DRAFT
ConditionalOperatorNotExpression
The conditional operator is not an expression
JavaScript
DRAFT
ConstDeclarationCanBeLeftUninitialized
Declarations of constants do not need to be immediately initialized
JavaScript
ConstReferenceImpliesImmutability
An object referred to by a const variable is an immutable object
Java
ConstructorAllocates
The constructor allocates the object
ConstructorParameterIsField
Formal constructor parameters are equivalent to instance variables
Java
ConstructorReturnsObject
Constructors need to return objects
ConstructorWithoutNew
One can write the constructor name, without new, to instantiate a class
Java
ControlledLocalAccess
One can control access to local variables using access modifiers
Java
DeferredReturn
A return statement in the middle of a method doesn't return immediately
Python
DeferredReturn
A return statement in the middle of a function doesn't return immediately
ElsIf
There is an elsif keyword for multi-way conditional statements
Java
DRAFT
ElseAlwaysExecutes
The else branch of an if-else statement always executes
Scratch
DRAFT
ElseAlwaysExecutes
The else branch of an if-then-else block always executes
Scratch
DRAFT
EqualityOperatorComparesListIdentities
(list a) = (list b) compares the identities of list a and list b
Java
EqualityOperatorComparesObjectsValues
o==p compares the objects referred to by variables o and p
JavaScript
DRAFT
EqualityOperatorComparesObjectsValues
The equality operator compares two objects' values
JavaScript
DRAFT
EqualityOperatorComparesOnlyTypes
The equality operator '==' compares only the types of the operands
Scratch
DRAFT
EqualityOperatorComparesOnlyTypes
() = () compares only the types of its operands
Java
EqualsComparesReferences
o.equals(p) compares the references stored in the variables o and p
EvaluationResultsArePrinted
Evaluating an expression means outputting its result
ExceptionRoot
Exception is the top-most exception class
Java
DRAFT
ExpressionAssigns
An expression that reads a variable also updates its value after the evaluation
Scratch
DRAFT
ExpressionAssigns
An expression that reads a variable also updates its value after the evaluation
ExpressionsDynamicallyTyped
One has to evaluate an expression to determine its type
Java
FinalReferenceImpliesImmutability
An object referred to by a final variable is an immutable object
Java
DRAFT
ForEachIteratesOverIndices
An enhanced for loop iterates over the indices of an array or a collection
ForEachTraversesRecursiveStructure
For-each loops know how to traverse any recursive data structure
ForEachVariableIsElement
One can assign to the variable of an enhanced for statement to store a value in the corresponding array or collection element
ForIsConditional
The body of a for statement executes at most once
ForVariableScopeBeyondLoop
The scope of variables declared in a for loop header extends beyond the loop
FrameIsClassInstance
A stack frame is the same as an instance of a class
JavaScript
DRAFT
FunctionAsValueWithParentheses
To use a function as a value, one needs to have parentheses after its name
JavaScript
DRAFT
FunctionOverloading
It is possible to create multiple functions with the same name but with different signatures
JavaScript
DRAFT
FunctionsCannotBeImmediatelyInvoked
Functions cannot be called in the expression in which they are defined
JavaScript
DRAFT
FunctionsMustBeNamed
Every function definition requires an associated name
JavaScript
DRAFT
IdentifierAsStringInBracketNotation
An identifier used to access a property with the bracket notation is treated as a string
Java
IfIsLoop
The body of an if statement executes repeatedly, as long as the condition holds
Python
IfIsLoop
The body of an if-statement executes repeatedly, as long as the condition holds
IfRequiresElse
Every if statement requires an else
ImmutableRequiresFinalParameters
Immutable classes need final constructor/method parameters
ImplicitInterfaceImplementation
Java implicitly produces implementations of any methods a class inherits from the interfaces it implements
Python
InitCreates
__init__ must create a new object
Python
InitReturnsObject
__init__ needs to return an object
InlineCallInExpressionTree
The expression tree of an expression involving a call inlines the call's computation of the returned value
InlineVariableInExpressionTree
The expression tree of an expression involving a variable inlines the variable's definition
IntegerDivisionToRational
Dividing two integers can produce a rational number
InterfaceExtendClass
An interface can extend a class
InterproceduralEdge
In an intra-procedural control-flow graph, method call nodes point to the called method
Java
LargeIntegerLong
Large integer numbers have type long
Scratch
DRAFT
ListLengthCannotBeZero
A list cannot have a length of 0 items
Scratch
DRAFT
ListsHomogeneous
All items in a list must have the same type
LiteralNoExpression
A literal is not an expression
LiteralString
When passing a literal string as argument to a method, no quotes are needed
Java
LocalVariablesAutoInitialized
Local variables are automatically initialized
LoopBodyScopeImpliesLoopLifetime
Lifetime of variables declared in a loop body extends across all loop iterations
Java
DRAFT
LoopTerminatingCondition
For and while loops end when the condition becomes true
JavaScript
DRAFT
MandatoryAssignment
An expression must be assigned to have a valid statement
JavaScript
DRAFT
MapInPlace
Map modifies the elements of the array on which it operates in place
MapIsMultiMap
Maps can store multiple values for a given key
MapPutNoOverwrite
Map.put with an existing key does nothing
Java
MapToBooleanWithConditionalOperator
To map a boolean expression to a boolean, a conditional operator is necessary
Java
MapToBooleanWithIf
To map a boolean expression to a boolean, an if statement is necessary
Python
MapToBooleanWithIf
To map a boolean expression to a bool, an if statement is necessary
Python
MapToBooleanWithTernaryOperator
To map a boolean expression to a bool, a ternary conditional operator is necessary
MethodAsField
Each object contains its own special fields for all of its methods
MethodWithoutReturnType
A method declaration does not need to include a return type
MethodsWithoutClass
Methods can be defined outside a class
Scratch
MissingElseTerminates
Blocks following an if without else will not execute if the condition is false
MultiReferenceVariable
A reference variable can point to multiple objects
MultiValueVariable
A variable can contain more than one value
MultidimensionalArray
A multi-dimensional array is one thing
MultipleSuperclasses
A class can have multiple superclasses
Python
MultipleValuesReturn
Functions can return multiple values
Java
MustInitializeFieldInConstructor
Constructors must assign values to all fields
NamedTypeParameter
To instantiate a generic type, one needs to specify type parameter names as well as types
NestedObjectsImplyNestedClasses
If objects are part of a containment hierarchy, their classes are nested, too
NestedPackages
Packages can contain other packages
Java
NoAtomicExpression
Expressions must consist of more than one piece
JavaScript
NoAtomicExpression
Expressions must consist of more than one piece
Python
NoAtomicExpression
Expressions must consist of more than one piece
JavaScript
DRAFT
NoBracketNotationForObjects
Square brackets cannot be used to access properties of an object
NoCallOnStringLiteral
One cannot invoke methods on String literals
NoCastIfSameSize
If a variable is at least as big (bit-width) as a value, then no cast is needed to a assign the value to the variable
NoCharEscape
\ is a normal character in char and String literals
Java
NoEmptyConstructor
A constructor must do something
Python
NoEmptyInit
__init__ must do something
NoFieldInheritance
An object contains only the fields declared in its class
NoFieldlessObjects
Objects without instance variables can't exist
Java
NoFloatLiterals
There are no float literals
JavaScript
DRAFT
NoFunctionCallsChaining
It is not allowed to chain function calls
JavaScript
DRAFT
NoGlobalObject
There isn't a global object
Java
DRAFT
NoImplicitWidening
Smaller types are never automatically converted into bigger ones without an explicit cast
Java
DRAFT
NoInsideMethodCallInConstructor
It is foirbidden to call other methods on the same object while inside its constructor
NoJaggedArrays
Multi-dimensional arrays have a rectangular shape
NoLocalVariables
There are no local variables
Java
NoLongLiterals
There are no long literals
Java
DRAFT
NoMethodInheritance
Subclasses inherit fields but not methods
Java
NoReservedWords
Every sequence of letters and digits starting with a letter can be used as an identifier
Python
NoReservedWords
Every sequence of letters and digits starting with a letter or an underscore can be used as an identifier
JavaScript
DRAFT
NoReturnValue
Functions without return statements return no value at all
Python
DRAFT
NoSequenceRepetition
There is no operator that repeats sequences
Java
NoShortCircuit
&& and || always evaluate both operands
Python
NoShortCircuit
and/or always evaluate both operands
Java
NoSingleLogicAnd
& is only a bitwise AND
NoStringToString
One cannot invoke toString() on a String
JavaScript
DRAFT
NullAndUndefinedAreTheSame
The values null and undefined are the same
Java
NullIsObject
null is an object
JavaScript
NullIsObject
null is an object
Java
DRAFT
NullPointerExceptionCompileTime
NullPointerExceptions are detected at compile time
JavaScript
DRAFT
NumberOfParametersMatchArguments
Functions must be called with the same number of arguments as defined in their signature
NumericToBooleanCoercion
Numeric types can be coerced to boolean
JavaScript
DRAFT
ObjectAsParameterIsCopied
Objects are passed by value
ObjectLabeledWithConstructorSignature
In stack and heap diagrams, an object on the heap is labeled like a stack frame of a constructor call
ObjectLabeledWithVariableName
In stack and heap diagrams, an object on the heap is labeled with the name of the variable that refers to it
Java
ObjectsMustBeNamed
A variable is needed to instantiate an object
Python
ObjectsMustBeNamed
A variable is needed to instantiate an object
OnlyInnermostArrayElements
Only the elements of the innermost array of a multi-dimensional array are accessible
OnlyRuntimeLibraryPackages
Only the creators of the JDK can create packages
OutOfBoundsElementsAreNull
Out-of-bounds array elements are null
Python
OutsideInFunctionNesting
Nested function calls are invoked outside in
Java
OutsideInMethodNesting
Nested method calls are invoked outside in
Java
ParenthesesOnlyIfArgument
() are optional for method calls without arguments
Python
ParenthesesOnlyIfArgument
() are optional for function calls without arguments
Python
DRAFT
PlusConcatenatesNumbers
The plus operator can concatenate strings and numbers
PreIncrementBeforeLoop
Pre-increment in update part of for loop means increment before loop body
PrimitiveIsObject
Primitive values are heap objects
PrimitiveTypeParameter
Type parameters of generic types can be assigned primitive types
PrimitiveVariablesDynamicallyTyped
The type of a primitive variable depends on its value
PrintNewLineFirst
println(...) starts a new line and then prints
Java
DRAFT
PrivateAccessibleInSubclass
Private members of a superclass are accessible from a subclass
PrivateFieldsImplyImmutability
A class where all fields are private is immutable
Java
PrivateFromOtherInstance
An object cannot access private members of other objects of the same class
Java
PrivateFromStatic
Static methods cannot access private members of instances of same class
PrivateMeansFinal
A private field cannot be changed
JavaScript
DRAFT
PrototypesAreClasses
JavaScript is based on a class-based object model
RationalLiterals
Rational fractions are literals
Java
RecursiveActivationsShareFrame
Recursive calls of a method share a stack frame
RecursiveCallSiteNoReturn
Tail-recursive call sites have no continuation
Python
RecursiveFunctionNeedsIfElse
A recursive function needs to contain an if-else statement
Java
RecursiveMethodImpliesRecursiveType
A class with a recursive method represents part of a recursive data structure
Java
RecursiveMethodNeedsIfElse
A recursive method needs to contain an if-else statement
ReferenceIntoStack
References can point into the stack
ReferenceLabeledWithDynamicType
In stack and heap diagrams, reference variables are labeled with the types of the objects they refer to
ReferenceToBooleanCoercion
Every reference type can be coerced to boolean
ReferenceToIntegerConversion
One can cast between references and ints
Java
ReferenceToVariable
References can point to variables
ReferringToRecursiveStructureMakesRecursive
A class referring to a recursive data structure is (indirectly) part of that recursion as well
Scratch
DRAFT
RepeatDistributes
Each block in a loop is repeated individually
Scratch
ResetStateEachLoopIteration
The computation of all loop iterations starts from the state before the loop
Scratch
ResetStateEachProgramExecution
Running a Scratch program first resets the state of the world and then executes the program
Java
ReturnCall
Return statements need () around the return value
Python
ReturnCall
Return statements need () around the return value
ReturnNoOutEdge
In a control-flow graph, a return statement has no outgoing edge
Java
ReturnUnwindsMultipleFrames
A return statement can unwind multiple call stack frames
Python
ReturnUnwindsMultipleFrames
A return statement can unwind multiple call stack frames
Java
RightToLeftChaining
Chained accesses are invoked from right to left
Python
RightToLeftChaining
Chained accesses are invoked from right to left
RuntimeExceptionChecked
RuntimeExceptions are checked exceptions
Python
SelfNoExpression
The name self is not an expression
SemanticEquivalenceImpliesSyntacticEquivalence
Two pieces of code with the same observable behavior have to be implemented in the same way
JavaScript
DRAFT
SetTimeout0IsSynchronous
Scheduling the execution of a function after 0 milliseconds with setTimeout is equivalent to a synchronous call
JavaScript
DRAFT
SetTimeoutReturnsCallbackResult
SetTimeout returns the value returned by the callback function
SetterIsStatic
Setter methods are static
SingleQuoteString
String literals can be in single quotes
StackTraceIsCallHistory
A stack trace is the sequence of previously called methods
StatementMultipleOutEdges
A non-condition node in a control-flow graph can have multiple outgoing edges
StaticCallPolymorphic
A static method call is dispatched polymorphically at runtime based on the argument types
Java
DRAFT
StaticDispatch
The method to be called is determined by the static type
StaticFrameInGlobals
Stack frame of static method calls lives in the global memory area
Java
DRAFT
StringLengthField
One can know the length of a String object by accessing its length field
Java
StringLiteralNoObject
One needs to call the String constructor to get a String object from a literal
Java
StringPlusStringifiesExpression
String concatenation stringifies non-String operand expressions
Java
DRAFT
StringRepetitionOperator
The multiplication operator can repeat a String a number of times
JavaScript
DRAFT
StringRepetitionOperator
One can repeat a String by multiplying it with a number
Java
DRAFT
SubtypeCompatibleWithSupertype
A variable of a subtype can reference an object of a supertype
Java
DRAFT
SuperAlwaysHasParentheses
To call a method on a superclass, parentheses are needed after the keyword super
Java
DRAFT
SuperNotFirstStatement
super() can be called anywhere in the constructor of a subclass
Java
DRAFT
SuperclassObjectAllocated
When instantiating an object of a subclass, an object of a superclass is also allocated
Java
DRAFT
SupertypeIncompatibleWithSubtype
A variable of a supertype cannot reference an object of a subtype
TargetTyping
The type of a numerical expression depends on the type expected by the surrounding context
ThisAsField
this is a special field in the object
Java
ThisAssignable
One can assign to this
JavaScript
ThisAssignable
One can assign to this
Java
ThisCanBeNull
this can be null
ThisChildInCallExpression
Instance method or constructor call nodes in expression trees have a child labeled "this"
Java
ThisExistsInStaticMethod
this is a local variable, also in static methods
ThisInConstructorIsNull
In a constructor, this is null
Java
ThisNoExpression
The name this is not an expression
ToStringPrints
Invoking toString() prints something
TryCatchMandatory
If code could throw an exception, you must surround that code with a try/catch block
TryFinishes
Exceptions get thrown at the end of the try block
JavaScript
DRAFT
TypeofArrayIsArray
The typeof operator applied on an array returns 'array'
JavaScript
DRAFT
TypeofNullIsNull
The value null is of type 'null'
UndeclaredVariables
Variables don't need to be declared
UnqualifiedNamesMustDiffer
The unqualified names of different classes must be different
UntypedVariables
Variable declarations don't need a type
UseOfSelfTypeImpliesRecursiveType
If a class has a method that has a local variable, parameter, or return value with the class as its type, the class is a recursive type
Java
VariablesHoldExpressions
= stores an expression in a variable
Python
VariablesHoldExpressions
= stores an expression: it stores a reference to the expression in a variable
Java
VariablesHoldObjects
A variable of a reference type contains a whole object
Python
VariablesHoldObjects
A variable contains a whole object
VoidMethodNotRecursive
A method with void return type can't be recursive
VoidMethodReturnsValue
A method with void return type can return a value
ZeroDigitsCompress
In integer numbers, decimal digits with value `0` take less storage than decimal digits with other values
ZeroInEdges
A control-flow graph node (other than the entry node) can have zero incoming edges
ZeroOutEdges
A control-flow graph node (other than the exit node) can have zero outgoing edges

Stay up-to-date

Follow us on  twitter to hear about new misconceptions.