What is the difference between a map and a dictionary?

devoured elysium picture devoured elysium · May 21, 2010 · Viewed 92.9k times · Source

I know a map is a data structure that maps keys to values. Isn't a dictionary the same? What is the difference between a map and a dictionary1?


1. I am not asking for how they are defined in language X or Y (which seems to be what generally people are asking here on SO), I want to know what is their difference in theory.

Answer

BlueRaja - Danny Pflughoeft picture BlueRaja - Danny Pflughoeft · May 21, 2010

Two terms for the same thing:

  • "Map" is used by Java, C++
  • "Dictionary" is used by .Net, Python
  • "Associative array" is used by PHP

"Map" is the correct mathematical term, but it is avoided because it has a separate meaning in functional programming.

Some languages use still other terms ("Object" in Javascript, "Hash" in Ruby, "Table" in Lua), but those all have separate meanings in programming too, so I'd avoid them.

See here for more info.