r/AskComputerScience • u/z3ny4tta-b0i • Apr 19 '21
Whats the difference between RAM and cache?
I’m struggling to understand what a RAM is, looked up and it really sounds like what the cache does im confused
10
u/lifeHacker42 Apr 19 '21 edited Apr 19 '21
Lookup "the memory hierarchy" that should help you understand all this.
It's a fundamental thing to understand when it comes to memory so make sure you get it before moving forward. If you need any further help explaining it if Google isn't clear enough drop me a message I'll happily help but Google should be enough as there are some really clear explanations there
Edit: typo and additional information
9
u/msiekkinen Apr 19 '21
2
u/Bottled_Void Apr 19 '21
I'm not sure the distinction between DRAM and SRAM is the important point. There are some types of SRAM which aren't used for cache and aren't faster.
1
u/msiekkinen Apr 19 '21
Seemed important enough of a distinction to be in opening of the wiki article I linked.
7
u/spaztheannoyingkitty Apr 19 '21
To add to what others have said, a cache is also a generic term for keeping friendly accessed information quickly at hand for fast access: https://en.m.wikipedia.org/wiki/Cache_(computing)
12
u/Knaapje Apr 19 '21
To add to what others have said a ram is also a siege engine used in medieval warfare, used to breach keep doors and other fortified structures. Their use as siege engines quickly declined with the advance of gunpowder and other siege engines, such as the trebuchet, the superior siege engine.
7
u/FoxchildWasTaken Apr 19 '21
Oh cache is where they stored weapons and such, right?
3
u/Knaapje Apr 19 '21
Correct, there's different levels of caches too. Level 1 caches provide quickest access, since it's on the ground floor. Level 2 takes a bit longer, and so on.
2
2
u/not-just-yeti Apr 19 '21 edited Apr 19 '21
price vs. speed
[I mean, the top post is a great answer to what OP was after; but once that is understood, the whole memory-hierarchy is largely one big continuum of trading off the above two.]
2
u/oligIsWorking Apr 19 '21
A nice way of thinking about it I just thought of is this:
End user uses Storage memory (HDD/SSD)
Developer uses/programmes RAM
CPU Architect uses the cache.
2
Apr 20 '21
Just to add some insight, cache is a very special memory because it's closer to the processor, it uses probability inference to store the data, it's used to store those chunks of bytes that the processor access the most.
-8
u/CuriousCerberus Apr 19 '21
RAM is the physical memory chips you install in your computer on the motherboard. Cache can be virtual memory used by the operating system and you can change the size of it in system settings and is a temporary location on the hard drive. That's why the size of it can be changed because it uses the hard drive space. RAM is a static size depending on the size and number of chips installed in the computer.
3
u/Bottled_Void Apr 19 '21
I believe they're asking about the l1 and l2 cache on the processor, not virtual memory.
42
u/jhaluska Apr 19 '21
They're very similar. Cache is a type of memory. It's faster but smaller. It contains a copy of a portion of the larger RAM. CPUs read and write to the cache to avoid hitting the slower RAM. This allows the computer to run faster.
Modern computers have multiple caches for the CPU, labeled L1, L2 and L3. L1 is smallest and fastest. L3 and largest and slowest.
A lot of the speed restrictions are literally the speed of light! So think about the further away you go from a point, light takes longer to reach and return but it covers more and more volume!