Why only literal strings saved in the intern pool by default?

The short answer: interning literal strings is cheap at runtime and saves memory. Interning non-literal strings is expensive at runtime and therefore saves a tiny amount of memory in exchange for making the common cases much slower. The cost of the interning-strings-at-runtime “optimization” does not pay for the benefit, and is therefore not actually an … Read more

Why do the older C language specs require function-local variables to be declared up-front?

Looking at the early (6th edition Unix, 1975) C manual from Dennis Ritchie’s home page, in that version function-local variables could only be declared at the beginning of a function: The function-statement is just a compound statement which may have declarations at the start. function-statement: { declaration-listopt statement-list } declaration-list is not defined (an omission), … Read more

Delphi: How to organize source code to increase compiler performance?

Some things that could slow down the compiler Redundant units in your uses clause. See this question for a link to CnPack. Not explicitly adding units to your project file. You’ve already seem to have covered that. Changed compiler settings, most notably include TDD32 info. Try to get rid of unused units in your uses … Read more

Benefits of ‘Optimize code’ option in Visual Studio build

You are the only person who can answer the “performance hit” question. Try it both ways, measure the performance, and see what happens. The hit could be enormous or it could be nonexistant; no one reading this knows whether “enormous” to you means one microsecond or twenty minutes. If you’re interested in what optimizations are … Read more

What does a JIT compiler do?

Java code is normally distributed as bytecode, which is machine-independent pseudocode. (The same idea was previously used in UCSD-p system developed in the 70’ies.) The advantage of this is that the same application can be run in different processors and operating systems. In addition, the bytecode is often smaller than compiled application. The disadvantage is … Read more

Why isn’t pass struct by reference a common optimization?

Don’t forget that in C/C++ the compiler needs to be able to compile a call to a function based only on the function declaration. Given that callers might be using only that information, there’s no way for a compiler to compile the function to take advantage of the optimization you’re talking about. The caller can’t … Read more

How to change mode from c++98 mode in Dev-C++ to a mode that supports C++0x (range based for)?

Go to Tools -> Compiler Options -> “Compiler” tab Check the checkbox labeled, “Add the following commands when calling the compiler” And add in the text entry box, “-std=c++11” or if that doesn’t work “-std=C++0x“ Should be something like that anyway, I haven’t had Dev C++ installed for many years, so I had to look … Read more