I want to select between "symbol(s)" and "character(s)" for my variables' names in cases when these terms are synonyms. Please teach me some information which allows to make this choice.

Frequent use cases

const MINIMAL_SYMBOLS_COUNT: number = 5;
const ALLOWED_SYMBOLS: number = [ 1, 0 ];

function removeLastSymbol(): string { /* */ }
function removeLastCharacter(): string { /* */ }
  • 1
    Words mean what you want them to mean. From what you posted your question is impossible to answer.
    – gnasher729
    Oct 17 at 9:45
  • @gnasher729, it has been answered, anyway. I knew what I wanted. Oct 27 at 0:44

strings are collections of characters The term "symbol" is not used to mean a letter/number/symbol in a string.

From the naming of your variables it looks to me like you should NOT use the word "symbol", you should use "character".

I would only use symbol if I had a defined set of characters which were all symbols, eg mathematical operators, planetary astronomical symbols, names of pop stars trolling their record labels some such.

  • 1
    I can absolutely not see how you draw the conclusion, because there is nothing in the question giving me any clue whether symbols or characters are meant.
    – gnasher729
    Oct 17 at 11:54
  • Thank you for the answer! Thanks to, now I can make the choice. Oct 17 at 12:00

Symbol refers to something semantically higher level that characters. In a programming language characters are meaningless until they form a statement, a keyword, an operator, an identifier, a constant or a value. What a symbol is exactly varies over languages and/or compiler implementations. In the Microsoft world they relate to debugging, they map points in a compiled program to source code locations.

I found this page to be helpful.


Your question is open to interpretation in multiple different ways because the term 'symbol' has no single universal definition.

In the context of 'characters' there is a connection to 'symbols', i.e. the shapes and glyphs you see as a human which appear to you on a display device as something that you might recognise as text, numbers, punctuation, emojis, etc.

A key aspect of the term 'character' is that it typically refers to a construct which has a well-defined, direct electronic representation using integers (e.g. based on character sets such as UTF8 or ASCII), so is often treated as a primitive construct in programming languages.

The term 'symbol', while being ambiguous, could be seen in the context of text characters as referring to visual glyphs or shapes on a visual display or output device (or even sequences/collections of shapes, such as words or multi-character operators); meaningful to humans but generally meaningless or at least very hard for computers to understand the shapes/patterns by themselves -- i.e. computers have no idea what the various pixel-patterns or colours actually mean.

That is to say, it would typically require some reasonably sophisticated image/text recognition algorithm to determine that a pixel pattern shaped as A should indeed be interpreted as an ASCII or Unicode integer for 'A' (and that interpretation may even have a small chance to fail).

The term 'symbol' is not clearly defined, but a common concept behind the term is that it refers to human-relatable semantics rather than electronic representation.

In addition, not all electronic characters are associated with symbols; for example, EOF is a non-printable control character which is used to denote the end of a byte stream -- it's really handy for electronic devices but useless to humans.

If I were to take a guess about the example code in the question, I might wonder whether white-space characters (tab/space/newline/CR) could also be excluded from the definition of "symbol" being that humans generally use whitespace for separation/layout/formatting, but this would be a matter of consulting the documentation and understanding what the original programmer meant by the term "symbol" -- people frequently choose unclear, ambiguous and misleading names in their code.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.