From: Phillip Gawlowski Date: 2010-11-26T21:04:34+09:00 Subject: Re: instance_eval vs attr_reader On Fri, Nov 26, 2010 at 12:25 PM, Joe Pikachu wrote: > @Phillip Gawlowski: If I'm not mistaken, symblos are NEVER G.collected. > That's my concern. Since I'm making dozen of symbols. Also, can you give > me a good link on how memory/speed works in computer programming. I use > google, but I don't think I'm using the right keywords. 124 * 8 bytes << 2 GB of address space total (on a 32 bit system). ;) As for speed and memory comparisons: The question is what you are looking at, both in hardware and software, so I can talk only in the most general terms: - RAM is faster than a hard drive for memory access, but is vastly slower than L2 cache. - CISC architectures are slower, but more versatile than RISC architectures (CPU design). - Algorithms are compared on speed and accuracy / stability. - Doing multiplication of large integers is slower than performing addition. This begets the question what of those matters to you and your code. A couple of keywords that might be of interest: - memory profiling - Benchmarking and micro benchmarks - Big O notation (for algorithms) In the end, you'll have to make trade offs between speed of code execution, speed of code development, ease of code maintenance, and available resources (both to you, and your target). You have to write code differently for a PLC than for a current gen desktop computer than for a smart phone, and all bets are off when writing a device driver. But for now, if you are new to programming, just learn to program, and worry about performance later. Once you have the right habits (like: writing unit tests, either in test driven development, or in bug hunting; Don't Repeat Yourself; You Ain't Gonna Need It; and many more), you'll find it much easier to evaluate code for performance issues, and you'll have an idea which tool to use in which situation. -- Phillip Gawlowski Though the folk I have met, (Ah, how soon!) they forget When I've moved on to some other place, There may be one or two, When I've played and passed through, Who'll remember my song or my face.