Every now and then people get into silly arguments about which programming language is “faster.” I always ask, faster for what? Faster compile-run-test cycle, faster to write correct programs, faster to run…? Besides, each language is tuned for certain usage patterns, making like to like comparisons impossible.
Tag Archives: C
When 0.3 is not 3/10
If you’ve taken a course in numerical computing you’ll be familiar with the various sources of numerical error. First you have representation error that arises when you have to represent a number with a finite number of digits. A common example: the decimal expansion for 1/3 = 0.3333… has a never-ending string of 3’s and …
Counting combinations modulo power of 2
It is pretty simple to calculate the number of ways to choose k items out of n: There are n ways to choose the first item, n-1 ways to choose the second item, and so on, until there are \(n-k+1\) ways to choose the kth item. By the rule of product there are \(n (n-1)···(n-k+1)\) ways …
Calling C From Java Is Easy
Sometimes we need to access operating system functions that the standard Java API doesn’t expose, or use non-Java libraries. Although it’s well known that you can call this “native code” from Java using JNI, there is not so much entry-level material on how it’s actually done. It is often left out of introductory material–including the official …