Skip to content

Instantly share code, notes, and snippets.

@maxtruxa
Last active November 15, 2024 20:10
Show Gist options
  • Save maxtruxa/b2ca551e42d3aead2b3d to your computer and use it in GitHub Desktop.
Save maxtruxa/b2ca551e42d3aead2b3d to your computer and use it in GitHub Desktop.
A list of common terms used in programming and their respective antonyms.

Antonym List

Note: The table headings (positive/negative) are not necessarily meaningful.

Positive Negative
acquire release
add remove (e.g. an item), subtract (arithmetic)
advance retreat
allocate deallocate (correct), free (common)
allow deny
assemble disassemble
assign deassign (e.g. a task)
associate dissociate
attach detach
begin end
bind unbind
commit rollback
compile decompile
compress decompress
connect disconnect
construct destruct
create destroy
do undo
enable disable
encode decode
encrypt decrypt
enqueue dequeue
enter leave, exit
expand collapse (e.g. a tree view), contract
first last
freeze unfreeze
front back
get set
grant revoke
head tail
import export
include exclude
increase decrease
increment decrement
indent dedent
inflate deflate
inject eject
input output
insert delete (e.g. from a collection), extract (e.g. in a stream)
install uninstall
link unlink
load unload (e.g. a module), save (e.g. state), store (e.g. a value)
lock unlock
maximum minimum
new old
next previous
open close
compose parse
paste cut
push pop (e.g. a stack item), pull (communication strategy)
raise lower
read write
reference dereference (e.g. a pointer), unreference (e.g. an object in the case of reference counting)
register deregister
resume suspend
select deselect
send receive
serialize deserialize
set unset (e.g. a key), clear (e.g. a bit), get (e.g. a value)
set up tear down
show hide
start stop
start up shut down, clean up (maybe)
up down
upper lower

Remarks

Motivation

Using sensible, consistent wording in APIs improves readability, usability and greatly helps new users getting started. There is nothing more annoying than wondering what a function call is supposed to do while reading (someone else's or your own) code.

Initialize

There is no precise antonym for initialize and I don't think there has to be: By using initialize only for simple initializations that don't need any clean up code (initialize as its own antonym) you can

  1. establish a convention through that initialization routines without a corresponding clean up routine can be easily recognized, and
  2. circumvent the need for an antonym ;).

For routines that do not fall into this category, select another verb from the table above (most of the time there is a more descriptive alternative anyway).

If you still feel like you need an antonym; possibilities include but are not limited to: exit (very common in conjunction with init), reset, finalize, terminate.

"De-" vs. "Un-"

Both prefixes (de- and un-) can be defined as a reversal of action. Most of the time the prefix de- is used for verbs while un- is used for adjectives. There are many exceptions to this rule though. In some cases careful usage of these prefixes can avoid ambiguity. For example, "he was unregistered" is ambiguous because it can mean either "he was not registered" or "his registration was removed", while "he was deregistered" is not.

@0xTomDaniel
Copy link

success / failure; resolve / reject

@marius-ne
Copy link

What is the opposite of caller? As in functions.

@maxtruxa
Copy link
Author

maxtruxa commented Jul 5, 2021

@marius-ne: Caller / callee. Same as in trainer / trainee.

@iseahound
Copy link

What pairs with put, from, and to? Please help.

@simonhf
Copy link

simonhf commented Mar 10, 2022

I would love to see this list divided into two lists; the first containing words of the same length e.g. get / set or success / failure, and the second containing words of different lengths e.g. read / write or begin / end etc :-)

I would then spend most of my time in the first list :-) It might be just OCD on my part, but I love to see related names all the same length, e.g. instead of:

OnsuccessfulWrite()
OnUnsuccessfulWrite()
OnsuccessfulRead()
OnUnsuccessfulRead()

Then:

OnKeyPutSuccess()
OnKeyPutFailure()
OnKeyGetSuccess()
OnKeyGetFailure()

Does anybody else have this affliction? :-)

@Oli-Wright
Copy link

Oli-Wright commented Apr 22, 2022

WRT first / last

'Last' is unfortunately overloaded in English. It can mean 'final' ("last bus") or 'previous' ("last time") depending on context.

This means it can be ambiguous in code. Is lastValue the final value in an array, or the previous value that we looked at?

So I've always preferred to ban last and prefer final in this context.

@wffranco
Copy link

WRT first / last

'Last' is unfortunately overloaded in English. It can mean 'final' ("last bus") or 'previous' ("last time") depending on context.

This means it can be ambiguous in code. Is lastValue the final value in an array, or the previous value that we looked at?

So I've always preferred to ban last and prefer final in this context.

Is ambiguous if you use it wrong. By default in development first/last are the border values in a list of items.
For the context you mention use previous/next instead.


Some missing terms:

  • top / bottom
  • before / after
  • from / to
  • mount / unmount

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment