Just to pile on: 0-based indexing is also more convenient when you want to build a multi-dimensional array from a one-dimensional array primitive using the integer division and modulo operators to map between 1D and nD indices. E.g., a matrix with M rows and N columns can be mapped to the range 0 <= i < (NxM) by letting i = (row * N) + col, and the backward mapping is row = i / N, col = i % N.
If instead you use 1 <= i <= (NxM), 1 <= row <= M, 1 <= col <= N, then the mappings aren't nearly as clean. Sure, you could hide all this behind some kind of API, eg. Image.getPixel(x,y), but if you work with multidimensional arrays very often, eventually you'll need to marshal arrays back and forth between different containers that use different access APIs, and the simplest common representation to use for this kind of data is as a 1D array, so being able to work with nD data that is stored in a 1D array comes up fairly often.
> Take C++ for example. Everyone who has mastered C++ knows that you call a class that implements operator() a functor.
Nope. This is what dilettantes call them. Capable C++ programmers (I don't claim to be a master, that would be foolish) know how to grep the standard. The term "functor" is not found in it, at least not that draft that comes up first on Google. The plain and transparent term "function object" has its own section, 20.3.
The term "functor" is widely used -- including such places as SGI's STL documentation (http://www.sgi.com/tech/stl/functors.html) and numerous other reference sites.
According to Bruce Eckel's Thinking in C++ Vol 2 (in the section describing the Command Pattern), the term dates to 1992:
> In Advanced C++: Programming Styles And Idioms (Addison Wesley, 1992), Jim Coplien coins the term functor which is an object whose sole purpose is to encapsulate a function (since “functor” has a meaning in mathematics, we shall use the more explicit term function object). The point is to decouple the choice of function to be called from the site where that function is called.
Unfortunately, I don't have a copy of Advanced C++: Programming Styles and Idioms, so I can't verify this myself. But, if it's accurate, that means the term predates the standard by at least six years since ISO/IEC 14882 was released in 1998... :)
Personally, I do prefer "function object" though, since it seems like a clearer term.
Bjarne Stroustrup's own "The C++ Programming Language" introduces them that way on page 515 as "a function-like object, a functor, or simply a function object". I don't like the term either, but that seems like a pretty authoritative source giving its blessing.
Surely the premium costs will be higher than the subsidy, so in some sense the headline is right, although I'm not quite sure what point it's trying to make. Health care costs money. In Canada in 2009, it cost $5452 per person. http://en.wikipedia.org/wiki/Health_care_in_Canada#Economics
That's a good analogy to describe the current state of things, by why can't we aim for something better? For example, I would not be afraid to put a random CD in my CD player.
What is an example of an optimization that a JIT compiler can make that a AOT compiler cannot?
If the developer is able to profile the application on typical end-user workloads, don't profile-guided optimizations provide the same benefit as JIT runtime profiling?
Why can't an AOT compiler just consider every path a "hot" path?
For one: JIT can do polymorphic inline caching (you can read more about from Google's senior vice president of operations Urs Hölzle[1]), while AOT can't.
Wikipedia gives a few more[2]: runtime profile-guided optimizations and pseudo-constant propagation
The Polymorphic Inline Caching paper refers to AOT compiling with runtime hints.
In the case of non-dynamic languages like C and C++ that clang generally targets, are there other examples of where JIT would make things possible that are not possible in AOT?
Profile guided optimizations that are relevant for the specific invocation of the program. Loop optimization based on invocation parameters for that specific run of the program. Hard-coding in the jump target address for calling functions from dynamically loaded libraries (can't do that AOT, because if the library is replaced, the symbol offsets change).
Optimizing for the specific processor you're running on, as opposed to being forced to compile for a lowest common denominator.
One nice thing JITs can do that AOT compilers can't is on-stack replacement. That's where you recompile a particular function at run-time based on new information. This allows you do speculative optimizations.
For example, you might see that branch X is always taken. So you assume that X will always be true, and add a guard just in case which triggers a recompilation. You reoptimized the function on the basis of your new (speculative) information about X. This could improve register allocation, allow you remove lots of code (other branches maybe), inline functions, etc.
Java JITs have been known to inline hundreds of functions deep with this.
A simple example: let program P do a zillion <something> * <command line argument> multiplications, and call the program every hour with argument value zero or one, depending on a coin flip. An AOT compiler would not even know that the program will never be called with other arguments. A JIT compiler could remove all multiplications.
Profile-guided optimizations only work on the next run, and, when used by the developer, do not work for cases where there are widely different usage profiles for a single program. For example, most users would have data sets that fit in memory, but others will have ones that do not.
Wouldn't you get a code explosion and difficulties dealing with cache coherency if every path was a hot path (serious question, I don't know much about this stuff)?
On the other hand, servicing the interest on the mortgage can be more expensive than rent, and the amortization schedule is such that for the early part of the mortgage you are only paying interest, not paying down principal in any substantial amount. The money you save by renting can be invested elsewhere. But if you say in the house long enough, then yes it makes sense. It depends on what market you live in and how long you plan to be there.
Where do Google Scholar and CiteSeer fit into this analogy?
Can't speak for other fields, but in CS any outlet worth submitting to will let you post a preprint on your own website, and from there Google Scholar will pick it up and place the link to your free copy right next to the paywall link. It's not a perfect system---it's like an extreme form price discrimination, like when Microsoft turns a blind eye to piracy in emerging markets---but it does give access to those who can't pay, and its not as dystopian as you make it out to be.
I think that CS is a lot more open than other fields, even putting preprints online and soliciting feedback before publication (that's unheard of in chemistry and biology). You're right that some authors put PDFs of their papers on their websites and Google Scholar finds them, but I frequently need papers that I can only get through interlibrary loan (and I work at MIT; even a relatively wealthy university can't afford everything).
"In this field we don't rely on peer-reviewed journals...papers are also published in journals, but I believe this is a formality that has more to do with obtaining grants and such than with actual communication within the community."
So peer reviewed journals are only important for grants, but your community doesn't rely on peer reviewed journals. Do you not rely on grants? Who funds your work? Do you all work for free, in your spare time?
I guess I wasn't clear enough. What I mean is that the communication within the community, and the reputation of a researcher among her peers, does not rely on publications in reviewed journals. These are the things that can be compared with open-source development.
If researchers also need to publish their work in journals, write grant proposals etc., how is it relevant to the idea of applying the GitHub model to science? Of course raising money is part of the job for a professor, but thanks to the arXiv it's decoupled from the actual research work. It's at a point where I, as a Ph.D. student, have no reason to consider publishing in reviewed journals. This is in contrast to my friends in optics or condensed matter, for whom a publication in Nature or Science practically guarantees a good postdoc position.
Likewise. I used the flash player in state A, then moved to state B and bought an iPhone, but I continually get adds related to state A on my phone. Never got a single add when I actually lived in state A, though.
If instead you use 1 <= i <= (NxM), 1 <= row <= M, 1 <= col <= N, then the mappings aren't nearly as clean. Sure, you could hide all this behind some kind of API, eg. Image.getPixel(x,y), but if you work with multidimensional arrays very often, eventually you'll need to marshal arrays back and forth between different containers that use different access APIs, and the simplest common representation to use for this kind of data is as a 1D array, so being able to work with nD data that is stored in a 1D array comes up fairly often.