Uellue's Blog

Two-column float gets stuck with revtex

When preparing a manuscript with revtex (documentclass[aip,apl,amsmath,amssymb,reprint]{revtex4-1}), I ran into a problem: A two-column float with the figure* environment got stuck and ended up at the end of the document. The solution was trivial: Remove all placing hints for the float, instead of \begin{figure*}[h] use just \begin{figure*}!

C and C++ vs. interpreted languages like Python

Check out these articles!

A high-level summary: The C and C++ standards are defined in such a way that the result of many operations is undefined if it would require additional checks to make it defined on all platforms. This includes dereferencing invalid pointers, signed integer overflows and shifting beyond bit boundaries. The compiler has lots of room to rearrange or drop code which consequently leads to a fast program. On the down side, it can lead to unexpected and unsafe behavior in many cases. Informing the user about all cases where the code could possibly be unsafe would be either too noisy with tons of false positives or contain too many false negatives.

It seem that such errors are kind of unavoidable in large codebases because only geniuses can figure out what exactly is going on and the bytecode that optimizing compilers generate has little resemblance of the corresponding source code because of loop unrolling, inlining and so on.

A language like Python looks to me like a very good solution: The programming language has many high-level functions and libraries with completely defined behavior, and the average programmer does not have to worry about undefined behavior. These high-level functions are implemented as highly efficient and thoroughly tested C routines. The interpreter will then, in an ideal case, spend a significant amount of time in these optimized functions (say, for example, multiplying numpy matrices) which reduces the overhead from permanent bounds checking and so on. For the interpreted language it is critical that moving parts of the code to C is easy, for example by allowing calls to libraries (example: ctypes) or implementing subroutines in C (example). C is in those cases only used to speed up the performance bottlenecks or access existing routines.