
What every programmer should know about memory - haskellito
http://lwn.net/Articles/250967/
======
klochner
Does every programmer really need to know the physics behind dynamic ram?

What every programmer _should_ know is the latency of the various memory types
(cache, RAM, virtual) and their respective sizes.

Here's a nice graphic:

[http://duartes.org/gustavo/blog/post/what-your-computer-
does...](http://duartes.org/gustavo/blog/post/what-your-computer-does-while-
you-wait)

~~~
mahmud
Not every programmer needs to be a hardcore systems hacker; you can ignore the
low-level details and lead a healthy productive life. But me, personally, I
get a massive inferiority complex if I don't dive into Nasm and GDB every 2-4
months. It would pain me not to know useless things about obscure stuff.

Yesterday I was prancing through reddit when I followed this link:
<http://pvk.ca/>

My stomach sank when I realized I wouldn't have the time to "follow along"
(i.e. waste the day reproducing his results, checking facts, researching and
following links) because I am about to start a lead-dev/PM position and need
to work on SaaS and EA stuff. So I closed the tab and moved on to focus on
what matters. It wasn't until 1AM that I realized what I have done; aarongough
sent me a link to his toy prototyping language and I have just spent 5 hours
reimplementing it in Lisp, in the process re-digging into the Self papers!
(and discovering warts, but that's another story.)

I am an Adderall prescription away from leading a healthy productive life,
without unnecessary knowledge about _stuff_.

------
pacemkr
Nonsense. What happened to abstraction?

To suggest this as recommended knowledge to all programmers is actually making
me angry.

My education is in Computer and Electrical Engineering, while I mostly work
with high level languages building software for the web. I've traveled up and
down the abstraction ladder out of curiosity -- that explains the dual in EE.
I've enjoyed it all, but there is zero reason for a programmer to know almost
anything from that page. You can make phenomenal software without ever knowing
what a transistor looks like on paper; and that's the whole point of progress.

If anything, we should encourage higher level thinking and discovery of more
expressive languages and tools.

~~~
Groxx
To me, the mentality that CS should require (near) EE dual-citizenship reeks
of "we had to learn it, so you have to too". I highly doubt that knowing how
to construct a logic gate from silicon will help me program one iota better.

Heck, even including what the logic gates _are_ and how to combine them to
make RAM, for instance, is valueless. So my CPU is mostly NAND... this changes
things for me how? If you're going into digital electronics, then by all
means... but CS != digital electronics.

~~~
scott_s
I maintain that to work well at abstraction level N, you need a good
_conceptual_ understanding of abstraction level N - 1. All abstractions leak,
and you need to be able to handle it.

~~~
vecter
So by induction, you need to learn N - 2, N - 3, ..., 2, ... 1? I
wholeheartedly disagree. By that logic, why stop at transistors? Let's get
down to the physics of how transistors work, or hey, atomic physics.

~~~
Groxx
Ehhh... only partially. If you need to work well _at_ level N-1, then yes, the
inductive proof works. They only mentioned knowledge _about_ a level lower
than you're _working_ at, though.

~~~
vecter
My bad, I read it wrong.

------
delano
If it's something every programmer should know then there should be a summary
that every programmer will actually read.

~~~
tav
Grep the articles for "conclusion" and read the articles on "what every
programmer should do..." in semi-detail. HTH.

------
ramchip
It's a cool link, but it gets reposted a lot, last one being 5 days ago:
<http://news.ycombinator.com/item?id=1496377>

That link is a PDF/scribd version. I find it easier to read than a webpage.

~~~
toadie
Yeah, but every time the discussion is different though. To me, most of HN
value is in comments.

------
Groxx
If anyone is interested, a PDF of the entire thing is available at:
<http://people.redhat.com/drepper/cpumemory.pdf>

Drepper's site has a bunch more articles, too:
<http://people.redhat.com/~drepper/>

------
lispygem
_The former is much faster and provides the same functionality. Why is not all
RAM in a machine SRAM? The answer is, as one might expect, cost._

But since the density of transistors is pushing the cost of everything down
how expensive is expensive? Does it make sense to product a SRAM-based laptop
with 512MB of fast memory?

~~~
terminus
Well, part of the faster-than-DRAM is because the cache is limited in size.
Addressing 512 MB (and keeping it close enough to the CPU) would require a lot
more address lines/multiplexing and CPU die real estate [1] that it would be
prohibitively expensive and not as fast.

It'll still be faster than DRAM so you still have a point.

[1] In this die-shot (<http://en.wikipedia.org/wiki/File:Barcelona_die.jpg>)
of AMD's Barcelona (4 core) all the regular grid like pattern is the cache
(total is about 4MB + 512KB or so.) That takes about half the chip's real
estate.

